| 1 | package SMS::Send::Driver::WebService; | ||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use base qw{SMS::Send::Driver}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use URI qw{}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use Path::Class qw{}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Config::IniFiles qw{}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use HTTP::Tiny qw{}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 9 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 11 | 9 | our $PACKAGE = __PACKAGE__; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | SMS::Send::Driver::WebService - SMS::Send driver base class for web services | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | package SMS::Send::My::Driver; | ||||||||||||||||||||||||||||
| 20 | use base qw{SMS::Send::Driver::WebService}; | ||||||||||||||||||||||||||||
| 21 | sub send_sms { | ||||||||||||||||||||||||||||
| 22 | my $self = shift; | ||||||||||||||||||||||||||||
| 23 | my $ua = $self->ua; #isa LWP::UserAgent | ||||||||||||||||||||||||||||
| 24 | my $uat = $self->uat; #isa HTTP::Tiny | ||||||||||||||||||||||||||||
| 25 | my $cfg = self->cfg; #isa Config::IniFiles | ||||||||||||||||||||||||||||
| 26 | #call web service die on critical error | ||||||||||||||||||||||||||||
| 27 | #parse return with a package like XML::Simple or JSON::XS | ||||||||||||||||||||||||||||
| 28 | #return 1 for successful or 0 for unsuccessful | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | The SMS::Send::Driver::WebService package provides an L<SMS::Send> driver base class to support two common needs. The first need is a base class that provides L<LWP::UserAgent> as a simple method. The second need is a way to configure various setting for multiple SMS providers without having to rebuild the SMS::Send driver concept. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 USAGE | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | use base qw{SMS::Send::Driver::WebService}; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head1 METHODS | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head2 new | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | SMS::Send API; Note: $service isa SMS::Send object in this syntax | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | my $service = SMS::Send->new("My::Driver", | ||||||||||||||||||||||||||||
| 46 | _username => $username, | ||||||||||||||||||||||||||||
| 47 | _password => $password, | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | Driver API; Note: $service isa SMS::Send::My::Driver object in this syntax | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | my $service = SMS::Send::My::Driver->new( | ||||||||||||||||||||||||||||
| 53 | username => $username, | ||||||||||||||||||||||||||||
| 54 | password => $password, | ||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | SMS::Send API with SMS-Send.ini file | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | SMS-Send.ini | ||||||||||||||||||||||||||||
| 60 | [My::Driver1] | ||||||||||||||||||||||||||||
| 61 | username=user1 | ||||||||||||||||||||||||||||
| 62 | password=pass1 | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | [My::Driver2] | ||||||||||||||||||||||||||||
| 65 | username=user2 | ||||||||||||||||||||||||||||
| 66 | password=pass2 | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | my $service1 = SMS::Send->new("My::Driver1"); #username and password read from SMS-Send.ini | ||||||||||||||||||||||||||||
| 69 | my $service2 = SMS::Send->new("My::Driver2"); #username and password read from SMS-Send.ini | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Driver API with SMS-Send.ini file | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | my $service = SMS::Send::My::Driver1->new; | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 9 | my $this=shift; | |||||||||||||||||||||||||||
| 79 | 9 | ▶ | my $class=ref($this) || $this; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table33%1/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||
| 80 | 9 | my $self={}; | |||||||||||||||||||||||||||
| 81 | 9 | bless $self, $class; | |||||||||||||||||||||||||||
| 82 | 9 | $self->initialize(@_); | |||||||||||||||||||||||||||
| 83 | 9 | return $self; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 initialize | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Initializes data to compensate for the API deltas between SMS::Send and this package (i.e. removes underscore "_" from all parameters passed) | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | In this example | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | SMS::Send->new("My::Driver", _password => "mypassword"); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | _password would be available to the driver as password=>"mypassword"; | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 9 | ▶ | sub initialize { | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 9 | my $self=shift; | |||||||||||||||||||||||||||
| 100 | 9 | my %hash=@_; | |||||||||||||||||||||||||||
| 101 | #SMS::Send API deltas | ||||||||||||||||||||||||||||
| 102 | 9 | foreach my $key (keys %hash) { | |||||||||||||||||||||||||||
| 103 | 27 | ▶ | if ($key =~ m/^_(.*)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | my $newkey=$1; | |||||||||||||||||||||||||||
| 105 | 0 | $hash{$newkey}=delete($hash{$key}); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 9 | %$self=%hash; | |||||||||||||||||||||||||||
| 109 | 9 | return $self; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head2 send_sms | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | You will need to overload this method in your sub class. | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | Override in sub class (Example from Kannel SMSBox implementation) | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | sub send_sms { | ||||||||||||||||||||||||||||
| 119 | my $self = shift; | ||||||||||||||||||||||||||||
| 120 | my %argv = @_; | ||||||||||||||||||||||||||||
| 121 | my $to = $argv{"to"} or die("Error: to address required"); | ||||||||||||||||||||||||||||
| 122 | my $text = defined($argv{"text"}) ? $argv{"text"} : ''; #use < 5.10 syntax to support older Perls | ||||||||||||||||||||||||||||
| 123 | my $url = $self->url; #isa URI | ||||||||||||||||||||||||||||
| 124 | my @form = ( | ||||||||||||||||||||||||||||
| 125 | username => $self->username, | ||||||||||||||||||||||||||||
| 126 | password => $self->password, | ||||||||||||||||||||||||||||
| 127 | to => $to, | ||||||||||||||||||||||||||||
| 128 | text => $text, | ||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||
| 130 | $url->query_form(\@form); #isa URI | ||||||||||||||||||||||||||||
| 131 | my $response = $self->ua->get($url); #isa HTTP::Response see LWP::UserAgent->get | ||||||||||||||||||||||||||||
| 132 | die(sprintf("HTTP Error: %s", $response->status_line)) unless $response->is_success; | ||||||||||||||||||||||||||||
| 133 | my $content = $response->decoded_content; | ||||||||||||||||||||||||||||
| 134 | return $content =~ m/^0:/ ? 1 : 0; #0: Accepted for delivery | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head1 PROPERTIES | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =head2 username | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Sets and returns the username string value | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | Override in sub class | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | sub _username_default {"myusername"}; | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Override in configuration | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | [My::Driver] | ||||||||||||||||||||||||||||
| 150 | username=myusername | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =cut | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 6 | ▶ | sub username { | ||||||||||||||||||||||||||
|
Subroutine
username: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 6 | my $self=shift; | |||||||||||||||||||||||||||
| 156 | 6 | ▶ | $self->{'username'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 6 | ▶ | $self->{'username'}=$self->cfg_property('username', $self->_username_default) unless defined $self->{'username'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 6 | ▶ | die('Error: username property required') unless defined $self->{'username'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 6 | return $self->{'username'}; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 2 | ▶ | sub _username_default {undef}; | ||||||||||||||||||||||||||
|
Subroutine
_username_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =head2 password | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | Sets and returns the password string value (passed to the web service as PWD) | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | Override in sub class | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | sub _password_default {"mypassword"}; | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | Override in configuration | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | [My::Driver] | ||||||||||||||||||||||||||||
| 175 | password=mypassword | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =cut | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 4 | ▶ | sub password { | ||||||||||||||||||||||||||
|
Subroutine
password: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 180 | 4 | my $self=shift; | |||||||||||||||||||||||||||
| 181 | 4 | ▶ | $self->{'password'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 4 | ▶ | $self->{'password'}=$self->cfg_property('password', $self->_password_default) unless defined $self->{'password'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 4 | ▶ | die('Error: password property required') unless defined $self->{'password'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 4 | return $self->{'password'}; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 2 | ▶ | sub _password_default {undef}; | ||||||||||||||||||||||||||
|
Subroutine
_password_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | =head2 host | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | Default: 127.0.0.1 | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | Override in sub class | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | sub _host_default {"myhost.domain.tld"}; | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | Override in configuration | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | [My::Driver] | ||||||||||||||||||||||||||||
| 200 | host=myhost.domain.tld | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =cut | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 9 | ▶ | sub host { | ||||||||||||||||||||||||||
|
Subroutine
host: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 205 | 9 | my $self=shift; | |||||||||||||||||||||||||||
| 206 | 9 | ▶ | $self->{'host'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 9 | ▶ | $self->{'host'}=$self->cfg_property('host', $self->_host_default) unless defined $self->{'host'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 9 | return $self->{'host'}; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 2 | ▶ | sub _host_default {'127.0.0.1'}; | ||||||||||||||||||||||||||
|
Subroutine
_host_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =head2 protocol | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | Default: http | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | Override in sub class | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | sub _protocol_default {"https"}; | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | Override in configuration | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | [My::Driver] | ||||||||||||||||||||||||||||
| 224 | protocol=https | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 9 | ▶ | sub protocol { | ||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 229 | 9 | my $self=shift; | |||||||||||||||||||||||||||
| 230 | 9 | ▶ | $self->{'protocol'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 9 | ▶ | $self->{'protocol'}=$self->cfg_property('protocol', $self->_protocol_default) unless defined $self->{'protocol'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 9 | return $self->{'protocol'}; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 2 | ▶ | sub _protocol_default {'http'}; | ||||||||||||||||||||||||||
|
Subroutine
_protocol_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head2 port | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | Default: 80 | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | Override in sub class | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | sub _port_default {443}; | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | Override in configuration | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | [My::Driver] | ||||||||||||||||||||||||||||
| 248 | port=443 | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | =cut | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 9 | ▶ | sub port { | ||||||||||||||||||||||||||
|
Subroutine
port: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 253 | 9 | my $self=shift; | |||||||||||||||||||||||||||
| 254 | 9 | ▶ | $self->{'port'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 9 | ▶ | $self->{'port'}=$self->cfg_property('port', $self->_port_default) unless defined $self->{'port'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 9 | return $self->{'port'}; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 2 | ▶ | sub _port_default {'80'}; | ||||||||||||||||||||||||||
|
Subroutine
_port_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | =head2 script_name | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | Default: /cgi-bin/sendsms | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | Override in sub class | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | sub _script_name_default {"/path/file"}; | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | Override in configuration | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | [My::Driver] | ||||||||||||||||||||||||||||
| 272 | script_name=/path/file | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | =cut | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 10 | ▶ | sub script_name { | ||||||||||||||||||||||||||
|
Subroutine
script_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 277 | 10 | my $self=shift; | |||||||||||||||||||||||||||
| 278 | 10 | ▶ | $self->{'script_name'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 10 | ▶ | $self->{'script_name'}=$self->cfg_property('script_name', $self->_script_name_default) unless defined $self->{'script_name'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 10 | return $self->{'script_name'}; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 2 | ▶ | sub _script_name_default {'/cgi-bin/sendsms'}; | ||||||||||||||||||||||||||
|
Subroutine
_script_name_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =head2 url | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | Returns a L<URI> object based on above properties OR returns a string from sub class or configuration file. | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | Override in sub class (Can be a string or any object that stringifies to a URL) | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | sub _url_default {"http://myservice.domain.tld/path/file"}; | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | Override in configuration | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | [My::Driver] | ||||||||||||||||||||||||||||
| 296 | url=http://myservice.domain.tld/path/file | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | Overriding the url method in the sub class or the configuration makes the protocol, host, port, and script_name methods inoperable. | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | =cut | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 6 | ▶ | sub url { | ||||||||||||||||||||||||||
|
Subroutine
url: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 303 | 6 | my $self=shift; | |||||||||||||||||||||||||||
| 304 | 6 | ▶ | $self->{'url'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 6 | ▶ | $self->{'url'}=$self->cfg_property('url', $self->_url_default) unless defined $self->{'url'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 6 | ▶ | unless (defined $self->{'url'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 1 | my $url=URI->new(); | |||||||||||||||||||||||||||
| 308 | 1 | $url->scheme($self->protocol); | |||||||||||||||||||||||||||
| 309 | 1 | $url->host($self->host); | |||||||||||||||||||||||||||
| 310 | 1 | $url->port($self->port); | |||||||||||||||||||||||||||
| 311 | 1 | $url->path($self->script_name); | |||||||||||||||||||||||||||
| 312 | 1 | $self->{'url'}=$url; #object assignment | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | #print $self->{'url'}, "\n"; | ||||||||||||||||||||||||||||
| 315 | 6 | return $self->{'url'}; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 3 | ▶ | sub _url_default {undef}; | ||||||||||||||||||||||||||
|
Subroutine
_url_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | =head1 OBJECT ACCESSORS | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | =head2 uat | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | Returns a lazy loaded L<HTTP::Tiny> object | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =cut | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 1 | ▶ | sub uat { | ||||||||||||||||||||||||||
|
Subroutine
uat: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 329 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 330 | 1 | ▶ | unless ($self->{'uat'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 1 | $self->{'uat'} = HTTP::Tiny->new( | |||||||||||||||||||||||||||
| 332 | keep_alive => 0, #override bad default | ||||||||||||||||||||||||||||
| 333 | agent => $self->_http_agent, | ||||||||||||||||||||||||||||
| 334 | ); | ||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | 1 | return $self->{'uat'}; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | =head2 ua | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | Returns a lazy loaded L<LWP::UserAgent> object | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | =cut | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 1 | ▶ | sub ua { | ||||||||||||||||||||||||||
|
Subroutine
ua: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 346 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 347 | 1 | ▶ | unless ($self->{'ua'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | 1 | local $@; | |||||||||||||||||||||||||||
| 349 | 1 | ▶ | eval 'use LWP::UserAgent'; #Lazy Load Package | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 350 | 1 | my $error = $@; | |||||||||||||||||||||||||||
| 351 | 1 | ▶ | die($error) if $error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | 1 | $self->{'ua'} = LWP::UserAgent->new( | |||||||||||||||||||||||||||
| 353 | env_proxy => 1, #override bad default | ||||||||||||||||||||||||||||
| 354 | agent => $self->_http_agent, | ||||||||||||||||||||||||||||
| 355 | ); | ||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | 1 | return $self->{'ua'}; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 2 | ▶ | sub _http_agent { | ||||||||||||||||||||||||||
|
Subroutine
_http_agent: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 361 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 362 | 2 | ▶ | $self->{'_http_agent'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | $self->{'_http_agent'} = "Mozilla/5.0 (compatible; $PACKAGE/$VERSION; See rt.cpan.org 35173)" | ||||||||||||||||||||||||||||
| 364 | 2 | ▶ | unless defined $self->{'_http_agent'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 2 | return $self->{'_http_agent'}; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | =head2 cfg | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | Returns a lazy loaded L<Config::IniFiles> object so that you can read settings from the INI file. | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | my $cfg=$driver->cfg; #isa Config::IniFiles | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =cut | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 74 | ▶ | sub cfg { | ||||||||||||||||||||||||||
|
Subroutine
cfg: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 377 | 74 | my $self=shift; | |||||||||||||||||||||||||||
| 378 | 74 | ▶ | unless (exists $self->{'cfg'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | 5 | my $file=$self->cfg_file; | |||||||||||||||||||||||||||
| 380 | 5 | ▶ | if ($file and -r $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$file and -r $file
MC/DC0%0/2
$file and -r $file
$file
-r $file
Truth table33%1/3
A and B
A= $fileB= -r $file
| |||||||||||||||||||||||||||||
| 381 | 5 | $self->{'cfg'}=Config::IniFiles->new(-file=>"$file") | |||||||||||||||||||||||||||
| 382 | } else { | ||||||||||||||||||||||||||||
| 383 | 0 | $self->{'cfg'}=undef; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | 74 | return $self->{'cfg'}; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =head2 cfg_file | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | Sets or returns the profile INI filename | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | my $file=$driver->cfg_file; | ||||||||||||||||||||||||||||
| 395 | my $file=$driver->cfg_file("./my.ini"); | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | Set on construction | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | my $driver=SMS::Send::My::Driver->new(cfg_file=>"./my.ini"); | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | Default: SMS-Send.ini | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =cut | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 9 | ▶ | sub cfg_file { | ||||||||||||||||||||||||||
|
Subroutine
cfg_file: called CC=7 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||
| 406 | 9 | my $self=shift; | |||||||||||||||||||||||||||
| 407 | 9 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 408 | 0 | $self->{'cfg_file'}=shift; | |||||||||||||||||||||||||||
| 409 | 0 | ▶ | die(sprintf(qq{Error: Cannot read file "%s".}, $self->{'cfg_file'})) unless -r $self->{'cfg_file'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | 9 | ▶ | unless (defined $self->{'cfg_file'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 5 | ▶ | die(sprintf(qq{Error: path method returned a "%s"; expecting an array reference.}, ref($self->cfg_path))) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 413 | unless ref($self->cfg_path) eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 414 | 5 | foreach my $path (@{$self->cfg_path}) { | |||||||||||||||||||||||||||
| 415 | 5 | $self->{'cfg_file'}=Path::Class::file($path, $self->_cfg_file_default); | |||||||||||||||||||||||||||
| 416 | 5 | ▶ | last if -r $self->{'cfg_file'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | #We may not have a vaild file here? We'll let Config::IniFiles catch the error. | ||||||||||||||||||||||||||||
| 420 | 9 | return $self->{'cfg_file'}; | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 5 | ▶ | sub _cfg_file_default {'SMS-Send.ini'}; | ||||||||||||||||||||||||||
|
Subroutine
_cfg_file_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =head2 cfg_path | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | Sets and returns a list of search paths for the INI file. | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | my $path=$driver->cfg_path; # [] | ||||||||||||||||||||||||||||
| 430 | my $path=$driver->cfg_path(".", ".."); # [] | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | Default: ["."] | ||||||||||||||||||||||||||||
| 433 | Default: [".", 'C:\Windows'] on Windows-like systems that have Win32 installed | ||||||||||||||||||||||||||||
| 434 | Default: [".", "/etc"] on other systems that have Sys::Path installed | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | override in sub class | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | sub cfg_path {["/my/path"]}; | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | =cut | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 18 | ▶ | sub cfg_path { | ||||||||||||||||||||||||||
|
Subroutine
cfg_path: called CC=6 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||
| 443 | 18 | my $self=shift; | |||||||||||||||||||||||||||
| 444 | 18 | ▶ | $self->{'path'}=[@_] if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 445 | 18 | ▶ | unless (ref($self->{'path'}) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | 5 | my @path=('.'); | |||||||||||||||||||||||||||
| 447 | 5 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | 0 | eval('use Win32'); | |||||||||||||||||||||||||||
| 449 | 0 | ▶ | push @path, eval('Win32::GetFolderPath(Win32::CSIDL_WINDOWS)') unless $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 450 | } else { | ||||||||||||||||||||||||||||
| 451 | 0 | ▶ | eval('use Sys::Path'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 452 | 5 | ▶ | push @path, eval('Sys::Path->sysconfdir') unless $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | 5 | $self->{'path'}=\@path; | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | 18 | return $self->{'path'}; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =head2 cfg_section | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | Returns driver name as specified by package namespace | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | Example | ||||||||||||||||||||||||||||
| 464 | package SMS::Send::My::Driver; | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | Configuration in SMS-Send.ini file | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | [My::Driver] | ||||||||||||||||||||||||||||
| 469 | username=myuser | ||||||||||||||||||||||||||||
| 470 | password=mypass | ||||||||||||||||||||||||||||
| 471 | host=myserver | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | =cut | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 38 | ▶ | sub cfg_section { | ||||||||||||||||||||||||||
|
Subroutine
cfg_section: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 476 | 38 | my $self=shift; | |||||||||||||||||||||||||||
| 477 | 38 | ▶ | $self->{'cfg_section'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | 38 | ▶ | unless ($self->{'cfg_section'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | 4 | my $section=ref($self); | |||||||||||||||||||||||||||
| 480 | 4 | $section =~ s/\ASMS::Send:://; | |||||||||||||||||||||||||||
| 481 | 4 | $self->{'cfg_section'}=$section; | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | 38 | return $self->{'cfg_section'}; | |||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | =head2 cfg_property | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | my $property=$self->cfg_property("username"); | ||||||||||||||||||||||||||||
| 489 | my $property=$self->cfg_property("host", "mydefault"); | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =cut | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 35 | ▶ | sub cfg_property { | ||||||||||||||||||||||||||
|
Subroutine
cfg_property: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 494 | 35 | my $self = shift; | |||||||||||||||||||||||||||
| 495 | 35 | ▶ | my $property = shift or die('Error: property name required'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | 35 | my $default = shift; #|| undef | |||||||||||||||||||||||||||
| 497 | 35 | my $cfg = $self->cfg; | |||||||||||||||||||||||||||
| 498 | 35 | ▶ | if ($cfg) { #if config object | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 499 | 34 | return $self->cfg->val($self->cfg_section, $property, $default); | |||||||||||||||||||||||||||
| 500 | } else { | ||||||||||||||||||||||||||||
| 501 | 1 | return $default; | |||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | =head2 warnings | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | Enable warnings to STDERR for issues such as failed resource and web calls | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | $ws->warnings(1); | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | Default: 0 | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | Override in sub class | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | sub _warnings_default {1}; | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | Override in configuration | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | [My::Driver] | ||||||||||||||||||||||||||||
| 520 | warnings=1 | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | =cut | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 6 | ▶ | sub warnings { | ||||||||||||||||||||||||||
|
Subroutine
warnings: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 525 | 6 | my $self=shift; | |||||||||||||||||||||||||||
| 526 | 6 | ▶ | $self->{'warnings'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 527 | 6 | ▶ | $self->{'warnings'}=$self->cfg_property('warnings', $self->_warnings_default) unless defined $self->{'warnings'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 528 | 6 | return $self->{'warnings'}; | |||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | 2 | ▶ | sub _warnings_default {0}; | ||||||||||||||||||||||||||
|
Subroutine
_warnings_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =head2 debug | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | Enable debug level to STDOUT for logging information such as steps, urls, and parameters | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | $ws->debug(5); | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | Default: 0 | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | Override in sub class | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | sub _debug_default {5}; | ||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | Override in configuration | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | [My::Driver] | ||||||||||||||||||||||||||||
| 548 | debug=5 | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | =cut | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | 6 | ▶ | sub debug { | ||||||||||||||||||||||||||
|
Subroutine
debug: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 554 | 6 | my $self=shift; | |||||||||||||||||||||||||||
| 555 | 6 | ▶ | $self->{'debug'}=shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 556 | 6 | ▶ | $self->{'debug'}=$self->cfg_property('debug', $self->_debug_default) unless defined $self->{'debug'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 557 | 6 | return $self->{'debug'}; | |||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 2 | ▶ | sub _debug_default {0}; | ||||||||||||||||||||||||||
|
Subroutine
_debug_default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | =head1 ISSUES | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | Please open issue on GitHub | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | Michael R. Davis | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | Copyright (c) 2025 Michael R. Davis | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | MIT License | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | L<SMS::Send> | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | =cut | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | 9 | 1; | |||||||||||||||||||||||||||