Skip to content

Commit

Permalink
Loads of stuff
Browse files Browse the repository at this point in the history
 - Internal status to prevent (possibly) damaging actions from taking place
  + For example, hash checking the same torrent twice in two threads
      or trying to write to a torrent being checked or requesting pieces
      for a paused torrent.
 - pause(), start(), stop(), and queue() for individual torrents [untested]
 - *::_as_string() works as it should
 - Default bandwidth limits are now 2**20 (virtually unlimited)
 - Moved from Data::Dumper to optional Data::Dump prerequisite
 - Net::BitTorrent::Torrent's API and docs are less sketchy
 - Net::BitTorrent::Torrent->_peers() returns list
 - New Build actions for dev:
  + profile (for future use)
  + tidy
 - N::B::P::_rw()'s dispatch subs are no longer inline
  • Loading branch information
sanko committed Nov 9, 2008
1 parent 2d84cfc commit 7c7ea1c
Show file tree
Hide file tree
Showing 21 changed files with 2,205 additions and 1,414 deletions.
112 changes: 100 additions & 12 deletions Build.PL
Expand Up @@ -40,10 +40,104 @@ FTW
****************************************************************************
FAIL
# in expectation of future developments (combined profiling in NYTProf)
my $class = $is_developer #&& 0
? Module::Build->subclass(class => q[Net::BitTorrent::Build],
code => <<'SUBCLASS' ) : q[Module::Build];
sub ACTION_profile {
my ($self) = @_;
print qq[...?\n];
unless (Module::Build::ModuleInfo->find_module_by_name('Devel::NYTProf')) {
warn(qq[Cannot run testcover action unless Devel::NYTProf is installed.\n]);
return;
}
#unless (Module::Build::ModuleInfo->find_module_by_name('Devel::Cover')) {
# warn("Cannot run testcover action unless Devel::Cover is installed.\n");
# return;
#}
$self->add_to_cleanup('nytprof.out', 'nytprof');
$self->depends_on('code');
# See whether any of the *.pm files have changed since last time
# testcover was run. If so, start over.
#if (-e 'cover_db') {
# my $pm_files = $self->rscan_dir
# (File::Spec->catdir($self->blib, 'lib'), file_qr('\.pm$') );
# my $cover_files = $self->rscan_dir('cover_db', sub {-f $_ and not /\.html$/});
# $self->do_system(qw(cover -delete))
# unless $self->up_to_date($pm_files, $cover_files)
# && $self->up_to_date($self->test_files, $cover_files);
#}

local $Test::Harness::switches =
local $Test::Harness::Switches =
local $ENV{HARNESS_PERL_SWITCHES} = q[-d:NYTProf];

$self->notes(profile => 1);

$self->depends_on(q[test]);
$self->do_system(q[nytprofhtml --open]);

$self->notes(profile => 0); # clean up
}

sub ACTION_tidy {
my $self = shift;
unless (Module::Build::ModuleInfo->find_module_by_name('Perl::Tidy')) {
warn(qq[Cannot run tidy action unless Perl::Tidy is installed.\n]);
return;
}
require Perl::Tidy;
my @files =
map { File::Spec->rel2abs(q[./] . $_) }
sort(values %{$self->find_pm_files},
keys %{$self->script_files});
Perl::Tidy::perltidy(argv => <<'END' . join q[ ], @files);
--brace-tightness=2
--block-brace-tightness=1
--block-brace-vertical-tightness=2
--paren-tightness=2
--paren-vertical-tightness=2
--square-bracket-tightness=2
--square-bracket-vertical-tightness=2
--brace-tightness=2
--brace-vertical-tightness=2
--delete-old-whitespace
--no-indent-closing-brace
--line-up-parentheses
--no-outdent-keywords
--no-outdent-long-quotes
--no-space-for-semicolon
--swallow-optional-blank-lines
--continuation-indentation=4
--maximum-line-length=78
--want-break-before='% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= \ >>= ||= .= %= ^= x= ? :'
--standard-error-output
--warning-output
--backup-and-modify-in-place
--backup-file-extension=tidy
END
$self->add_to_cleanup(map{File::Spec->abs2rel($_.q[.tidy])}@files);
$self->depends_on(q[code]);
return 1;
}

SUBCLASS

#
my $mb = Module::Build->new(
module_name => q[Net::BitTorrent],
license => q[artistic_2], # requires MB 0.2808_01 or better
my $mb = $class->new(
module_name => q[Net::BitTorrent],
license => q[artistic_2], # M::B 0.2808_01+
dist_author => q[Sanko Robinson <sanko@cpan.org>],
dist_abstract => q[BitTorrent peer-to-peer protocol],
dist_version_from => q[lib/Net/BitTorrent/Version.pm],
Expand All @@ -66,7 +160,7 @@ my $mb = Module::Build->new(
build_requires => {q[Module::Build] => 0.30, # dev on 0.30
q[Test::More] => 0.80, # dev on 0.80
},
recommends => {q[Data::Dump] => 0},
recommends => {q[Data::Dump] => 0}, # debug output
auto_features => {
win32_utf8_support => {
description => q[Support for Wide-char filenames on Windows],
Expand All @@ -79,7 +173,7 @@ my $mb = Module::Build->new(
},
}
},
script_files => qw[./scripts/bittorrent.pl],
script_files => qw[.\scripts\bittorrent.pl],
test_files => \@tests,
meta_merge => {
resources => {
Expand Down Expand Up @@ -107,13 +201,7 @@ $mb->notes(gmtime => gmtime);
$mb->notes(verbose => scalar grep {m[^v$]} keys %{$mb->args()});
$mb->notes(threads => $Config::Config{q[useithreads]} ? 1 : 0);

# M::B is lazy and leaves this file behind on Win32 but it needs that to wrap
# things up...
# $mb->add_to_cleanup(qw[./Build.bat]);
# I'm lazy and... well... yeah...
#$mb->fix_shebang_line(@tests);
#$mb->fix_shebang_line(@{($mb->rscan_dir(q[./lib], qr[\.pm$]))[0]});
# Break it off, let's go.
# okay, let's go
$mb->create_build_script;
exit 0;

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST
Expand Up @@ -14,6 +14,7 @@ lib/Net/BitTorrent/Util.pm
lib/Net/BitTorrent/Version.pm
LICENSE
MANIFEST This list of files
META.yml
Notes.pod
README
scripts/bittorrent.pl
Expand Down Expand Up @@ -42,4 +43,3 @@ t/900_data/950_torrents/953_miniswarm.torrent
t/900_data/950_torrents/955_unicode.torrent
t/900_data/950_torrents/credits.txt
TODO.pod
META.yml
9 changes: 9 additions & 0 deletions MANIFEST.SKIP
Expand Up @@ -24,6 +24,9 @@
# Avoid profiler stuff
\.out$

# Avoid NYTProf stuff
\bnytprof\b

# Avoid temp and backup files.
~$
\.tmp$
Expand Down Expand Up @@ -64,3 +67,9 @@ scripts/.*\.torrent
\.gif
\.html?
\.css

# Skip between-commit-changelog
commitlog.txt

# Skip perltidy backups
\.ti?dy

0 comments on commit 7c7ea1c

Please sign in to comment.