[libcatmandu-marc-perl] 30/208: Making internal mapping functions to instance functions

Jonas Smedegaard dr at jones.dk
Sat Oct 28 03:42:32 UTC 2017


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 cc33d21a450ae12b04b2f955c733dea9674fb5a9
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Fri Jul 8 10:43:06 2016 +0200

    Making internal mapping functions to instance functions
---
 lib/Catmandu/Fix/Inline/marc_add.pm              |  2 +-
 lib/Catmandu/Fix/Inline/marc_map.pm              |  3 ++-
 lib/Catmandu/Fix/Inline/marc_remove.pm           |  2 +-
 lib/Catmandu/Fix/Inline/marc_set.pm              |  2 +-
 lib/Catmandu/Fix/marc_add.pm                     |  2 +-
 lib/Catmandu/Fix/marc_decode_dollar_subfields.pm |  2 +-
 lib/Catmandu/Fix/marc_in_json.pm                 |  4 ++--
 lib/Catmandu/Fix/marc_map.pm                     |  2 +-
 lib/Catmandu/Fix/marc_remove.pm                  |  2 +-
 lib/Catmandu/Fix/marc_set.pm                     |  2 +-
 lib/Catmandu/Fix/marc_xml.pm                     |  2 +-
 lib/Catmandu/MARC.pm                             | 21 ++++++++++++---------
 12 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/lib/Catmandu/Fix/Inline/marc_add.pm b/lib/Catmandu/Fix/Inline/marc_add.pm
index 245a09c..f4f48b2 100644
--- a/lib/Catmandu/Fix/Inline/marc_add.pm
+++ b/lib/Catmandu/Fix/Inline/marc_add.pm
@@ -11,7 +11,7 @@ our $VERSION = '0.219';
 
 sub marc_add {
     my ($data,$marc_path, at subfields) = @_;
-    return Catmandu::MARC::marc_add($data, $marc_path, @subfields);
+    return Catmandu::MARC->new->marc_add($data, $marc_path, @subfields);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/Inline/marc_map.pm b/lib/Catmandu/Fix/Inline/marc_map.pm
index 7668301..07c17c1 100644
--- a/lib/Catmandu/Fix/Inline/marc_map.pm
+++ b/lib/Catmandu/Fix/Inline/marc_map.pm
@@ -69,8 +69,9 @@ our $VERSION = '0.219';
 
 sub marc_map {
     my ($data,$marc_path,%opts) = @_;
+    # Set default to nested_arrays for backwards compatibility
     $opts{'-nested_arrays'} = 1 unless exists $opts{'-nested_arrays'};
-    return Catmandu::MARC::marc_map($data,$marc_path,%opts);
+    return Catmandu::MARC->new->marc_map($data,$marc_path,%opts);
 }
 
 1;
diff --git a/lib/Catmandu/Fix/Inline/marc_remove.pm b/lib/Catmandu/Fix/Inline/marc_remove.pm
index 048dabc..236a856 100644
--- a/lib/Catmandu/Fix/Inline/marc_remove.pm
+++ b/lib/Catmandu/Fix/Inline/marc_remove.pm
@@ -11,7 +11,7 @@ our $VERSION = '0.219';
 
 sub marc_remove {
     my ($data,$marc_path) = @_;
-    return Catmandu::MARC::marc_remove($data,$marc_path);
+    return Catmandu::MARC->new->marc_remove($data,$marc_path);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/Inline/marc_set.pm b/lib/Catmandu/Fix/Inline/marc_set.pm
index 006e775..33d66eb 100644
--- a/lib/Catmandu/Fix/Inline/marc_set.pm
+++ b/lib/Catmandu/Fix/Inline/marc_set.pm
@@ -11,7 +11,7 @@ our $VERSION = '0.219';
 
 sub marc_set {
     my ($data,$marc_path,$value) = @_;
-    return Catmandu::MARC::marc_set($data,$marc_path,$value);
+    return Catmandu::MARC->new->marc_set($data,$marc_path,$value);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/marc_add.pm b/lib/Catmandu/Fix/marc_add.pm
index 6bbd44e..bc0aba8 100644
--- a/lib/Catmandu/Fix/marc_add.pm
+++ b/lib/Catmandu/Fix/marc_add.pm
@@ -17,7 +17,7 @@ sub fix {
     my $marc_path  = $self->marc_path;
     my @subfields  = @{$self->subfields};
 
-    return Catmandu::MARC::marc_add($data,$marc_path, at subfields);
+    return Catmandu::MARC->new->marc_add($data,$marc_path, at subfields);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/marc_decode_dollar_subfields.pm b/lib/Catmandu/Fix/marc_decode_dollar_subfields.pm
index 7e01bc3..f716022 100644
--- a/lib/Catmandu/Fix/marc_decode_dollar_subfields.pm
+++ b/lib/Catmandu/Fix/marc_decode_dollar_subfields.pm
@@ -14,7 +14,7 @@ has record    => (fix_opt => 1);
 sub fix {
 	my ($self,$data) = @_;
     my $record_key = $self->record // 'record';
-    return Catmandu::MARC::marc_decode_dollar_subfields($data, record => $record_key);
+    return Catmandu::MARC->new->marc_decode_dollar_subfields($data, record => $record_key);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/marc_in_json.pm b/lib/Catmandu/Fix/marc_in_json.pm
index 9dbf31d..7d09d77 100644
--- a/lib/Catmandu/Fix/marc_in_json.pm
+++ b/lib/Catmandu/Fix/marc_in_json.pm
@@ -20,10 +20,10 @@ sub fix {
     my $record_key = $self->record // 'record';
 
     if ($self->reverse) {
-        return Catmandu::MARC::marc_json_to_record($data, record => $record_key);
+        return Catmandu::MARC->new->marc_json_to_record($data, record => $record_key);
     }
     else {
-        return Catmandu::MARC::marc_record_to_json($data, record => $record_key);
+        return Catmandu::MARC->new->marc_record_to_json($data, record => $record_key);
     }
 }
 
diff --git a/lib/Catmandu/Fix/marc_map.pm b/lib/Catmandu/Fix/marc_map.pm
index 8ebf403..dbc5c8b 100644
--- a/lib/Catmandu/Fix/marc_map.pm
+++ b/lib/Catmandu/Fix/marc_map.pm
@@ -35,7 +35,7 @@ sub emit {
     my $result      = $fixer->generate_var;
 
     my $perl =<<EOF;
-if (my ${result} = Catmandu::MARC::marc_map(
+if (my ${result} = Catmandu::MARC->new->marc_map(
             ${var},
             ${marc_path},
             -split => ${split_opt},
diff --git a/lib/Catmandu/Fix/marc_remove.pm b/lib/Catmandu/Fix/marc_remove.pm
index 6cedd42..e63cd6d 100644
--- a/lib/Catmandu/Fix/marc_remove.pm
+++ b/lib/Catmandu/Fix/marc_remove.pm
@@ -16,7 +16,7 @@ sub fix {
     my ($self,$data) = @_;
     my $marc_path  = $self->marc_path;
     my $record_key = $self->record // 'record';
-    return Catmandu::MARC::marc_remove($data, $marc_path, record => $record_key);
+    return Catmandu::MARC->new->marc_remove($data, $marc_path, record => $record_key);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/marc_set.pm b/lib/Catmandu/Fix/marc_set.pm
index d6dbfc3..a78140c 100644
--- a/lib/Catmandu/Fix/marc_set.pm
+++ b/lib/Catmandu/Fix/marc_set.pm
@@ -18,7 +18,7 @@ sub fix {
     my $marc_path   = $self->marc_path;
     my $value       = $self->value;
     my $record_key  = $self->record;
-    return Catmandu::MARC::marc_set($data,$marc_path,$value, record => $record_key);
+    return Catmandu::MARC->new->marc_set($data,$marc_path,$value, record => $record_key);
 }
 
 =head1 NAME
diff --git a/lib/Catmandu/Fix/marc_xml.pm b/lib/Catmandu/Fix/marc_xml.pm
index 0407c98..23bc48b 100644
--- a/lib/Catmandu/Fix/marc_xml.pm
+++ b/lib/Catmandu/Fix/marc_xml.pm
@@ -14,7 +14,7 @@ has path  => (fix_arg => 1);
 # Transform a raw MARC array into MARCXML
 sub fix {
     my ($self, $data) = @_;
-    my $xml = Catmandu::MARC::marc_xml($data);
+    my $xml = Catmandu::MARC->new->marc_xml($data);
     $data->{$self->path} = $xml;
     $data;
 }
diff --git a/lib/Catmandu/MARC.pm b/lib/Catmandu/MARC.pm
index 20622ee..539b88d 100644
--- a/lib/Catmandu/MARC.pm
+++ b/lib/Catmandu/MARC.pm
@@ -5,13 +5,16 @@ use Catmandu::Util;
 use Catmandu::Exporter::MARC::XML;
 use Memoize;
 use Carp;
+use Moo;
 
-memoize('_compile_marc_path');
+#memoize('_compile_marc_path');
 
 our $VERSION = '0.219';
 
+warn 'here';
+
 sub marc_map {
-    my ($data,$marc_path,%opts) = @_;
+    my ($self,$data,$marc_path,%opts) = @_;
     my $record_key = $opts{record} // 'record';
 
     return undef unless exists $data->{$record_key};
@@ -140,7 +143,7 @@ sub _extract_subfields {
 
 
 sub marc_add {
-    my ($data,$marc_path, at subfields) = @_;
+    my ($self,$data,$marc_path, at subfields) = @_;
 
     my %subfields  = @subfields;
     my $record_key = $subfields{'-record'} // 'record';
@@ -190,7 +193,7 @@ sub marc_add {
 }
 
 sub marc_set {
-    my ($data,$marc_path,$value,%opts) = @_;
+    my ($self,$data,$marc_path,$value,%opts) = @_;
     my $record_key = $opts{record} // 'record';
     my $record = $data->{$record_key};
 
@@ -237,7 +240,7 @@ sub marc_set {
 }
 
 sub marc_remove {
-    my ($data, $marc_path,%opts) = @_;
+    my ($self,$data, $marc_path,%opts) = @_;
     my $record_key = $opts{record} // 'record';
     my $record = $data->{$record_key};
 
@@ -287,7 +290,7 @@ sub marc_remove {
 }
 
 sub marc_xml {
-    my ($data) = @_;
+    my ($self,$data) = @_;
 
     my $xml;
     my $exporter = Catmandu::Exporter::MARC::XML->new(file => \$xml , xml_declaration => 0 , collection => 0);
@@ -298,7 +301,7 @@ sub marc_xml {
 }
 
 sub marc_record_to_json {
-    my ($data,%opts) = @_;
+    my ($self,$data,%opts) = @_;
     my $record_key = $opts{record} // 'record';
 
     if (my $marc = delete $data->{$record_key}) {
@@ -331,7 +334,7 @@ sub marc_record_to_json {
 }
 
 sub marc_json_to_record {
-    my ($data,%opts) = @_;
+    my ($self,$data,%opts) = @_;
     my $record_key = $opts{record} // 'record';
 
     my $record = [];
@@ -380,7 +383,7 @@ sub marc_json_to_record {
 }
 
 sub marc_decode_dollar_subfields {
-    my ($data,%opts) = @_;
+    my ($self,$data,%opts) = @_;
     my $record_key = $opts{record} // 'record';
     my $old_record = $data->{$record_key};
     my $new_record = [];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git



More information about the Pkg-perl-cvs-commits mailing list