lib/Acme/Coinbase/Config.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 42 CC 2 SCAR 11.0
CC
2
Cov
0%
read_config
6.0
get_param
2.0
dump
2.0
CRAP 3.0
1 package Acme::Coinbase::Config;
2 # vim: set ts=4 sw=4 expandtab showmatch
3 #
4 use strict;
5  
6 # FOR MOOSE
7 use Moose; # automatically turns on strict and warnings
8 #use Config::INI::Reader;
9 use Config::IniFiles;
10 use Data::Dumper;
11  
12 has 'config_file' => (is => 'rw', isa => 'Str');
13 has 'config_reader' => (is => 'rw');
14  
15 sub read_config {
16 my $self = shift;
17 die "$0: no config file" unless $self->config_file;
18 print "$0: Config file is " . $self->config_file . "\n";
19 #my $config_hash = Config::INI::Reader->read_file( $self->config_file );
20 my $config = Config::IniFiles->new(); # -file => $self->config_file);
21 $config->SetFileName( $self->config_file ) || die "$0: Can't set config filename\n";;
22 $config->ReadConfig();
23 #print "READ: " . $config->OutputConfig();
24 $self->config_reader( $config );
25 }
26 sub get_param {
27 my ($self, $section, $param) = @_;
28 return $self->config_reader->val( $section, $param ) || "";
29 }
30  
31 sub dump {
32 my $self = shift;
33  
34 my @sections = $self->config_reader->Sections();
35 return "Sections: " . Dumper( \@sections ) . "\n";
36 }
37  
38 # dummy data
39 #has 'api_key' => (is => 'rw', isa => 'Str', default=>"lmnop");
40 #has 'api_secret' => (is => 'rw', isa => 'Str', default=>"qwerty");
41  
42 1;