summaryrefslogtreecommitdiffstats
path: root/Module-Pluggable-4.8-Allow-single-letter-package-names.patch
blob: 5cb7615bdb5782a15ec49cb6597ee19c722bde66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
From 7872bc27ac7f828a6b53d00717abdf83f2d1866d Mon Sep 17 00:00:00 2001
From: Simon Wistow <simon@fastly.com>
Date: Tue, 22 Oct 2013 09:32:27 -0700
Subject: [PATCH] Allow single letter package names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 lib/Module/Pluggable/Object.pm |  2 +-
 t/25single_letter_package.t    | 42 ++++++++++++++++++++++++++++++++++++++++++
 t/lib/M/X.pm                   |  7 +++++++
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100755 t/25single_letter_package.t
 create mode 100644 t/lib/M/X.pm

diff --git a/lib/Module/Pluggable/Object.pm b/lib/Module/Pluggable/Object.pm
index 6f7a051..46240a8 100755
--- a/lib/Module/Pluggable/Object.pm
+++ b/lib/Module/Pluggable/Object.pm
@@ -234,7 +234,7 @@ sub search_paths {
             }
             my $plugin = join '::', $searchpath, @dirs, $name;
 
-            next unless $plugin =~ m!(?:[a-z\d]+)[a-z\d]!i;
+            next unless $plugin =~ m!(?:[a-z\d]+)[a-z\d]*!i;
 
             $self->handle_finding_plugin($plugin, \@plugins)
         }
diff --git a/t/25single_letter_package.t b/t/25single_letter_package.t
new file mode 100755
index 0000000..dd55fff
--- /dev/null
+++ b/t/25single_letter_package.t
@@ -0,0 +1,42 @@
+#!perl -w
+
+use strict;
+use FindBin;
+use lib (($FindBin::Bin."/lib")=~/^(.*)$/);
+use Test::More tests => 5;
+
+my $foo;
+ok($foo = M->new());
+
+my @plugins;
+my @expected = qw(M::X);
+ok(@plugins = sort $foo->plugins);
+
+
+
+is_deeply(\@plugins, \@expected, "is deeply");
+
+@plugins = ();
+
+ok(@plugins = sort M->plugins);
+
+
+
+
+is_deeply(\@plugins, \@expected, "is deeply class");
+
+
+
+package M;
+
+use strict;
+use Module::Pluggable search_path => "M";
+
+
+sub new {
+    my $class = shift;
+    return bless {}, $class;
+
+}
+1;
+
diff --git a/t/lib/M/X.pm b/t/lib/M/X.pm
new file mode 100644
index 0000000..77f8f58
--- /dev/null
+++ b/t/lib/M/X.pm
@@ -0,0 +1,7 @@
+package M::X;
+
+use strict;
+
+sub new { return bless {}, $_[0]; }
+sub frobnitz {}
+1;
-- 
1.8.3.1