line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Acme::Chef::Ingredient; |
3
|
|
|
|
|
|
|
|
4
|
10
|
|
|
10
|
|
51
|
use strict; |
|
10
|
|
|
|
|
88
|
|
|
10
|
|
|
|
|
347
|
|
5
|
10
|
|
|
10
|
|
50
|
use warnings; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
286
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
40
|
use Carp; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
682
|
|
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
43
|
use vars qw/$VERSION %Measures %MeasureTypes/; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
5386
|
|
10
|
|
|
|
|
|
|
$VERSION = '1.00'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Acme::Chef::Ingredient - Internal module used by Acme::Chef |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Acme::Chef; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Please see L; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 METHODS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This is a list of methods in the package. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 2 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
%Measures = ( |
34
|
|
|
|
|
|
|
'' => '', |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
g => 'dry', |
37
|
|
|
|
|
|
|
kg => 'dry', |
38
|
|
|
|
|
|
|
pinch => 'dry', |
39
|
|
|
|
|
|
|
pinches => 'dry', |
40
|
|
|
|
|
|
|
ml => 'liquid', |
41
|
|
|
|
|
|
|
l => 'liquid', |
42
|
|
|
|
|
|
|
dash => 'liquid', |
43
|
|
|
|
|
|
|
dashes => 'liquid', |
44
|
|
|
|
|
|
|
cup => '', |
45
|
|
|
|
|
|
|
cups => '', |
46
|
|
|
|
|
|
|
teaspoon => '', |
47
|
|
|
|
|
|
|
teaspoons => '', |
48
|
|
|
|
|
|
|
tablespoon => '', |
49
|
|
|
|
|
|
|
tablespoons => '', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
%MeasureTypes = ( |
53
|
|
|
|
|
|
|
heaped => 'dry', |
54
|
|
|
|
|
|
|
level => 'dry', |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item new |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Acme::Chef::Ingredient constructor. Takes key/value pairs as argument which |
60
|
|
|
|
|
|
|
will be used as attributes. The following attributes are currently |
61
|
|
|
|
|
|
|
required: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
name |
64
|
|
|
|
|
|
|
value |
65
|
|
|
|
|
|
|
measure |
66
|
|
|
|
|
|
|
measure_type |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new { |
71
|
1643
|
|
|
1643
|
1
|
1366
|
my $proto = shift; |
72
|
1643
|
|
66
|
|
|
3105
|
my $class = ref $proto || $proto; |
73
|
|
|
|
|
|
|
|
74
|
1643
|
|
|
|
|
1663
|
my $self = {}; |
75
|
|
|
|
|
|
|
|
76
|
1643
|
100
|
|
|
|
2620
|
if ( ref $proto ) { |
77
|
1587
|
|
|
|
|
5035
|
%$self = %$proto; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
1643
|
|
|
|
|
2232
|
my %args = @_; |
81
|
|
|
|
|
|
|
|
82
|
1643
|
|
|
|
|
8950
|
%$self = ( |
83
|
|
|
|
|
|
|
name => '', |
84
|
|
|
|
|
|
|
value => undef, |
85
|
|
|
|
|
|
|
measure => '', |
86
|
|
|
|
|
|
|
measure_type => '', |
87
|
|
|
|
|
|
|
type => '', |
88
|
|
|
|
|
|
|
%$self, |
89
|
|
|
|
|
|
|
%args, |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
1643
|
|
|
|
|
2977
|
bless $self => $class; |
93
|
|
|
|
|
|
|
|
94
|
1643
|
100
|
|
|
|
3493
|
$self->determine_type() if not $self->{type}; |
95
|
|
|
|
|
|
|
|
96
|
1643
|
|
|
|
|
3910
|
return $self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item type |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the type of the Ingredient. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub type { |
107
|
248
|
|
|
248
|
1
|
212
|
my $self = shift; |
108
|
|
|
|
|
|
|
|
109
|
248
|
100
|
|
|
|
415
|
$self->determine_type() if $self->{type} eq ''; |
110
|
|
|
|
|
|
|
|
111
|
248
|
|
|
|
|
520
|
return $self->{type}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item determine_type |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Also returns the type if the Ingredient, but forces a fresh run of the |
117
|
|
|
|
|
|
|
type inferer. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub determine_type { |
122
|
1246
|
|
|
1246
|
1
|
1039
|
my $self = shift; |
123
|
|
|
|
|
|
|
|
124
|
1246
|
|
|
|
|
1086
|
my $type = ''; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
exists $Measures{$self->{measure}} |
127
|
1246
|
50
|
|
|
|
2113
|
or croak "Invalid measure specified: '$self->{measure}'."; |
128
|
|
|
|
|
|
|
|
129
|
1246
|
|
|
|
|
1373
|
$type = $Measures{ $self->{measure} }; |
130
|
|
|
|
|
|
|
|
131
|
1246
|
50
|
|
|
|
2004
|
if ( exists $MeasureTypes{ $self->{measure_type} } ) { |
132
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
0
|
if ( $type eq '' ) { |
134
|
0
|
|
|
|
|
0
|
$type = $MeasureTypes{ $self->{measure_type} }; |
135
|
|
|
|
|
|
|
} else { |
136
|
0
|
0
|
|
|
|
0
|
$MeasureTypes{ $self->{measure_type} } eq $type |
137
|
|
|
|
|
|
|
or croak "'Measure type' ($self->{measure_type}) does not match type of measure ($type)."; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
1246
|
|
|
|
|
1124
|
$self->{type} = $type; |
143
|
1246
|
|
|
|
|
1321
|
return $self->{type}; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item value |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Mutator for the Ingredient's value. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub value { |
154
|
3481
|
|
|
3481
|
1
|
2857
|
my $self = shift; |
155
|
3481
|
|
|
|
|
2614
|
my $new_val = shift; |
156
|
|
|
|
|
|
|
|
157
|
3481
|
100
|
|
|
|
5144
|
$self->{value} = $new_val if defined $new_val; |
158
|
|
|
|
|
|
|
|
159
|
3481
|
50
|
|
|
|
5268
|
if (not defined $self->{value}) { |
160
|
0
|
|
|
|
|
0
|
my $name = $self->{name}; |
161
|
0
|
|
|
|
|
0
|
croak "Attempted to use undefined ingredient '$name'."; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
3481
|
|
|
|
|
6060
|
return $self->{value}; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item liquify |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Sets the type of the Ingredient to be liquid. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub liquify { |
175
|
174
|
|
|
174
|
1
|
133
|
my $self = shift; |
176
|
|
|
|
|
|
|
|
177
|
174
|
|
|
|
|
145
|
$self->{type} = 'liquid'; |
178
|
|
|
|
|
|
|
|
179
|
174
|
|
|
|
|
201
|
return $self; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
__END__ |