Skip to content

Commit

Permalink
releng and repo maintenance (perltidy, readme gen, install docs etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Gruenauer committed Oct 19, 2009
1 parent f8a8976 commit 6a02a86
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 86 deletions.
27 changes: 27 additions & 0 deletions 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
9 changes: 3 additions & 6 deletions 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';
Expand All @@ -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;
44 changes: 11 additions & 33 deletions 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__
Expand Down Expand Up @@ -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 <http://www.perl.com/CPAN/> to find a CPAN
site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
site near you. Or see L<http://search.cpan.org/dist/DB-Pluggable/>.
=head1 AUTHORS
Expand Down
28 changes: 5 additions & 23 deletions 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(
Expand All @@ -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+)*)$/) {
Expand All @@ -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];
Expand All @@ -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__
Expand Down Expand Up @@ -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 <http://www.perl.com/CPAN/> to find a CPAN
site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
site near you. Or see L<http://search.cpan.org/dist/DB-Pluggable/>.
=head1 AUTHORS
Expand Down
21 changes: 2 additions & 19 deletions 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__
Expand Down Expand Up @@ -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 <http://www.perl.com/CPAN/> to find a CPAN
site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
site near you. Or see L<http://search.cpan.org/dist/DB-Pluggable/>.
=head1 AUTHORS
Expand Down
5 changes: 0 additions & 5 deletions 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 <<EOYAML);
global:
log:
Expand All @@ -16,8 +13,6 @@ global:
plugins:
- module: BreakOnTestNumber
EOYAML

isa_ok($handler, 'DB::Pluggable');

# hm, it's a bit difficult to test deep debugger magic...

0 comments on commit 6a02a86

Please sign in to comment.