[libcatmandu-marc-perl] 33/208: Trying singletons

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 ca552fcce2d6ac05ba030034b351ad7755530071
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Tue Jul 12 13:48:22 2016 +0200

    Trying singletons
---
 Build.PL                                         | 1 +
 cpanfile                                         | 1 +
 lib/Catmandu/Fix/Inline/marc_add.pm              | 2 +-
 lib/Catmandu/Fix/Inline/marc_map.pm              | 2 +-
 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                             | 1 +
 14 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/Build.PL b/Build.PL
index 7807ca1..d7b2952 100644
--- a/Build.PL
+++ b/Build.PL
@@ -31,6 +31,7 @@ my %module_build_args = (
     "MARC::Parser::RAW" => 0,
     "MARC::Record" => "v2.0.6",
     "Moo" => "1.0",
+    "MooX::Singleton" => 0,
     "YAML::XS" => "0.34",
     "perl" => "v5.10.1"
   },
diff --git a/cpanfile b/cpanfile
index 6bfeae0..ae0e652 100644
--- a/cpanfile
+++ b/cpanfile
@@ -18,3 +18,4 @@ requires 'MARC::File::MiJ' , '0.04';
 requires 'MARC::Record', '2.0.6';
 requires 'MARC::Parser::RAW', '0';
 requires 'Moo', '1.0';
+requires 'MooX::Singleton', '0';
diff --git a/lib/Catmandu/Fix/Inline/marc_add.pm b/lib/Catmandu/Fix/Inline/marc_add.pm
index f4f48b2..7fbb589 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->new->marc_add($data, $marc_path, @subfields);
+    return Catmandu::MARC->instance->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 ab8bc74..7f2daa1 100644
--- a/lib/Catmandu/Fix/Inline/marc_map.pm
+++ b/lib/Catmandu/Fix/Inline/marc_map.pm
@@ -72,7 +72,7 @@ sub marc_map {
     # Set default to nested_arrays for backwards compatibility
     $opts{'-record'} = 'record' unless exists $opts{'-record'};
     $opts{'-nested_arrays'} = 1 unless exists $opts{'-nested_arrays'};
-    return Catmandu::MARC->new->marc_map(
+    return Catmandu::MARC->instance->marc_map(
                 $data,
                 $marc_path,
                 \%opts);
diff --git a/lib/Catmandu/Fix/Inline/marc_remove.pm b/lib/Catmandu/Fix/Inline/marc_remove.pm
index 236a856..c64cb4a 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->new->marc_remove($data,$marc_path);
+    return Catmandu::MARC->instance->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 33d66eb..aef7dd5 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->new->marc_set($data,$marc_path,$value);
+    return Catmandu::MARC->instance->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 bc0aba8..5817f29 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->new->marc_add($data,$marc_path, at subfields);
+    return Catmandu::MARC->instance->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 f716022..290fca1 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->new->marc_decode_dollar_subfields($data, record => $record_key);
+    return Catmandu::MARC->instance->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 7d09d77..2b8701a 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->new->marc_json_to_record($data, record => $record_key);
+        return Catmandu::MARC->instance->marc_json_to_record($data, record => $record_key);
     }
     else {
-        return Catmandu::MARC->new->marc_record_to_json($data, record => $record_key);
+        return Catmandu::MARC->instance->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 90bda3f..295f96c 100644
--- a/lib/Catmandu/Fix/marc_map.pm
+++ b/lib/Catmandu/Fix/marc_map.pm
@@ -22,7 +22,7 @@ sub emit {
     my ($self,$fixer) = @_;
     my $path        = $fixer->split_path($self->path);
 
-    my $marc        = $fixer->capture(Catmandu::MARC->new);
+    my $marc        = $fixer->capture(Catmandu::MARC->instance);
     my $marc_path   = $fixer->emit_string($self->marc_path);
     my $marc_opt    = $fixer->capture({
                             '-record' => $self->record // 'record' ,
diff --git a/lib/Catmandu/Fix/marc_remove.pm b/lib/Catmandu/Fix/marc_remove.pm
index e63cd6d..633ef43 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->new->marc_remove($data, $marc_path, record => $record_key);
+    return Catmandu::MARC->instance->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 a78140c..7eb30cc 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->new->marc_set($data,$marc_path,$value, record => $record_key);
+    return Catmandu::MARC->instance->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 23bc48b..f5e51d6 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->new->marc_xml($data);
+    my $xml = Catmandu::MARC->instance->marc_xml($data);
     $data->{$self->path} = $xml;
     $data;
 }
diff --git a/lib/Catmandu/MARC.pm b/lib/Catmandu/MARC.pm
index 5f4a817..018d784 100644
--- a/lib/Catmandu/MARC.pm
+++ b/lib/Catmandu/MARC.pm
@@ -6,6 +6,7 @@ use Catmandu::Exporter::MARC::XML;
 use Memoize;
 use Carp;
 use Moo;
+with 'MooX::Singleton';
 
 memoize('_compile_marc_path');
 

-- 
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