App-CISetup

 view release on metacpan or  search on metacpan

lib/App/CISetup/Role/ConfigUpdater.pm  view on Meta::CPAN

package App::CISetup::Role::ConfigUpdater;

use strict;
use warnings;
use namespace::autoclean;
use autodie qw( :all );

our $VERSION = '0.19';

use App::CISetup::Travis::ConfigFile;
use App::CISetup::Types qw( Bool CodeRef Dir Str );
use File::pushd qw( pushd );
use Git::Sub qw( remote );
use Path::Iterator::Rule;
use Path::Tiny qw( path );
use Try::Tiny;
use YAML qw( Load );

use Moose::Role;

requires qw(
    _config_file_class
    _config_filename
    _cli_params
);

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

has dir => (
    is       => 'ro',
    isa      => Dir,
    required => 1,
    coerce   => 1,
);

has _config_file_iterator => (
    is      => 'ro',
    isa     => CodeRef,
    lazy    => 1,
    builder => '_build_config_file_iterator',
);

with 'MooseX::Getopt::Dashes';

sub run {
    my $self = shift;

    return $self->create
        ? $self->_create_file
        : $self->_update_files;
}

sub _create_file {
    my $self = shift;

    my $file = $self->dir->child( $self->_config_filename );
    $self->_config_file_class->new( $self->_cf_params($file) )->create_file;

    print "Created $file\n" or die $!;

    return 0;



( run in 1.057 second using v1.01-cache-2.11-cpan-5a3173703d6 )