| 1 | package Net::Amazon::S3::Utils; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: misc utils | ||||||||||||||||||||||||||||
| 3 | 99 | $Net::Amazon::S3::Utils::VERSION = '0.99'; | |||||||||||||||||||||||||||
| 4 | sub parse_arguments { | ||||||||||||||||||||||||||||
| 5 | 206 | ▶ | my ($self, $arguments, $positional, $aliases) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 6 | 206 | my %args; | |||||||||||||||||||||||||||
| 7 | 206 | ▶ | $aliases = {} unless $aliases; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 206 | ▶ | 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 | 206 | my %positional = map +($_ => 1), grep ! exists $args{$_}, @$positional; | |||||||||||||||||||||||||||
| 13 | 206 | my $positional_count = scalar keys %positional; | |||||||||||||||||||||||||||
| 14 | 206 | ▶ | 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 | 471 | my ($name, $value) = splice @$arguments, -2, 2; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 471 | ▶ | next if exists $args{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 470 | $args{$name} = $value; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 470 | ▶ | $name = $aliases->{$name} if exists $aliases->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 470 | ▶ | if (exists $positional{$name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 155 | $positional_count--; | |||||||||||||||||||||||||||
| 25 | 155 | delete $positional{$name}; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | #die "Odd number of named arguments" | ||||||||||||||||||||||||||||
| 30 | # if @$arguments != $positional_count; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 206 | for my $key (keys %$aliases) { | |||||||||||||||||||||||||||
| 33 | 141 | ▶ | 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 | 206 | for my $name (@$positional) { | |||||||||||||||||||||||||||
| 40 | 291 | ▶ | next if exists $args{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 136 | $args{$name} = shift @$arguments; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 206 | return %args; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub parse_arguments_with_bucket { | ||||||||||||||||||||||||||||
| 48 | 59 | ▶ | my ($self, $arguments) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments_with_bucket: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 59 | return $self->parse_arguments ($arguments, [qw[ bucket ]], { name => 'bucket' }); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub parse_arguments_with_bucket_and_object { | ||||||||||||||||||||||||||||
| 54 | 7 | ▶ | my ($self, $arguments) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments_with_bucket_and_object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 7 | return $self->parse_arguments ($arguments, [qw[ bucket key ]], { name => 'bucket' }); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub parse_arguments_with_object { | ||||||||||||||||||||||||||||
| 60 | 74 | ▶ | my ($self, $arguments) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse_arguments_with_object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 74 | return $self->parse_arguments ($arguments, [qw[ key ]], { name => 'bucket' }); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 99 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =pod | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head1 NAME | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Net::Amazon::S3::Utils - misc utils | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 VERSION | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | version 0.99 | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Branislav Zahradník <barney@cpan.org> | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 90 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||