Parser/JSON.pm

filter: Statementstmt 100% 35 / 35 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 98.1% 52 / 53 CC 4 SCAR 5.1
CC
4
Cov
98%
_load_file
3.0
raw_data
2.0
BEGIN
1.0
CRAP 1.7
« Report.pm ↑ Summary
1 package CPAN::Testers::WWW::Reports::Parser::JSON;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 $VERSION = '0.05';
8  
9 #----------------------------------------------------------------------------
10 # Library Modules
11  
12 2 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #----------------------------------------------------------------------------
15 # The Application Programming Interface
16  
17 sub new {
18 4 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19 4 my $self = {};
20 4 bless $self, $class;
21 4 return $self;
22 }
23  
24 sub DESTROY {
25 4 ▶ my $self = shift;
Subroutine DESTROY: called CC=1 SCAR=0.0
26 }
27  
28 # full data set methods
29  
30 sub register {
31 4 ▶ my $self = shift;
Subroutine register: called CC=1 SCAR=0.0
Pod documented
32 4 my %hash = @_;
33 4 $self->{file} = $hash{file};
34 4 $self->{data} = $hash{data};
35 }
36  
37 sub raw_data {
38 17 ▶ my $self = shift;
Subroutine raw_data: called CC=2 SCAR=6.9
Pod documented
39 17 ▶ $self->{data} = $self->_load_file($self->{file}) if($self->{file});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"file"} 13 4 17
40 17 return decode_json($self->{data});
41 }
42  
43 sub _load_file {
44 13 ▶ my ($self,$file) = @_;
Subroutine _load_file: called CC=3 SCAR=11.0
45 13 my $fh;
46  
47 13 ▶ if (ref $file eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq 'GLOB') { } 4 9 13
48 4 $fh = $file;
49 4 seek($fh,0,0);
50 } else {
51 9 ▶ open $fh, '<', $file or die "Cannot open file [$file]: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<", $file or die "Cannot open file [$file]: $!\n" 0 9 9
52 }
53 13 return do { local $/; <$fh> };
54 }
55  
56 2 q{ Is all that we or seem, but a dream within a dream ? };
57  
58 __END__
« Report.pm ↑ Summary