| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catmandu::Cmd::breaker; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
296283
|
use Catmandu::Sane; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.141'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
199
|
use parent 'Catmandu::Cmd'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
1
|
|
|
1
|
|
15721
|
use Catmandu; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
539
|
use Catmandu::Breaker; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Path::Tiny; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
41
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub command_opt_spec { |
|
15
|
0
|
|
|
0
|
1
|
|
( [ "verbose|v", "verbose output" ], |
|
16
|
|
|
|
|
|
|
[ "maxscan=i", |
|
17
|
|
|
|
|
|
|
"maximum number of lines to scan for uniq fields (default -1 = unlimited)" |
|
18
|
|
|
|
|
|
|
], |
|
19
|
|
|
|
|
|
|
[ "fields=s", |
|
20
|
|
|
|
|
|
|
"a file or comma delimited string of unique fields to use" |
|
21
|
|
|
|
|
|
|
], |
|
22
|
|
|
|
|
|
|
[ "as=s", "set ouput format (default Table)" ], |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub command { |
|
27
|
0
|
|
|
0
|
1
|
|
my ( $self, $opts, $args ) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
unless ( @$args == 1 ) { |
|
30
|
0
|
|
|
|
|
|
say STDERR "usage: $0 breaker file\n"; |
|
31
|
0
|
|
|
|
|
|
exit 1; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $file = $args->[0]; |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
0
|
|
|
|
my $maxscan = $opts->maxscan // -1; |
|
37
|
0
|
|
0
|
|
|
|
my $as = $opts->as // 'Table'; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $tags; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ( $opts->fields ) { |
|
42
|
0
|
0
|
|
|
|
|
if ( -r $opts->fields ) { |
|
43
|
0
|
|
|
|
|
|
$tags = join ",", |
|
44
|
|
|
|
|
|
|
path( $opts->fields )->lines_utf8( { chomp => 1 } ); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
else { |
|
47
|
0
|
|
|
|
|
|
$tags = $opts->fields; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
|
my $breaker = Catmandu::Breaker->new( |
|
51
|
|
|
|
|
|
|
verbose => $opts->verbose, |
|
52
|
|
|
|
|
|
|
maxscan => $maxscan, |
|
53
|
|
|
|
|
|
|
tags => $tags, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$breaker->parse($file, $as); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Catmandu::Cmd::breaker - Parse Catmandu::Breaker exports |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
catmandu breaker [<OPTIONS>] <BREAKER.FILE> |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$ catmandu convert XML --path book to Breaker --handler xml < t/book.xml > data.breaker |
|
74
|
|
|
|
|
|
|
$ catmandu breaker data.breaker |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# verbose output |
|
77
|
|
|
|
|
|
|
$ catmandu breaker -v data.breaker |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# The breaker command needs to know the unique fields in the dataset to build statistics |
|
80
|
|
|
|
|
|
|
# By default it will scan the whole file for fields. This can be a very |
|
81
|
|
|
|
|
|
|
# time consuming process. With --maxscan one can limit the number of lines |
|
82
|
|
|
|
|
|
|
# in the breaker file that can be scanned for unique fields |
|
83
|
|
|
|
|
|
|
$ catmandu breaker -v --maxscan 1000000 data.breaker |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Alternatively the fields option can be used to specify the unique fields |
|
86
|
|
|
|
|
|
|
$ catmandu breaker -v --fields 245a,022a data.breaker |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$ cat data.breaker | cut -f 2 | sort -u > fields.txt |
|
89
|
|
|
|
|
|
|
$ catmandu breaker -v --fields fields.txt data.breaker |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Export statistics as CSV. See L<Catmandu::Exporter::Stat> for supported formats. |
|
92
|
|
|
|
|
|
|
$ catmandu breaker --as CSV data.breaker |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |