Hello community,
here is the log from the commit of package perl-Safe-Isa for openSUSE:Factory checked in at 2017-10-03 23:17:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Safe-Isa (Old)
and /work/SRC/openSUSE:Factory/.perl-Safe-Isa.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Safe-Isa"
Tue Oct 3 23:17:41 2017 rev:5 rq:530067 version:1.000007
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Safe-Isa/perl-Safe-Isa.changes 2016-11-10 13:27:38.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.perl-Safe-Isa.new/perl-Safe-Isa.changes 2017-10-03 23:17:42.730811647 +0200
@@ -1,0 +2,9 @@
+Fri Sep 22 06:02:44 UTC 2017 - coolo@suse.com
+
+- updated to 1.000007
+ see /usr/share/doc/packages/perl-Safe-Isa/Changes
+
+ 1.000007 - 2017-09-22
+ - added new interface: $obj->$_call_if_can
+
+-------------------------------------------------------------------
Old:
----
Safe-Isa-1.000006.tar.gz
New:
----
Safe-Isa-1.000007.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Safe-Isa.spec ++++++
--- /var/tmp/diff_new_pack.uMCbCX/_old 2017-10-03 23:17:43.274735099 +0200
+++ /var/tmp/diff_new_pack.uMCbCX/_new 2017-10-03 23:17:43.278734535 +0200
@@ -1,7 +1,7 @@
#
# spec file for package perl-Safe-Isa
#
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 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
@@ -17,14 +17,14 @@
Name: perl-Safe-Isa
-Version: 1.000006
+Version: 1.000007
Release: 0
%define cpan_name Safe-Isa
Summary: Call isa, can, does and DOES safely on things that may not be objects
License: Artistic-1.0 or GPL-1.0+
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/Safe-Isa/
-Source0: http://www.cpan.org/authors/id/H/HA/HAARG/%{cpan_name}-%{version}.tar.gz
+Source0: https://cpan.metacpan.org/authors/id/E/ET/ETHER/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
++++++ Safe-Isa-1.000006.tar.gz -> Safe-Isa-1.000007.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/Changes new/Safe-Isa-1.000007/Changes
--- old/Safe-Isa-1.000006/Changes 2016-10-31 23:08:01.000000000 +0100
+++ new/Safe-Isa-1.000007/Changes 2017-09-22 04:23:38.000000000 +0200
@@ -1,5 +1,8 @@
Revision history for Safe-Isa
+1.000007 - 2017-09-22
+ - added new interface: $obj->$_call_if_can
+
1.000006 - 2016-10-31
- now falling back to $obj->isa if DOES/does is not implemented on the
object, to avoid fatal errors on perls too old to have their own DOES
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/META.json new/Safe-Isa-1.000007/META.json
--- old/Safe-Isa-1.000006/META.json 2016-10-31 23:08:10.000000000 +0100
+++ new/Safe-Isa-1.000007/META.json 2017-09-22 04:24:11.000000000 +0200
@@ -4,13 +4,13 @@
"mst - Matt S. Trout (cpan:MSTROUT) "
],
"dynamic_config" : 0,
- "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005",
+ "generated_by" : "ExtUtils::MakeMaker version 7.3103, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
- "version" : "2"
+ "version" : 2
},
"name" : "Safe-Isa",
"no_index" : {
@@ -20,9 +20,6 @@
]
},
"prereqs" : {
- "build" : {
- "requires" : {}
- },
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
@@ -53,6 +50,6 @@
"web" : "http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/Safe-Isa.git"
}
},
- "version" : "1.000006",
- "x_serialization_backend" : "JSON::PP version 2.27300"
+ "version" : "1.000007",
+ "x_serialization_backend" : "JSON::MaybeXS version 1.003009"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/META.yml new/Safe-Isa-1.000007/META.yml
--- old/Safe-Isa-1.000006/META.yml 2016-10-31 23:08:10.000000000 +0100
+++ new/Safe-Isa-1.000007/META.yml 2017-09-22 04:24:11.000000000 +0200
@@ -7,7 +7,7 @@
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150005'
+generated_by: 'ExtUtils::MakeMaker version 7.3103, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -24,5 +24,5 @@
resources:
bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Safe-Isa
repository: git://git.shadowcat.co.uk/p5sagit/Safe-Isa.git
-version: '1.000006'
+version: '1.000007'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/Makefile.PL new/Safe-Isa-1.000007/Makefile.PL
--- old/Safe-Isa-1.000006/Makefile.PL 2016-10-17 17:37:55.000000000 +0200
+++ new/Safe-Isa-1.000007/Makefile.PL 2017-09-22 01:48:05.000000000 +0200
@@ -27,6 +27,7 @@
},
META_ADD => {
+ 'meta-spec' => { version => 2 },
prereqs => {
configure => {
requires => {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/README new/Safe-Isa-1.000007/README
--- old/Safe-Isa-1.000006/README 2016-10-31 23:08:10.000000000 +0100
+++ new/Safe-Isa-1.000007/README 2017-09-22 04:24:11.000000000 +0200
@@ -40,9 +40,10 @@
$maybe_an_object->$_does('RoleName'); # true or false, no boom today
$maybe_an_object->$_DOES('RoleName'); # true or false, no boom today
- And just in case we missed a method:
+ And just in case we missed a method or two:
$maybe_an_object->$_call_if_object(name => @args);
+ $maybe_an_object->$_call_if_can(name => @args);
Or to re-use a previous example for purposes of explication:
@@ -116,6 +117,13 @@
If called on an object, calls "method_name" on it and returns the
result, otherwise returns nothing.
+ $_call_if_can
+ $maybe_an_object->$_call_if_can(name => @args);
+
+ If called on an object, calls "can" on it; if that returns true, then
+ calls "method_name" on it and returns the result; if any condition is
+ false returns nothing.
+
SEE ALSO
I gave a lightning talk on this module (and curry and Import::Into) at
YAPC::NA 2013 https://www.youtube.com/watch?v=wFXWV2yY7gE&t=46m05s.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/lib/Safe/Isa.pm new/Safe-Isa-1.000007/lib/Safe/Isa.pm
--- old/Safe-Isa-1.000006/lib/Safe/Isa.pm 2016-10-31 23:07:58.000000000 +0100
+++ new/Safe-Isa-1.000007/lib/Safe/Isa.pm 2017-09-22 04:21:32.000000000 +0200
@@ -2,19 +2,19 @@
use strict;
use warnings FATAL => 'all';
-use Scalar::Util qw(blessed);
+use Scalar::Util ();
use Exporter 5.57 qw(import);
-our $VERSION = '1.000006';
+our $VERSION = '1.000007';
-our @EXPORT = qw($_call_if_object $_isa $_can $_does $_DOES);
+our @EXPORT = qw($_call_if_object $_isa $_can $_does $_DOES $_call_if_can);
our $_call_if_object = sub {
my ($obj, $method) = (shift, shift);
# This is intentionally a truth test, not a defined test, otherwise
# we gratuitously break modules like Scalar::Defer, which would be
# un-perlish.
- return unless blessed($obj);
+ return unless Scalar::Util::blessed($obj);
return $obj->isa(@_) if lc($method) eq 'does' and not $obj->can($method);
return $obj->$method(@_);
};
@@ -24,6 +24,11 @@
sub { my $obj = shift; $obj->$_call_if_object($method => @_) }
} qw(isa can does DOES);
+our $_call_if_can = sub {
+ my ($obj, $method) = (shift, shift);
+ $obj->$_call_if_object(can => $method) && $obj->$_call_if_object($method => @_);
+};
+
1;
__END__
@@ -72,9 +77,10 @@
$maybe_an_object->$_does('RoleName'); # true or false, no boom today
$maybe_an_object->$_DOES('RoleName'); # true or false, no boom today
-And just in case we missed a method:
+And just in case we missed a method or two:
$maybe_an_object->$_call_if_object(name => @args);
+ $maybe_an_object->$_call_if_can(name => @args);
Or to re-use a previous example for purposes of explication:
@@ -154,6 +160,14 @@
If called on an object, calls C on it and returns the result,
otherwise returns nothing.
+=head2 $_call_if_can
+
+ $maybe_an_object->$_call_if_can(name => @args);
+
+If called on an object, calls C<can> on it; if that returns true, then
+calls C on it and returns the result; if any condition is false
+returns nothing.
+
=head1 SEE ALSO
I gave a lightning talk on this module (and L<curry> and LImport::Into) at
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Safe-Isa-1.000006/t/safe_isa.t new/Safe-Isa-1.000007/t/safe_isa.t
--- old/Safe-Isa-1.000006/t/safe_isa.t 2016-10-17 17:37:55.000000000 +0200
+++ new/Safe-Isa-1.000007/t/safe_isa.t 2017-09-22 04:21:32.000000000 +0200
@@ -1,9 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 20;
+use Test::More tests => 38;
{ package Foo; sub new { bless({}, $_[0]) } }
-{ package Bar; our @ISA = qw(Foo); sub bar { 1 } }
+{ package Bar; our @ISA = qw(Foo); sub bar { $_[1] } }
my $foo = Foo->new;
my $bar = Bar->new;
@@ -27,15 +27,25 @@
ok($foo->$_isa('Foo'), 'foo $_isa Foo');
ok($bar->$_isa('Foo'), 'bar $_isa Foo');
-ok(eval { $blam->$_isa('Foo'); 1 }, 'no boom today');
-ok(eval { $undef->$_isa('Foo'); 1 }, 'nor tomorrow either');
+ok(eval { is($blam->$_isa('Foo'), undef, 'blam isn\'t Foo'); 1 }, 'no boom today');
+ok(eval { is($undef->$_isa('Foo'), undef, 'undef isn\'t Foo either'); 1 }, 'and no boom tomorrow either');
ok(!$foo->$_can('bar'), 'foo !$_can bar');
ok($bar->$_can('bar'), 'bar $_can bar');
-ok(eval { $blam->$_can('bar'); 1 }, 'no boom today');
-ok(eval { $undef->$_can('bar'); 1 }, 'nor tomorrow either');
+ok(eval { is($blam->$_can('bar'), undef, 'blam can\'t bar'); 1 }, 'no boom today');
+ok(eval { is($undef->$_can('bar'), undef, 'undef can\'t bar either'); 1 }, 'and no boom tomorrow either');
ok($foo->$_call_if_object(isa => 'Foo'), 'foo $_call_if_object(isa => Foo)');
ok($bar->$_call_if_object(isa => 'Foo'), 'bar $_call_if_object(isa => Foo)');
-ok(eval { $blam->$_call_if_object(isa => 'Foo'); 1 }, 'no boom today');
-ok(eval { $undef->$_call_if_object(isa => 'Foo'); 1 }, 'nor tomorrow either');
+is($bar->$_call_if_object(bar => ), undef, 'bar $_call_if_object(bar => undef)');
+is($bar->$_call_if_object(bar => 2), 2, 'bar $_call_if_object(bar => 2)');
+ok(eval { is($blam->$_call_if_object(isa => 'Foo'), undef, 'blam can\'t call anything'); 1 }, 'no boom today');
+ok(eval { is($undef->$_call_if_object(isa => 'Foo'), undef, 'undef can\'t call anything'); 1 }, 'and no boom tomorrow either');
+
+ok($foo->$_call_if_can(isa => 'Foo'), 'foo $_call_if_can(isa => Foo)');
+ok($bar->$_call_if_can(isa => 'Foo'), 'bar $_call_if_can(isa => Foo)');
+ok(eval { is($foo->$_call_if_can(bar => ), undef, 'foo can\'t call bar'); 1 }, 'no boom today');
+is($bar->$_call_if_can(bar => ), undef, 'bar $_call_if_can(bar => ');
+is($bar->$_call_if_can(bar => 2), 2, 'bar $_call_if_can(bar => 2');
+ok(eval { is($blam->$_call_if_can(isa => 'Foo'), undef, 'blam can\'t call anything'); 1 }, 'no boom today');
+ok(eval { is($undef->$_call_if_can(isa => 'Foo'), undef, 'undef can\'t call anything'); 1 }, 'and no boom tomorrow either');