| 1 | package Geoffrey::Utils; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 17 | ▶ | use utf8; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 17 | ▶ | use 5.016; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 17 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 17 | ▶ | use Readonly; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 17 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | 17 | $Geoffrey::Utils::VERSION = '0.000206'; | |||||||||||||
| 10 | |||||||||||||||
| 11 | 17 | Readonly::Scalar our $INT_64BIT_SIGNED => 9_223_372_036_854_775_807; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 61 | ▶ | sub replace_spare { | ||||||||||||
|
Subroutine
replace_spare: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 14 | 61 | my ( $string, $options ) = @_; | |||||||||||||
| 15 | 61 | ▶ | if ( !$string ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | 1 | require Geoffrey::Exception::RequiredValue; | |||||||||||||
| 17 | 1 | Geoffrey::Exception::RequiredValue::throw_common( 'String to replace', __PACKAGE__ . '::replace_spare' ); | |||||||||||||
| 18 | } | ||||||||||||||
| 19 | 60 | ▶ | eval { $string =~ s/\{(\d+)\}/$options->[$1]/g; } or do { }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 20 | 60 | return $string; | |||||||||||||
| 21 | } | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 14 | ▶ | sub add_schema { | ||||||||||||
|
Subroutine
add_schema: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 24 | 14 | my ($s_string) = @_; | |||||||||||||
| 25 | 14 | ▶ | return q// unless $s_string; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | 13 | return qq~$s_string.~; | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 8 | ▶ | sub add_name { | ||||||||||||
|
Subroutine
add_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 30 | 8 | my ($hr_params) = @_; | |||||||||||||
| 31 | 8 | ▶ | return $hr_params->{name} if $hr_params->{name}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | 3 | my @name_values = ( $hr_params->{prefix} ); | |||||||||||||
| 33 | 3 | ▶ | push @name_values, $hr_params->{context} if $hr_params->{context}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 34 | 3 | push @name_values, time; | |||||||||||||
| 35 | 3 | return join q/_/, @name_values; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 56 | ▶ | sub obj_from_name { | ||||||||||||
|
Subroutine
obj_from_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 39 | 56 | my $s_module_name = shift; | |||||||||||||
| 40 | 56 | ▶ | if ( !$s_module_name ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | 1 | require Geoffrey::Exception::RequiredValue; | |||||||||||||
| 42 | 1 | Geoffrey::Exception::RequiredValue::throw_package_name('obj_from_name'); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | 55 | my $return_eval = eval qq~require $s_module_name~; | |||||||||||||
| 45 | 55 | ▶ | if ( !$return_eval ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | 2 | require Geoffrey::Exception::General; | |||||||||||||
| 47 | 2 | Geoffrey::Exception::General::throw_eval($@); | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | 53 | return $s_module_name->new(@_); | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | 3 | ▶ | sub converter_obj_from_name { | ||||||||||||
|
Subroutine
converter_obj_from_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 53 | 3 | my $s_converter_name = shift; | |||||||||||||
| 54 | 3 | return obj_from_name( 'Geoffrey::Converter::' . $s_converter_name ); | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 49 | ▶ | sub action_obj_from_name { | ||||||||||||
|
Subroutine
action_obj_from_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 58 | 49 | my $s_action_name = shift; | |||||||||||||
| 59 | 49 | return obj_from_name( 'Geoffrey::Action::' . $s_action_name, @_ ); | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 3 | ▶ | sub changelog_io_from_name { | ||||||||||||
|
Subroutine
changelog_io_from_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 63 | 3 | my $s_file_name = shift; | |||||||||||||
| 64 | 3 | return obj_from_name( 'Geoffrey::Changelog::' . $s_file_name ); | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 49 | ▶ | sub parse_package_sub { | ||||||||||||
|
Subroutine
parse_package_sub: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 68 | 49 | my ($s_action) = @_; | |||||||||||||
| 69 | 49 | my @a_action = split /\./, lc $s_action; | |||||||||||||
| 70 | 49 | my $s_sub = pop @a_action; | |||||||||||||
| 71 | 49 | return ( $s_sub, join q//, map { ucfirst } split /_/, ( join q/::/, map { ucfirst } @a_action ) ); | |||||||||||||
| 72 | } | ||||||||||||||
| 73 | |||||||||||||||
| 74 | 7 | ▶ | sub to_lowercase { | ||||||||||||
|
Subroutine
to_lowercase: called CC=8 SCAR=22.3
Pod
documented
| |||||||||||||||
| 75 | 7 | my ($ur_entry) = @_; | |||||||||||||
| 76 | 7 | ▶ | return unless $ur_entry; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 77 | 1 | ▶ | if ( ref($ur_entry) eq 'ARRAY' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 78 | 0 | $_ = to_lowercase($_) for @{$ur_entry}; | |||||||||||||
| 79 | 0 | return $ur_entry; | |||||||||||||
| 80 | } | ||||||||||||||
| 81 | 1 | for my $s_key ( sort keys %{$ur_entry} ) { | |||||||||||||
| 82 | 8 | my $ur_value = delete $ur_entry->{$s_key}; | |||||||||||||
| 83 | 8 | ▶ | next unless $ur_value; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 84 | 7 | ▶ | $ur_entry->{ lc $s_key eq 'plain_sql' ? 'as' : lc $s_key } = | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 85 | ref($ur_value) =~ /(HASH|ARRAY)/ ? to_lowercase($ur_value) : $ur_value; | ||||||||||||||
| 86 | } | ||||||||||||||
| 87 | 1 | return $ur_entry; | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | |||||||||||||||
| 90 | 17 | 1; # End of Geoffrey::Utils | |||||||||||||
| 91 | |||||||||||||||
| 92 | __END__ | ||||||||||||||