line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::App::Satpass2::Format::Dump; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2710
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use parent qw{ Astro::App::Satpass2::Format }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
|
|
1082
|
use Astro::App::Satpass2::Utils qw{ |
9
|
|
|
|
|
|
|
load_package |
10
|
|
|
|
|
|
|
CODE_REF |
11
|
|
|
|
|
|
|
@CARP_NOT |
12
|
2
|
|
|
2
|
|
112
|
}; |
|
2
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.052'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %dumper_hash = ( |
17
|
|
|
|
|
|
|
'YAML' => 'Dump', |
18
|
|
|
|
|
|
|
'Data::Dumper' => 'Dumper', |
19
|
|
|
|
|
|
|
'JSON' => 'to_json', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $dumper_default; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
2
|
|
|
2
|
1
|
852
|
my ( $class, @args ) = @_; |
28
|
2
|
|
|
|
|
18
|
my $self = $class->SUPER::new( @args ); |
29
|
2
|
50
|
|
|
|
20
|
if ( ! $self->dumper() ) { |
30
|
2
|
50
|
|
|
|
7
|
if ( $dumper_default ) { |
31
|
0
|
|
|
|
|
0
|
$self->dumper( $dumper_default ); |
32
|
|
|
|
|
|
|
} else { |
33
|
2
|
|
|
|
|
9
|
$self->dumper( |
34
|
|
|
|
|
|
|
'YAML,Data::Dumper' |
35
|
|
|
|
|
|
|
); |
36
|
2
|
|
|
|
|
6
|
$dumper_default = $self->dumper(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
|
|
|
10
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub dumper { |
45
|
6
|
|
|
6
|
1
|
15
|
my ( $self, @args ) = @_; |
46
|
6
|
100
|
|
|
|
24
|
@args or return $self->{+__PACKAGE__}{dumper}; |
47
|
2
|
|
|
|
|
5
|
my $val = shift @args; |
48
|
2
|
|
|
|
|
6
|
my $ref = ref $val; |
49
|
2
|
50
|
|
|
|
7
|
if ( ! $ref ) { |
|
|
0
|
|
|
|
|
|
50
|
2
|
|
|
|
|
18
|
foreach my $possible ( split qr{ , }smx, $val ) { |
51
|
4
|
50
|
|
|
|
17
|
my $code = $dumper_hash{$possible} or next; |
52
|
4
|
100
|
|
|
|
12
|
load_package( $possible ) or next; |
53
|
2
|
50
|
|
|
|
35
|
$code = $possible->can( $code ) or next; |
54
|
2
|
|
|
|
|
5
|
$val = $code; |
55
|
2
|
|
|
|
|
5
|
last; |
56
|
|
|
|
|
|
|
} |
57
|
2
|
50
|
|
|
|
13
|
ref $val |
58
|
|
|
|
|
|
|
or $self->wail( |
59
|
|
|
|
|
|
|
"Unknown or unavailable dumper class '$val'" ); |
60
|
|
|
|
|
|
|
} elsif ( CODE_REF ne $ref ) { |
61
|
0
|
|
|
|
|
0
|
$self->wail( |
62
|
|
|
|
|
|
|
'Dumper must be a code ref or the name of a known class' ); |
63
|
|
|
|
|
|
|
} |
64
|
2
|
|
|
|
|
8
|
$self->{+__PACKAGE__}{dumper} = $val; |
65
|
2
|
|
|
|
|
5
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _dump { |
69
|
0
|
|
|
0
|
|
|
my ( $self, $object ) = @_; |
70
|
0
|
0
|
|
|
|
|
if ( defined $object ) { |
71
|
0
|
|
|
|
|
|
return $self->dumper()->( $object ); |
72
|
|
|
|
|
|
|
} else { |
73
|
0
|
|
|
|
|
|
return ''; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub format : method { ## no critic (ProhibitBuiltInHomonyms) |
78
|
0
|
|
|
0
|
1
|
|
my ( $self, %data ) = @_; |
79
|
0
|
|
|
|
|
|
return $self->_dump( \%data ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |