Subject: | [PATCH] Restore Net::DNS::RR->new_from_hash |
Subject: [PATCH] Restore Net::DNS::RR->new_from_hash
There are a number of packages that expect Net::DNS::RR to have
new_from_hash() as an alternate constructor. While recent Net::DNS
claims compatability with prior versions, for some reason this constructor
disappeared in favor of the similarly named new_hash().
This patch restores new_from_hash(), adds a test to ensure it doesn't
disappear again, and tweaks the pod tests a bit.
Thanks! :)
Subject: | 0001-Restore-Net-DNS-RR-new_from_hash.patch |
From 0413d9511624d80ce22168b278df126663def25e Mon Sep 17 00:00:00 2001
From: Chris Weyl <cweyl@alumni.drew.edu>
Date: Fri, 7 Dec 2012 20:44:45 -0800
Subject: [PATCH] Restore Net::DNS::RR->new_from_hash
There are a number of packages that expect Net::DNS::RR to have
new_from_hash() as an alternate constructor. While recent Net::DNS
claims compatability with prior versions, for some reason this constructor
disappeared in favor of the similarly named new_hash().
This patch restores new_from_hash(), adds a test to ensure it doesn't
disappear again, and tweaks the pod tests a bit.
Thanks! :)
---
MANIFEST | 1 +
lib/Net/DNS/RR.pm | 4 ++++
t/00-pod.t | 33 +++++++++++++++------------------
t/80-compat.t | 11 +++++++++++
4 files changed, 31 insertions(+), 18 deletions(-)
create mode 100644 t/80-compat.t
diff --git a/MANIFEST b/MANIFEST
index ca2a015..aa366af 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -146,6 +146,7 @@ t/08-online.t
t/10-recurse.t
t/11-inet6.t
t/13-udp-trunc.t
+t/80-compat.t
t/99-cleanup.t
t/NonFatal.pm
t/TestData.pm
diff --git a/lib/Net/DNS/RR.pm b/lib/Net/DNS/RR.pm
index dccad7d..9386497 100644
--- a/lib/Net/DNS/RR.pm
+++ b/lib/Net/DNS/RR.pm
@@ -162,6 +162,9 @@ If omitted, C<ttl> defaults to 0 and C<class> defaults to IN.
Omitting the optional fields is useful for creating the empty RDATA
sections required for certain dynamic update operations.
+The older new_from_hash() constructor will still work; it just delegates to
+new() directly.
+
=cut
sub new_hash {
@@ -198,6 +201,7 @@ sub new_hash {
return $self;
}
+sub new_from_hash { warn 'in new_from_hash()'; shift->new_hash(@_) }
=head2 decode
diff --git a/t/00-pod.t b/t/00-pod.t
index 6563213..f122578 100644
--- a/t/00-pod.t
+++ b/t/00-pod.t
@@ -1,26 +1,23 @@
# $Id: 00-pod.t 1068 2012-12-06 10:38:51Z willem $
-use Test::More;
-use File::Spec;
-use File::Find;
use strict;
+use warnings;
-eval "use Test::Pod 0.95";
+# test iff we're a in release testing
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
-if ($@) {
- plan skip_all => "Test::Pod v0.95 required for testing POD";
-} else {
- Test::Pod->import;
-
- my @files;
- my $blib = File::Spec->catfile(qw(blib lib));
-
- find( sub { push(@files, $File::Find::name) if /\.p(l|m|od)$/}, $blib);
+use Test::More;
- plan tests => scalar @files;
+# test iff we have a recent level of Test::Pod
+use Test::Requires {
+ 'Test::Pod' => '1.00',
+};
- foreach my $file (@files) {
- pod_file_ok($file);
- }
-}
+all_pod_files_ok();
+done_testing;
diff --git a/t/80-compat.t b/t/80-compat.t
new file mode 100644
index 0000000..9cd87eb
--- /dev/null
+++ b/t/80-compat.t
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+
+# ABSTRACT: A simple check to make sure we don't lose new_from_hash() again
+
+use Test::More;
+use Net::DNS::RR;
+
+can_ok 'Net::DNS::RR', 'new_from_hash';
+
+done_testing;
--
1.8.0.1