[libdist-zilla-util-configdumper-perl] 04/04: add dump_plugin util

Florian Schlichting fsfs at moszumanska.debian.org
Sat Nov 11 15:43:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

fsfs pushed a commit to annotated tag 0.003000-source
in repository libdist-zilla-util-configdumper-perl.

commit db5081855a42cc870f9a8f1169c7e7274e404d76
Author: Kent Fredric <kentfredric at gmail.com>
Date:   Sun Aug 24 02:08:27 2014 +1200

    add dump_plugin util
---
 Changes                             |  2 ++
 README.mkdn                         | 31 ++++++++++++++++++++-
 lib/Dist/Zilla/Util/ConfigDumper.pm | 54 +++++++++++++++++++++++++++++++++++--
 misc/Changes.deps                   |  2 +-
 misc/Changes.deps.all               |  2 +-
 misc/Changes.deps.dev               |  2 +-
 misc/Changes.deps.opt               |  2 +-
 7 files changed, 88 insertions(+), 7 deletions(-)

diff --git a/Changes b/Changes
index fcafa91..f004450 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
 Release history for Dist-Zilla-Util-ConfigDumper
 
 {{$NEXT}}
+ [00 Major]
+ - Add dump_plugin utility for deep nested "I want to pretend I'm dzil" stuff.
 
 0.002001 2014-08-22T18:38:02Z
  [Bugfix]
diff --git a/README.mkdn b/README.mkdn
index e17b632..4676a95 100644
--- a/README.mkdn
+++ b/README.mkdn
@@ -4,7 +4,7 @@ Dist::Zilla::Util::ConfigDumper - Easy implementation of 'dumpconfig'
 
 # VERSION
 
-version 0.002002
+version 0.003000
 
 # SYNOPSIS
 
@@ -55,6 +55,35 @@ Either way:
 
 Except with some extra "things dun goofed" handling.
 
+## `dump_plugin`
+
+This function serves the other half of the equation, emulating `dzil`'s own
+internal behavior for extracting the `plugin` configuration data.
+
+    for my $plugin ( @{ $zilla->plugins } ) {
+      pp( dump_plugin( $plugin )); # could prove useful somewhere.
+    }
+
+Its not usually something you need, but its useful in:
+
+- Tests
+- Crazy Stuff like injecting plugins
+- Crazy Stuff like having "Child" plugins
+
+This serves to be a little more complicated than merely calling `->dump_config`,
+as the structure `dzil` uses is:
+
+    {
+      class   => ...
+      name    => ...
+      version => ...
+      config  => $dump_config_results_here
+    }
+
+And of course, there's a bunch of magic stuff with `meta`, `can` and `if keys %$configresults`
+
+All that insanity is wrapped in this simple interface.
+
 # ADVANCED USE
 
 ## CALLBACKS
diff --git a/lib/Dist/Zilla/Util/ConfigDumper.pm b/lib/Dist/Zilla/Util/ConfigDumper.pm
index f99b54b..298af64 100644
--- a/lib/Dist/Zilla/Util/ConfigDumper.pm
+++ b/lib/Dist/Zilla/Util/ConfigDumper.pm
@@ -5,7 +5,7 @@ use utf8;
 
 package Dist::Zilla::Util::ConfigDumper;
 
-our $VERSION = '0.002002';
+our $VERSION = '0.003000';
 
 # ABSTRACT: Easy implementation of 'dumpconfig'
 
@@ -13,7 +13,7 @@ our $VERSION = '0.002002';
 
 use Carp qw( croak );
 use Try::Tiny qw( try catch );
-use Sub::Exporter::Progressive -setup => { exports => [qw( config_dumper )], };
+use Sub::Exporter::Progressive -setup => { exports => [qw( config_dumper dump_plugin )], };
 
 =function C<config_dumper>
 
@@ -77,6 +77,56 @@ sub config_dumper {
   };
 }
 
+=function C<dump_plugin>
+
+This function serves the other half of the equation, emulating C<dzil>'s own
+internal behavior for extracting the C<plugin> configuration data.
+
+  for my $plugin ( @{ $zilla->plugins } ) {
+    pp( dump_plugin( $plugin )); # could prove useful somewhere.
+  }
+
+Its not usually something you need, but its useful in:
+
+=over 4
+
+=item * Tests
+
+=item * Crazy Stuff like injecting plugins
+
+=item * Crazy Stuff like having "Child" plugins
+
+=back
+
+This serves to be a little more complicated than merely calling C<< ->dump_config >>,
+as the structure C<dzil> uses is:
+
+  {
+    class   => ...
+    name    => ...
+    version => ...
+    config  => $dump_config_results_here
+  }
+
+And of course, there's a bunch of magic stuff with C<meta>, C<can> and C<if keys %$configresults>
+
+All that insanity is wrapped in this simple interface.
+
+=cut
+
+sub dump_plugin {
+  my ($plugin) = @_;
+  my $object_config = {};
+  $object_config->{class}   = $plugin->meta->name  if $plugin->can('meta') and $plugin->meta->can('name');
+  $object_config->{name}    = $plugin->plugin_name if $plugin->can('plugin_name');
+  $object_config->{version} = $plugin->VERSION     if $plugin->can('VERSION');
+  if ( $plugin->can('dump_config') ) {
+    my $finder_config = $plugin->dump_config;
+    $object_config->{config} = $finder_config if keys %{$finder_config};
+  }
+  return $object_config;
+}
+
 sub _mk_method_test {
   my ( undef, $methodname ) = @_;
   return sub {
diff --git a/misc/Changes.deps b/misc/Changes.deps
index 1329281..3b0f6bb 100644
--- a/misc/Changes.deps
+++ b/misc/Changes.deps
@@ -1,6 +1,6 @@
 This file contains changes in REQUIRED dependencies for standard CPAN phases (configure/build/runtime/test)
 
-0.002002
+0.003000
 
 0.002001 2014-08-22T18:38:02Z
 
diff --git a/misc/Changes.deps.all b/misc/Changes.deps.all
index aa0193a..cd69faa 100644
--- a/misc/Changes.deps.all
+++ b/misc/Changes.deps.all
@@ -1,6 +1,6 @@
 This file contains ALL changes in dependencies in both REQUIRED / OPTIONAL dependencies for all phases (configure/build/runtime/test/develop)
 
-0.002002
+0.003000
 
 0.002001 2014-08-22T18:38:02Z
 
diff --git a/misc/Changes.deps.dev b/misc/Changes.deps.dev
index 0ff6d14..9c9b637 100644
--- a/misc/Changes.deps.dev
+++ b/misc/Changes.deps.dev
@@ -1,6 +1,6 @@
 This file contains changes to DEVELOPMENT dependencies only ( both REQUIRED and OPTIONAL )
 
-0.002002
+0.003000
 
 0.002001 2014-08-22T18:38:02Z
 
diff --git a/misc/Changes.deps.opt b/misc/Changes.deps.opt
index 1ea4af2..a12a47e 100644
--- a/misc/Changes.deps.opt
+++ b/misc/Changes.deps.opt
@@ -1,6 +1,6 @@
 This file contains changes in OPTIONAL dependencies for standard CPAN phases (configure/build/runtime/test)
 
-0.002002
+0.003000
 
 0.002001 2014-08-22T18:38:02Z
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-util-configdumper-perl.git



More information about the Pkg-perl-cvs-commits mailing list