File Coverage

blib/lib/Business/AU/Data/ANZIC.pm
Criterion Covered Total %
statement 30 40 75.0
branch 3 6 50.0
condition 1 2 50.0
subroutine 11 13 84.6
pod 0 3 0.0
total 45 64 70.3


line stmt bran cond sub pod time code
1             package Business::AU::Data::ANZIC;
2              
3 2     2   25048 use 5.005;
  2         8  
  2         79  
4 2     2   12 use strict;
  2         4  
  2         76  
5 2     2   2037 use IO::File ();
  2         24268  
  2         54  
6 2     2   2408 use Parse::CSV ();
  2         39689  
  2         51  
7 2     2   2064 use File::ShareDir ();
  2         16789  
  2         65  
8 2     2   25 use Params::Util '_CLASS';
  2         5  
  2         226  
9              
10 2     2   30 use vars qw{$VERSION};
  2         5  
  2         98  
11             BEGIN {
12 2     2   630 $VERSION = '0.01';
13             }
14              
15             # Locate the file
16             my $csv_file = File::ShareDir::module_file('Business::AU::Data::ANZIC', 'anzic.csv');
17              
18              
19              
20              
21              
22              
23             #####################################################################
24              
25             sub new {
26 0     0 0 0 my $class = shift;
27 0         0 my $self = bless { }, $class;
28 0         0 return $self;
29             }
30              
31             sub provides {
32 0     0 0 0 my @provides = qw{ IO::File Parse::CSV };
33 0         0 my $want = _CLASS($_[1]);
34 0 0       0 if ( $want ) {
35 0         0 return grep { $_->isa($want) } @provides;
  0         0  
36             } else {
37 0         0 return @provides;
38             }
39             }
40              
41             sub get {
42 2     2 0 1040 my $either = shift;
43 2   50     76 my $want = _CLASS($_[0]) || 'Parse::CSV';
44 2 100       30 if ( $want eq 'IO::File' ) {
45 1         5 return $either->_io_file;
46             }
47 1 50       8 if ( $want eq 'Parse::CSV' ) {
48 1         5 return $either->_parse_csv;
49             }
50 0         0 Carp::croak("Unknown or unsupported data class '$_[0]'");
51             }
52              
53             sub _io_file {
54 1     1   10 IO::File->new( $csv_file );
55             }
56              
57             sub _parse_csv {
58 1     1   12 Parse::CSV->new(
59             file => $csv_file,
60             );
61             }
62              
63             1;
64              
65             __END__