Moose/DataFile/Meta.pm

filter: Statementstmt 93.1% 54 / 58 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 90.0% 72 / 80 CC 6 SCAR 11.3
CC
6
Cov
88%
log
6.6
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« Moose/Instrument/HP34410A.pm ↑ Summary Moose/Instrument/AH2700A.pm »
1 package Lab::Moose::DataFile::Meta;
2 #ABSTRACT: YAML Metadata file
3 27 $Lab::Moose::DataFile::Meta::VERSION = '3.931';
4 27 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 27 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 27 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 27 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 27 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 27 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 27 ▶use Time::HiRes qw/gettimeofday tv_interval/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 27 ▶use YAML::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 27 ▶use Fcntl 'SEEK_SET';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 27 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 27 extends 'Lab::Moose::DataFile';
22  
23 27 has mode => (
24 is => 'ro',
25 default => '>>',
26 init_arg => undef
27 );
28  
29 27 has meta_data => (
30 is => 'ro',
31 isa => 'ArrayRef | HashRef',
32 writer => '_meta_data',
33 init_arg => undef
34 );
35  
36 27 has start_time => (
37 is => 'ro',
38 isa => 'ArrayRef[Int]',
39 init_arg => undef,
40 writer => '_start_time'
41 );
42  
43 75 ▶sub log {
Subroutine log: called CC=6 SCAR=18.8
Pod documented
44 75 my $self = shift;
45 75 my ($meta)
46 = validated_list( \@_, meta => { isa => 'ArrayRef | HashRef' } );
47  
48 75 my $existing_meta = $self->meta_data();
49 75 ▶ if ( defined $existing_meta ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $existing_meta) { } 2 73 75
50 2 my $meta_type = ref $meta;
51 2 my $existing_meta_type = ref $existing_meta;
52  
53 2 ▶ if ( $meta_type ne $existing_meta_type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_type ne $existing_meta_type) 0 2 2
54 0 croak "meta has reftype $meta_type "
55 . "while existing meta has reftype $existing_meta_type";
56 }
57  
58 2 ▶ if ( $meta_type eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_type eq 'ARRAY') { } 0 2 2
59 0 $existing_meta = [ @{$existing_meta}, @{$meta} ];
60 }
61 else {
62 2 $existing_meta = { %{$existing_meta}, %{$meta} };
63 }
64  
65 2 $self->_meta_data($existing_meta);
66 }
67 else {
68 73 $self->_meta_data($meta);
69 }
70  
71 75 my $fh = $self->filehandle();
72  
73 75 ▶ truncate $fh, 0
Branch: 1 branch
BranchTrueFalseTotal
truncate $fh, 0 or croak("truncate failed: $!") 75 0 75
74 or croak "truncate failed: $!";
75 75 ▶ seek $fh, 0, SEEK_SET
Branch: 1 branch
BranchTrueFalseTotal
seek $fh, 0, 0 or croak("seek failed: $!") 75 0 75
76 or croak "seek failed: $!";
77  
78 75 print {$fh} Dump( $self->meta_data );
79 }
80  
81 27 __PACKAGE__->meta->make_immutable();
82  
83  
84 27 1;
85  
86 __END__
« Moose/Instrument/HP34410A.pm ↑ Summary Moose/Instrument/AH2700A.pm »