r48045 - in /trunk/libstring-rewriteprefix-perl: Changes META.yml Makefile.PL debian/changelog lib/String/RewritePrefix.pm t/basic.t
bricas-guest at users.alioth.debian.org
bricas-guest at users.alioth.debian.org
Tue Dec 1 15:06:56 UTC 2009
Author: bricas-guest
Date: Tue Dec 1 15:06:35 2009
New Revision: 48045
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=48045
Log:
New upstream release
Modified:
trunk/libstring-rewriteprefix-perl/Changes
trunk/libstring-rewriteprefix-perl/META.yml
trunk/libstring-rewriteprefix-perl/Makefile.PL
trunk/libstring-rewriteprefix-perl/debian/changelog
trunk/libstring-rewriteprefix-perl/lib/String/RewritePrefix.pm
trunk/libstring-rewriteprefix-perl/t/basic.t
Modified: trunk/libstring-rewriteprefix-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libstring-rewriteprefix-perl/Changes?rev=48045&op=diff
==============================================================================
--- trunk/libstring-rewriteprefix-perl/Changes (original)
+++ trunk/libstring-rewriteprefix-perl/Changes Tue Dec 1 15:06:35 2009
@@ -1,4 +1,8 @@
Revision history for String-RewritePrefix
+
+0.005 2009-11-30
+ export "rewrite" with Sub::Exporter
+ prefix new_rewriter with a _; it was always private
0.004 2009-02-20
allow coderef prefix generators (thanks FLORA)
Modified: trunk/libstring-rewriteprefix-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libstring-rewriteprefix-perl/META.yml?rev=48045&op=diff
==============================================================================
--- trunk/libstring-rewriteprefix-perl/META.yml (original)
+++ trunk/libstring-rewriteprefix-perl/META.yml Tue Dec 1 15:06:35 2009
@@ -1,21 +1,24 @@
--- #YAML:1.0
name: String-RewritePrefix
-version: 0.004
+version: 0.005
abstract: ~
author: []
license: perl
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
requires:
- Test::More: 0.47
+ Sub::Exporter: 0
+ Test::More: 0.47
resources:
Repository: http://github.com/rjbs/string-rewriteprefix
no_index:
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.48
+generated_by: ExtUtils::MakeMaker version 6.55_02
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: trunk/libstring-rewriteprefix-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libstring-rewriteprefix-perl/Makefile.PL?rev=48045&op=diff
==============================================================================
--- trunk/libstring-rewriteprefix-perl/Makefile.PL (original)
+++ trunk/libstring-rewriteprefix-perl/Makefile.PL Tue Dec 1 15:06:35 2009
@@ -7,6 +7,7 @@
(eval { ExtUtils::MakeMaker->VERSION(6.21) } ? (LICENSE => 'perl') : ()),
PREREQ_PM => {
'Test::More' => '0.47',
+ 'Sub::Exporter' => 0,
},
(eval { ExtUtils::MakeMaker->VERSION(6.46) }
? (META_MERGE => {
Modified: trunk/libstring-rewriteprefix-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libstring-rewriteprefix-perl/debian/changelog?rev=48045&op=diff
==============================================================================
--- trunk/libstring-rewriteprefix-perl/debian/changelog (original)
+++ trunk/libstring-rewriteprefix-perl/debian/changelog Tue Dec 1 15:06:35 2009
@@ -1,4 +1,7 @@
-libstring-rewriteprefix-perl (0.004-2) UNRELEASED; urgency=low
+libstring-rewriteprefix-perl (0.005-1) UNRELEASED; urgency=low
+
+ [ Brian Cassidy ]
+ * New upstream release
[ Salvatore Bonaccorso ]
* debian/control: Changed: Replace versioned (build-)dependency on
@@ -9,7 +12,7 @@
* debian/control: Changed: (build-)depend on perl instead of perl-
modules.
- -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com> Sun, 16 Aug 2009 20:15:49 +0200
+ -- Brian Cassidy <brian.cassidy at gmail.com> Tue, 01 Dec 2009 11:05:01 -0400
libstring-rewriteprefix-perl (0.004-1) unstable; urgency=low
Modified: trunk/libstring-rewriteprefix-perl/lib/String/RewritePrefix.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libstring-rewriteprefix-perl/lib/String/RewritePrefix.pm?rev=48045&op=diff
==============================================================================
--- trunk/libstring-rewriteprefix-perl/lib/String/RewritePrefix.pm (original)
+++ trunk/libstring-rewriteprefix-perl/lib/String/RewritePrefix.pm Tue Dec 1 15:06:35 2009
@@ -2,6 +2,10 @@
use warnings;
package String::RewritePrefix;
use Carp ();
+
+use Sub::Exporter -setup => {
+ exports => [ rewrite => \'_new_rewriter' ],
+};
=head1 NAME
@@ -9,7 +13,7 @@
=head1 VERSION
-version 0.004
+version 0.005
=head1 SYNOPSIS
@@ -22,9 +26,21 @@
# now you have:
qw(MyApp::Plugin MyApp::Mixin MyApp::Addon Corporate::Thinger)
+You can also import a rewrite routine:
+
+ use String::RewritePrefix rewrite => {
+ -as => 'rewrite_dt_prefix',
+ prefixes => { '' => 'MyApp::', '+' => '' },
+ };
+
+ my @to_load = rewrite_dt_prefix( qw(Plugin Mixin Addon +Corporate::Thinger));
+
+ # now you have:
+ qw(MyApp::Plugin MyApp::Mixin MyApp::Addon Corporate::Thinger)
+
=cut
-our $VERSION = '0.004';
+our $VERSION = '0.005';
=head1 METHODS
@@ -43,11 +59,12 @@
sub rewrite {
my ($self, $arg, @rest) = @_;
- return $self->new_rewriter($arg)->(@rest);
+ return $self->_new_rewriter(rewrite => { prefixes => $arg })->(@rest);
}
-sub new_rewriter {
- my ($self, $rewrites) = @_;
+sub _new_rewriter {
+ my ($self, $name, $arg) = @_;
+ my $rewrites = $arg->{prefixes} || {};
my @rewrites;
for my $prefix (sort { length $b <=> length $a } keys %$rewrites) {
Modified: trunk/libstring-rewriteprefix-perl/t/basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libstring-rewriteprefix-perl/t/basic.t?rev=48045&op=diff
==============================================================================
--- trunk/libstring-rewriteprefix-perl/t/basic.t (original)
+++ trunk/libstring-rewriteprefix-perl/t/basic.t Tue Dec 1 15:06:35 2009
@@ -1,14 +1,17 @@
use strict;
use warnings;
-use Test::More tests => 2;
+use Test::More tests => 3;
use String::RewritePrefix;
-my $rewriter = String::RewritePrefix->new_rewriter({
- '-' => 'Tet::',
- '@' => 'KaTet::',
- '+' => sub { $_[0] . '::Foo::' },
+# testing this method directly seems excessive -- rjbs, 2009-11-30
+my $rewriter = String::RewritePrefix->_new_rewriter(undef, {
+ prefixes => {
+ '-' => 'Tet::',
+ '@' => 'KaTet::',
+ '+' => sub { $_[0] . '::Foo::' },
+ },
});
my @results = $rewriter->(qw(
@@ -25,7 +28,6 @@
"rewrote prefices",
);
-
my @to_load = String::RewritePrefix->rewrite(
{ '' => 'MyApp::', '+' => '' },
qw(Plugin Mixin Addon +Corporate::Thinger),
@@ -37,3 +39,19 @@
"from synopsis, code okay",
);
+{
+ String::RewritePrefix->import(
+ rewrite => { -as => 'pfx_rw', prefixes => {
+ '-' => 'minus ',
+ '+' => 'plus ',
+ '' => 'plus ',
+ } }
+ );
+
+ is_deeply(
+ [ pfx_rw(qw(+10 10 -10 0)) ],
+ [ 'plus 10', 'plus 10', 'minus 10', 'plus 0' ],
+ 'rewrote with import',
+ );
+}
+
More information about the Pkg-perl-cvs-commits
mailing list