File Coverage

blib/lib/Data/Sah/Compiler/human/TH/str.pm
Criterion Covered Total %
statement 52 52 100.0
branch 2 2 100.0
condition n/a
subroutine 12 12 100.0
pod 0 7 0.0
total 66 73 90.4


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 6     6   533 use strict;
  6         17  
4 6     6   28 use warnings;
  6         12  
  6         104  
5 6     6   24 #use Log::Any '$log';
  6         8  
  6         180  
6              
7             use Mo qw(build default);
8 6     6   47 use Role::Tiny::With;
  6         10  
  6         29  
9 6     6   1534  
  6         12  
  6         3336  
10             extends 'Data::Sah::Compiler::human::TH';
11             with 'Data::Sah::Compiler::human::TH::Sortable';
12             with 'Data::Sah::Compiler::human::TH::Comparable';
13             with 'Data::Sah::Compiler::human::TH::HasElems';
14             with 'Data::Sah::Type::str';
15              
16             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
17             our $DATE = '2022-09-30'; # DATE
18             our $DIST = 'Data-Sah'; # DIST
19             our $VERSION = '0.913'; # VERSION
20              
21              
22 1069     1069 0 4777 my ($self, $cd) = @_;
23             my $c = $self->compiler;
24              
25 1071     1071 0 2125 $c->add_ccl($cd, {
26 1071         3627 fmt => ["text", "texts"],
27             type => 'noun',
28 1071         7805 });
29             }
30              
31             my ($self, $cd) = @_;
32             my $c = $self->compiler;
33             my $cv = $cd->{cl_value};
34              
35 18     18 0 38 my %iargs = %{$cd->{args}};
36 18         54 $iargs{outer_cd} = $cd;
37 18         79 $iargs{schema} = $cv;
38             $iargs{schema_is_normalized} = 0;
39 18         27 $iargs{cache} = $cd->{args}{cache};
  18         280  
40 18         54 my $icd = $c->compile(%iargs);
41 18         35  
42 18         31 $c->add_ccl($cd, {
43 18         49 type => 'list',
44 18         125 fmt => 'each subscript of text %(modal_verb)s be',
45             items => [
46             $icd->{ccls},
47             ],
48             vals => [],
49             });
50             }
51 18         113  
52             my ($self, $cd) = @_;
53             my $c = $self->compiler;
54             my $cv = $cd->{cl_value};
55              
56             my %iargs = %{$cd->{args}};
57 18     18 0 34 $iargs{outer_cd} = $cd;
58 18         55 $iargs{schema} = $cv;
59 18         79 $iargs{schema_is_normalized} = 0;
60             $iargs{cache} = $cd->{args}{cache};
61 18         26 my $icd = $c->compile(%iargs);
  18         223  
62 18         50  
63 18         34 $c->add_ccl($cd, {
64 18         43 type => 'list',
65 18         36 fmt => 'each character of the text %(modal_verb)s be',
66 18         101 items => [
67             $icd->{ccls},
68             ],
69             vals => [],
70             });
71             }
72              
73 18         112 my ($self, $cd) = @_;
74             my $c = $self->compiler;
75             my $cv = $cd->{cl_value};
76              
77             $c->_die($cd, "Only 'utf8' encoding is currently supported")
78             unless $cv eq 'utf8';
79 12     12 0 25 # currently does nothing
80 12         42 }
81 12         55  
82             my ($self, $cd) = @_;
83 12 100       48 my $c = $self->compiler;
84             my $cv = $cd->{cl_value};
85              
86             $c->add_ccl($cd, {
87             fmt => q[%(modal_verb)s match regex pattern %s],
88             #expr => 1, # weird
89 95     95 0 189 });
90 95         289 }
91 95         421  
92             my ($self, $cd) = @_;
93 95         363 my $c = $self->compiler;
94             my $cv = $cd->{cl_value};
95              
96             $c->add_ccl($cd, {
97             fmt => q[%(modal_verb)s be a regex pattern],
98             });
99             }
100 36     36 0 78  
101 36         110 1;
102 36         151 # ABSTRACT: perl's type handler for type "str"
103              
104 36         125  
105             =pod
106              
107             =encoding UTF-8
108              
109             =head1 NAME
110              
111             Data::Sah::Compiler::human::TH::str - perl's type handler for type "str"
112              
113             =head1 VERSION
114              
115             This document describes version 0.913 of Data::Sah::Compiler::human::TH::str (from Perl distribution Data-Sah), released on 2022-09-30.
116              
117             =for Pod::Coverage ^(name|clause_.+|superclause_.+|before_.+|after_.+)$
118              
119             =head1 HOMEPAGE
120              
121             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>.
122              
123             =head1 SOURCE
124              
125             Source repository is at L<https://github.com/perlancar/perl-Data-Sah>.
126              
127             =head1 AUTHOR
128              
129             perlancar <perlancar@cpan.org>
130              
131             =head1 CONTRIBUTING
132              
133              
134             To contribute, you can send patches by email/via RT, or send pull requests on
135             GitHub.
136              
137             Most of the time, you don't need to build the distribution yourself. You can
138             simply modify the code, then test via:
139              
140             % prove -l
141              
142             If you want to build the distribution (e.g. to try to install it locally on your
143             system), you can install L<Dist::Zilla>,
144             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
145             L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
146             Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
147             that are considered a bug and can be reported to me.
148              
149             =head1 COPYRIGHT AND LICENSE
150              
151             This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>.
152              
153             This is free software; you can redistribute it and/or modify it under
154             the same terms as the Perl 5 programming language system itself.
155              
156             =head1 BUGS
157              
158             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah>
159              
160             When submitting a bug or request, please include a test-file or a
161             patch to an existing test-file that illustrates the bug or desired
162             feature.
163              
164             =cut