Stop depending on XS module Sub::Identify
Arthur Axel 'fREW' Schmidt [Sat, 22 Feb 2014 15:32:27 +0000 (09:32 -0600)]
Changes
cpanfile
lib/Log/Contextual.pm

diff --git a/Changes b/Changes
index d31cd84..dce51d8 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for {{$dist->name}}
 
 {{$NEXT}}
+  - Stop depending on XS module Sub::Identify
 
 0.006002  2014-02-20 16:05:20CST-0600 America/Chicago
   - Fix missing POD
index c6d4c43..9de00a8 100644 (file)
--- a/cpanfile
+++ b/cpanfile
@@ -3,7 +3,6 @@ requires 'Exporter::Declare' => 0.111;
 requires 'Carp' => 0;
 requires 'Scalar::Util' => 0;
 requires 'Moo' => 1.003000;
-requires 'Sub::Identify' => 0.04;
 
 on test => sub {
    requires 'Test::Fatal';
index 0370a5b..54f33f4 100644 (file)
@@ -11,7 +11,19 @@ use Exporter::Declare;
 use Exporter::Declare::Export::Generator;
 use Data::Dumper::Concise;
 use Scalar::Util 'blessed';
-use Sub::Identify 'stash_name';
+
+use B qw(svref_2object);
+
+sub stash_name {
+   my ($coderef) = @_;
+   ref $coderef or return;
+   my $cv = B::svref_2object($coderef);
+   $cv->isa('B::CV') or return;
+   # bail out if GV is undefined
+   $cv->GV->isa('B::SPECIAL') and return;
+
+   return $cv->GV->STASH->NAME;
+}
 
 my @dlog = ((map "Dlog_$_", @levels), (map "DlogS_$_", @levels));