Hades/Myths/Object.pm

filter: Statementstmt 88.0% 125 / 142 Branchbran 76.9% 80 / 104 Conditioncond 63.2% 31 / 49 MC/DCmcdc 45.1% 14 / 31 Subroutinesub 95.0% 19 / 20 Podpod 100% 10 / 10 totaltotal 78.3% 279 / 356 CC 75 SCAR 27.4
CC
75
Cov
80%
string
43.2
add
13.8
convert_locale
11.2
CRAP 15.4
« Hades/Macro/FH.pm ↑ Summary Hades/Macro.pm »
1 package Hades::Myths::Object;
2 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use POSIX qw/locale_h/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 our $VERSION = 0.03;
6  
7 sub new {
8 42 ▶ my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ );
Subroutine new: called CC=7 SCAR=19.7
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 26 16 42
9 42 my $self = bless {}, $cls;
10 my %accessors = (
11 locales => {
12 builder => sub {
13 40 ▶ my ( $self, $value ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
14 40 $value = $self->_build_locales($value);
15 38 return $value;
16 }
17 },
18 fb => { default => 'en', },
19 locale => {
20 builder => sub {
21 37 ▶ my ( $self, $value ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
22 37 $value = $self->_build_locale($value);
23 35 return $value;
24 }
25 },
26 42 language => {},
27 );
28 42 for my $accessor ( keys %accessors ) {
29 my $param
30 = defined $args{$accessor}
31 ? $args{$accessor}
32 152 ▶ : $accessors{$accessor}->{default};
Branch: 1 branch
BranchTrueFalseTotal
defined $args{$accessor} ? : 51 101 152
33 my $value
34 = $self->$accessor( $accessors{$accessor}->{builder}
35 152 ▶ ? $accessors{$accessor}->{builder}->( $self, $param )
Branch: 1 branch
BranchTrueFalseTotal
$accessors{$accessor}{'builder'} ? : 77 75 152
36 : $param );
37 143 ▶ unless ( !$accessors{$accessor}->{required} || defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not $accessors{$accessor}{"required"} or defined $value) 0 143 143
Condition33%1/3
not $accessors{$accessor}{"required"} or defined $value
l!l&&r!l&&!r
14300
MC/DC0%0/2
not $accessors{$accessor}{"required"} or defined $value
not $accessors{$accessor}{"required"} defined $value
Truth table33%1/3
not(A) or B
A= not $accessors{$accessor}{"required"}B= defined $value
ABresult
1X1
011
000
38 0 die "$accessor accessor is required";
39 }
40 }
41 33 return $self;
42 }
43  
44 sub fb {
45 43 ▶ my ( $self, $value ) = @_;
Subroutine fb: called CC=3 SCAR=11.0
Pod documented
46 43 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 41 2 43
47 41 ▶ if ( ref $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 4 37 41
48 4 die qq{Str: invalid value $value for accessor fb};
49 }
50 37 $self->{fb} = $value;
51 }
52 39 return $self->{fb};
53 }
54  
55 sub locale {
56 50 ▶ my ( $self, $value ) = @_;
Subroutine locale: called CC=3 SCAR=11.0
Pod documented
57 50 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 38 12 50
58 38 ▶ if ( ref $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 2 36 38
59 2 die qq{Str: invalid value $value for accessor locale};
60 }
61 36 $self->{locale} = $value;
62 36 $self->_set_language_from_locale($value);
63 }
64 48 return $self->{locale};
65 }
66  
67 sub _build_locale {
68 39 ▶ my ( $self, $locale ) = @_;
Subroutine _build_locale: called CC=4 SCAR=13.9
69 39 ▶ if ( defined $locale ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $locale) 23 16 39
70 23 ▶ if ( ref $locale ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $locale) 4 19 23
71 4 die
72 qq{Optional[Str]: invalid value $locale for variable \$locale in method _build_locale};
73 }
74 }
75  
76 35 ▶ return $locale || setlocale(LC_CTYPE);
Condition66%2/3
$locale || setlocale(0)
l!l&&r!l&&!r
19160
MC/DC0%0/2
$locale || setlocale(0)
$locale setlocale(0)
Truth table66%2/3
A || B
A= $localeB= setlocale(0)
ABresult
1X1
011
000
77  
78 }
79  
80 sub _set_language_from_locale {
81 39 ▶ my ( $self, $value ) = @_;
Subroutine _set_language_from_locale: called CC=6 SCAR=18.2
82 39 ▶ if ( !defined($value) || ref $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value or ref $value) 3 36 39
Condition100%3/3
not defined $value or ref $value
l!l&&r!l&&!r
1236
MC/DC100%2/2
not defined $value or ref $value
not defined $value ref $value
Truth table100%3/3
not(A) or B
A= not defined $valueB= ref $value
ABresult
1X1
011
000
83 3 ▶ $value = defined $value ? $value : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 2 1 3
84 3 die
85 qq{Str: invalid value $value for variable \$value in method _set_language_from_locale};
86 }
87  
88 36 ▶ unless ( $self->has_language ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_language) 36 0 36
89 36 my ( $locale, $lang ) = $self->convert_locale($value);
90 36 ▶ if ($lang) { $self->language($lang); }
Branch: 1 branch
BranchTrueFalseTotal
if ($lang) 0 36 36
91 }
92  
93 }
94  
95 sub language {
96 51 ▶ my ( $self, $value ) = @_;
Subroutine language: called CC=3 SCAR=11.0
Pod documented
97 51 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 3 48 51
98 3 ▶ if ( ref $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 2 1 3
99 2 die qq{Str: invalid value $value for accessor language};
100 }
101 1 $self->{language} = $value;
102 }
103 49 return $self->{language};
104 }
105  
106 sub has_language {
107 38 ▶ my ($self) = @_;
Subroutine has_language: called CC=1 SCAR=0.0
Pod documented
108 38 return exists $self->{language};
109 }
110  
111 sub locales {
112 96 ▶ my ( $self, $value ) = @_;
Subroutine locales: called CC=9 SCAR=22.0
Pod documented
113 96 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 44 52 96
114 44 ▶ if ( ( ref($value) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $value || "") ne "HASH") 2 42 44
Condition100%2/2
ref $value || ''
l!l
431
MC/DC100%1/1
ref $value || ''
ref $value
Truth table100%2/2
A
A= ref $value
Aresult
11
00
115 2 die
116 qq{Map[Str, HashRef]: invalid value $value for accessor locales};
117 }
118 42 for my $key ( keys %{$value} ) {
119 1837 my $val = $value->{$key};
120 1837 ▶ if ( ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $key) 0 1837 1837
121 0 die
122 qq{Map[Str, HashRef]: invalid value $key for accessor locales expected Str};
123 }
124 1837 ▶ if ( ( ref($val) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $val || "") ne "HASH") 6 1831 1837
Condition100%2/2
ref $val || ''
l!l
18334
MC/DC100%1/1
ref $val || ''
ref $val
Truth table100%2/2
A
A= ref $val
Aresult
11
00
125 6 ▶ $val = defined $val ? $val : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 4 2 6
126 6 die
127 qq{Map[Str, HashRef]: invalid value $val for accessor locales expected HashRef};
128 }
129 }
130 36 $self->{locales} = $value;
131 }
132 88 return $self->{locales};
133 }
134  
135 sub _build_locales {
136 42 ▶ my ( $self, $values ) = @_;
Subroutine _build_locales: called CC=6 SCAR=18.1
137 42 ▶ $values = defined $values ? $values : {};
Branch: 1 branch
BranchTrueFalseTotal
defined $values ? : 12 30 42
138 42 ▶ if ( ( ref($values) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $values || "") ne "HASH") 4 38 42
Condition100%2/2
ref $values || ''
l!l
402
MC/DC100%1/1
ref $values || ''
ref $values
Truth table100%2/2
A
A= ref $values
Aresult
11
00
139 4 ▶ $values = defined $values ? $values : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $values ? : 4 0 4
140 4 die
141 qq{HashRef: invalid value $values for variable \$values in method _build_locales};
142 }
143  
144 38 my ($debug_steps) = debug_steps();
145 return {
146 38 ▶ %{$values}, %{$debug_steps},
Branch: 1 branch
BranchTrueFalseTotal
$self->locales ? : 0 38 38
147 38 ( $self->locales ? ( %{ $self->locales } ) : () )
148 };
149  
150 }
151  
152 sub convert_locale {
153 54 ▶ my ( $self, $locale, $fb ) = @_;
Subroutine convert_locale: called CC=10 SCAR=24.1
Pod documented
154 54 ▶ if ( !defined($locale) || ref $locale ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $locale or ref $locale) 2 52 54
Condition66%2/3
not defined $locale or ref $locale
l!l&&r!l&&!r
0252
MC/DC50%1/2
not defined $locale or ref $locale
not defined $locale ref $locale
Truth table66%2/3
not(A) or B
A= not defined $localeB= ref $locale
ABresult
1X1
011
000
155 2 ▶ $locale = defined $locale ? $locale : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $locale ? : 2 0 2
156 2 die
157 qq{Str: invalid value $locale for variable \$locale in method convert_locale};
158 }
159 52 ▶ $fb = defined $fb ? $fb : "en";
Branch: 1 branch
BranchTrueFalseTotal
defined $fb ? : 2 50 52
160 52 ▶ if ( !defined($fb) || ref $fb ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $fb or ref $fb) 2 50 52
Condition66%2/3
not defined $fb or ref $fb
l!l&&r!l&&!r
0250
MC/DC50%1/2
not defined $fb or ref $fb
not defined $fb ref $fb
Truth table66%2/3
not(A) or B
A= not defined $fbB= ref $fb
ABresult
1X1
011
000
161 2 ▶ $fb = defined $fb ? $fb : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $fb ? : 2 0 2
162 2 die
163 qq{Str: invalid value $fb for variable \$fb in method convert_locale};
164 }
165  
166 50 $locale =~ m/^(\w\w)_(\w\w).*/;
167 50 ▶ return $1 && $2 ? ( $1 . '_' . $2, $1, $fb ) : ( $locale, undef, $fb );
Branch: 1 branch
BranchTrueFalseTotal
$1 && $2 ? : 0 50 50
Condition33%1/3
$1 and $2
!ll&&!rl&&r
5000
MC/DC0%0/2
$1 and $2
$1 $2
Truth table33%1/3
A and B
A= $1B= $2
ABresult
0X0
100
111
168  
169 }
170  
171 sub add {
172 7 ▶ my ( $self, $key, $locales ) = @_;
Subroutine add: called CC=12 SCAR=26.2
Pod documented
173 7 ▶ if ( !defined($key) || ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $key or ref $key) 2 5 7
Condition66%2/3
not defined $key or ref $key
l!l&&r!l&&!r
025
MC/DC50%1/2
not defined $key or ref $key
not defined $key ref $key
Truth table66%2/3
not(A) or B
A= not defined $keyB= ref $key
ABresult
1X1
011
000
174 2 ▶ $key = defined $key ? $key : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 2 0 2
175 2 die qq{Str: invalid value $key for variable \$key in method add};
176 }
177 5 ▶ if ( ( ref($locales) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $locales || "") ne "HASH") 2 3 5
Condition100%2/2
ref $locales || ''
l!l
41
MC/DC100%1/1
ref $locales || ''
ref $locales
Truth table100%2/2
A
A= ref $locales
Aresult
11
00
178 2 ▶ $locales = defined $locales ? $locales : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $locales ? : 2 0 2
179 2 die
180 qq{Map[Str, HashRef]: invalid value $locales for variable \$locales in method add};
181 }
182 3 for my $key ( keys %{$locales} ) {
183 3 my $val = $locales->{$key};
184 3 ▶ if ( ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $key) 0 3 3
185 0 die
186 qq{Map[Str, HashRef]: invalid value $key for variable \$locales in method add expected Str};
187 }
188 3 ▶ if ( ( ref($val) || "" ) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((ref $val || "") ne "HASH") 3 0 3
Condition100%2/2
ref $val || ''
l!l
12
MC/DC100%1/1
ref $val || ''
ref $val
Truth table100%2/2
A
A= ref $val
Aresult
11
00
189 3 ▶ $val = defined $val ? $val : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 2 1 3
190 3 die
191 qq{Map[Str, HashRef]: invalid value $val for variable \$locales in method add expected HashRef};
192 }
193 }
194  
195 0 $self->locales->{$key} = { %{ $self->locales->{$key} }, %{$locales} };
196  
197 }
198  
199 sub string {
200 19 ▶ my ( $self, $key, $locale, $lang, $fb ) = @_;
Subroutine string: called CC=21 SCAR=37.7
Pod documented
201 19 ▶ if ( !defined($key) || ref $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $key or ref $key) 2 17 19
Condition66%2/3
not defined $key or ref $key
l!l&&r!l&&!r
0217
MC/DC50%1/2
not defined $key or ref $key
not defined $key ref $key
Truth table66%2/3
not(A) or B
A= not defined $keyB= ref $key
ABresult
1X1
011
000
202 2 ▶ $key = defined $key ? $key : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 2 0 2
203 2 die qq{Str: invalid value $key for variable \$key in method string};
204 }
205 17 ▶ $locale = defined $locale ? $locale : $self->locale;
Branch: 1 branch
BranchTrueFalseTotal
defined $locale ? : 6 11 17
206 17 ▶ if ( !defined($locale) || ref $locale ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $locale or ref $locale) 2 15 17
Condition66%2/3
not defined $locale or ref $locale
l!l&&r!l&&!r
0215
MC/DC50%1/2
not defined $locale or ref $locale
not defined $locale ref $locale
Truth table66%2/3
not(A) or B
A= not defined $localeB= ref $locale
ABresult
1X1
011
000
207 2 ▶ $locale = defined $locale ? $locale : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $locale ? : 2 0 2
208 2 die
209 qq{Str: invalid value $locale for variable \$locale in method string};
210 }
211 15 ▶ $lang = defined $lang ? $lang : $self->language;
Branch: 1 branch
BranchTrueFalseTotal
defined $lang ? : 4 11 15
212 15 ▶ if ( !defined($lang) || ref $lang ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $lang or ref $lang) 13 2 15
Condition100%3/3
not defined $lang or ref $lang
l!l&&r!l&&!r
1122
MC/DC100%2/2
not defined $lang or ref $lang
not defined $lang ref $lang
Truth table100%3/3
not(A) or B
A= not defined $langB= ref $lang
ABresult
1X1
011
000
213 13 ▶ $lang = defined $lang ? $lang : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $lang ? : 2 11 13
214 13 die qq{Str: invalid value $lang for variable \$lang in method string};
215 }
216 2 ▶ $fb = defined $fb ? $fb : $self->fb;
Branch: 1 branch
BranchTrueFalseTotal
defined $fb ? : 2 0 2
217 2 ▶ if ( !defined($fb) || ref $fb ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $fb or ref $fb) 2 0 2
Condition33%1/3
not defined $fb or ref $fb
l!l&&r!l&&!r
020
MC/DC0%0/2
not defined $fb or ref $fb
not defined $fb ref $fb
Truth table33%1/3
not(A) or B
A= not defined $fbB= ref $fb
ABresult
1X1
011
000
218 2 ▶ $fb = defined $fb ? $fb : 'undef';
Branch: 1 branch
BranchTrueFalseTotal
defined $fb ? : 2 0 2
219 2 die qq{Str: invalid value $fb for variable \$fb in method string};
220 }
221  
222 die "string $key is empty"
223 if ( !ref $self->locales->{$key}
224 0 ▶ || !scalar keys %{ $self->locales->{$key} } );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->locales->{$key} and scalar keys %{$self->locales->{$key};} 0 0 0
Condition0%0/3
ref $self->locales->{$key} and scalar keys %{$self->locales->{$key};}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self->locales->{$key} and scalar keys %{$self->locales->{$key};}
ref $self->locales->{$key} scalar keys %{$self->locales->{$key};}
Truth table0%0/3
A and B
A= ref $self->locales->{$key}B= scalar keys %{$self->locales->{$key};}
ABresult
0X0
100
111
225 $_ && exists $self->locales->{$key}->{$_}
226 and return $self->locales->{$key}->{$_}
227 0 ▶ for ( $locale, $lang, $fb );
Branch: 1 branch
BranchTrueFalseTotal
$_ and exists $self->locales->{$key}{$_} and return $self->locales->{$key}{$_} 0 0 0
Condition0%0/3
$_ and exists $self->locales->{$key}{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
$_ and exists $self->locales->{$key}{$_}
$_ exists $self->locales->{$key}{$_}
Truth table0%0/3
A and B
A= $_B= exists $self->locales->{$key}{$_}
ABresult
0X0
100
111
228 return $self->locales->{$key}
229 0 ->{ [ keys %{ $self->locales->{$key} } ]->[0] };
230  
231 }
232  
233 sub debug_steps {
234 38 ▶ my ( $self, $steps ) = @_;
Subroutine debug_steps: called CC=1 SCAR=0.0
Pod documented
235  
236 38 $steps = {
237 debug_step_1 => { en => 'About to run hades with %s.', },
238 debug_step_2 =>
239 { en => 'Parsing the eval string of length %s into classes.', },
240 debug_step_3 =>
241 { en => 'Parsed the eval string into %s number of classes.', },
242 debug_step_4 => {
243 en => 'Set the Module::Generate %s accessor with the value %s.'
244 },
245 debug_step_5 => { en => 'Start building macros' },
246 debug_step_6 => { en => 'Build macro' },
247 debug_step_7 => { en => 'Attempt to import %s macro object.' },
248 debug_step_8 => { en => 'Successfully imported %s macro object.', },
249 debug_step_9 =>
250 { en => 'Attempt to import %s macro from the hades file.' },
251 debug_step_10 =>
252 { en => 'Successfully imported %s macro from the hades file.' },
253 debug_step_11 => { en => 'Successfully built macros.' },
254 debug_step_12 => { en => 'Building Module::Generate class %s.' },
255 debug_step_13 => { en => 'Parsing class token.' },
256 debug_step_14 => { en => 'Setting last inheritance token: %s.' },
257 debug_step_14_b => { en => 'The last token was: %s.' },
258 debug_step_15 =>
259 { en => 'Call Module::Generate\'s %s method with the value %s.' },
260 debug_step_16 =>
261 { en => 'Build a accessor named %s with no arguments.' },
262 debug_step_17 => { en => 'Build the classes %s.' },
263 debug_step_18 => { en => 'Build a sub named %s with no arguments.' },
264 debug_step_19 =>
265 { en => 'Declare the classes global our variables', },
266 debug_step_20 => {
267 en => 'Found a group of attributes or subs so will iterrate each.'
268 },
269 debug_step_21 =>
270 { en => 'Building attributes for a sub or accessor named %s.' },
271 debug_step_22 => { en => 'Built attributes for %s.' },
272 debug_step_23 => { en => 'Constructing accessor named %s.' },
273 debug_step_24 => { en => 'Built private code for %s.' },
274 debug_step_25 => { en => 'Built coerce code for %s.' },
275 debug_step_26 => { en => 'Built type code for %s.' },
276 debug_step_27 => { en => 'Built trigger for %s.' },
277 debug_step_28 => { en => 'Constructed accessor named %s.' },
278 debug_step_29 => { en => 'Construct a modify sub routine named %s.' },
279 debug_step_30 =>
280 { en => 'Constructed a modify sub routine named %s.' },
281 debug_step_31 => { en => 'Construct a sub routine named %s.' },
282 debug_step_32 => { en => 'Constructed a sub routine named %s.' },
283 debug_step_33 =>
284 { en => 'Construct the new sub routine for class %s.' },
285 debug_step_34 =>
286 { en => 'Constructed the new sub routine for class %s.' },
287 debug_step_35 => { en => 'Finished Compiling the class.' },
288 debug_step_36 => { en => 'Finished Compiling all classes.' },
289 debug_step_37 => {
290 en =>
291 'Calling Module::Generates generate method which will write the files to disk.'
292 },
293 debug_step_38 => { en => 'Constructing code for %s.', },
294 debug_step_39 => { en => 'Build macro for: %s.' },
295 debug_step_40 => { en => 'Matched macro %s that has parameters.' },
296 debug_step_41 => { en => 'Macro %s has a code callback.' },
297 debug_step_42 => { en => 'Generated code for macro %s.' },
298 debug_step_43 => { en => 'Match macro %s that has no parameters.' },
299 debug_step_44 => { en => 'Constructed code for %s.', },
300 debug_step_45 => { en => 'Constructing predicate named has_%s.' },
301 debug_step_46 => { en => 'Constructed predicate named has_%s.' },
302 debug_step_47 => { en => 'Constructing clearer named clearer_%s.' },
303 debug_step_48 => { en => 'Constructed clearer named clearer_%s.' },
304 press_enter_to_continue => { en => 'Press enter to continue' },
305 };
306 38 return $steps;
307  
308 }
309  
310 sub DESTROY {
311 28 ▶ my ($self) = @_;
Subroutine DESTROY: called CC=1 SCAR=0.0
312  
313 }
314  
315 sub AUTOLOAD {
316 0 ▶ my ($self) = @_;
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
317  
318 0 my ( $cls, $vn ) = ( ref $_[0], q{[^:'[:cntrl:]]{0,1024}} );
319 0 our $AUTOLOAD =~ /^${cls}::($vn)$/;
320 0 ▶ return $self->string($1) if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 0 0 0
321  
322 }
323  
324 15 1;
325  
326 __END__
327  
328 =head1 NAME
329  
330 Hades::Myths::Object - display text locally.
331  
332 =head1 VERSION
333  
334 Version 0.01
335  
336 =cut
337  
338 =head1 SYNOPSIS
339  
340 Quick summary of what the module does:
341  
342 use Hades::Myths::Object;
343  
344 my $locales = Hades::Myths::Object->new({
345 locale => 'ja_JP',
346 locales => {
347 stranger => {
348 en_GB => 'Hello stranger',
349 en_US => 'Howdy stranger',
350 ja_JP => 'こんにちは見知らぬ人'
351 },
352 }
353 });
354  
355 say $locales->stranger;
356  
357 =head1 SUBROUTINES/METHODS
358  
359 =head2 new
360  
361 Instantiate a new Hades::Myths::Object object.
362  
363 Hades::Myths::Object->new
364  
365 =head2 _build_locale
366  
367 call _build_locale method. Expects param $locale to be a Optional[Str].
368  
369 $obj->_build_locale($locale)
370  
371 =head2 _set_language_from_locale
372  
373 call _set_language_from_locale method. Expects param $value to be a Str.
374  
375 $obj->_set_language_from_locale($value)
376  
377 =head2 has_language
378  
379 has_language will return true if language accessor has a value.
380  
381 $obj->has_language
382  
383 =head2 _build_locales
384  
385 call _build_locales method. Expects param $values to be a HashRef.
386  
387 $obj->_build_locales($values)
388  
389 =head2 convert_locale
390  
391 Split a locale into locale and language.
392  
393 $obj->convert_locale($locale, $fb)
394  
395 =head2 add
396  
397 Add an item into the locales. This method expects a reference $key that should be a Str and a locales HashRef where the keys are locales and the values are the text string.
398  
399 locales->add('stranger', {
400 en_US => 'Howdy stranger!'
401 });
402
403  
404 =head2 string
405  
406 call string method. Expects param $key to be a Str, param $locale to be a Str, param $lang to be a Str, param $fb to be a Str.
407  
408 $obj->string($key, $locale, $lang, $fb)
409  
410 =head2 debug_steps
411  
412 call debug_steps method. Expects param $steps to be any value including undef.
413  
414 $obj->debug_steps($steps)
415  
416 =head2 DESTROY
417  
418 call DESTROY method. Expects no params.
419  
420 $obj->DESTROY()
421  
422 =head2 AUTOLOAD
423  
424 call AUTOLOAD method. Expects no params.
425  
426 $obj->AUTOLOAD()
427  
428 =head1 ACCESSORS
429  
430 =head2 fb
431  
432 The fallback locale/language that is used when no value in the locales hash matches the objects locale or language. You can get or set this attribute and it expects a Str value. This attribute will default to be 'en'.
433  
434 $obj->fb;
435  
436 $obj->fb($value);
437  
438 =head2 locale
439  
440 The locale that will be checked for first when stringiying. You can get or set this attribute and it expects a Str value. This attribute will default to use Posix::setlocale
441  
442 $obj->locale;
443  
444 $obj->locale($value);
445  
446 =head2 language
447  
448 The language that will be checked for second when stringifying. You can get or set this attribute and it expects a Str value. This attribute will be defaulted to be the first part of a locale.
449  
450 $obj->language;
451  
452 $obj->language($value);
453  
454 =head2 locales
455  
456 The hash reference of strings that map to each locale.
457  
458 $obj->locales({
459 stranger => {
460 en_US => 'Howdy stranger!'
461 }
462 })
463
464  
465 =head1 AUTHOR
466  
467 LNATION, C<< <email at lnation.org> >>
468  
469 =head1 BUGS
470  
471 Please report any bugs or feature requests to C<bug-hades::myths::object at rt.cpan.org>, or through
472 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Myths-Object>. I will be notified, and then you'll
473 automatically be notified of progress on your bug as I make changes.
474  
475 =head1 SUPPORT
476  
477 You can find documentation for this module with the perldoc command.
478  
479 perldoc Hades::Myths::Object
480  
481 You can also look for information at:
482  
483 =over 4
484  
485 =item * RT: CPAN's request tracker (report bugs here)
486  
487 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Myths-Object>
488  
489 =item * AnnoCPAN: Annotated CPAN documentation
490  
491 L<http://annocpan.org/dist/Hades-Myths-Object>
492  
493 =item * CPAN Ratings
494  
495 L<https://cpanratings.perl.org/d/Hades-Myths-Object>
496  
497 =item * Search CPAN
498  
499 L<https://metacpan.org/release/Hades-Myths-Object>
500  
501 =back
502  
503 =head1 ACKNOWLEDGEMENTS
504  
505 =head1 LICENSE AND COPYRIGHT
506  
507 This software is Copyright (c) 2020 by LNATION.
508  
509 This is free software, licensed under:
510  
511 The Artistic License 2.0 (GPL Compatible)
512  
513 =cut
514  
515
« Hades/Macro/FH.pm ↑ Summary Hades/Macro.pm »