| 1 | package Flickr::Tools; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use Flickr::API; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Flickr::Roles::Permissions; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Flickr::Types::Tools qw( FlickrAPI FlickrToken FlickrAPIargs HexNum); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Types::Standard qw( Maybe Str HashRef Int InstanceOf Bool); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Storable qw( retrieve_fd ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use strictures; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4 | our $VERSION = '1.22'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | with('Flickr::Roles::Permissions'); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | has _api => ( | |||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||
| 23 | isa => InstanceOf ['Flickr::API'], | ||||||||||||||||||||||||||||
| 24 | clearer => 1, | ||||||||||||||||||||||||||||
| 25 | predicate => 'has_api', | ||||||||||||||||||||||||||||
| 26 | lazy => 1, | ||||||||||||||||||||||||||||
| 27 | builder => '_build_api', | ||||||||||||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | has '_api_name' => ( | ||||||||||||||||||||||||||||
| 32 | is => 'ro', | ||||||||||||||||||||||||||||
| 33 | 4 | ▶ | isa => sub { $_[0] =~ m/^Flickr::API$/ }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 4 | required => 1, | |||||||||||||||||||||||||||
| 35 | default => 'Flickr::API', | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | has access_token => ( | |||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||
| 40 | clearer => 1, | ||||||||||||||||||||||||||||
| 41 | isa => Maybe [ InstanceOf ['Net::OAuth::AccessTokenResponse'] ], | ||||||||||||||||||||||||||||
| 42 | required => 0, | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 4 | has auth_uri => ( | |||||||||||||||||||||||||||
| 46 | is => 'ro', | ||||||||||||||||||||||||||||
| 47 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 48 | clearer => 1, | ||||||||||||||||||||||||||||
| 49 | required => 0, | ||||||||||||||||||||||||||||
| 50 | default => 'https://api.flickr.com/services/oauth/authorize', | ||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 4 | has callback => ( | |||||||||||||||||||||||||||
| 54 | is => 'ro', | ||||||||||||||||||||||||||||
| 55 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 56 | clearer => 1, | ||||||||||||||||||||||||||||
| 57 | required => 0, | ||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 4 | has config_file => ( | |||||||||||||||||||||||||||
| 61 | is => 'ro', | ||||||||||||||||||||||||||||
| 62 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 63 | clearer => 1, | ||||||||||||||||||||||||||||
| 64 | required => 0, | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 4 | has consumer_key => ( | |||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||
| 69 | isa => HexNum, | ||||||||||||||||||||||||||||
| 70 | required => 1, | ||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 4 | has consumer_secret => ( | |||||||||||||||||||||||||||
| 74 | is => 'ro', | ||||||||||||||||||||||||||||
| 75 | isa => HexNum, | ||||||||||||||||||||||||||||
| 76 | required => 1, | ||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 4 | has local => ( | |||||||||||||||||||||||||||
| 80 | is => 'rw', | ||||||||||||||||||||||||||||
| 81 | isa => Maybe [HashRef], | ||||||||||||||||||||||||||||
| 82 | clearer => 1, | ||||||||||||||||||||||||||||
| 83 | required => 0, | ||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 4 | has request_method => ( | |||||||||||||||||||||||||||
| 87 | is => 'ro', | ||||||||||||||||||||||||||||
| 88 | clearer => 1, | ||||||||||||||||||||||||||||
| 89 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 90 | required => 0, | ||||||||||||||||||||||||||||
| 91 | default => 'GET', | ||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 4 | has request_token => ( | |||||||||||||||||||||||||||
| 95 | is => 'ro', | ||||||||||||||||||||||||||||
| 96 | isa => Maybe [ InstanceOf ['Net::OAuth::V1_0A::RequestTokenResponse'] ], | ||||||||||||||||||||||||||||
| 97 | clearer => 1, | ||||||||||||||||||||||||||||
| 98 | required => 0, | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 4 | has request_url => ( | |||||||||||||||||||||||||||
| 102 | is => 'ro', | ||||||||||||||||||||||||||||
| 103 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 104 | clearer => 1, | ||||||||||||||||||||||||||||
| 105 | required => 0, | ||||||||||||||||||||||||||||
| 106 | default => 'https://api.flickr.com/services/rest/', | ||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 4 | has rest_uri => ( | |||||||||||||||||||||||||||
| 110 | is => 'ro', | ||||||||||||||||||||||||||||
| 111 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 112 | clearer => 1, | ||||||||||||||||||||||||||||
| 113 | required => 0, | ||||||||||||||||||||||||||||
| 114 | default => 'https://api.flickr.com/services/rest/', | ||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 4 | has signature_method => ( | |||||||||||||||||||||||||||
| 118 | is => 'ro', | ||||||||||||||||||||||||||||
| 119 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 120 | clearer => 1, | ||||||||||||||||||||||||||||
| 121 | required => 0, | ||||||||||||||||||||||||||||
| 122 | default => 'HMAC-SHA1', | ||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 4 | has token => ( | |||||||||||||||||||||||||||
| 126 | is => 'ro', | ||||||||||||||||||||||||||||
| 127 | isa => Maybe [FlickrToken], | ||||||||||||||||||||||||||||
| 128 | predicate => 1, | ||||||||||||||||||||||||||||
| 129 | clearer => 1, | ||||||||||||||||||||||||||||
| 130 | required => 0, | ||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 4 | has token_secret => ( | |||||||||||||||||||||||||||
| 134 | is => 'ro', | ||||||||||||||||||||||||||||
| 135 | isa => Maybe [HexNum], | ||||||||||||||||||||||||||||
| 136 | predicate => 1, | ||||||||||||||||||||||||||||
| 137 | clearer => 1, | ||||||||||||||||||||||||||||
| 138 | required => 0, | ||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | has unicode => ( | ||||||||||||||||||||||||||||
| 142 | is => 'ro', | ||||||||||||||||||||||||||||
| 143 | 3 | ▶ | isa => sub { $_[0] != 0 ? 1 : 0; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 4 | clearer => 1, | |||||||||||||||||||||||||||
| 145 | required => 0, | ||||||||||||||||||||||||||||
| 146 | default => 0, | ||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 4 | has _user => ( | |||||||||||||||||||||||||||
| 150 | is => 'rw', | ||||||||||||||||||||||||||||
| 151 | isa => Maybe [HashRef], | ||||||||||||||||||||||||||||
| 152 | predicate => 1, | ||||||||||||||||||||||||||||
| 153 | clearer => 1, | ||||||||||||||||||||||||||||
| 154 | required => 0, | ||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 4 | has version => ( | |||||||||||||||||||||||||||
| 158 | is => 'ro', | ||||||||||||||||||||||||||||
| 159 | isa => Maybe [Str], | ||||||||||||||||||||||||||||
| 160 | clearer => 1, | ||||||||||||||||||||||||||||
| 161 | required => 0, | ||||||||||||||||||||||||||||
| 162 | default => '1.0', | ||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub _dump { | ||||||||||||||||||||||||||
|
Subroutine
_dump: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 167 | 0 | say 'Examine the tool'; | |||||||||||||||||||||||||||
| 168 | 0 | print Dumper($self); | |||||||||||||||||||||||||||
| 169 | 0 | return; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 9 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=9 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 9 | my $class = shift; | |||||||||||||||||||||||||||
| 175 | 9 | my $args = shift; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 9 | my $import; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | # args should be either a hashref, or a string containing the path to a config file | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 9 | ▶ | unless ( ref $args ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 2 | my $config_filename = $args; | |||||||||||||||||||||||||||
| 184 | 2 | undef $args; | |||||||||||||||||||||||||||
| 185 | 2 | $args->{config_file} = $config_filename; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | confess | ||||||||||||||||||||||||||||
| 190 | 9 | ▶ | "\n\nFlickr::Tools->new() expects a hashref,\n or at least the name of a config file\n\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | unless ref($args) eq 'HASH'; | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 6 | ▶ | if ( $args->{config_file} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 1 | ▶ | if ( -r $args->{config_file} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | my $info = Storable::file_magic( $args->{config_file} ); | |||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ( $info->{version} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | open my $IMPORT, '<', $args->{config_file} | ||||||||||||||||||||||||||||
| 201 | 0 | ▶ | or carp "\nCannot open $args->{config_file} for read: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | $import = retrieve_fd($IMPORT); | |||||||||||||||||||||||||||
| 203 | 0 | close $IMPORT; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | else { | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | carp $args->{config_file}, | ||||||||||||||||||||||||||||
| 209 | 0 | " is not in storable format, removing from arguments\n"; | |||||||||||||||||||||||||||
| 210 | 0 | delete $args->{config_file}; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | else { | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | carp $args->{config_file}, | ||||||||||||||||||||||||||||
| 216 | 1 | " is not a readable file, removing from arguments\n"; | |||||||||||||||||||||||||||
| 217 | 1 | delete $args->{config_file}; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 6 | my $fullargs = _merge_configs( $args, $import ); | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 6 | ▶ | unless (exists( $fullargs->{consumer_key} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $fullargs->{"consumer_key"} and exists $fullargs->{"consumer_secret"}
MC/DC0%0/2
exists $fullargs->{"consumer_key"} and exists $fullargs->{"consumer_secret"}
exists $fullargs->{"consumer_key"}
exists $fullargs->{"consumer_secret"}
Truth table33%1/3
A and B
A= exists $fullargs->{"consumer_key"}B= exists $fullargs->{"consumer_secret"}
| |||||||||||||||||||||||||||||
| 225 | and exists( $fullargs->{consumer_secret} ) ) | ||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | carp | |||||||||||||||||||||||||||
| 229 | "\nMust provide, at least, a consumer_key and consumer_secret. They can be\npassed directly or in a config_file\n"; | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 6 | return $fullargs; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 9 | ▶ | sub api { | ||||||||||||||||||||||||||
|
Subroutine
api: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 237 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 238 | 9 | ▶ | return $self->_api if $self->has_api; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 3 | $self->_build_api; | |||||||||||||||||||||||||||
| 240 | 3 | return $self->_api; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub clear_api { | ||||||||||||||||||||||||||
|
Subroutine
clear_api: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 244 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 245 | 0 | $self->_clear_api; | |||||||||||||||||||||||||||
| 246 | 0 | $self->_clear_api_connects; | |||||||||||||||||||||||||||
| 247 | 0 | return; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub user { | ||||||||||||||||||||||||||
|
Subroutine
user: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 251 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 252 | 0 | ▶ | return $self->_user if $self->_has_user; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | carp 'No user found'; | |||||||||||||||||||||||||||
| 254 | 0 | return; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub prepare_method { } | ||||||||||||||||||||||||||
|
Subroutine
prepare_method: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub validate_method { } | ||||||||||||||||||||||||||
|
Subroutine
validate_method: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub call_method { } | ||||||||||||||||||||||||||
|
Subroutine
call_method: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub make_arglist { } | ||||||||||||||||||||||||||
|
Subroutine
make_arglist: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub auth_method { } | ||||||||||||||||||||||||||
|
Subroutine
auth_method: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub set_method { | ||||||||||||||||||||||||||
|
Subroutine
set_method: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 268 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 269 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ( $args->{method} =~ m/flickr\.people\./x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | else { | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | return; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | # then specific tools::person or such operate on the family of methods | ||||||||||||||||||||||||||||
| 282 | # and they can override some of the above. | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 3 | ▶ | sub _build_api { | ||||||||||||||||||||||||||
|
Subroutine
_build_api: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 287 | 3 | my $args = shift; | |||||||||||||||||||||||||||
| 288 | 3 | my $call = {}; | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | # required args | ||||||||||||||||||||||||||||
| 291 | 3 | $call->{consumer_key} = $self->consumer_key; | |||||||||||||||||||||||||||
| 292 | 3 | $call->{consumer_secret} = $self->consumer_secret; | |||||||||||||||||||||||||||
| 293 | 3 | $call->{api_type} = 'oauth'; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 3 | $call->{unicode} = $self->unicode; | |||||||||||||||||||||||||||
| 296 | 3 | $call->{request_method} = $self->request_method; | |||||||||||||||||||||||||||
| 297 | 3 | $call->{request_url} = $self->request_url; | |||||||||||||||||||||||||||
| 298 | 3 | $call->{rest_uri} = $self->rest_uri; | |||||||||||||||||||||||||||
| 299 | 3 | $call->{auth_uri} = $self->auth_uri; | |||||||||||||||||||||||||||
| 300 | 3 | $call->{signature_method} = $self->signature_method; | |||||||||||||||||||||||||||
| 301 | 3 | $call->{version} = $self->version; | |||||||||||||||||||||||||||
| 302 | 3 | $call->{callback} = $self->callback; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 3 | ▶ | if ( $self->has_token && $self->has_token_secret ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->has_token and $self->has_token_secret
MC/DC0%0/2
$self->has_token and $self->has_token_secret
$self->has_token
$self->has_token_secret
Truth table33%1/3
A and B
A= $self->has_tokenB= $self->has_token_secret
| |||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 3 | $call->{token} = $self->token; | |||||||||||||||||||||||||||
| 307 | 3 | $call->{token_secret} = $self->token_secret; | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 3 | $self->{_api} = $self->{_api_name}->new($call); | |||||||||||||||||||||||||||
| 312 | 3 | return; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | # | ||||||||||||||||||||||||||||
| 316 | # make a template configuration and overwrite template values | ||||||||||||||||||||||||||||
| 317 | # with ones passed into new(). Any extra keys get weeded out | ||||||||||||||||||||||||||||
| 318 | # and added to args->{local}->{unused_keys} | ||||||||||||||||||||||||||||
| 319 | # | ||||||||||||||||||||||||||||
| 320 | 6 | ▶ | sub _merge_configs { | ||||||||||||||||||||||||||
|
Subroutine
_merge_configs: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 321 | 6 | my @hashes = (@_); | |||||||||||||||||||||||||||
| 322 | 6 | my $template = _make_config_template(); | |||||||||||||||||||||||||||
| 323 | 6 | my $extrakeys = {}; | |||||||||||||||||||||||||||
| 324 | 6 | my $key; | |||||||||||||||||||||||||||
| 325 | my $value; | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 6 | foreach my $hashref (@hashes) { | |||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 12 | ▶ | while ( ( $key, $value ) = each %{$hashref} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 9 | ▶ | if ( exists( $template->{$key} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 9 | $template->{$key} = $value; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | else { | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | $extrakeys->{$key} = $value; | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 6 | $template->{local}->{unused_args} = $extrakeys; | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 6 | return $template; | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | # | ||||||||||||||||||||||||||||
| 349 | # make a shell of a configuration to deal with any random stuff | ||||||||||||||||||||||||||||
| 350 | # that might be sent into new(). | ||||||||||||||||||||||||||||
| 351 | # | ||||||||||||||||||||||||||||
| 352 | 6 | ▶ | sub _make_config_template { | ||||||||||||||||||||||||||
|
Subroutine
_make_config_template: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 6 | my %empty = ( | |||||||||||||||||||||||||||
| 355 | access_token => undef, | ||||||||||||||||||||||||||||
| 356 | auth_uri => 'https://api.flickr.com/services/oauth/authorize', | ||||||||||||||||||||||||||||
| 357 | callback => undef, | ||||||||||||||||||||||||||||
| 358 | config_file => undef, | ||||||||||||||||||||||||||||
| 359 | consumer_key => undef, | ||||||||||||||||||||||||||||
| 360 | consumer_secret => undef, | ||||||||||||||||||||||||||||
| 361 | local => undef, | ||||||||||||||||||||||||||||
| 362 | nonce => undef, | ||||||||||||||||||||||||||||
| 363 | request_method => 'GET', | ||||||||||||||||||||||||||||
| 364 | request_token => undef, | ||||||||||||||||||||||||||||
| 365 | request_url => 'https://api.flickr.com/services/rest/', | ||||||||||||||||||||||||||||
| 366 | rest_uri => 'https://api.flickr.com/services/rest/', | ||||||||||||||||||||||||||||
| 367 | signature_method => 'HMAC-SHA1', | ||||||||||||||||||||||||||||
| 368 | timestamp => undef, | ||||||||||||||||||||||||||||
| 369 | token => undef, | ||||||||||||||||||||||||||||
| 370 | token_secret => undef, | ||||||||||||||||||||||||||||
| 371 | unicode => 0, | ||||||||||||||||||||||||||||
| 372 | user => undef, | ||||||||||||||||||||||||||||
| 373 | version => '1.0', | ||||||||||||||||||||||||||||
| 374 | ); | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 6 | return \%empty; | |||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 4 | 1; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | __END__ | ||||||||||||||||||||||||||||