From 6a02a8614fef9de65ed4d0e85f48d7582e80d046 Mon Sep 17 00:00:00 2001 From: Marcel Gruenauer Date: Mon, 19 Oct 2009 18:44:15 +0200 Subject: [PATCH] releng and repo maintenance (perltidy, readme gen, install docs etc) --- INSTALL | 27 ++++++++++++++++ Makefile.PL | 9 ++---- lib/DB/Pluggable.pm | 44 +++++++-------------------- lib/DB/Pluggable/BreakOnTestNumber.pm | 28 +++-------------- lib/DB/Pluggable/Constants.pm | 21 ++----------- t/01_misc.t | 5 --- 6 files changed, 48 insertions(+), 86 deletions(-) create mode 100644 INSTALL diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..eaee95a --- /dev/null +++ b/INSTALL @@ -0,0 +1,27 @@ +This is the Perl distribution DB-Pluggable. + +## Installation + +DB-Pluggable installation is straightforward. If your CPAN shell is +set up, you should just be able to do + + % cpan DB::Pluggable + +Download it, unpack it, then build it as per the usual: + + % perl Makefile.PL + % make && make test + +Then install it: + + % make install + +## Documentation + +DB-Pluggable documentation is available as in POD. So you can do: + + % perldoc DB::Pluggable + +to read the documentation online with your favorite pager. + +Marcel Gruenauer diff --git a/Makefile.PL b/Makefile.PL index e7fb706..5717fef 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,20 +1,17 @@ use inc::Module::Install; include 'Module::AutoInstall'; - name 'DB-Pluggable'; all_from 'lib/DB/Pluggable.pm'; - +readme_from_pod; +readme_markdown_from_pod; auto_set_homepage; auto_set_bugtracker; auto_set_repository; - requires 'Hook::LexWrap'; requires 'Hook::Modular'; - test_requires 'Test::Differences'; test_requires 'Test::More' => '0.70'; extra_tests; - author_requires 'ShipIt'; author_requires 'ShipIt::Step::DistClean'; author_requires 'ShipIt::Step::DistTestExtra'; @@ -26,11 +23,11 @@ author_requires 'Test::Pod'; author_requires 'Test::Spelling'; author_requires 'Pod::Wordlist::hanekomu'; author_requires 'Test::Pod::Coverage'; + # author_requires 'Test::Kwalitee'; # Attempt to free unreferenced scalar author_requires 'Test::YAML::Meta'; author_requires 'Test::Portability::Files'; author_requires 'Test::Synopsis'; - auto_install; auto_include; WriteAll; diff --git a/lib/DB/Pluggable.pm b/lib/DB/Pluggable.pm index 728864e..f103ebe 100644 --- a/lib/DB/Pluggable.pm +++ b/lib/DB/Pluggable.pm @@ -1,77 +1,55 @@ package DB::Pluggable; - +use 5.006; use strict; use warnings; -use 5.006; use DB::Pluggable::Constants ':all'; use Hook::LexWrap; - - use base 'Hook::Modular'; - - our $VERSION = '0.04'; - - use constant PLUGIN_NAMESPACE => 'DB::Pluggable'; - sub enable_watchfunction { my $self = shift; no warnings 'once'; $DB::trace |= 4; # Enable watchfunction } - - -package # hide from PAUSE indexer - DB; +package # hide from PAUSE indexer + DB; # switch package so as to get the desired stack trace - sub watchfunction { return unless defined $DB::PluginHandler; - my $depth = 1; while (1) { my ($package, $file, $line, $sub) = caller $depth; last unless defined $package; return if $sub =~ /::DESTROY$/; - $depth++; } - $DB::PluginHandler->run_hook('db.watchfunction'); } - package DB::Pluggable; - sub run { my $self = shift; - $self->run_hook('plugin.init'); - our $cmd_b_wrapper = wrap 'DB::cmd_b', pre => sub { my ($cmd, $line, $dbline) = @_; - - my @result = $self->run_hook('db.cmd.b', { - cmd => $cmd, - line => $line, - dbline => $dbline, - }); + my @result = $self->run_hook( + 'db.cmd.b', + { cmd => $cmd, + line => $line, + dbline => $dbline, + } + ); # short-circuit (i.e., don't call the original debugger function) if # a plugin has handled it - $_[-1] = 1 if grep { $_ eq HANDLED } @result; }; } - - 1; - - __END__ @@ -226,7 +204,7 @@ See perlmodinstall for information and options on installing Perl modules. The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit to find a CPAN -site near you. Or see . +site near you. Or see L. =head1 AUTHORS diff --git a/lib/DB/Pluggable/BreakOnTestNumber.pm b/lib/DB/Pluggable/BreakOnTestNumber.pm index 0ab6778..c5cff05 100644 --- a/lib/DB/Pluggable/BreakOnTestNumber.pm +++ b/lib/DB/Pluggable/BreakOnTestNumber.pm @@ -1,16 +1,10 @@ package DB::Pluggable::BreakOnTestNumber; - use strict; use warnings; use DB::Pluggable::Constants ':all'; - - our $VERSION = '0.04'; - - use base 'Hook::Modular::Plugin'; - sub register { my ($self, $context) = @_; $context->register_hook( @@ -21,13 +15,11 @@ sub register { ); } - sub plugin_init { my ($self, $context, $args) = @_; @DB::testbreak = (); } - sub cmd_b { my ($self, $context, $args) = @_; if ($args->{line} =~ /\s*#\s*(\d+(?:\s*,\s*\d+)*)$/) { @@ -37,23 +29,19 @@ sub cmd_b { # enable the watchfunction JIT so we don't waste time at the beginning $context->enable_watchfunction; - return HANDLED; } else { return DECLINED; } } - sub watchfunction { my ($self, $context, $args) = @_; - if (@DB::testbreak && exists $INC{'Test/Builder.pm'}) { my $next = Test::Builder->new->current_test + 1; if ($next >= $DB::testbreak[0]) { shift @DB::testbreak - while @DB::testbreak && $next >= $DB::testbreak[0]; - + while @DB::testbreak && $next >= $DB::testbreak[0]; my $depth = 1; while (1) { my $package = (caller $depth)[0]; @@ -64,21 +52,15 @@ sub watchfunction { # Doesn't stop at the breakpoint without something like this in # exactly this location. WTF? - - use Data::Dumper; my $dummy = Dumper $depth; - + use Data::Dumper; + my $dummy = Dumper $depth; no warnings 'once'; - $DB::stack[-$depth] = 1; + $DB::stack[ -$depth ] = 1; } } - return; } - - 1; - - __END__ @@ -195,7 +177,7 @@ See perlmodinstall for information and options on installing Perl modules. The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit to find a CPAN -site near you. Or see . +site near you. Or see L. =head1 AUTHORS diff --git a/lib/DB/Pluggable/Constants.pm b/lib/DB/Pluggable/Constants.pm index 5502137..1358eba 100644 --- a/lib/DB/Pluggable/Constants.pm +++ b/lib/DB/Pluggable/Constants.pm @@ -1,30 +1,13 @@ package DB::Pluggable::Constants; - use strict; use warnings; - - our $VERSION = '0.04'; - - use base 'Exporter'; - - -our %EXPORT_TAGS = ( - util => [ qw(HANDLED DECLINED) ], -); - - +our %EXPORT_TAGS = (util => [qw(HANDLED DECLINED)],); our @EXPORT_OK = @{ $EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ] }; - - use constant HANDLED => '200'; use constant DECLINED => '500'; - - 1; - - __END__ @@ -89,7 +72,7 @@ See perlmodinstall for information and options on installing Perl modules. The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit to find a CPAN -site near you. Or see . +site near you. Or see L. =head1 AUTHORS diff --git a/t/01_misc.t b/t/01_misc.t index 5efee0f..9205029 100644 --- a/t/01_misc.t +++ b/t/01_misc.t @@ -1,13 +1,10 @@ #!/usr/bin/env perl - use warnings; use strict; use Test::More tests => 1; use Test::Differences; use YAML; use DB::Pluggable; - - my $handler = DB::Pluggable->new(config => Load <