line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
86188
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
19
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
61
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Acme::Odometer; |
7
|
|
|
|
|
|
|
$Acme::Odometer::VERSION = '0.0.4'; |
8
|
1
|
|
|
1
|
|
920
|
use Moo 1.001; |
|
1
|
|
|
|
|
17172
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
2401
|
use namespace::clean; |
|
1
|
|
|
|
|
13176
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
598
|
use GD; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Memoize; |
13
|
|
|
|
|
|
|
use MooX::Types::MooseLike::Numeric qw(PositiveInt PositiveOrZeroInt); |
14
|
|
|
|
|
|
|
use Path::Class qw( file ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
memoize( '_digit_as_image' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has asset_path => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has file_extension => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
required => 0, |
26
|
|
|
|
|
|
|
default => 'gif', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has _digit_height => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => PositiveInt, |
32
|
|
|
|
|
|
|
required => 0, |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
builder => '_build_height', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has _digit_width => ( |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
isa => PositiveInt, |
40
|
|
|
|
|
|
|
required => 0, |
41
|
|
|
|
|
|
|
lazy => 1, |
42
|
|
|
|
|
|
|
builder => '_build_width', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has _first_image => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
init_arg => undef, |
48
|
|
|
|
|
|
|
lazy => 1, |
49
|
|
|
|
|
|
|
builder => '_build_first_image', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has _i => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => PositiveOrZeroInt, |
55
|
|
|
|
|
|
|
required => 0, |
56
|
|
|
|
|
|
|
init_arg => undef, |
57
|
|
|
|
|
|
|
writer => '_set_i', |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _build_width { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
return $self->_first_image->width; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_height { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
return $self->_first_image->height; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _build_first_image { |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
return $self->_digit_as_image( substr( $self->_i, 0, 1 ) ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _digit_as_image { |
76
|
|
|
|
|
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
my $digit = sprintf( "%i.%s", shift(), $self->file_extension ); |
78
|
|
|
|
|
|
|
return GD::Image->new( file( $self->asset_path, $digit )->stringify ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub image { |
82
|
|
|
|
|
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
$self->_set_i( shift() ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $total_width = $self->_digit_width * length $self->_i; |
86
|
|
|
|
|
|
|
my $im = GD::Image->new( $total_width, $self->_digit_height ); |
87
|
|
|
|
|
|
|
my $percent = 100; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $pos = 0; |
90
|
|
|
|
|
|
|
foreach my $digit ( split //, $self->_i ) { |
91
|
|
|
|
|
|
|
$im->copyMergeGray( |
92
|
|
|
|
|
|
|
$self->_digit_as_image( $digit ), |
93
|
|
|
|
|
|
|
$pos * $self->_digit_width, |
94
|
|
|
|
|
|
|
0, 0, 0, $self->_digit_width, $self->_digit_height, $percent |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
$pos++; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return $im; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# ABSTRACT: Create graphical web counters |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |