App-MechaCPAN

 view release on metacpan or  search on metacpan

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


L<MetaCPAN|https://metacpan.org> is used to search for modules by name. If module name is provided, it will attempt to install from the current directory's C<cpanfile>.

=head2 Methods

=head3 go( \%opts, @srcs )

There is only a single public function that should be called. This will install the modules listed in C<@srcs> using the options in C<\%opts>. The options available are listed in the L<arguments|/Arguments> section below.

  # Example of calling go
  App::MecahCPAN::Install->go({}, 'Try::Tiny');

=head2 Arguments

=head3 skip-tests

=head3 skip-tests-for

By default the tests of each module will be ran. If you do not want to run tests when installing modules, use this option. Alternatively, you can use C<skip-tests-for> to specify module names that will skip the tests for that module.

  # Examples of --skip-tests
  mechacpan install Try::Tiny --skip-tests
  mechacpan install Catalyst --skip-tests-for=Moose

=head3 smart-tests

An alternative to skipping all tests is to try and be clever about which tests to run and which to skip. The smart-tests option will skip tests for any package that it considers pristine. It defines pristine modules as modules that only depend on mod...

This isn't a fool-proof system, tests are an important part of making sure that all modules installed play well. This option is most useful with L<App::MechaCPAN::Deploy> and a C<cpanfile.snapshot> since the versions of packages listed in the snapsho...

=head3 install-man

By default, man pages are not installed. Use this option to install the man pages.

=head3 source

Add a source translation to the installation. This can be used to translate a module name into another form, like using an exact version of a module or pull another module from its git repo. This can be repeated multiple times for multiple translatio...

  # Examples of --source
  mechacpan install Catalyst --source Try::Tiny=ETHER/Try-Tiny-0.24
  mechacpan install Catalyst --source Catalyst=git://git.shadowcat.co.uk/catagits/Catalyst-Runtime.git

=head3 only-sources

Do not use modules not listed in the source list. This means if you do not specify every module and every prerequisite in the source list, then it will not be installed. This doesn't sound very useful since you would be potentially listing hundreds o...

=head3 update

If an older version of a given module is installed, a newer version will be installed. This is on by default.

t/22_install__get_targz.t  view on Meta::CPAN

#  * File::Remove is included to make sure that it's not confused with file://
foreach my $src (
  qw[
  test_dists/NoDeps/NoDeps-1.0.tar.gz
  authors/id/E/ET/ETHER/Try-Tiny-0.24.tar.gz
  E/ET/ETHER/Try-Tiny-0.24.tar.gz
  ETHER/Try-Tiny-0.24.tar.gz
  https://github.com/p5sagit/Try-Tiny.git
  https://github.com/p5sagit/Try-Tiny.git@v0.24
  https://github.com/p5sagit/Try-Tiny/archive/v0.24.zip
  Try::Tiny
  Try::Tiny@0.24
  Try::Tiny~0.24
  Try::Tiny~<0.24
  File::Remove
  ],
  [qw/Try::Tiny 0.24/],
  [qw/Try::Tiny <0.24/],
  )
{
SKIP:
  {
    if ( $src =~ m/[.]git/xms && !$has_git )
    {
      skip "git not available", 1;
    }

    local $App::MechaCPAN::Install::dest_dir

t/23_install_array.t  view on Meta::CPAN

use FindBin;
use Test::More;
use Config;
use Cwd qw/cwd/;
use File::Temp qw/tempdir/;

require q[./t/helper.pm];

my $pwd  = cwd;
my %pkgs = (
  'Try::Tiny'  => 'Try/Tiny.pm',
  'Test::More' => 'Test/More.pm',
);

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

local $Module::CoreList::version{$]}{'Test::More'} = 0
    if $] >= 5.028000;

t/25_depend_source.t  view on Meta::CPAN

use strict;
use FindBin;
use Test::More;
BEGIN { diag("(BEGIN) Try::Tiny => $INC{'Try/Tiny.pm'}"); }
use Config;
use Cwd qw/cwd/;
use File::Temp qw/tempdir/;

require q[./t/helper.pm];

my $pwd = cwd;

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

my $lib     = 'ConfigDeps';
my $deplib  = 'Try/Tiny';
my $options = {
  source => {
    $lib        => "$pwd/test_dists/$lib/$lib-1.0.tar.gz",
    'Try::Tiny' => 'E/ET/ETHER/Try-Tiny-0.24.tar.gz',
  },
};

diag("cwd => $dir");
diag("Try::Tiny => $INC{'Try/Tiny.pm'}");

is( App::MechaCPAN::Install->go( $options, "$lib" ), 0, 'Can use a source' );
diag("Try::Tiny => $INC{'Try/Tiny.pm'}");
is( cwd, $dir, 'Returned to whence it started' );

ok( -e "$dir/local/lib/perl5/$lib.pm", "Library file $lib exists" );
ok( -e "$dir/local/lib/perl5/$deplib.pm", "Library file $deplib exists" );
diag("Try::Tiny => $INC{'Try/Tiny.pm'}");

{
  # Silence warnings for the require_ok. If the user has LWP installed, then
  # it will cause harmless warnings about redefined subs. These don't cause
  # errors and just add to the noise in cpantesters.
  local $SIG{__WARN__} = sub {};
  require_ok("$dir/local/lib/perl5/$deplib.pm");
}

diag("Try::Tiny => $INC{'Try/Tiny.pm'}");
is( $Try::Tiny::VERSION, '0.24', "The correct version was installed" );

chdir $pwd;
done_testing;

t/26_avoid_reinstall.t  view on Meta::CPAN

use strict;
use FindBin;
use Test::More;
use Config;
use Cwd qw/cwd/;
use File::Temp qw/tempdir/;

require q[./t/helper.pm];

my $pwd  = cwd;
my $dist = 'Try::Tiny';
my $tmpdir  = tempdir( TEMPLATE => File::Spec->tmpdir . "/mechacpan_t_XXXXXXXX", CLEANUP => 1 );
chdir $tmpdir;
my $dir = cwd;

is( App::MechaCPAN::main( 'install', $dist ), 0, "Can install $dist" );

{
  no strict 'refs';
  no warnings 'redefine';
  my $ran_configure = 0;

t/28_cpanfile.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 );

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;
};

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

require q[./t/helper.pm];

my $pwd = cwd;

my $cpanfile      = "$FindBin::Bin/../test_dists/DeployCpanfile/cpanfile";
my $cpanfile_info = App::MechaCPAN::parse_cpanfile($cpanfile);

my $output = {
  'runtime' => {
    'requires' => {
      'Try::Tiny' => undef,
    },
  },
  'configure' => { 'requires' => { 'Test::More' => undef } },
  'perl' => '5.012000',
};

is_deeply(
  $cpanfile_info, $output,
  "parse_cpan produces the expected requirements"
);

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


my $pwd = cwd;

my $cpanfile      = "$FindBin::Bin/../test_dists/DeploySnapshot/cpanfile";
my $snapshot      = "$cpanfile.snapshot";
my $cpanfile_info = App::MechaCPAN::Deploy::parse_snapshot($snapshot);

my $output = {
  'Try-Tiny-0.24' => {
    'pathname'     => 'E/ET/ETHER/Try-Tiny-0.24.tar.gz',
    'provides'     => { 'Try::Tiny' => '0.24' },
    'requirements' => {
      'Carp'                => '0',
      'warnings'            => '0',
      'constant'            => '0',
      'Exporter'            => '5.57',
      'ExtUtils::MakeMaker' => '0',
      'perl'                => '5.006',
      'strict'              => '0'
    }
  }

t/35_deploy_snapshot.t  view on Meta::CPAN

ok( -e "$dir/local/lib/perl5/$lib", "Library file $lib exists" );

{
  # Silence warnings for the require_ok. If the user has LWP installed, then
  # it will cause harmless warnings about redefined subs. These don't cause
  # errors and just add to the noise in cpantesters.
  local $SIG{__WARN__} = sub {};
  require_ok("$dir/local/lib/perl5/$lib");
}

is( $Try::Tiny::VERSION, '0.24', "The correct version was installed" );

chdir $pwd;
done_testing;

test_dists/ConfigDeps/Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.005.
use strict;
use warnings;

use 5.008005;

use ExtUtils::MakeMaker;
use Try::Tiny;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Blah blah blah",
  "AUTHOR" => "Jon Gentle <cpan\@atrodo.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0,
    "Try::Tiny" => 0
  },
  "DISTNAME" => "ConfigDeps",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.008005",
  "NAME" => "ConfigDeps",
  "PREREQ_PM" => {},
  "VERSION" => "1.0",
  "test" => {
    "TESTS" => "t/*.t"
  }

test_dists/ConfigDeps/cpanfile  view on Meta::CPAN

requires 'perl', '5.008005';

on configure => sub {
  requires 'Try::Tiny';
};

test_dists/DeployCpanfile/cpanfile  view on Meta::CPAN

requires 'perl', '5.012000';

requires 'Try::Tiny';

on 'configure' => sub { requires 'Test::More' };

test_dists/DeploySnapshot/cpanfile  view on Meta::CPAN

requires 'perl', '5.012000';

requires 'Try::Tiny';

test_dists/DeploySnapshot/cpanfile.snapshot  view on Meta::CPAN

# carton snapshot format: version 1.0
DISTRIBUTIONS
  Try-Tiny-0.24
    pathname: E/ET/ETHER/Try-Tiny-0.24.tar.gz
    provides:
      Try::Tiny 0.24
    requirements:
      Carp 0
      Exporter 5.57
      ExtUtils::MakeMaker 0
      constant 0
      perl 5.006
      strict 0
      warnings 0

test_dists/MBDeps/cpanfile  view on Meta::CPAN

requires 'perl', '5.008005';

requires 'Try::Tiny';

on test => sub {
    requires 'Test::More', '0.96';
};

test_dists/MMDeps/cpanfile  view on Meta::CPAN

requires 'perl', '5.008005';

requires 'Try::Tiny';

on test => sub {
    requires 'Test::More', '0.96';
};

test_dists/TestDeps/cpanfile  view on Meta::CPAN

requires 'perl', '5.008005';

requires 'Try::Tiny';

test_dists/TestDeps/t/basic.t  view on Meta::CPAN

use strict;
use Test::More;
use TestDeps;
use Try::Tiny;

# replace with the actual test
#is(try { die } catch { 0 }, 0, 'Use okay');
ok(try { die } catch { 1 });

done_testing;



( run in 0.994 second using v1.01-cache-2.11-cpan-05444aca049 )