Librarian/Library.pm

filter: Statementstmt 94.4% 34 / 36 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 86.5% 45 / 52 CC 5 SCAR 9.5
CC
5
Cov
83%
new
5.6
_load_item_list
2.0
BEGIN
1.0
CRAP 2.6
« Librarian.pm ↑ Summary Librarian/Book.pm »
1 package JSAN::Librarian::Library;
2  
3 # Implements a JavaScript::Librarian::Library object from a Config::Tiny
4 # index of a JSAN installed lib.
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Config::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Params::Util '_INSTANCE';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use JSAN::Librarian::Book ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use JavaScript::Librarian::Library;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 $VERSION = '0.03';
15 2 @ISA = 'JavaScript::Librarian::Library';
16 }
17  
18  
19  
20  
21  
22 #####################################################################
23 # Constructor
24  
25 1 ▶sub new {
Subroutine new: called CC=4 SCAR=17.3
Pod documented
26 1 my $class = shift;
27 1 my $config = undef;
28 1 ▶ if ( _INSTANCE($_[0], 'Config::Tiny') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&_INSTANCE($_[0], 'Config::Tiny')) { } 1 0 1
elsif (defined _STRING($_[0])) { } 0 0 0
29 1 $config = shift;
30 } elsif ( defined _STRING($_[0]) ) {
31 0 ▶ $config = Config::Tiny->read($_[0]) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$config = "Config::Tiny"->read($_[0]) or return undef 0 0 0
32 } else {
33 0 return undef;
34 }
35  
36 # Remove any root entries
37 1 delete $config->{_};
38  
39 # Create the object
40 1 my $self = bless {
41 config => $config,
42 }, $class;
43  
44 1 $self;
45 }
46  
47 1 ▶sub _load_item_list {
Subroutine _load_item_list: called CC=2 SCAR=6.9
48 1 my $self = shift;
49 1 my @books = ();
50 1 my $config = $self->{config};
51 1 foreach my $book ( keys %$config ) {
52 3 push @books, JSAN::Librarian::Book->new( $book, $config->{$book} );
53 }
54 1 return \@books;
55 }
56  
57 2 1;
« Librarian.pm ↑ Summary Librarian/Book.pm »