line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Demo::Story::Event; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
439
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new{ |
6
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
7
|
0
|
|
|
|
|
|
my $args = shift; |
8
|
|
|
|
|
|
|
|
9
|
0
|
0
|
|
|
|
|
if( ! $args ){ |
10
|
0
|
|
|
|
|
|
die( "No args passed" ); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
0
|
0
|
|
|
|
|
if( ! ref( $args ) eq 'HASH' ){ |
14
|
0
|
|
|
|
|
|
die( "args passed weren't a HASHREF" ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $self = {}; |
18
|
0
|
|
|
|
|
|
my $logger = Log::Log4perl->get_logger( "Git::Demo::Story::Event" ); |
19
|
0
|
|
|
|
|
|
$self->{logger} = $logger; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Required attributes |
22
|
0
|
|
|
|
|
|
foreach( qw/characters action type/ ){ |
23
|
0
|
0
|
|
|
|
|
if( ! $args->{$_} ){ |
24
|
0
|
|
|
|
|
|
die( "Required argument $_ not passed" ); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
$self->{$_} = $args->{$_}; |
27
|
|
|
|
|
|
|
} |
28
|
0
|
0
|
|
|
|
|
if( $args->{args} ){ |
29
|
0
|
0
|
|
|
|
|
if( ref( $args->{args} ) eq 'ARRAY' ){ |
30
|
0
|
|
|
|
|
|
$self->{args} = $args->{args}; |
31
|
|
|
|
|
|
|
}else{ |
32
|
0
|
|
|
|
|
|
die( "args is not an arrayref" ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
0
|
|
|
|
$self->{args} ||= []; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
bless $self, $class; |
38
|
0
|
|
|
|
|
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub characters{ |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
return $self->{characters}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub action{ |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
return $self->{action}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub type{ |
52
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
return $self->{type}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub args{ |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
return $self->{args}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub to_hash{ |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
my $hash = { characters => $self->{characters}, |
64
|
|
|
|
|
|
|
action => $self->{action}, |
65
|
|
|
|
|
|
|
type => $self->{type}, |
66
|
|
|
|
|
|
|
args => $self->{args} }; |
67
|
0
|
|
|
|
|
|
return $hash; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub stringify{ |
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
return sprintf( "%-12s %s %s\n", $self->{characters}, $self->{action}, join( ' ', @{ $self->{args} } ) ); |
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |