Dist-Man

 view release on metacpan or  search on metacpan

lib/Dist/Man/BuilderSet.pm  view on Meta::CPAN

    my $builder_set = Dist::Man::BuilderSet->new;
    my @supported_builders = $builder_set->supported_builders();
    my $default_builder = $builder_set->default_builder();
    my $output_file = $builder_set->file_for_builder($default_builder);

    my $create_method = $builder_set->method_for_builder($default_builder);
    Dist::Man::Simple->$create_method($default_builder); # eeew.

    my @build_commands = $builder_set->instructions_for_builder($default_builder);
    my @builder_dependencies = $builder_set->deps_for_builder($default_builder);
    my @compatible_builders = $builder_set->check_compatibility(@builder_list);

=head1 DESCRIPTION

Dist::Man::BuilderSet is a collection of utility methods used to
provide metadata about builders supported by Dist::Man.

=head1 CLASS METHODS

=head2 C<< new() >>

This method initializes and returns an object representing the set of
Builders supported by Dist::Man

=cut

sub new {
    my $class = shift;

    my $self =
      {
       'Module::Build' =>
       {
        file         => "Build.PL",
        build_method => "create_Build_PL",
        build_deps   => [],
        instructions => [ 'perl Build.PL',
                          './Build',
                          './Build test',
                          './Build install',
                        ],
       },
       'Module::Install' =>
       {
        file         => "Makefile.PL",
        build_method => "create_MI_Makefile_PL",
        build_deps   => [],
        instructions => [ 'perl Makefile.PL',
                          'make',
                          'make test',
                          'make install',
                        ],
       },
       'ExtUtils::MakeMaker' =>
       {
        file         => "Makefile.PL",
        build_method => "create_Makefile_PL",
        build_deps   => [ { command => 'make',
                            aliases => [ 'make', 'gmake' ],
                          },
                          { command => 'chmod',
                            aliases => [ 'chmod' ],
                          },
                        ],
        instructions => [ 'perl Makefile.PL',
                          'make',
                          'make test',
                          'make install',
                        ],
       }
      };

    return bless $self, $class;
}

sub _builder {
    my $self = shift;
    my $builder = shift;

    $builder = $self->default_builder unless $builder;

    unless (exists $self->{$builder}) {
        carp("Don't know anything about builder '$builder'.");
        return;
    }

    return $self->{$builder};
}

=head2 C<< supported_builders() >>

This method returns a list of builders supported by Dist::Man

=cut

sub supported_builders {
    my $self = shift;

    return keys %$self;
}

=head2 C<< file_for_builder($builder) >>

This method returns the name of the file generated by Dist::Man
that will be used to build the generated module

=cut

sub file_for_builder {
    my $self = shift;
    my $builder = shift;

    return $self->_builder($builder)->{file};
}

=head2 C<< method_for_builder($builder) >>

This method returns the name of the method in the
C<Dist::Man::Simple> package that is called to create the file
returned by C<file_for_builder($builder)>

=cut



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