line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Astro::App::Satpass2::ParseTime::Code; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2047
|
use 5.008; |
|
2
|
|
|
|
|
9
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
43
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
19
|
use parent qw{ Astro::App::Satpass2::ParseTime }; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
24
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
164
|
use Astro::App::Satpass2::Utils qw{ CODE_REF HASH_REF @CARP_NOT }; |
|
2
|
|
|
|
|
87
|
|
|
2
|
|
|
|
|
299
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.051'; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
16
|
use constant DUMMY => 'DUMMY'; |
|
2
|
|
|
|
|
75
|
|
|
2
|
|
|
|
|
1516
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# __arguments() is normally called as a subroutine, but it needs access |
17
|
|
|
|
|
|
|
# to this namespace to figure out the options, so we just load this |
18
|
|
|
|
|
|
|
# module and then call __arguments() as a static method. |
19
|
|
|
|
|
|
|
require Astro::App::Satpass2; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub attribute_names { |
22
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
23
|
1
|
|
|
|
|
10
|
return ( $self->SUPER::attribute_names(), qw{ code } ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub class_name_of_record { |
27
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
28
|
0
|
|
|
|
|
0
|
my $code = $self->code(); |
29
|
0
|
0
|
|
|
|
0
|
ref $code |
30
|
|
|
|
|
|
|
and $code = DUMMY; |
31
|
0
|
|
|
|
|
0
|
return $code; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub code { |
35
|
1
|
|
|
1
|
1
|
4
|
my ( $self, @args ) = @_; |
36
|
1
|
50
|
|
|
|
3
|
if ( @args ) { |
37
|
1
|
|
|
|
|
2
|
my ( $val, $name ) = @args; |
38
|
1
|
50
|
|
|
|
4
|
if ( my $ref = ref $val ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
3
|
if ( CODE_REF eq $ref ) { |
40
|
1
|
50
|
|
|
|
3
|
defined $name |
41
|
|
|
|
|
|
|
or $name = $val; |
42
|
1
|
|
|
|
|
3
|
return $self->_code_storage( $name, $val ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} elsif ( $val =~ m/ ( .* ) :: ( .* ) /smx ) { |
45
|
0
|
0
|
|
|
|
0
|
if ( my $code = $1->can( $2 ) ) { |
46
|
0
|
|
|
|
|
0
|
return $self->_code_storage( $val, $code ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} elsif ( my $code = caller->can( $val ) ) { |
49
|
0
|
|
|
|
|
0
|
return $self->_code_storage( $val, $code ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
$self->wail( |
52
|
0
|
|
|
|
|
0
|
'Code attribute must be a CODE ref or a subroutine name' ); |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
0
|
return $self->_attr()->{code}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub delegate { |
58
|
3
|
|
|
3
|
1
|
1655
|
return __PACKAGE__; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub parse_time_absolute { |
62
|
18
|
|
|
18
|
1
|
40
|
my ( $self, $string ) = @_; |
63
|
18
|
|
|
|
|
43
|
return $self->_call_code( parse => $string ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub tz { |
67
|
0
|
|
|
0
|
1
|
0
|
my ( $self, @args ) = @_; |
68
|
|
|
|
|
|
|
@args |
69
|
0
|
0
|
|
|
|
0
|
and $self->_call_code( tz => $args[0] ); |
70
|
0
|
|
|
|
|
0
|
return $self->SUPER::tz( @args ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub use_perltime { |
74
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
75
|
0
|
|
|
|
|
0
|
return $self->_call_code( 'use_perltime' ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _attr { |
79
|
19
|
|
|
19
|
|
40
|
my ( $self ) = @_; |
80
|
19
|
|
|
|
|
33
|
my $pkg = __PACKAGE__; |
81
|
19
|
|
100
|
|
|
76
|
return $self->{$pkg} ||= {}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _call_code { |
85
|
18
|
|
|
18
|
|
40
|
my ( $self, @args ) = @_; |
86
|
18
|
|
|
|
|
77
|
( undef, @args ) = Astro::App::Satpass2->__arguments( @args ); |
87
|
|
|
|
|
|
|
my $code = $self->_attr()->{_code} |
88
|
18
|
50
|
|
|
|
57
|
or $self->wail( 'No code specified' ); |
89
|
18
|
|
|
|
|
71
|
return $code->( $self, @args ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _code_storage { |
93
|
1
|
|
|
1
|
|
4
|
my ( $self, $name, $code ) = @_; |
94
|
1
|
|
|
|
|
3
|
my $attr = $self->_attr(); |
95
|
1
|
|
|
|
|
2
|
$attr->{code} = $name; |
96
|
1
|
|
|
|
|
2
|
$attr->{_code} = $code; |
97
|
1
|
|
|
|
|
4
|
return $self; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |