| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package CPAN::Testers::WWW::Reports::Parser::JSON; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 4 |  |  | 4 |  | 11186 | use strict; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 126 |  | 
| 4 | 4 |  |  | 4 |  | 15 | use warnings; | 
|  | 4 |  |  |  |  | 6 |  | 
|  | 4 |  |  |  |  | 98 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 4 |  |  | 4 |  | 14 | use vars qw($VERSION); | 
|  | 4 |  |  |  |  | 35 |  | 
|  | 4 |  |  |  |  | 179 |  | 
| 7 |  |  |  |  |  |  | $VERSION = '0.06'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | #---------------------------------------------------------------------------- | 
| 10 |  |  |  |  |  |  | # Library Modules | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 4 |  |  | 4 |  | 16 | use JSON::XS; | 
|  | 4 |  |  |  |  | 4 |  | 
|  | 4 |  |  |  |  | 914 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | #---------------------------------------------------------------------------- | 
| 15 |  |  |  |  |  |  | # The Application Programming Interface | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub new { | 
| 18 | 4 |  |  | 4 | 1 | 5 | my $class = shift; | 
| 19 | 4 |  |  |  |  | 8 | my $self = {}; | 
| 20 | 4 |  |  |  |  | 8 | bless $self, $class; | 
| 21 | 4 |  |  |  |  | 26 | return $self; | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | sub DESTROY { | 
| 25 | 4 |  |  | 4 |  | 1221 | my $self = shift; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # full data set methods | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | sub register { | 
| 31 | 4 |  |  | 4 | 1 | 20 | my $self = shift; | 
| 32 | 4 |  |  |  |  | 9 | my %hash = @_; | 
| 33 | 4 |  |  |  |  | 9 | $self->{file} = $hash{file}; | 
| 34 | 4 |  |  |  |  | 12 | $self->{data} = $hash{data}; | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | sub raw_data { | 
| 38 | 17 |  |  | 17 | 1 | 24 | my $self = shift; | 
| 39 | 17 | 100 |  |  |  | 66 | $self->{data} = $self->_load_file($self->{file})  if($self->{file}); | 
| 40 | 17 |  |  |  |  | 44662 | return decode_json($self->{data}); | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub _load_file { | 
| 44 | 13 |  |  | 13 |  | 21 | my ($self,$file) = @_; | 
| 45 | 13 |  |  |  |  | 14 | my $fh; | 
| 46 |  |  |  |  |  |  |  | 
| 47 | 13 | 100 |  |  |  | 32 | if (ref $file eq 'GLOB') { | 
| 48 | 4 |  |  |  |  | 8 | $fh = $file; | 
| 49 | 4 |  |  |  |  | 21 | seek($fh,0,0); | 
| 50 |  |  |  |  |  |  | } else { | 
| 51 | 9 | 50 |  |  |  | 313 | open $fh, '<', $file     or die "Cannot open file [$file]: $!\n"; | 
| 52 |  |  |  |  |  |  | } | 
| 53 | 13 |  |  |  |  | 16 | return do { local $/; <$fh> }; | 
|  | 13 |  |  |  |  | 48 |  | 
|  | 13 |  |  |  |  | 3433 |  | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | q{ Is all that we or seem, but a dream within a dream ? }; | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | __END__ |