line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Boolean; |
2
|
|
|
|
|
|
|
# ABSTRACT: DEPRECATED module to comprehensively parse boolean response strings |
3
|
6
|
|
|
6
|
|
288172
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
429
|
|
4
|
6
|
|
|
6
|
|
35
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
252
|
|
5
|
6
|
|
|
6
|
|
152
|
use 5.010001; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
267
|
|
6
|
6
|
|
|
6
|
|
3566
|
use experimental qw/smartmatch/; |
|
6
|
|
|
|
|
3376
|
|
|
6
|
|
|
|
|
34
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.008'; # VERSION |
9
|
6
|
|
|
6
|
|
468
|
use Carp; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
3222
|
|
10
|
6
|
|
|
6
|
|
7252
|
use boolean 0.21 qw(true false); |
|
6
|
|
|
|
|
52351
|
|
|
6
|
|
|
|
|
49
|
|
11
|
6
|
|
|
6
|
|
10043
|
use String::Trim qw(trim); |
|
6
|
|
|
|
|
24246
|
|
|
6
|
|
|
|
|
1062
|
|
12
|
6
|
|
|
6
|
|
13439
|
use Module::Load qw(load); |
|
6
|
|
|
|
|
9703
|
|
|
6
|
|
|
|
|
55
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
371
|
use Exporter qw(import); |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
6695
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw(boolean); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
85
|
|
|
85
|
1
|
991
|
my $class = shift; |
21
|
85
|
|
|
|
|
170
|
my $lang = shift; |
22
|
|
|
|
|
|
|
|
23
|
85
|
|
|
|
|
135
|
my $objects; |
24
|
85
|
|
|
|
|
202
|
BUILD: foreach my $plugin ( map { __PACKAGE__ . "::$_" } qw/ English French / ) { |
|
170
|
|
|
|
|
597
|
|
25
|
170
|
|
|
|
|
689
|
load $plugin; |
26
|
170
|
|
|
|
|
10611
|
my $obj = $plugin->new(); |
27
|
170
|
100
|
100
|
|
|
2106
|
next BUILD if (defined $lang and $obj->{LANG} ne $lang); |
28
|
|
|
|
|
|
|
|
29
|
104
|
|
|
|
|
482
|
$objects->{ $obj->{LANG} } = $obj; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
85
|
|
|
|
|
289
|
my $self = { |
33
|
|
|
|
|
|
|
languages => $objects, |
34
|
|
|
|
|
|
|
lang => $lang, |
35
|
|
|
|
|
|
|
}; |
36
|
85
|
|
|
|
|
182
|
bless $self, $class; |
37
|
85
|
|
|
|
|
322
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _boolean { |
42
|
211
|
|
|
211
|
|
1047
|
my $self = shift; |
43
|
211
|
|
|
|
|
787
|
my $to_test = shift; |
44
|
211
|
|
100
|
|
|
599
|
my $lang = shift || 'en'; |
45
|
211
|
|
|
|
|
487
|
trim($to_test); |
46
|
|
|
|
|
|
|
|
47
|
211
|
100
|
|
|
|
3961
|
if ($self->_looks_true($to_test, $lang)) { |
|
|
100
|
|
|
|
|
|
48
|
80
|
|
|
|
|
1357
|
return true; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif ($self->_looks_false($to_test, $lang)) { |
51
|
75
|
|
|
|
|
1490
|
return false; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
18
|
|
|
|
|
3641
|
croak "'$to_test' isn't recognizable as either true or false"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub boolean { |
59
|
211
|
100
|
|
211
|
1
|
149821
|
my $self = ref $_[0] eq __PACKAGE__ ? shift : __PACKAGE__->new($_[1]); |
60
|
211
|
|
|
|
|
393
|
my $to_test = shift; |
61
|
211
|
|
66
|
|
|
886
|
my $lang = shift || $self->{lang}; |
62
|
211
|
|
|
|
|
4832
|
trim($to_test); |
63
|
|
|
|
|
|
|
|
64
|
211
|
|
|
|
|
5106
|
return $self->_boolean($to_test, $lang); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub languages { |
69
|
4
|
100
|
|
4
|
1
|
1211
|
my $self = ref $_[0] eq __PACKAGE__ ? shift : __PACKAGE__->new(); |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
7
|
my @long_names; |
72
|
4
|
|
|
|
|
5
|
foreach my $l (keys %{ $self->{languages} }) { |
|
4
|
|
|
|
|
24
|
|
73
|
8
|
|
|
|
|
26
|
push @long_names, $self->{languages}->{$l}->{LANGUAGE}; |
74
|
|
|
|
|
|
|
} |
75
|
4
|
|
|
|
|
45
|
return @long_names; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub langs { |
80
|
4
|
100
|
|
4
|
1
|
2850
|
my $self = ref $_[0] eq __PACKAGE__ ? shift : __PACKAGE__->new(); |
81
|
|
|
|
|
|
|
|
82
|
4
|
|
|
|
|
9
|
my @lang_codes = keys %{ $self->{languages} }; |
|
4
|
|
|
|
|
29
|
|
83
|
4
|
|
|
|
|
25
|
return @lang_codes; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _looks_true { |
88
|
211
|
|
|
211
|
|
3532
|
my $self = shift; |
89
|
211
|
|
|
|
|
302
|
my $to_test = shift; |
90
|
211
|
|
50
|
|
|
442
|
my $lang = shift || 'en'; |
91
|
211
|
|
|
|
|
692
|
trim($to_test); |
92
|
|
|
|
|
|
|
|
93
|
211
|
100
|
|
|
|
9228
|
croak "I don't know anything about the language '$lang'" unless exists $self->{languages}->{$lang}->{match}->{True}; |
94
|
173
|
100
|
|
|
|
2118
|
return true if ($to_test ~~ $self->{languages}->{$lang}->{match}->{True}); |
95
|
93
|
|
|
|
|
277
|
return false; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _looks_false { |
99
|
93
|
|
|
93
|
|
1244
|
my $self = shift; |
100
|
93
|
|
|
|
|
137
|
my $to_test = shift; |
101
|
93
|
|
50
|
|
|
370
|
my $lang = shift || 'en'; |
102
|
93
|
|
|
|
|
219
|
trim($to_test); |
103
|
|
|
|
|
|
|
|
104
|
93
|
50
|
|
|
|
2109
|
croak "I don't know anything about the language '$lang'" unless exists $self->{languages}->{$lang}->{match}->{False}; |
105
|
93
|
100
|
|
|
|
1098
|
return true if ($to_test ~~ $self->{languages}->{$lang}->{match}->{False}); |
106
|
18
|
|
|
|
|
50
|
return false; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |