Ado

 view release on metacpan or  search on metacpan

lib/Ado/Build.pm  view on Meta::CPAN

}

sub ACTION_submit {
    my $self = shift;

    #$self->depends_on("perltidy");
    say "TODO: commit and push after tidying and testing and who knows what";
    return;
}


#Empties log files in a given directory.
sub _empty_log_files {
    (my ($log_dir) = @_) || Carp::croak('Please provide $log_dir');
    open my $logd, ">", "$log_dir/development.log" || Carp::croak $!;
    close $logd;
    open my $logp, ">", "$log_dir/production.log" || Carp::croak $!;
    close $logp;
    return;
}

sub do_create_readme {
    my $self = shift;
    if ($self->dist_version_from =~ /Ado\.pm$/) {

        #Create README from Ado::Manual.pod
        require Pod::Text;
        my $readme_from = catfile('lib', 'Ado', 'Manual.pod');
        my $parser = Pod::Text->new(sentence => 0, indent => 2, width => 76);
        $parser->parse_from_file($readme_from, 'README');
        $self->log_info("Created README$/");

        #add README.md just to be cool..
        eval { require Pod::Markdown }
          || return $self->log_warn('Pod::Markdown required for creating README.md' . $/);
        $parser = Pod::Markdown->new;
        $parser->parse_from_file($readme_from);
        my $readme_md = 'README.md';
        if (open(my $out, '>', $readme_md)) {
            my $markdown = $parser->as_markdown;
            my $ci_badge =
                '[![Build Status](https://travis-ci.org/kberov/Ado.svg?'
              . 'branch=master)](https://travis-ci.org/kberov/Ado)';
            $markdown =~ s/(\n.+Travis-CI.+\n)/$1\n$ci_badge\n\n/xgm;
            $out->say($markdown);
            $out->close;
            $self->log_info("Created $readme_md$/");
        }
        else { Carp::croak("Could not create $readme_md... $!"); }
    }
    else {
        $self->SUPER::do_create_readme();
    }
    return;
}

1;

=pod

=encoding utf8

=head1 NAME

Ado::Build - Custom routines for Ado installation

=head1 SYNOPSIS

  #Build.PL
  use 5.014000;
  use strict;
  use warnings FATAL => 'all';
  use FindBin;
  use lib("$FindBin::Bin/lib");
  use Ado::Build;
  my $builder = Ado::Build->new(..);
  $builder->create_build_script();

  #on the command line
  cd /path/to/cloned/Ado
  perl Build.PL
  ./Build
  ./Build test
  #change/add some code
  ./Build test
  ./Build perltidy
  ./Build dist
  ./Build submit
  #.... and so on


=head1 DESCRIPTION

This is a subclass of L<Module::Build>. We use L<Module::Build::API> to add
custom functionality. This module and L<Ado::BuildPlugin> exist just because of
the additional install paths that we use beside C<lib> and C<bin> and
processing the files in those paths. These modules also can serve as examples
for your own builders if you have some custom things to do during  build, test,
install and even if you need to add a new C<ACTION_*> to your setup.

=head1 ATTRIBUTES

Ado::Build defines some attributes, used across different actions.

=head2 PERL_DIRS

Returns the list of absolute paths to directories in the project containing
Perl files. Read-only.

  $self->PERL_DIRS;
  #(/base/dir/bin, /base/dir/lib, /base/dir/t, /base/dir/etc)



=head1 METHODS

Ado::Build inherits all methods from L<Module::Build> and implements
the following ones.

=head2 create_build_script



( run in 1.193 second using v1.01-cache-2.11-cpan-39bf76dae61 )