| 1 | package Spoon::Base; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | ▶ | use Spiffy 0.24 -Base; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use Spiffy qw(-yaml); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use Spiffy qw(WWW XXX YYY ZZZ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | # WWW - Creating a wrapper sub to require() IO::All caused spurious segfaults | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use IO::All 0.32; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | our @EXPORT = qw(io trace WWW XXX YYY ZZZ); | |||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | our @EXPORT_OK = qw(conf); | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | field used_classes => []; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | field 'encoding'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | const plugin_base_directory => './plugin'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | field using_debug => 0; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | field config_class => 'Spoon::Config'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 43 | ▶ | sub hub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hub: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 43 | ▶ | return $Spoon::Base::HUB | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $Spoon::Base::HUB and not @_
MC/DC50%1/2
defined $Spoon::Base::HUB and not @_
defined $Spoon::Base::HUB
not @_
Truth table66%2/3
A and not(B)
A= defined $Spoon::Base::HUBB= not @_
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | if defined($Spoon::Base::HUB) and not @_; | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | Carp::confess "Too late to create a new hub. One already exists" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | if defined $Spoon::Base::HUB; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | my ($args, @config_files); | |||||||||||||||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | local *paired_arguments = sub { qw(-config_class) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | ($args, @config_files) = $self->parse_arguments(@_); | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | my $config_class = $args->{-config_class} || | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | $self->can('config_class') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args->{"-config_class"} or $self->can("config_class")
MC/DC0%0/2
$args->{"-config_class"} or $self->can("config_class")
$args->{"-config_class"}
$self->can("config_class")
Truth table33%1/3
A or B
A= $args->{"-config_class"}B= $self->can("config_class")
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | ? $self->config_class | ||||||||||||||||||||||||||||||||||||||||||
| 31 | : 'Spoon::Config'; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | ▶ | eval "require $config_class"; die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | my $config = $config_class->new(@config_files); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 6 | my $hub_class = $config->hub_class; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | eval "require $hub_class"; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | my $hub = $hub_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 37 | config => $config, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | config_files => \@config_files, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | ▶ | sub destroy_hub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destroy_hub: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | undef $Spoon::Base::HUB; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 24 | ▶ | sub init { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub assert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | die "Assertion failed" unless shift; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub trace() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | require Spoon::Trace; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 11 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | *trace = \ &Spoon::Trace::trace; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | goto &trace; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub t { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
t: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | trace->mark; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub conf() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conf: not called CC=1 SCAR=4.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ($name, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $package = caller; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | *{$package . '::' . $name} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | return $self->{$name} | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if exists $self->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | $self->{$name} = exists($self->hub->config->{$name}) | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | ? $self->hub->config->{$name} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | : $default; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return bless {%$self}, ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub is_in_cgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_cgi: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | defined $ENV{GATEWAY_INTERFACE}; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub is_in_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_test: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | defined $ENV{SPOON_TEST}; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub have_plugin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
have_plugin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my $hub = $self->class_id eq 'hub' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | ? $self | ||||||||||||||||||||||||||||||||||||||||||
| 93 | : $self->hub; | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | eval { $hub->load_class(shift) } | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub plugin_directory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plugin_directory: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $dir = join '/', | |||||||||||||||||||||||||||||||||||||||||
| 100 | $self->plugin_base_directory, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | $self->class_id, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | mkdir $dir unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $dir; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=4 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 11 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | if ($self->is_in_cgi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | eval 'use CGI::Carp qw(fatalsToBrowser)'; die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $SIG{__DIE__} = sub { CGI::Carp::confess(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 113 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 4 | ▶ | $SIG{__DIE__} = sub { Carp::confess(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | $self->using_debug(1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | if ref $self; | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 11 | our ($UPPER, $LOWER, $ALPHA, $NUM, $ALPHANUM, $WORD, $WIKIWORD); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 11 | push @EXPORT_OK, qw($UPPER $LOWER $ALPHA $NUM $ALPHANUM $WORD $WIKIWORD); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 11 | our %EXPORT_TAGS = (char_classes => [@EXPORT_OK]); | |||||||||||||||||||||||||||||||||||||||||
| 125 | 11 | ▶ | if ($] < 5.008) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $UPPER = 'A-Z\xc0-\xde'; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $LOWER = 'a-z\xdf-\xff'; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $ALPHA = $UPPER . $LOWER; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $NUM = '0-9'; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $ALPHANUM = $ALPHA . $NUM; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $WORD = $ALPHANUM . '_'; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $WIKIWORD = $WORD; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 11 | $UPPER = '\p{UppercaseLetter}'; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 11 | $LOWER = '\p{LowercaseLetter}'; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 11 | $ALPHA = '\p{Letter}'; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 11 | $NUM = '\p{Number}'; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 11 | $ALPHANUM = '\p{Letter}\p{Number}\pM'; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 11 | $WORD = '\p{Letter}\p{Number}\p{ConnectorPunctuation}\pM'; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 11 | $WIKIWORD = "$UPPER$LOWER$NUM" . '\p{ConnectorPunctuation}\pM'; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub env_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
env_check: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $variable = shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | die "Environment variable '$variable' not set" | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | unless defined $ENV{$variable}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub dumper_to_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumper_to_file: not called CC=2 SCAR=13.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 11 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | local $Data::Dumper::Indent = 1; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | local $Data::Dumper::Terse = (@_ == 1) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | io("$path")->assert->print(Data::Dumper::Dumper(@_)); | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # Codecs and Escaping | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 11 | my $has_utf8; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | sub has_utf8 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_utf8: called CC=5 SCAR=17.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | $has_utf8 = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | return $has_utf8 if defined($has_utf8); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | $has_utf8 = $] < 5.008 ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | require Encode if $has_utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | sub utf8_decode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
utf8_decode: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | ▶ | $_[0] = Encode::decode('utf8', $_[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->has_utf8 and defined $_[0] and not &Encode::is_utf8($_[0])
$self->has_utf8 and defined $_[0]
MC/DC0%0/3
$self->has_utf8 and defined $_[0] and not &Encode::is_utf8($_[0])
$self->has_utf8
defined $_[0]
not &Encode::is_utf8($_[0])
Truth table25%1/4
A and B and not(C)
A= $self->has_utf8B= defined $_[0]C= not &Encode::is_utf8($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | if $self->has_utf8 and | ||||||||||||||||||||||||||||||||||||||||||
| 172 | defined $_[0] and | ||||||||||||||||||||||||||||||||||||||||||
| 173 | not Encode::is_utf8($_[0]); | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub utf8_encode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
utf8_encode: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $_[0] = Encode::encode('utf8', $_[0]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->has_utf8 and defined $_[0]
MC/DC0%0/2
$self->has_utf8 and defined $_[0]
$self->has_utf8
defined $_[0]
Truth table0%0/3
A and B
A= $self->has_utf8B= defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | if $self->has_utf8 and | ||||||||||||||||||||||||||||||||||||||||||
| 180 | defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub uri_escape { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_escape: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | require CGI::Util; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $self->utf8_encode($data); | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | return CGI::Util::escape($data); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub uri_unescape { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_unescape: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | require CGI::Util; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $data = CGI::Util::unescape($data); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->utf8_decode($data); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | # WWW - The CGI.pm version is broken in Chinese | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | ▶ | sub html_escape { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_escape: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 10 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 10 | $val =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 10 | $val =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 10 | $val =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 10 | $val =~ s/\(/(/g; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 10 | $val =~ s/\)/)/g; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | $val =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 10 | $val =~ s/'/'/g; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 10 | return $val; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub html_unescape { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_unescape: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | CGI::unescapeHTML(shift); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub base64_encode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base64_encode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | MIME::Base64::encode_base64(@_); | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub base64_decode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base64_decode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | MIME::Base64::decode_base64(@_); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # XXX Move to IO::All. Make more robust. Use Damian's prompting module. | ||||||||||||||||||||||||||||||||||||||||||
| 227 | package IO::All; | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub prompt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prompt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | print shift; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | io('-')->chomp->getline; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 11 | __END__ | |||||||||||||||||||||||||||||||||||||||||