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   520 use strict;
  6         18  
4 6     6   26 use warnings;
  6         10  
  6         135  
5 6     6   25 #use Log::Any '$log';
  6         10  
  6         178  
6              
7             use Mo qw(build default);
8 6     6   27 use Role::Tiny::With;
  6         11  
  6         26  
9 6     6   1373  
  6         13  
  6         3266  
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-08-20'; # DATE
18             our $DIST = 'Data-Sah'; # DIST
19             our $VERSION = '0.912'; # VERSION
20              
21              
22 1069     1069 0 5482 my ($self, $cd) = @_;
23             my $c = $self->compiler;
24              
25 1071     1071 0 2339 $c->add_ccl($cd, {
26 1071         4248 fmt => ["text", "texts"],
27             type => 'noun',
28 1071         9106 });
29             }
30              
31             my ($self, $cd) = @_;
32             my $c = $self->compiler;
33             my $cv = $cd->{cl_value};
34              
35 18     18 0 45 my %iargs = %{$cd->{args}};
36 18         61 $iargs{outer_cd} = $cd;
37 18         99 $iargs{schema} = $cv;
38             $iargs{schema_is_normalized} = 0;
39 18         32 $iargs{cache} = $cd->{args}{cache};
  18         282  
40 18         75 my $icd = $c->compile(%iargs);
41 18         35  
42 18         36 $c->add_ccl($cd, {
43 18         44 type => 'list',
44 18         116 fmt => 'each subscript of text %(modal_verb)s be',
45             items => [
46             $icd->{ccls},
47             ],
48             vals => [],
49             });
50             }
51 18         163  
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 41 $iargs{outer_cd} = $cd;
58 18         65 $iargs{schema} = $cv;
59 18         96 $iargs{schema_is_normalized} = 0;
60             $iargs{cache} = $cd->{args}{cache};
61 18         32 my $icd = $c->compile(%iargs);
  18         275  
62 18         61  
63 18         50 $c->add_ccl($cd, {
64 18         45 type => 'list',
65 18         48 fmt => 'each character of the text %(modal_verb)s be',
66 18         114 items => [
67             $icd->{ccls},
68             ],
69             vals => [],
70             });
71             }
72              
73 18         163 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 29 # currently does nothing
80 12         39 }
81 12         51  
82             my ($self, $cd) = @_;
83 12 100       52 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 321 });
90 95         330 }
91 95         527  
92             my ($self, $cd) = @_;
93 95         420 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 75  
101 36         112 1;
102 36         165 # ABSTRACT: perl's type handler for type "str"
103              
104 36         126  
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.912 of Data::Sah::Compiler::human::TH::str (from Perl distribution Data-Sah), released on 2022-08-20.
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