| 1 | package Amazon::SQS::Config; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Config::IniFiles; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Scalar::Util qw(openhandle); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | our $VERSION = '2.0.6'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | Readonly::Array our @REQUIRED_ACCESSORS => qw( | |||||||||||||||||||||||||||
| 16 | aws_access_key_id | ||||||||||||||||||||||||||||
| 17 | aws_secret_access_key | ||||||||||||||||||||||||||||
| 18 | error_delete | ||||||||||||||||||||||||||||
| 19 | error_exit | ||||||||||||||||||||||||||||
| 20 | handler_class | ||||||||||||||||||||||||||||
| 21 | handler_pidfile | ||||||||||||||||||||||||||||
| 22 | log_file | ||||||||||||||||||||||||||||
| 23 | log_level | ||||||||||||||||||||||||||||
| 24 | queue_create_queue | ||||||||||||||||||||||||||||
| 25 | queue_name | ||||||||||||||||||||||||||||
| 26 | queue_url | ||||||||||||||||||||||||||||
| 27 | queue_interval | ||||||||||||||||||||||||||||
| 28 | queue_max_messages | ||||||||||||||||||||||||||||
| 29 | queue_max_wait | ||||||||||||||||||||||||||||
| 30 | queue_visibility_timeout | ||||||||||||||||||||||||||||
| 31 | queue_wait_time | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||
| 35 | 2 | __PACKAGE__->mk_accessors(qw(config file queue_list service)); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | use parent qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | ######################################################################## | ||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | ######################################################################## | ||||||||||||||||||||||||||||
| 42 | 1 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $options = ref $args[0] ? $args[0] : {@args}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 1 | my $self = $class->SUPER::new($options); | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | my $file = $self->get_file; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | die "file is a required argument\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | if !$file; | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | ▶ | die sprintf "no such file: [%s]\n", $file | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&openhandle($file) or -e $file
MC/DC0%0/2
&openhandle($file) or -e $file
&openhandle($file)
-e $file
Truth table33%1/3
A or B
A= &openhandle($file)B= -e $file
| |||||||||||||||||||||||||||||
| 54 | if !openhandle($file) && !-e $file; | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | my $config = Config::IniFiles->new( | |||||||||||||||||||||||||||
| 57 | -file => $self->get_file, | ||||||||||||||||||||||||||||
| 58 | -fallback => 'main' | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | $self->set_config($config); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | $self->create_config_accessors(); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | my @required_accessors = grep { !$self->can($_) } @REQUIRED_ACCESSORS; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1 | $self->mk_accessors(@required_accessors); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 1 | return $self; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | ######################################################################## | ||||||||||||||||||||||||||||
| 73 | 1 | ▶ | sub create_config_accessors { | ||||||||||||||||||||||||||
|
Subroutine
create_config_accessors: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | ######################################################################## | ||||||||||||||||||||||||||||
| 75 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | my $config = $self->get_config; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | my @sections = $config->Sections; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | foreach my $section (@sections) { | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 4 | my %section_config; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 4 | foreach ( $config->Parameters($section) ) { | |||||||||||||||||||||||||||
| 86 | 9 | $section_config{$_} = $self->get_config->val( $section, $_ ); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 4 | my @extra_vars = keys %section_config; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 4 | ▶ | if (@extra_vars) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 2 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 93 | 4 | my @ok_vars; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 4 | for (@extra_vars) { | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 9 | ▶ | my $name = $section eq 'main' ? $_ : "${section}_$_"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | next | ||||||||||||||||||||||||||||
| 100 | 9 | ▶ | if defined *{ ref($self) . q{::} . "get_$name" }{CODE}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 9 | push @ok_vars, $_; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 4 | ▶ | $self->mk_accessors( map { $section eq 'main' ? $_ : "${section}_$_" } @ok_vars ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 4 | for (@extra_vars) { | |||||||||||||||||||||||||||
| 108 | 9 | ▶ | my $name = $section eq 'main' ? $_ : "${section}_$_"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 9 | $self->set( "$name", $section_config{$_} ); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1 | return $self; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 2 | 1; | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||||||||||