App-PM-Website

 view release on metacpan or  search on metacpan

lib/App/PM/Website/Command.pm  view on Meta::CPAN

        $class->options($app),
        [ 'config-file=s' => "path to configuration file",
            { required => 1, default => "config/pm-website.yaml"}],
        [],
        [ 'help|h!'    => "show this help" ],
        [ 'dry-run|n!' => "take no action" ],
        [ 'verbose|v+' => "increase verbosity" ],
    );
}

sub validate_args
{
    my ( $self, $opt, $args ) = @_;
    die $self->_usage_text if $opt->{help};
    $self->validate_config( $opt, $args );
    $self->validate( $opt, $args );
}

sub validate_required_dir
{
    my ($self, $opt, $dir) = @_;
    my $c = $self->{config}{config}{website};
    $opt->{$dir} ||= $c->{$dir};
    die $self->usage_error("$dir is required")
        if !$opt->{$dir};

    die $self->usage_error(
        "$dir does not exist: $opt->{$dir}")
        if !-d $opt->{$dir};

    return 1
}
sub validate_or_create_dir
{
    my ($self, $opt, $dir) = @_;
    my $c = $self->{config}{config}{website};
    $opt->{$dir} ||= $c->{$dir};

    die $self->usage_error("$dir is required")
        if !$opt->{$dir};

    if ( ! -d $opt->{$dir} )
    {

lib/App/PM/Website/Command.pm  view on Meta::CPAN

            mkdir( $opt->{$dir} )
                or die $self->usage_error(
                "failed to make output directory $opt->{$dir} : $!");
        }
    }

    return 1
}


sub validate_config
{
    my ( $self, $opt, $args ) = @_;
    $self->{config} = Config::YAML->new( config => $opt->{config_file} )
        or die $self->usage_error("failed to open configuration file: $!");
}

sub meetings
{
    my $self = shift;
    my $meetings = $self->{config}->get_meetings;

lib/App/PM/Website/Command/Build.pm  view on Meta::CPAN

    return (
        [ 'template-dir=s' => 'template dir path',
            { default => "template" } ],
        [ 'build-dir=s' => 'build dir path',
            { default => "./website" } ],
        [ 'date=s' => 'which month to build',
            { default => scalar $class->today() } ],
    );
}

sub validate
{
    my ($self, $opt, $args ) = @_;
    $self->validate_or_create_dir($opt,'build_dir');
    $self->validate_required_dir($opt, 'template_dir');

    die $self->usage_error( "no arguments allowed") if @$args;

    return 1;
}

sub execute
{
    my( $self, $opt, $args ) = @_;

lib/App/PM/Website/Command/Init.pm  view on Meta::CPAN

        [   'username' => 'pm.org username',
            { default => 'USERNAME' }
        ],
        [   'groupname' => 'long city name of monger group',
            { default => 'GROUPNAME' }
        ],
    );
    return
}

sub validate
{
    my ($self, $opt, $args ) = @_;
    die $self->usage_error( "no arguments allowed") if @$args;

    return 1;
}

sub _create_config_dir
{
    my ( $self, $opt, $config_file) = @_;

lib/App/PM/Website/Command/Init.pm  view on Meta::CPAN

        title: first
      - abstract: our first talk will be about App::PM::Website
        presenter: default
        title: second talk
EOYAML
    print $config_fh $yaml;
    close $config_fh;
    print "creating new config file: $config_file\n";
}

sub validate_config
{
    my ( $self, $opt, $args ) = @_;
    my $config_file = $opt->{config_file};
    if ( !-e $config_file )
    {
        $self->_create_config_dir( $opt, $config_file );
        $self->_create_config_file( $opt, $config_file );
    }
    else
    {

lib/App/PM/Website/Command/Install.pm  view on Meta::CPAN

        [ 'build-dir=s'   => 'path to local rendered files' ,
            { default => 'website' }],
        [ 'filename=s'    => 'upload name, rather than index.html' ,
            {default => 'index.html'}],
        [ 'username=s'    => 'username for webdav, override .netrc' ],
        [ 'password=s'    => 'password for webdav, override .netrc' ],
        [ 'certificate=s' => 'path to ca certificate' ],
    );
}

sub validate
{
    my ($self, $opt, $args ) = @_;

    $self->validate_certificate($opt);
    $self->validate_url($opt);
    $self->validate_login($opt);

    if(@$args)
    {
        die $self->usage_error("no arguments allowed")
    }
}
sub validate_certificate
{
    my ($self, $opt) = @_;
    my $c = $self->{config}{config}{website};
    $opt->{certificate} ||= $c->{certificate};

    if ($opt->{certificate} && ! -f $opt->{certificate} )
    {
        die $self->usage_error("could not find certificate file: $opt->{certificate}");

    }

    return 1; #certificate is optional.
}
sub validate_url
{
    my ($self, $opt ) = @_;
    my $c = $self->{config}{config}{website};

    $opt->{url} ||= $c->{url};
    die $self->usage_error( "url must be defined on command line or in config file") 
        unless $opt->{url};
}
sub validate_login
{
    my ( $self, $opt ) = @_;

    my $c       = $self->{config}{config}{website};
    my $url     = $opt->{url};
    my $machine = $opt->{machine} || $c->{machine};

    $opt->{username} ||= $c->{username};
    $opt->{password} ||= $c->{password};



( run in 0.530 second using v1.01-cache-2.11-cpan-4d50c553e7e )