Hello community,
here is the log from the commit of package perl-Class-Singleton for
openSUSE:Factory checked in at 2015-04-16 14:11:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Class-Singleton (Old)
and /work/SRC/openSUSE:Factory/.perl-Class-Singleton.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Class-Singleton"
Changes:
--------
---
/work/SRC/openSUSE:Factory/perl-Class-Singleton/perl-Class-Singleton.changes
2011-09-23 12:36:25.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Class-Singleton.new/perl-Class-Singleton.changes
2015-04-16 14:11:30.000000000 +0200
@@ -1,0 +2,6 @@
+Mon Apr 13 19:13:23 UTC 2015 - [email protected]
+
+- updated to 1.5
+ see /usr/share/doc/packages/perl-Class-Singleton/Changes
+
+-------------------------------------------------------------------
Old:
----
Class-Singleton-1.4.tar.gz
New:
----
Class-Singleton-1.5.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Class-Singleton.spec ++++++
--- /var/tmp/diff_new_pack.7kKIVL/_old 2015-04-16 14:11:30.000000000 +0200
+++ /var/tmp/diff_new_pack.7kKIVL/_new 2015-04-16 14:11:30.000000000 +0200
@@ -1,7 +1,7 @@
#
-# spec file for package perl-Class-Singleton (Version 1.4)
+# spec file for package perl-Class-Singleton
#
-# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -15,44 +15,41 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
-# norootforbuild
-
Name: perl-Class-Singleton
-%define cpan_name %( echo %{name} | %{__sed} -e 's,perl-,,' )
+Version: 1.5
+Release: 0
+%define cpan_name Class-Singleton
Summary: Implementation of a "Singleton" class
-Version: 1.4
-Release: 4
-License: Artistic-1.0
+License: GPL-1.0+ or Artistic-1.0
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/Class-Singleton/
-Source:
http://search.cpan.org/CPAN/authors/id/A/AB/ABW/Class-Singleton-1.4.tar.gz
+Source:
http://www.cpan.org/authors/id/S/SH/SHAY/%{cpan_name}-%{version}.tar.gz
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-%{perl_requires}
BuildRequires: perl
BuildRequires: perl-macros
+%{perl_requires}
%description
-This is the "Class::Singleton" module. A Singleton describes an object
+This is the 'Class::Singleton' module. A Singleton describes an object
class that can have only one instance in any system. An example of a
Singleton might be a print spooler or system registry. This module
implements a Singleton class from which other classes can be derived. By
-itself, the "Class::Singleton" module does very little other than manage
+itself, the 'Class::Singleton' module does very little other than manage
the instantiation of a single object. In deriving a class from
-"Class::Singleton", your module will inherit the Singleton instantiation
+'Class::Singleton', your module will inherit the Singleton instantiation
method and can implement whatever specific functionality is required.
For a description and discussion of the Singleton class, see "Design
Patterns", Gamma et al, Addison-Wesley, 1995, ISBN 0-201-63361-2.
-Author: Andy Wardley <[email protected]>
-
%prep
%setup -q -n %{cpan_name}-%{version}
+find . -type f -print0 | xargs -0 chmod 644
%build
-%{__perl} Makefile.PL OPTIMIZE="$RPM_OPT_FLAGS -Wall"
+%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}
%check
@@ -60,18 +57,11 @@
%install
%perl_make_install
-# do not perl_process_packlist (noarch)
-# remove .packlist file
-%{__rm} -rf $RPM_BUILD_ROOT%perl_vendorarch
-# remove perllocal.pod file
-%{__rm} -rf $RPM_BUILD_ROOT%perl_archlib
+%perl_process_packlist
%perl_gen_filelist
-%clean
-%{__rm} -rf $RPM_BUILD_ROOT
-
%files -f %{name}.files
-%defattr(-,root,root)
+%defattr(-,root,root,755)
%doc Changes README
%changelog
++++++ Class-Singleton-1.4.tar.gz -> Class-Singleton-1.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Class-Singleton-1.4/Changes
new/Class-Singleton-1.5/Changes
--- old/Class-Singleton-1.4/Changes 2007-09-28 10:08:29.000000000 +0200
+++ new/Class-Singleton-1.5/Changes 2014-11-07 22:11:49.000000000 +0100
@@ -1,5 +1,12 @@
#------------------------------------------------------------------------
-# Version 1.04 Date: 2007/09/28
+# Version 1.5 Date: 2014/11/07
+#------------------------------------------------------------------------
+
+* Work around global destruction order issue. [Craig Manley
+ <[email protected]>, CPAN RT#23568/68526]
+
+#------------------------------------------------------------------------
+# Version 1.4 Date: 2007/09/28
#------------------------------------------------------------------------
* Added the has_instance() method to return an existing instance without
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Class-Singleton-1.4/META.yml
new/Class-Singleton-1.5/META.yml
--- old/Class-Singleton-1.4/META.yml 2007-09-28 10:19:28.000000000 +0200
+++ new/Class-Singleton-1.5/META.yml 2014-11-07 22:07:53.000000000 +0100
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Class-Singleton
-version: 1.4
+version: 1.5
abstract: Base class for creating singleton objects
license: ~
generated_by: ExtUtils::MakeMaker version 6.31
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Class-Singleton-1.4/README
new/Class-Singleton-1.5/README
--- old/Class-Singleton-1.4/README 2007-09-28 10:18:08.000000000 +0200
+++ new/Class-Singleton-1.5/README 2014-11-07 22:37:03.000000000 +0100
@@ -3,7 +3,7 @@
SYNOPSIS
use Class::Singleton;
-
+
my $one = Class::Singleton->instance(); # returns a new instance
my $two = Class::Singleton->instance(); # returns same instance
@@ -32,9 +32,9 @@
CPAN stands for the Comprehensive Perl Archive Network.
This is a globally replicated collection of all known Perl
materials, including hundreds of unbunded modules.
-
+
[...]
-
+
For an up-to-date listing of CPAN sites, see
http://www.perl.com/perl/ or ftp://ftp.perl.com/perl/ .
@@ -103,12 +103,12 @@
package PrintSpooler;
use base 'Class::Singleton';
-
+
# derived class specific code
sub submit_job {
...
}
-
+
sub cancel_job {
...
}
@@ -116,9 +116,9 @@
The "PrintSpooler" class defined above could be used as follows:
use PrintSpooler;
-
+
my $spooler = PrintSpooler->instance();
-
+
$spooler->submit_job(...);
The instance() method calls the _new_instance() constructor method the
@@ -130,23 +130,23 @@
package MyConfig;
use base 'Class::Singleton';
-
+
sub foo {
shift->{ foo };
}
-
+
sub bar {
shift->{ bar };
}
-
+
package main;
-
+
# either: hash reference of named parameters
my $config = MyConfig->instance({ foo => 10, bar => 20 });
-
+
# or: list of named parameters
my $config = MyConfig->instance( foo => 10, bar => 20 );
-
+
print $config->foo(); # 10
print $config->bar(); # 20
@@ -157,26 +157,26 @@
package MyApp::Database;
use base 'Class::Singleton';
use DBI;
-
+
# this only gets called the first time instance() is called
sub _new_instance {
my $class = shift;
my $self = bless { }, $class;
- my $db = shift || "myappdb";
+ my $db = shift || "myappdb";
my $host = shift || "localhost";
-
+
$self->{ DB } = DBI->connect("DBI:mSQL:$db:$host")
|| die "Cannot connect to database: $DBI::errstr";
-
+
# any other initialisation...
-
+
return $self;
}
The above example might be used as follows:
use MyApp::Database;
-
+
# first use - database gets initialised
my $database = MyApp::Database->instance();
@@ -184,10 +184,10 @@
package MyApp::FooBar
use MyApp::Database;
-
+
# this FooBar object needs access to the database; the Singleton
# approach gives a nice wrapper around global variables.
-
+
sub new {
my $class = shift;
bless {
@@ -195,19 +195,13 @@
}, $class;
}
- The "Class::Singleton" instance() method uses a package variable to
- store a reference to any existing instance of the object. This variable,
- ""_instance"", is coerced into the derived class package rather than the
- base class package.
-
- Thus, in the "MyApp::Database" example above, the instance variable
- would be:
-
- $MyApp::Database::_instance;
+ The "Class::Singleton" instance() method uses a private hash to store a
+ reference to any existing instance of the object, keyed against the
+ derived class package name.
This allows different classes to be derived from "Class::Singleton" that
can co-exist in the same system, while still allowing only one instance
- of any one class to exists. For example, it would be possible to derive
+ of any one class to exist. For example, it would be possible to derive
both '"PrintSpooler"' and '"MyApp::Database"' from "Class::Singleton"
and have a single instance of *each* in a system, rather than a single
instance of *either*.
@@ -258,7 +252,7 @@
and other ideas.
VERSION
- This is version 1.4, released September 2007
+ This is version 1.5, released November 2014
COPYRIGHT
Copyright Andy Wardley 1998-2007. All Rights Reserved.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Class-Singleton-1.4/lib/Class/Singleton.pm
new/Class-Singleton-1.5/lib/Class/Singleton.pm
--- old/Class-Singleton-1.4/lib/Class/Singleton.pm 2007-09-28
10:18:04.000000000 +0200
+++ new/Class-Singleton-1.5/lib/Class/Singleton.pm 2014-11-07
22:30:24.000000000 +0100
@@ -19,7 +19,8 @@
use strict;
use warnings;
-our $VERSION = 1.4;
+our $VERSION = 1.5;
+my %_INSTANCES = ();
#========================================================================
@@ -28,12 +29,10 @@
#
# Module constructor. Creates an Class::Singleton (or derived) instance
# if one doesn't already exist. The instance reference is stored in the
-# _instance variable of the $class package. This means that classes
-# derived from Class::Singleton will have the variables defined in *THEIR*
-# package, rather than the Class::Singleton package. The impact of this is
+# %_INSTANCES hash of the Class::Singleton package. The impact of this is
# that you can create any number of classes derived from Class::Singleton
-# and create a single instance of each one. If the _instance variable
-# was stored in the Class::Singleton package, you could only instantiate
+# and create a single instance of each one. If the instance reference
+# was stored in a scalar $_INSTANCE variable, you could only instantiate
# *ONE* object of *ANY* class derived from Class::Singleton. The first
# time the instance is created, the _new_instance() constructor is called
# which simply returns a reference to a blessed hash. This can be
@@ -52,12 +51,12 @@
# already got an object
return $class if ref $class;
- # we store the instance in the _instance variable in the $class package.
- no strict 'refs';
- my $instance = \${ "$class\::_instance" };
- defined $$instance
- ? $$instance
- : ($$instance = $class->_new_instance(@_));
+ # we store the instance against the $class key of %_INSTANCES
+ my $instance = $_INSTANCES{$class};
+ unless(defined $instance) {
+ $_INSTANCES{$class} = $instance = $class->_new_instance(@_);
+ }
+ return $instance;
}
@@ -70,8 +69,7 @@
sub has_instance {
my $class = shift;
$class = ref $class || $class;
- no strict 'refs';
- return ${"$class\::_instance"};
+ return $_INSTANCES{$class};
}
@@ -90,6 +88,19 @@
}
+#========================================================================
+# END()
+#
+# END block to explicitly destroy all Class::Singleton objects since
+# destruction order at program exit is not predictable. See CPAN RT
+# bugs #23568 and #68526 for examples of what can go wrong without this.
+#========================================================================
+
+END {
+ # dereferences and causes orderly destruction of all instances
+ undef(%_INSTANCES);
+}
+
1;
@@ -296,19 +307,13 @@
}, $class;
}
-The C<Class::Singleton> L<instance()> method uses a package variable to store
-a reference to any existing instance of the object. This variable,
-"C<_instance>", is coerced into the derived class package rather than the base
-class package.
-
-Thus, in the C<MyApp::Database> example above, the instance variable would
-be:
-
- $MyApp::Database::_instance;
+The C<Class::Singleton> L<instance()> method uses a private hash to store
+a reference to any existing instance of the object, keyed against the derived
+class package name.
This allows different classes to be derived from C<Class::Singleton> that can
co-exist in the same system, while still allowing only one instance of any one
-class to exists. For example, it would be possible to derive both
+class to exist. For example, it would be possible to derive both
'C<PrintSpooler>' and 'C<MyApp::Database>' from C<Class::Singleton> and have a
single instance of I<each> in a system, rather than a single instance of
I<either>.
@@ -365,7 +370,7 @@
=head1 VERSION
-This is version 1.4, released September 2007
+This is version 1.5, released November 2014
=head1 COPYRIGHT