| 1 | package Net::Amazon::S3::Utils; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: misc utils | ||||||||||||||||||||||||||||
| 3 | 99 | $Net::Amazon::S3::Utils::VERSION = '0.992'; | |||||||||||||||||||||||||||
| 4 | 355 | ▶ | sub parse_arguments { | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 5 | 355 | my ($self, $arguments, $positional, $aliases) = @_; | |||||||||||||||||||||||||||
| 6 | 355 | my %args; | |||||||||||||||||||||||||||
| 7 | 355 | ▶ | $aliases = {} unless $aliases; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 355 | ▶ | push @$arguments, %{ pop @$arguments } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$arguments and Ref::Util::XS::is_plain_hashref($arguments->[-1])
MC/DC100%2/2
@$arguments and Ref::Util::XS::is_plain_hashref($arguments->[-1])
@$arguments
Ref::Util::XS::is_plain_hashref($arguments->[-1])
Truth table100%3/3
A and B
A= @$argumentsB= Ref::Util::XS::is_plain_hashref($arguments->[-1])
| |||||||||||||||||||||||||||||
| 10 | if @$arguments && Ref::Util::is_plain_hashref ($arguments->[-1]); | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 355 | my %positional = map +($_ => 1), grep ! exists $args{$_}, @$positional; | |||||||||||||||||||||||||||
| 13 | 355 | my $positional_count = scalar keys %positional; | |||||||||||||||||||||||||||
| 14 | 355 | ▶ | while (@$arguments > 1 && @$arguments > $positional_count) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$arguments > 1 and @$arguments > $positional_count
MC/DC100%2/2
@$arguments > 1 and @$arguments > $positional_count
@$arguments > 1
@$arguments > $positional_count
Truth table100%3/3
A and B
A= @$arguments > 1B= @$arguments > $positional_count
| |||||||||||||||||||||||||||||
| 15 | 473 | my ($name, $value) = splice @$arguments, -2, 2; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 473 | ▶ | next if exists $args{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 472 | $args{$name} = $value; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 472 | ▶ | $name = $aliases->{$name} if exists $aliases->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 472 | ▶ | if (exists $positional{$name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 156 | $positional_count--; | |||||||||||||||||||||||||||
| 25 | 156 | delete $positional{$name}; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | #die "Odd number of named arguments" | ||||||||||||||||||||||||||||
| 30 | # if @$arguments != $positional_count; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 355 | for my $key (keys %$aliases) { | |||||||||||||||||||||||||||
| 33 | 290 | ▶ | next unless exists $args{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 2 | my $value = delete $args{$key}; | |||||||||||||||||||||||||||
| 35 | 2 | my $alias_for = $aliases->{$key}; | |||||||||||||||||||||||||||
| 36 | 2 | ▶ | $args{$alias_for} = $value unless exists $args{$alias_for}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 355 | for my $name (@$positional) { | |||||||||||||||||||||||||||
| 40 | 440 | ▶ | next if exists $args{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 284 | $args{$name} = shift @$arguments; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 355 | return %args; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 208 | ▶ | sub parse_arguments_with_bucket { | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments_with_bucket: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 208 | my ($self, $arguments) = @_; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 208 | return $self->parse_arguments ($arguments, [qw[ bucket ]], { name => 'bucket' }); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 7 | ▶ | sub parse_arguments_with_bucket_and_object { | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments_with_bucket_and_object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 7 | my ($self, $arguments) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 7 | return $self->parse_arguments ($arguments, [qw[ bucket key ]], { name => 'bucket' }); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 74 | ▶ | sub parse_arguments_with_object { | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments_with_object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 74 | my ($self, $arguments) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 74 | return $self->parse_arguments ($arguments, [qw[ key ]], { name => 'bucket' }); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 99 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||