[libnet-mac-vendor-perl] 01/04: Imported Upstream version 1.23
gregor herrmann
gregoa at debian.org
Thu Jul 9 19:40:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to branch master
in repository libnet-mac-vendor-perl.
commit 66c95a5d113d328ea737447f9d264fc4562c2879
Author: gregor herrmann <gregoa at debian.org>
Date: Thu Jul 9 21:23:14 2015 +0200
Imported Upstream version 1.23
---
Changes | 5 +++--
META.json | 2 +-
META.yml | 2 +-
Makefile.PL | 11 +++++++----
lib/Net/MAC/Vendor.pm | 27 +++++++++++++++++++++------
t/fetch_oui.t | 2 +-
t/load_cache.t | 18 ++++++++++++++++++
7 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/Changes b/Changes
index 6f216e7..ee9e685 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
# $Id$
-1.22 - Wed Oct 8 04:11:27 2014
- * Better guards for tests that need to fetch from the IEEE
+1.23 - Thu Nov 13 12:39:54 2014
+ * IEEE now uses https (fixed by Frank071)
+ * Cache in a file instead of a db (added by Frank071)
1.21 - Fri Jan 3 13:34:19 2014
* Get rid of MYMETA
diff --git a/META.json b/META.json
index 851a2f2..384c504 100644
--- a/META.json
+++ b/META.json
@@ -26,5 +26,5 @@
"web" : "https://github.com/briandfoy/net-mac-vendor"
}
},
- "version" : "1.22"
+ "version" : "1.23"
}
diff --git a/META.yml b/META.yml
index 8dda7b7..2550123 100644
--- a/META.yml
+++ b/META.yml
@@ -16,4 +16,4 @@ no_index:
- inc
resources:
repository: https://github.com/briandfoy/net-mac-vendor
-version: 1.22
+version: 1.23
diff --git a/Makefile.PL b/Makefile.PL
index 124ffae..9f1e153 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,19 +5,22 @@ require 5.006;
eval "use Test::Manifest 1.21";
WriteMakefile(
- 'NAME' => 'Net::MAC::Vendor',
+ 'NAME' => 'Net::MAC::Vendor',
'ABSTRACT' => 'Look up the network interface vendor by its MAC',
'VERSION_FROM' => 'lib/Net/MAC/Vendor.pm',
'LICENSE' => 'perl',
'AUTHOR' => 'brian d foy <bdfoy at cpan.org>',
'PREREQ_PM' => {
- 'Test::More' => '0.98',
- 'LWP::Simple' => '0',
+ 'File::Temp' => '0',
+ 'LWP::Protocol::https' => '0',
+ 'LWP::Simple' => '0',
+ 'LWP::Simple' => '0',
+ 'Test::More' => '0.98',
},
'META_MERGE' => {
- 'meta-spec' => { version => 2 },
+ 'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
diff --git a/lib/Net/MAC/Vendor.pm b/lib/Net/MAC/Vendor.pm
index 77fd3ef..c125328 100644
--- a/lib/Net/MAC/Vendor.pm
+++ b/lib/Net/MAC/Vendor.pm
@@ -59,11 +59,11 @@ __PACKAGE__->run( @ARGV ) unless caller;
use Carp;
use LWP::Simple qw(get);
-# http://standards.ieee.org/regauth/oui/oui.txt
+# https://standards.ieee.org/regauth/oui/oui.txt
our $Cached = {};
-our $VERSION = '1.22';
+our $VERSION = '1.23';
=item run( @macs )
@@ -197,7 +197,7 @@ MAC.
sub fetch_oui_from_ieee {
my $mac = normalize_mac( shift );
- my $html = get( "http://standards.ieee.org/cgi-bin/ouisearch?$mac" );
+ my $html = get( "https://standards.ieee.org/cgi-bin/ouisearch?$mac" );
unless( defined $html ) {
carp "Could not fetch data from the IEEE!";
return;
@@ -300,13 +300,13 @@ sub parse_oui {
return \@lines;
}
-=item load_cache( [ SOURCE ] )
+=item load_cache( [ SOURCE[, DEST ] ] )
Downloads the current list of all OUIs, parses it with C<parse_oui()>,
and stores it in C<$Cached> anonymous hash keyed by the OUIs (i.e.
00-0D-93). The C<fetch_oui()> will use this cache if it exists.
-By default, this uses C<http://standards.ieee.org/regauth/oui/oui.txt>,
+By default, this uses C<https://standards.ieee.org/regauth/oui/oui.txt>,
but given an argument, it tries to use that. To load from a local
file, use the C<file://> scheme.
@@ -317,10 +317,15 @@ This previously used DBM::Deep if it was installed, but that was much
too slow. Instead, if you want persistence, you can play with
C<$Net::MAC::Vendor::Cached> yourself.
+If you want to store the data fetched for later use, add a destination
+filename to the request. To fetch from the default location and store,
+specify C<undef> as source.
+
=cut
sub load_cache {
- my $source = shift || "http://standards.ieee.org/regauth/oui/oui.txt";
+ my $source = shift || "https://standards.ieee.org/regauth/oui/oui.txt";
+ my $dest = shift;
my $data = do {
if( -e $source ) { # local files
@@ -334,6 +339,16 @@ sub load_cache {
return;
}
+ if ( $dest ) { # store cache
+ if ( open my $fh, '>', $dest ) {
+ print $fh $data;
+ close $fh;
+ }
+ else { # notify on error, but continue
+ carp "Could not write to '$dest'";
+ }
+ }
+
$data;
}
};
diff --git a/t/fetch_oui.t b/t/fetch_oui.t
index bfe0d72..a260554 100644
--- a/t/fetch_oui.t
+++ b/t/fetch_oui.t
@@ -13,7 +13,7 @@ ok( ! -e 'mac_oui.db', "Cache file has been unlinked" );
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-my $connected = head( 'http://standards.ieee.org/regauth/oui/oui.txt' );
+my $connected = head( 'https://standards.ieee.org/regauth/oui/oui.txt' );
ok( defined $connected, "Am connected to network" );
diff --git a/t/load_cache.t b/t/load_cache.t
index 2bf12c2..cf3a108 100644
--- a/t/load_cache.t
+++ b/t/load_cache.t
@@ -1,4 +1,5 @@
use Test::More;
+use File::Temp qw/ tempfile /;
my $class = 'Net::MAC::Vendor';
@@ -19,4 +20,21 @@ my $rc = Net::MAC::Vendor::load_cache();
ok( $rc, "load_cache returns true for default source");
}
+my ($fh, $filename) = tempfile( undef, UNLINK => 1 );
+{
+local *STDERR;
+open STDERR, ">", \my $output;
+my $rc = Net::MAC::Vendor::load_cache(undef,$filename);
+ok( $rc, "load_cache returns true for default source with write");
+}
+
+ok ( -s $filename, "load_cache results in file with size > 0");
+
+{
+local *STDERR;
+open STDERR, ">", \my $output;
+my $rc = Net::MAC::Vendor::load_cache($filename);
+ok( $rc, "load_cache returns true read from created source");
+}
+
done_testing();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-mac-vendor-perl.git
More information about the Pkg-perl-cvs-commits
mailing list