| 1 | package App::TimeTracker::Command::Billing; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Add a billing point as a tag to tasks | ||||||||||
| 4 | 1 | our $VERSION = '1.001'; # VERSION | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | sub munge_billing_start_attribs { | ||||||||
|
Subroutine
munge_billing_start_attribs: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 14 | 0 | my ( $class, $meta, $config ) = @_; | |||||||||
| 15 | 0 | my $billing = $config->{billing}; | |||||||||
| 16 | 0 | my %attr = ( | |||||||||
| 17 | isa => 'Str', | ||||||||||
| 18 | is => 'ro', | ||||||||||
| 19 | documentation => 'Billing', | ||||||||||
| 20 | ); | ||||||||||
| 21 | 0 | ▶ | $attr{required} = 1 if $billing->{required}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | if ( my $default = $billing->{default} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | ▶ | if ( $default eq 'strftime' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | my $format = $billing->{strftime}; | |||||||||
| 26 | 0 | ▶ | $attr{default} = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 27 | 0 | return DateTime->now->strftime($format); | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | } | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | $meta->add_attribute( 'billing' => \%attr ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | after '_load_attribs_start' => \&munge_billing_start_attribs; | |||||||||
| 36 | 1 | after '_load_attribs_append' => \&munge_billing_start_attribs; | |||||||||
| 37 | 1 | after '_load_attribs_continue' => \&munge_billing_start_attribs; | |||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | before [ 'cmd_start', 'cmd_continue', 'cmd_append' ] => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 40 | 0 | my $self = shift; | |||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | return unless my $billing = $self->billing; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | if (my $prefix = $self->config->{billing}{prefix}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | $billing = $prefix.$billing; | |||||||||
| 46 | } | ||||||||||
| 47 | 0 | $self->add_tag( $billing ); | |||||||||
| 48 | 1 | }; | |||||||||
| 49 | |||||||||||
| 50 | 1 | ▶ | no Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 51 | 1 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||