line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::DataFile::Meta; |
2
|
|
|
|
|
|
|
#ABSTRACT: YAML Metadata file |
3
|
|
|
|
|
|
|
$Lab::Moose::DataFile::Meta::VERSION = '3.880'; |
4
|
27
|
|
|
27
|
|
376
|
use v5.20; |
|
27
|
|
|
|
|
114
|
|
5
|
|
|
|
|
|
|
|
6
|
27
|
|
|
27
|
|
158
|
use warnings; |
|
27
|
|
|
|
|
88
|
|
|
27
|
|
|
|
|
705
|
|
7
|
27
|
|
|
27
|
|
139
|
use strict; |
|
27
|
|
|
|
|
71
|
|
|
27
|
|
|
|
|
627
|
|
8
|
|
|
|
|
|
|
|
9
|
27
|
|
|
27
|
|
146
|
use Moose; |
|
27
|
|
|
|
|
65
|
|
|
27
|
|
|
|
|
203
|
|
10
|
27
|
|
|
27
|
|
185093
|
use MooseX::Params::Validate; |
|
27
|
|
|
|
|
71
|
|
|
27
|
|
|
|
|
209
|
|
11
|
|
|
|
|
|
|
|
12
|
27
|
|
|
27
|
|
12690
|
use Carp; |
|
27
|
|
|
|
|
77
|
|
|
27
|
|
|
|
|
1848
|
|
13
|
|
|
|
|
|
|
|
14
|
27
|
|
|
27
|
|
227
|
use Time::HiRes qw/gettimeofday tv_interval/; |
|
27
|
|
|
|
|
77
|
|
|
27
|
|
|
|
|
207
|
|
15
|
27
|
|
|
27
|
|
2924
|
use YAML::XS; |
|
27
|
|
|
|
|
67
|
|
|
27
|
|
|
|
|
1742
|
|
16
|
27
|
|
|
27
|
|
226
|
use Fcntl 'SEEK_SET'; |
|
27
|
|
|
|
|
85
|
|
|
27
|
|
|
|
|
1367
|
|
17
|
|
|
|
|
|
|
|
18
|
27
|
|
|
27
|
|
242
|
use namespace::autoclean; |
|
27
|
|
|
|
|
72
|
|
|
27
|
|
|
|
|
225
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
extends 'Lab::Moose::DataFile'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has mode => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
default => '>>', |
26
|
|
|
|
|
|
|
init_arg => undef |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has meta_data => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'ArrayRef | HashRef', |
32
|
|
|
|
|
|
|
writer => '_meta_data', |
33
|
|
|
|
|
|
|
init_arg => undef |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has start_time => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => 'ArrayRef[Int]', |
39
|
|
|
|
|
|
|
init_arg => undef, |
40
|
|
|
|
|
|
|
writer => '_start_time' |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub log { |
44
|
75
|
|
|
75
|
1
|
2231
|
my $self = shift; |
45
|
75
|
|
|
|
|
376
|
my ($meta) |
46
|
|
|
|
|
|
|
= validated_list( \@_, meta => { isa => 'ArrayRef | HashRef' } ); |
47
|
|
|
|
|
|
|
|
48
|
75
|
|
|
|
|
26210
|
my $existing_meta = $self->meta_data(); |
49
|
75
|
100
|
|
|
|
207
|
if ( defined $existing_meta ) { |
50
|
2
|
|
|
|
|
7
|
my $meta_type = ref $meta; |
51
|
2
|
|
|
|
|
6
|
my $existing_meta_type = ref $existing_meta; |
52
|
|
|
|
|
|
|
|
53
|
2
|
50
|
|
|
|
15
|
if ( $meta_type ne $existing_meta_type ) { |
54
|
0
|
|
|
|
|
0
|
croak "meta has reftype $meta_type " |
55
|
|
|
|
|
|
|
. "while existing meta has reftype $existing_meta_type"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
50
|
|
|
|
11
|
if ( $meta_type eq 'ARRAY' ) { |
59
|
0
|
|
|
|
|
0
|
$existing_meta = [ @{$existing_meta}, @{$meta} ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
2
|
|
|
|
|
5
|
$existing_meta = { %{$existing_meta}, %{$meta} }; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
18
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
70
|
$self->_meta_data($existing_meta); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
73
|
|
|
|
|
2435
|
$self->_meta_data($meta); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
75
|
|
|
|
|
2091
|
my $fh = $self->filehandle(); |
72
|
|
|
|
|
|
|
|
73
|
75
|
50
|
|
|
|
2199
|
truncate $fh, 0 |
74
|
|
|
|
|
|
|
or croak "truncate failed: $!"; |
75
|
75
|
50
|
|
|
|
1227
|
seek $fh, 0, SEEK_SET |
76
|
|
|
|
|
|
|
or croak "seek failed: $!"; |
77
|
|
|
|
|
|
|
|
78
|
75
|
|
|
|
|
197
|
print {$fh} Dump( $self->meta_data ); |
|
75
|
|
|
|
|
2920
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Lab::Moose::DataFile::Meta - YAML Metadata file |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 3.880 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $file = Lab::Moose::DataFile::Meta->new( |
103
|
|
|
|
|
|
|
folder => $folder, |
104
|
|
|
|
|
|
|
filename => 'metafile.yml' |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$file->log(meta => {key1 => $value1, key2 => $value2}); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 METHODS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 log |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Log either an hashref or an arrayref to the log file. |
114
|
|
|
|
|
|
|
Augment the file's contents. The new keys/items will be merged with the |
115
|
|
|
|
|
|
|
existing ones. Rewrites the file with the new contents. |
116
|
|
|
|
|
|
|
You may not mixup calls with hashref and arrayref arguments. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Copyright 2016 Simon Reinhardt |
123
|
|
|
|
|
|
|
2017 Andreas K. Huettel |
124
|
|
|
|
|
|
|
2020 Andreas K. Huettel |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
128
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |