Data/Sah/Compiler/human/TH/str.pm

filter: Statementstmt 100% 62 / 62 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 7 totaltotal 91.5% 76 / 83 CC 2 SCAR 1.4
CC
2
Cov
100%
clause_encoding
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Data/Sah/Compiler/TH.pm ↑ Summary Data/Sah.pm »
1 package Data::Sah::Compiler::human::TH::str;
2  
3 9 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 #use Log::Any '$log';
7  
8 9 ▶use Mo qw(build default);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 extends 'Data::Sah::Compiler::human::TH';
12 9 with 'Data::Sah::Compiler::human::TH::Sortable';
13 9 with 'Data::Sah::Compiler::human::TH::Comparable';
14 9 with 'Data::Sah::Compiler::human::TH::HasElems';
15 9 with 'Data::Sah::Type::str';
16  
17 9 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
18 9 our $DATE = '2024-02-16'; # DATE
19 9 our $DIST = 'Data-Sah'; # DIST
20 9 our $VERSION = '0.917'; # VERSION
21  
22 1069 ▶sub name { "text" }
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
23  
24 1071 ▶sub handle_type {
Subroutine handle_type: called CC=1 SCAR=0.0
Pod undocumented
25 1071 my ($self, $cd) = @_;
26 1071 my $c = $self->compiler;
27  
28 1071 $c->add_ccl($cd, {
29 fmt => ["text", "texts"],
30 type => 'noun',
31 });
32 }
33  
34 18 ▶sub clause_each_index {
Subroutine clause_each_index: called CC=1 SCAR=0.0
Pod undocumented
35 18 my ($self, $cd) = @_;
36 18 my $c = $self->compiler;
37 18 my $cv = $cd->{cl_value};
38  
39 18 my %iargs = %{$cd->{args}};
40 18 $iargs{outer_cd} = $cd;
41 18 $iargs{schema} = $cv;
42 18 $iargs{schema_is_normalized} = 0;
43 18 $iargs{cache} = $cd->{args}{cache};
44 18 my $icd = $c->compile(%iargs);
45  
46 $c->add_ccl($cd, {
47 type => 'list',
48 fmt => 'each subscript of text %(modal_verb)s be',
49 items => [
50 $icd->{ccls},
51 18 ],
52 vals => [],
53 });
54 }
55  
56 18 ▶sub clause_each_elem {
Subroutine clause_each_elem: called CC=1 SCAR=0.0
Pod undocumented
57 18 my ($self, $cd) = @_;
58 18 my $c = $self->compiler;
59 18 my $cv = $cd->{cl_value};
60  
61 18 my %iargs = %{$cd->{args}};
62 18 $iargs{outer_cd} = $cd;
63 18 $iargs{schema} = $cv;
64 18 $iargs{schema_is_normalized} = 0;
65 18 $iargs{cache} = $cd->{args}{cache};
66 18 my $icd = $c->compile(%iargs);
67  
68 $c->add_ccl($cd, {
69 type => 'list',
70 fmt => 'each character of the text %(modal_verb)s be',
71 items => [
72 $icd->{ccls},
73 18 ],
74 vals => [],
75 });
76 }
77  
78 12 ▶sub clause_encoding {
Subroutine clause_encoding: called CC=2 SCAR=6.9
Pod undocumented
79 12 my ($self, $cd) = @_;
80 12 my $c = $self->compiler;
81 12 my $cv = $cd->{cl_value};
82  
83 12 ▶ $c->_die($cd, "Only 'utf8' encoding is currently supported")
Branch: 1 branch
BranchTrueFalseTotal
unless $cv eq "utf8" 3 9 12
84 unless $cv eq 'utf8';
85 # currently does nothing
86 }
87  
88 95 ▶sub clause_match {
Subroutine clause_match: called CC=1 SCAR=0.0
Pod undocumented
89 95 my ($self, $cd) = @_;
90 95 my $c = $self->compiler;
91 95 my $cv = $cd->{cl_value};
92  
93 95 $c->add_ccl($cd, {
94 fmt => q[%(modal_verb)s match regex pattern %s],
95 #expr => 1, # weird
96 });
97 }
98  
99 36 ▶sub clause_is_re {
Subroutine clause_is_re: called CC=1 SCAR=0.0
Pod undocumented
100 36 my ($self, $cd) = @_;
101 36 my $c = $self->compiler;
102 36 my $cv = $cd->{cl_value};
103  
104 36 $c->add_ccl($cd, {
105 fmt => q[%(modal_verb)s be a regex pattern],
106 });
107 }
108  
109 9 1;
110 # ABSTRACT: perl's type handler for type "str"
111  
112 __END__
« Data/Sah/Compiler/TH.pm ↑ Summary Data/Sah.pm »