Alien-ActiveMQ

 view release on metacpan or  search on metacpan

script/install-activemq  view on Meta::CPAN

use Const::Fast;

with 'MooseX::Getopt';

our $VERSION = '0.00005';

const my $DEFAULT_ACTIVEMQ_VERSION => '5.10.0';

has force => (
    isa => Bool,
    is => 'ro',
    default => 0,
);

has install_dir => (
    isa        => 'Path::Class::Dir',
    is         => 'ro',
    coerce     => 1,
    lazy_build => 1,
);

method _build_install_dir {
    dir( dist_dir('Alien-ActiveMQ'), $self->version_number );
}

has tarball => (
    isa        => 'Path::Class::File',
    is         => 'ro',
    coerce     => 1,
    lazy_build => 1
);

method _build_tarball {
    my $tarball = $self->download_uri;
    $tarball =~ s|.+/||;
    file( $self->_temp_dir, $tarball );
}

has version_number => (
    isa => Str,
    is => 'ro',
    required => 1,
    lazy_build => 1,
);

has script_name => (
    isa => Str,
    is => 'ro',
    required => 1,
    lazy_build => 1,
);

method _build_script_name {
    return file($0)->basename;
}

method _build_version_number {

   # If we have a tarball, use the version from that.
   # Otherwise, if we have a URI to download from, use the version from that.
   # Otherwise, guess.
   # None of this is done at all if the user gave a specific version, of course.

    my $version_source = $self->has_tarball ? $self->tarball : undef;
    if ( not defined $version_source ) {
        $version_source = $self->has_download_uri ? $self->download_uri : undef;
    }
    return $DEFAULT_ACTIVEMQ_VERSION unless $version_source;
    return $version_source =~ /activemq-(.+\d)/;
}

has download_uri => (
    isa => Str,
    is => 'ro',
    lazy_build => 1,
);

method _build_download_uri {
    return
      sprintf(
"http://www.apache.org/dyn/closer.cgi?path=/activemq/%s/apache-activemq-%s-bin.tar.gz",
        $self->version_number, $self->version_number );
}

has archive_uri => (
    isa => Str,
    is => 'ro',
    lazy_build => 1,
);

method _build_archive_uri {
    return
      sprintf(
"http://archive.apache.org/dist/activemq/apache-activemq/%s/apache-activemq-%s-bin.tar.gz",
        $self->version_number, $self->version_number );
}

has _temp_dir => (
    isa     => 'Path::Class::Dir',
    coerce  => 1,
    is      => 'ro',
    lazy    => 1,
    default => sub { tempdir( CLEANUP => 1 ) },
);

has verbose => (
    isa => 'Bool',
    is => 'ro',
    default => 0,
);

method output {
    print @_, "\n" if $self->verbose;
}

# To make it easier to test
method _get($uri) {
    return get($uri);
}

method _getstore( $uri, $file ) {



( run in 0.468 second using v1.01-cache-2.11-cpan-140bd7fdf52 )