| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Astro::App::Satpass2::ParseTime::Code; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 2001 | use 5.008; | 
|  | 2 |  |  |  |  | 8 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 2 |  |  | 2 |  | 11 | use strict; | 
|  | 2 |  |  |  |  | 12 |  | 
|  | 2 |  |  |  |  | 56 |  | 
| 6 | 2 |  |  | 2 |  | 9 | use warnings; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 58 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 2 |  |  | 2 |  | 10 | use parent qw{ Astro::App::Satpass2::ParseTime }; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 21 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 2 |  |  | 2 |  | 175 | use Astro::App::Satpass2::Utils qw{ CODE_REF HASH_REF @CARP_NOT }; | 
|  | 2 |  |  |  |  | 100 |  | 
|  | 2 |  |  |  |  | 295 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our $VERSION = '0.052'; | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 2 |  |  | 2 |  | 15 | use constant DUMMY	=> 'DUMMY'; | 
|  | 2 |  |  |  |  | 73 |  | 
|  | 2 |  |  |  |  | 1465 |  | 
| 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 |  |  |  |  | 19 | 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 | 3 | my ( $self, @args ) = @_; | 
| 36 | 1 | 50 |  |  |  | 12 | if ( @args ) { | 
| 37 | 1 |  |  |  |  | 3 | 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 |  |  |  | 2 | defined $name | 
| 41 |  |  |  |  |  |  | or $name = $val; | 
| 42 | 1 |  |  |  |  | 5 | 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 | 1790 | return __PACKAGE__; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | sub parse_time_absolute { | 
| 62 | 18 |  |  | 18 | 1 | 38 | 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 |  |  | 74 | return $self->{$pkg} ||= {}; | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | sub _call_code { | 
| 85 | 18 |  |  | 18 |  | 40 | my ( $self, @args ) = @_; | 
| 86 | 18 |  |  |  |  | 67 | ( undef, @args ) = Astro::App::Satpass2->__arguments( @args ); | 
| 87 |  |  |  |  |  |  | my $code = $self->_attr()->{_code} | 
| 88 | 18 | 50 |  |  |  | 54 | or $self->wail( 'No code specified' ); | 
| 89 | 18 |  |  |  |  | 59 | return $code->( $self, @args ); | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | sub _code_storage { | 
| 93 | 1 |  |  | 1 |  | 3 | my ( $self, $name, $code ) = @_; | 
| 94 | 1 |  |  |  |  | 3 | my $attr = $self->_attr(); | 
| 95 | 1 |  |  |  |  | 4 | $attr->{code} = $name; | 
| 96 | 1 |  |  |  |  | 2 | $attr->{_code} = $code; | 
| 97 | 1 |  |  |  |  | 4 | return $self; | 
| 98 |  |  |  |  |  |  | } | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | 1; | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | __END__ |