File Coverage

blib/lib/Device/CurrentCost/Constants.pm
Criterion Covered Total %
statement 19 20 95.0
branch n/a
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 25 27 92.5


line stmt bran cond sub pod time code
1 5     5   95766 use strict;
  5         13  
  5         169  
2 5     5   24 use warnings;
  5         8  
  5         446  
3             package Device::CurrentCost::Constants;
4             $Device::CurrentCost::Constants::VERSION = '1.142240';
5             # ABSTRACT: Module to export constants for Current Cost devices
6              
7              
8             my %constants =
9             (
10             CURRENT_COST_CLASSIC => 0x1,
11             CURRENT_COST_ENVY => 0x2,
12             );
13             my %names =
14             (
15             $constants{CURRENT_COST_ENVY} => 'Envy',
16             $constants{CURRENT_COST_CLASSIC} => 'Classic',
17             );
18              
19             sub import {
20 5     5   26 no strict qw/refs/; ## no critic
  5         7  
  5         775  
21 13     13   59 my $pkg = caller(0);
22 13         100 foreach (keys %constants) {
23 26         47 my $v = $constants{$_};
24 26     0   213 *{$pkg.'::'.$_} = sub () { $v };
  26         166  
  0         0  
25             }
26 13         31 foreach (qw/current_cost_type_string/) {
27 13         17 *{$pkg.'::'.$_} = \&{$_};
  13         337  
  13         34  
28             }
29             }
30              
31              
32             sub current_cost_type_string {
33 3     3 1 15 $names{$_[0]}
34             }
35              
36             __END__