line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package # Hide from PAUSE |
5
|
|
|
|
|
|
|
API::Shippo::Config; |
6
|
1
|
|
|
1
|
|
4
|
use Carp ( 'croak' ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
7
|
1
|
|
|
1
|
|
844
|
use YAML::XS (); |
|
1
|
|
|
|
|
3139
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
9882
|
use namespace::clean; |
|
1
|
|
|
|
|
33761
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
( my $value = __FILE__ ) =~ s{\.\w+$}{.yml}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub config_file |
14
|
|
|
|
|
|
|
{ |
15
|
1
|
|
|
1
|
0
|
4
|
my ( $class, $new_value ) = @_; |
16
|
1
|
50
|
|
|
|
10
|
return $value unless @_ > 1; |
17
|
0
|
|
|
|
|
0
|
$value = $new_value; |
18
|
0
|
|
|
|
|
0
|
return $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my $value = __PACKAGE__->parse_config_file; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub config |
26
|
|
|
|
|
|
|
{ |
27
|
1
|
|
|
1
|
0
|
2
|
my ( $class, $new_value ) = @_; |
28
|
1
|
50
|
|
|
|
7
|
return $value unless @_ > 1; |
29
|
0
|
|
|
|
|
0
|
$value = $new_value; |
30
|
0
|
|
|
|
|
0
|
return $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub parse_config_file |
35
|
|
|
|
|
|
|
{ |
36
|
1
|
|
|
1
|
0
|
4
|
my ( $class ) = @_; |
37
|
1
|
|
|
|
|
4
|
my $config_file = __PACKAGE__->config_file; |
38
|
1
|
50
|
|
|
|
72
|
unless ( -e $config_file ) { |
39
|
1
|
|
|
|
|
222
|
print STDERR << "EOF"; |
40
|
|
|
|
|
|
|
Oops! |
41
|
|
|
|
|
|
|
Configuration file not found: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$config_file |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
It should look something like this: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
--- |
48
|
|
|
|
|
|
|
private_token: |
49
|
|
|
|
|
|
|
public_token: |
50
|
|
|
|
|
|
|
default_token: public_token |
51
|
|
|
|
|
|
|
EOF |
52
|
1
|
|
|
|
|
10
|
return {}; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
0
|
|
|
|
|
open my $fh, '<:encoding(UTF-8)', $config_file |
55
|
|
|
|
|
|
|
or croak "Can't open file '$config_file': $!"; |
56
|
0
|
|
|
|
|
|
my $config_yaml = do { local $/ = <$fh> }; |
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
close $fh; |
58
|
0
|
|
|
|
|
|
return YAML::XS::Load( $config_yaml ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |