App-MechaCPAN

 view release on metacpan or  search on metacpan

lib/App/MechaCPAN.pm  view on Meta::CPAN

  {
    my $prog = ( File::Spec->splitpath($0) )[2] || 'mechacpan';

    my @options = map {
      my ($names) = m/^([^=:!+]+)/;
      join( ', ', map { length > 1 ? "--$_" : "-$_" } split /\|/, $names );
    } @App::MechaCPAN::args;

    my $orig_fh = select STDERR;

    say "Usage: $prog [options] <command> [<args>]";
    say "";
    say "Commands:";
    say "  $_"
      foreach @commands;
    say "";
    say "Global Options:";
    say "  $_"
      foreach @options;
    say "";
    say "Run '$prog --help' for full documentation.";

    select $orig_fh;
    return -1;
  }

  my $options = {};
  my $getopt_ret
    = Getopt::Long::GetOptionsFromArray( \@argv, $options, @args );
  return -1
    if !$getopt_ret;

t/28_cpanfile.t  view on Meta::CPAN

  CLEANUP  => 1
);
chdir $tmpdir;
my $dir = cwd;

my ( $fh, $cpanfile ) = tempfile( "cpanfile.XXXXXXXX", DIR => $tmpdir );

my @resolvd;
my @pkgs = qw/Try::Tiny Test::More/;

$fh->say("requires '$_';") foreach @pkgs;
$fh->seek( 0, 0 );

*App::MechaCPAN::Install::_resolve = sub
{
  my $target = shift;
  push @resolvd, $target->{src_name};
  return;
};

# Check that it will handle with a filname

t/33_snapshot.t  view on Meta::CPAN

  my $tmpdir = tempdir(
    TEMPLATE => File::Spec->tmpdir . "/mechacpan_t_XXXXXXXX",
    CLEANUP => 1,
  );

  chdir $tmpdir;
  my $dir = cwd;

  my ( $fh, $cpanfile ) = tempfile( "cpanfile.XXXXXXXX", DIR => $tmpdir );

  $fh->say("not a carton snapshot\nrest of content\n");

  local $@;
  my $result = eval { App::MechaCPAN::Deploy::parse_snapshot($cpanfile) };
  my $err = $@;

  is($result, undef, 'parse_snapshot produces error with a bad snapshot');
  like($err, qr/carton\s+snapshot/xms, 'Error is about carton snapshot');
};

subtest 'empty snapshot' => sub

zhuli.PL  view on Meta::CPAN

  {
    wanted => sub
    {
      my $file = $_;
      if ( -f $file && $file =~ m/^[^.] .* [.]pm$/xms )
      {
        warn "Will include '$file' in '$ARGV[0]'\n";
        my $filename = $File::Find::name;
        $filename =~ s[^$prefix][]xms;
        push @files, $filename;
        $ouFH->say("BEGIN { \$INC{'$filename'} = __FILE__ };");
      }
    },
  },
  $prefix
);

my $help_pod;

foreach my $file (sort @files)
{
  my $parser = Pod::Simple->new;

  my $in_end;
  $parser->cut_handler(
    sub
    {
      my $line        = shift;
      my $line_number = shift;
      my $parser      = shift;
      $ouFH->say(qq{# line $line_number "$file"})
        unless $in_end;
    }
  );
  $parser->code_handler(
    sub
    {
      my $line        = shift;
      my $line_number = shift;
      my $parser      = shift;
      $in_end = 1
        if $line =~ m/^__END__/xms;
      $ouFH->say($line)
        unless $in_end;
    }
  );

  $ouFH->say(qq{# line 1 "$file"});

  open my $inFH, '<', "$prefix/$file";
  my @lines = <$inFH>;
  $parser->parse_lines(@lines);

  next
    unless $file eq 'App/MechaCPAN.pm';

  foreach my $line (@lines)
  {
    if ( $line =~ m/__END__$/xms ... !defined $line )
    {
      $help_pod .= $line;
    }
  }
}

open my $mc_fh, "<", "$FindBin::Bin/script/mechacpan";
$ouFH->say("package main;");
$ouFH->say( do { local $/; <$mc_fh> } );

# Add the POD of App:MechaCPAN back to the end to let --help work
$ouFH->say($help_pod);



( run in 0.638 second using v1.01-cache-2.11-cpan-9169edd2b0e )