line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
6720
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util qw(:is); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
390
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
217
|
|
9
|
1
|
|
|
1
|
|
7
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
1070
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Fix::Bind', 'Catmandu::Fix::Bind::Group'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has importer_name => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has step => (fix_opt => 1); |
15
|
|
|
|
|
|
|
has importer_args => (fix_opt => 'collect'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has importer => (is => 'lazy'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my ($self) = @_; |
20
|
|
|
|
|
|
|
Catmandu->importer($self->importer_name, %{$self->importer_args}); |
21
|
3
|
|
|
3
|
|
31
|
} |
22
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
29
|
|
23
|
|
|
|
|
|
|
my ($self, $data) = @_; |
24
|
|
|
|
|
|
|
$data; |
25
|
|
|
|
|
|
|
} |
26
|
3
|
|
|
3
|
0
|
9
|
|
27
|
3
|
|
|
|
|
42
|
my ($self, $mvar, $code) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if ($self->step) { |
30
|
|
|
|
|
|
|
my $next = $self->importer->next; |
31
|
|
|
|
|
|
|
$code->($next) if $next; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
|
|
|
|
|
|
$self->importer->each( |
35
|
|
|
|
|
|
|
sub { |
36
|
|
|
|
|
|
|
$code->($_[0]); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$mvar; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Catmandu::Fix::Bind::importer - a binder runs fixes on records from an importer |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
catmandu run myfix.fix |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# with myfix.fix |
59
|
|
|
|
|
|
|
do importer(OAI,url: "http://lib.ugent.be/oai") |
60
|
|
|
|
|
|
|
retain(_id) |
61
|
|
|
|
|
|
|
add_to_exporter(.,YAML) |
62
|
|
|
|
|
|
|
end |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Or in an runnable Fix script: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#!/usr/bin/env catmandu run |
67
|
|
|
|
|
|
|
add_field(hello,world) |
68
|
|
|
|
|
|
|
add_to_exporter(.,YAML) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Or: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#!/usr/bin/env catmandu run |
74
|
|
|
|
|
|
|
do importer(OAI,url: "http://lib.ugent.be/oai") |
75
|
|
|
|
|
|
|
retain(_id) |
76
|
|
|
|
|
|
|
add_to_exporter(.,YAML) |
77
|
|
|
|
|
|
|
end |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The import binder computes all the Fix function on records read from the given importer. |
83
|
|
|
|
|
|
|
This importer doesn't change the current importer to the given one! Use the 'catmandu run' |
84
|
|
|
|
|
|
|
command line command to control importers solely by the Fix script. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 CONFIGURATION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 importer(IMPORTER_NAME, step: true|false, IMPORTER_ARGS...) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Load the import IMPORTER_NAME in the current context. When step is 'true' then for |
91
|
|
|
|
|
|
|
every execution of do importer() only one item will be read from the importer. This |
92
|
|
|
|
|
|
|
latter option can become handy in nested iterators: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# This will produce: |
95
|
|
|
|
|
|
|
# {"n":0} |
96
|
|
|
|
|
|
|
# {"m":0} |
97
|
|
|
|
|
|
|
# {"n":1} |
98
|
|
|
|
|
|
|
# {"m":1} |
99
|
|
|
|
|
|
|
# {"n":2} |
100
|
|
|
|
|
|
|
# {"m":2} |
101
|
|
|
|
|
|
|
# ... |
102
|
|
|
|
|
|
|
do importer(Mock,size:20) |
103
|
|
|
|
|
|
|
move_field(n,brol) |
104
|
|
|
|
|
|
|
add_to_exporter(.,JSON) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
do importer(Mock,size:20,step:true) |
107
|
|
|
|
|
|
|
move_field(n,m) |
108
|
|
|
|
|
|
|
add_to_exporter(.,JSON) |
109
|
|
|
|
|
|
|
end |
110
|
|
|
|
|
|
|
end |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<Catmandu::Fix::Bind>, |
115
|
|
|
|
|
|
|
L<Catmandu::Cmd::run> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |