Module-Provision

 view release on metacpan or  search on metacpan

lib/Module/Provision/Base.pm  view on Meta::CPAN

   builder          => sub { $_[ 0 ]->config->license };

option 'perms'      => is => 'ro',   isa => OctalNum, format => 'i',
   documentation    => 'Default permission for file / directory creation',
   default          => '640', coerce => TRUE;

option 'plugins'    => is => 'ro',   isa => ArrayRef[NonEmptySimpleStr],
   documentation    => 'Name of optional plugins to load, comma separated list',
   builder          => sub { [] }, format => 's', short => 'M',
   coerce           => sub { (is_arrayref $_[ 0 ])
                                ? $_[ 0 ] : [ split m{ , }mx, $_[ 0 ] ] };

option 'project'    => is => 'lazy', isa => NonEmptySimpleStr, format => 's',
   documentation    => 'Package name of the new projects main module';

option 'repository' => is => 'ro',   isa => NonEmptySimpleStr, format => 's',
   documentation    => 'Directory containing the SVN repository',
   builder          => sub { $_[ 0 ]->config->repository };

option 'vcs'        => is => 'lazy', isa => $VCS, format => 's',
   documentation    => 'Which VCS to use: git, none, or svn';

lib/Module/Provision/Base.pm  view on Meta::CPAN

   return (sort keys %BUILDERS);
};

my $_get_module_from = sub { # Return main module name from project file
   return
      (map    { s{ [-] }{::}gmx; $_ }
       map    { m{ \A [q\'\"] }mx ? eval $_ : $_ }
       map    { m{ \A \s* (?:module_name|module|name)
                      \s+ [=]?[>]? \s* ([^,;]+) [,;]? }imx }
       grep   { m{ \A \s*   (module|name) }imx }
       split m{ [\n] }mx, $_[ 0 ])[ 0 ];
};

my $_parse_manifest_line = sub { # Robbed from ExtUtils::Manifest
   my $line = shift; my ($file, $comment);

   # May contain spaces if enclosed in '' (in which case, \\ and \' are escapes)
   if (($file, $comment) = $line =~ m{ \A \' (\\[\\\']|.+)+ \' \s* (.*) }mx) {
      $file =~ s{ \\ ([\\\']) }{$1}gmx;
   }
   else {

lib/Module/Provision/Base.pm  view on Meta::CPAN

            distname        => $self->distname,
            first_name      => lc ((split SPC, $author)[ 0 ]),
            home_page       => $config->home_page,
            initial_wd      => NUL.$self->initial_wd,
            last_name       => lc ((split SPC, $author)[ -1 ]),
            lc_distname     => lc $self->distname,
            license         => $self->license,
            license_class   => $self->license_keys->{ $self->license },
            module          => $project,
            perl            => $perl_ver,
            prefix          => (split m{ :: }mx, lc $project)[ -1 ],
            project         => $project,
            pub_repo_prefix => $config->pub_repo_prefix,
            use_perl        => $perl_code,
            version         => $self->VERSION, };
}

sub _build_vcs {
   my $self = shift; my $appbase = $self->appbase;

   return $appbase->catdir( '.git'            )->exists ? 'git'

lib/Module/Provision/TraitFor/CreatingDistributions.pm  view on Meta::CPAN

   return Module::Provision->new
      ( method => 'edit_project', noask => TRUE, quiet => TRUE )->run;
}

sub show_tab_title : method {
   my $self = shift;
   my $file = $self->next_argv || $self->$_project_file_path;
   my $text = (grep { m{ tab-title: }msx } io( $file )->getlines)[ -1 ]
           || ':'.$self->distname;

   emit trim( (split m{ : }msx, $text, 2)[ 1 ] ).SPC.$self->appbase;
   return OK;
}

1;

__END__

=pod

=encoding utf-8

lib/Module/Provision/TraitFor/PrereqDifferences.pm  view on Meta::CPAN

};

my $_draw_line = sub {
    return emit '-' x ($_[ 0 ] // 60);
};

my $_extract_statements_from = sub {
   my $line = shift;

   return grep { length }
          map  { s{ \A \s+ }{}mx; s{ \s+ \z }{}mx; $_ } split m{ ; }mx, $line;
};

my $_looks_like_version = sub {
    my $ver = shift;

    return defined $ver && $ver =~ m{ \A v? \d+ (?: \.[\d_]+ )? \z }mx;
};

my $_parse_list = sub {
   my $string = shift;

   $string =~ s{ \A q w* [\(/] \s* }{}mx;
   $string =~ s{ \s* [\)/] \z }{}mx;
   $string =~ s{ [\'\"] }{}gmx;
   $string =~ s{ , }{ }gmx;

   return grep { length && !m{ [^\.:\w] }mx } split m{ \s+ }mx, $string;
};

my $_read_non_pod_lines = sub {
   my $path = shift; my $p = Pod::Eventual::Simple->read_file( $path );

   return join "\n", map  { $_->{content} }
                     grep { $_->{type} eq 'nonpod' } @{ $p };
};

my $_recover_module_name = sub {
   my $id = shift;  my @parts = split m{ [\-] }mx, $id; my $ver = pop @parts;

   return  join '::', @parts;
};

my $_version_diff = sub {
   my ($prereq, $depend) = @_;

   $prereq =~ s{ (\. [0-9]+?) 0+ \z }{$1}mx;
   $depend =~ s{ (\. [0-9]+?) 0+ \z }{$1}mx;

lib/Module/Provision/TraitFor/PrereqDifferences.pm  view on Meta::CPAN

   }

   return;
};

my $_parse_depends_line = sub {
   my $line = shift; my $modules = [];

   for my $stmt ($_extract_statements_from->( $line )) {
      if ($stmt =~ m{ \A (?: use | require ) \s+ }mx) {
         my (undef, $module, $rest) = split m{ \s+ }mx, $stmt, 3;

         # Skip common pragma and things that don't look like module names
         $module =~ m{ \A (?: lib | strict | warnings ) \z }mx and next;
         $module =~ m{ [^\.:\w] }mx and next;

         push @{ $modules }, $module eq 'base' || $module eq 'parent'
                          ? ($module, $_parse_list->( $rest )) : $module;
      }
      elsif ($stmt =~ m{ \A (?: with | extends ) \s+ (.+) }mx) {
         push @{ $modules }, $_parse_list->( $1 );

lib/Module/Provision/TraitFor/PrereqDifferences.pm  view on Meta::CPAN


   return \%result;
};

my $_dependencies = sub {
   my ($self, $paths) = @_; my $used = {};

   for my $path (@{ $paths }) {
      my $lines = $_read_non_pod_lines->( $path );

      for my $line (split m{ \n }mx, $lines) {
         my $modules = $_parse_depends_line->( $line ); $modules->[ 0 ] or next;

         for (@{ $modules }) {
            $_looks_like_version->( $_ ) and $used->{perl} = $_ and next;

            not exists $used->{ $_ }
               and $used->{ $_ } = $self->$_version_from_module( $_ );
         }
      }
   }

lib/Module/Provision/TraitFor/VCS.pm  view on Meta::CPAN


my $_get_rev_file = sub {
   my $self = shift; ($self->no_auto_rev or $self->vcs ne 'git') and return;

   return $self->appldir->parent->catfile( lc '.'.$self->distname.'.rev' );
};

my $_get_svn_repository = sub {
   my $self = shift; my $info = $self->run_cmd( 'svn info' )->stdout;

   return (split m{ : \s }mx, (grep { m{ \A Repository \s Root: }mx }
                               split  m{ \n }mx, $info)[ 0 ])[ 1 ];
};

my $_get_version_numbers = sub {
   my ($self, @args) = @_; $args[ 0 ] and $args[ 1 ] and return @args;

   my $prompt = '+Enter major/minor 0 or 1';
   my $comp   = $self->get_line( $prompt, 1, TRUE, 0 );
      $prompt = '+Enter increment/decrement';
   my $bump   = $self->get_line( $prompt, 1, TRUE, 0 ) or return @args;

lib/Module/Provision/TraitFor/VCS.pm  view on Meta::CPAN

   $msg = $self->loc( 'Add RCS keywords to project files' );
   $self->run_cmd( "svn commit ${branch} -m '${msg}'" );
   $self->chdir( $self->appldir );
   $self->run_cmd( 'svn update' );
   return;
};

my $_push_to_git_remote = sub {
   my $self = shift; my $info = $self->run_cmd( 'git remote -v' )->stdout;

   (grep { m{ \(push\) \z }mx } split m{ \n }mx, $info)[ 0 ] or return;

   my $params = $self->quiet ? {} : { out => 'stdout' };

   $self->run_cmd( 'git push --all',  $params );
   $self->run_cmd( 'git push --tags', $params );
   return;
};

my $_push_to_remote = sub {
   my $self = shift;

share/Build.PL  view on Meta::CPAN

use warnings;
use version; our $VERSION = qv( '0.1' );

use File::Spec::Functions   qw( catfile );
use Module::Build;

sub whimper { print {*STDOUT} $_[ 0 ]."\n"; exit 0 }

my $perl_ver   = [% perl %];
my $module     = '[% project %]';
my $class_path = catfile( 'lib', split m{ :: }mx, "${module}.pm" );

$] >= $perl_ver or $ENV{PERL5_CPANPLUS_IS_VERSION}
   or whimper "Minimum required Perl version is ${perl_ver}";

Module::Build->new
   (  add_to_cleanup      => [ 'Debian_CPANTS.txt', 'MANIFEST.bak',
                               '[% distname %]-*',
                               map { ( '*/' x $_ ).'*~' } 0 .. 5 ],
      build_requires      => {
         'version'        => 0.88,

share/gitpre-commit  view on Meta::CPAN


   print {$fh} $data; close $fh; return;
}

sub __get_module_from ($) {
   return
      (map    { s{ [-] }{::}gmx; $_ }
       map    { m{ \A [q\'\"] }mx ? eval $_ : $_ }
       map    { m{ \A \s* (?:module|name) \s+ [=]?[>]? \s* ([^,;]+) [,;]? }imx }
       grep   { m{ \A \s*   (module|name) }imx }
       split m{ [\n] }mx, $_[ 0 ])[ 0 ];
}

sub __get_ignore_rev_regex () {
   my $ignore_rev_file = '.gitignore-rev'; -f $ignore_rev_file or return;

   my $paths = __read_all_from $ignore_rev_file; chomp $paths;

   return join '|', split m{ [\n] }mx, $paths;
}

sub __update_version ($$) {
   my ($rev_ref, $path) = @_;

   my $rev = ${ $rev_ref }; my $content = __read_all_from $path;

   $content =~ m{ \$ (Rev (?:ision)?) (?:[:] \s+ (\d+) \s+)? \$ }mx or return 0;
   $content =~ s{ \$ (Rev (?:ision)?) (?:[:] \s+ (\d+) \s+)? \$ }{\$$1\$}gmx;
   $rev < ($2 || 0) + 1 and $rev = ${ $rev_ref } = ($2 || 0) + 1;

share/gitpre-commit  view on Meta::CPAN

   $module = __get_module_from __read_all_from $project_file;

   my $distname = lc $module; $distname =~ s{ :: }{-}gmx;

   $rev_file = catfile( updir, ".${distname}.rev" );

   if (-f $rev_file) { $rev = __read_all_from $rev_file; chomp $rev; $rev++ }
}

if (defined $rev and qx{ git branch 2>/dev/null } =~ m{ ^ [*] \s+ master }mx) {
   my $main   = catfile( 'lib', split m{ :: }mx, "${module}.pm" );
   my @stat   = split m{ \n }mx, qx{ git status --porcelain };
   my $ignore = __get_ignore_rev_regex;
   my $found  = 0;

   for my $path (map { s{ \A .+ \s+ }{}mx; $_ } grep { m{ \A [AM] }mx } @stat) {
      $ignore and $path =~ m{ (?: $ignore ) }mx and next; $found = 1;
      $main   ne  $path and __update_version \$rev, $path;
   }

   $found and __update_version \$rev, $main
          and __write_data_to $rev_file, "${rev}\n";
}

my $change_file = 'Changes';

if (-f $change_file) {
   my $changes    = __read_all_from $change_file;
   my $change_ver = qv( (split q( ),
                         (grep { m{ \A v? [0-9._]+ }mx } split m{ [\n] }mx,
                          $changes)[ 0 ] || q())[ 0 ] || '0.1.1' );
   my $meta       = defined $module
                  ? Module::Metadata->new_from_module( $module ) : undef;
   my $module_ver = $meta ? $meta->version : qv( '0.1.1' );

   $meta or warn 'No meta object for module '.($module // '<undef>');

   my $pmv = Perl::Version->new( $module_ver ); $pmv->components( 2 );
   my $pcv = Perl::Version->new( $change_ver ); $pcv->components( 2 );

share/perl_localenv  view on Meta::CPAN

   return $v;
};
my $was_called = caller() ? 1 : 0;
my $our_path   = $was_called ? (caller())[ 1 ] : $PROGRAM_NAME;
my $bindir     = $untaint->( abs_path( dirname( $our_path ) ) );
my $basedir    = -f catfile( $bindir, 'Build.PL' )
              || -f catfile( $bindir, 'Makefile.PL' )
               ? $bindir : dirname( $bindir );
my $libdir     = catdir( $basedir, 'lib' );
my $local_lib  = catdir( $basedir, $LOCAL_LIB );
my $appname    = (split m{ [\-_] }mx, basename( $our_path, '.pl' ))[ 0 ];
my $active_key = (uc $appname).'_LOCAL_LIB';
my $active     = -d $local_lib;

exists $ENV{ $active_key } and defined $ENV{ $active_key }
   and $active = !! $ENV{ $active_key };

if ($active) {
   not -d $local_lib and warn "Path ${local_lib} not found from ${our_path}\n";
   # So we can find local::lib when fully self contained
   lib->import( catdir( $local_lib, 'lib', 'perl5' ) );



( run in 1.685 second using v1.01-cache-2.11-cpan-5511b514fd6 )