This is an automated email from the git hooks/post-receive script. js pushed a commit to annotated tag upstream/1.19 in repository libcatmandu-marc-perl.
commit 57a2f027d960e7e91b41c9830ba06611465c2867 Author: Patrick Hochstenbach <[email protected]> Date: Tue Jul 4 11:23:48 2017 +0200 Renaming marc_struc to marc_copy --- lib/Catmandu/Fix/{marc_struc.pm => marc_copy.pm} | 58 +++++++----------------- lib/Catmandu/MARC.pm | 6 ++- t/{26-marc_struc.t => 26-marc_copy.t} | 38 ++++++++-------- 3 files changed, 39 insertions(+), 63 deletions(-) diff --git a/lib/Catmandu/Fix/marc_struc.pm b/lib/Catmandu/Fix/marc_copy.pm similarity index 74% rename from lib/Catmandu/Fix/marc_struc.pm rename to lib/Catmandu/Fix/marc_copy.pm index 9333cf3..a5b5ac9 100644 --- a/lib/Catmandu/Fix/marc_struc.pm +++ b/lib/Catmandu/Fix/marc_copy.pm @@ -1,4 +1,4 @@ -package Catmandu::Fix::marc_struc; +package Catmandu::Fix::marc_copy; use Catmandu::Sane; use Catmandu::MARC; @@ -30,7 +30,7 @@ sub emit { my $perl = ""; $perl .= $fixer->emit_declare_vars($current_value, "[]"); $perl .=<<EOF; -if (my ${result} = ${marc}->marc_struc( +if (my ${result} = ${marc}->marc_copy( ${var}, ${marc_path}) ) { ${result} = ref(${result}) ? ${result} : [${result}]; @@ -59,14 +59,14 @@ __END__ =head1 NAME -Catmandu::Fix::marc_struc - copy marc data in a structured way to a new field +Catmandu::Fix::marc_copy - copy marc data in a structured way to a new field =head1 SYNOPSIS # fixed field - marc_struc(001, fixed001) + marc_copy(001, fixed001) -may result into + May result into fixed001 : [ { @@ -77,12 +77,12 @@ may result into } ] -And + And # variable field - marc_struc(650, subjects) + marc_copy(650, subjects) -may result into + May result into subjects:[ { @@ -112,30 +112,30 @@ may result into Copy MARC data referred by MARC_TAG in a structured way to JSON path. -In contrast to L<Catmandu::Fix::marc_map> and L<Catmandu::Fix::marc_spec> -marc_struc will not only copy data content (values) but also all data elements -like tag, indicators and subfield codes into a nested data structure. +In contrast to L<Catmandu::Fix::marc_map> and L<Catmandu::Fix::marc_spec> +marc_copy will not only copy data content (values) but also all data elements +like tag, indicators and subfield codes into a nested data structure. =head1 METHODS -=head2 marc_struc(MARC_TAG, JSON_PATH) +=head2 marc_copy(MARC_TAG, JSON_PATH) Copy this data referred by a MARC_TAG to a JSON_PATH. MARC_TAG (meaning the field tag) is the first segment of MARC_PATH. -Using a MARC_PATH with subfield codes, indicators or substring will cause a +Using a MARC_PATH with subfield codes, indicators or substring will cause a warning and these segments will be ignored when referring the data. =head1 INLINE This Fix can be used inline in a Perl script: - use Catmandu::Fix::marc_struc as => 'marc_struc'; + use Catmandu::Fix::marc_copy as => 'marc_copy'; my $data = { record => ['650', ' ', 0, 'a', 'Perl'] }; - $data = marc_struc($data,'650','subject'); + $data = marc_copy($data,'650','subject'); print $data->{subject}->[0]->{tag} , "\n"; # '650' print $data->{subject}->[0]->{ind1} , "\n"; # ' ' @@ -146,33 +146,7 @@ This Fix can be used inline in a Perl script: =over -=item * L<Catmandu::Fix> - -=item * L<Catmandu::Fix::marc_map> - -=item * L<Catmandu::Fix::marc_spec> - -=item * L<Catmandu::Fix::marc_add> - -=item * L<Catmandu::Fix::marc_remove> - -=item * L<Catmandu::Fix::marc_xml> - -=item * L<Catmandu::Fix::marc_in_json> - -=item * L<Catmandu::Fix::marc_decode_dollar_subfields> - -=item * L<Catmandu::Fix::marc_set> - -=item * L<Catmandu::Fix::Bind::marc_each> - -=item * L<Catmandu::Fix::Condition::marc_match> - -=item * L<Catmandu::Fix::Condition::marc_has> - -=item * L<Catmandu::Fix::Condition::marc_has_many> - -=item * L<Catmandu::Fix::Condition::marc_has_ref> +=item * L<Catmandu::Fix::marc_paste> =back diff --git a/lib/Catmandu/MARC.pm b/lib/Catmandu/MARC.pm index f064a9f..e1f0541 100644 --- a/lib/Catmandu/MARC.pm +++ b/lib/Catmandu/MARC.pm @@ -1037,7 +1037,7 @@ sub compile_marc_path { }; } -sub marc_struc { +sub marc_copy { my $self = $_[0]; # $_[2] : marc_path @@ -1229,7 +1229,9 @@ Catmandu::MARC - Catmandu modules for working with MARC data =item * L<Catmandu::Fix::marc_set> -=item * L<Catmandu::Fix::marc_struc> +=item * L<Catmandu::Fix::marc_copy> + +=item * L<Catmandu::Fix::marc_paste> =item * L<Catmandu::Fix::Bind::marc_each> diff --git a/t/26-marc_struc.t b/t/26-marc_copy.t similarity index 85% rename from t/26-marc_struc.t rename to t/26-marc_copy.t index 29ce7a3..7d2c93a 100644 --- a/t/26-marc_struc.t +++ b/t/26-marc_copy.t @@ -25,13 +25,13 @@ my $mrc = <<'MRC'; </marc:collection> MRC -note 'marc_struc(001,cntrl)'; +note 'marc_copy(001,cntrl)'; { my $importer = Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(001,cntrl); retain_field(cntrl)' + fix => 'marc_copy(001,cntrl); retain_field(cntrl)' ); my $record = $importer->first; is_deeply $record->{cntrl}, @@ -42,16 +42,16 @@ note 'marc_struc(001,cntrl)'; ind2 => undef, content => " 92005291 " } - ], 'marc_struc(001,cntrl)'; + ], 'marc_copy(001,cntrl)'; } -note 'marc_struc(245,title)'; +note 'marc_copy(245,title)'; { my $importer = Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(245,title); retain_field(title)' + fix => 'marc_copy(245,title); retain_field(title)' ); my $record = $importer->first; is_deeply $record->{title}, @@ -68,54 +68,54 @@ note 'marc_struc(245,title)'; ], 'marc_map(245,title)'; } -note 'marc_struc(001/0-3,substr)'; +note 'marc_copy(001/0-3,substr)'; { warnings_like { Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(001/0-3,substr)' + fix => 'marc_copy(001/0-3,substr)' )->first} [{carped => qr/^path segments.+/},{carped => qr/^path segments.+/}], "warn on substring usage"; } -note 'marc_struc(245[,0],title)'; +note 'marc_copy(245[,0],title)'; { warnings_like { Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc("245[,0]",title)' + fix => 'marc_copy("245[,0]",title)' )->first} [{carped => qr/^path segments.+/},{carped => qr/^path segments.+/}], "warn on substring usage"; } -note 'marc_struc(245[1],title)'; +note 'marc_copy(245[1],title)'; { warnings_like { Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(245[1],title)' + fix => 'marc_copy(245[1],title)' )->first} [{carped => qr/^path segments.+/},{carped => qr/^path segments.+/}], "warn on substring usage"; } -note 'marc_struc(245a,title)'; +note 'marc_copy(245a,title)'; { warnings_like { Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(245a,title)' + fix => 'marc_copy(245a,title)' )->first} [{carped => qr/^path segments.+/},{carped => qr/^path segments.+/}], "warn on substring usage"; } -note 'marc_struc(999,local)'; +note 'marc_copy(999,local)'; { my $importer = Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(999,local); retain_field(local)' + fix => 'marc_copy(999,local); retain_field(local)' ); my $record = $importer->first; is_deeply $record->{local}, @@ -137,16 +137,16 @@ note 'marc_struc(999,local)'; { a => 'Z'} ] } - ], 'marc_struc(999,local)'; + ], 'marc_copy(999,local)'; } -note 'marc_struc(...,all)'; +note 'marc_copy(...,all)'; { my $importer = Catmandu->importer( 'MARC', file => \$mrc, type => 'XML', - fix => 'marc_struc(...,all); retain_field(all)' + fix => 'marc_copy(...,all); retain_field(all)' ); my $record = $importer->first; is_deeply $record->{all}, @@ -189,7 +189,7 @@ note 'marc_struc(...,all)'; { a => 'Z'} ] } - ], 'marc_struc(...,all)'; + ], 'marc_copy(...,all)'; } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits
