File Coverage

blib/lib/Dist/Zilla/Plugin/NameFromDirectory.pm
Criterion Covered Total %
statement 19 19 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::NameFromDirectory;
2 1     1   645543 use 5.008_001;
  1         3  
  1         41  
3             our $VERSION = '0.03';
4              
5 1     1   5 use Moose;
  1         2  
  1         5  
6             with 'Dist::Zilla::Role::NameProvider';
7              
8 1     1   4360 use Path::Class;
  1         13  
  1         169  
9              
10             sub provide_name {
11 1     1 0 37490 my $self = shift;
12              
13 1         27 my $root = $self->zilla->root->absolute;
14              
15             # make sure it is a root dir, by checking -e dist.ini
16 1 50       55 return unless -e $root->file('dist.ini');
17              
18 1         118 my $name = $root->basename;
19 1         7 $name =~ s/(?:^(?:perl|p5)-|[\-\.]pm$)//x;
20 1         8 $self->log("guessing your distribution name is $name");
21              
22 1         342 return $name;
23             }
24              
25             __PACKAGE__->meta->make_immutable;
26 1     1   5 no Moose;
  1         1  
  1         5  
27              
28             1;
29             __END__
30              
31             =encoding utf-8
32              
33             =head1 NAME
34              
35             Dist::Zilla::Plugin::NameFromDirectory - Guess distribution name from the current directory
36              
37             =head1 SYNOPSIS
38              
39             [NameFromDirectory]
40              
41             =head1 DESCRIPTION
42              
43             Dist::Zilla::Plugin::NameFromDirectory is a Dist::Zilla plugin to
44             guess distribution name (when it's not set in C<dist.ini>) from the
45             current working directory.
46              
47             Prefixes such as C<perl-> and C<p5->, as well as the postfix C<.pm>
48             and C<-pm> will be automatically trimmed. The following directory
49             names are all recognized as C<Foo-Bar>.
50              
51             Foo-Bar
52             p5-Foo-Bar
53             perl-Foo-Bar
54             Foo-Bar-pm
55              
56             It is designed to be used with Plugin bundle so that your dist.ini
57             doesn't need to contain per-project name anymore.
58              
59             Even when this plugin is used, you can always override the name by
60             specifying it in C<dist.ini>.
61              
62             =head1 AUTHOR
63              
64             Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
65              
66             =head1 COPYRIGHT
67              
68             Copyright 2013- Tatsuhiko Miyagawa
69              
70             =head1 LICENSE
71              
72             This library is free software; you can redistribute it and/or modify
73             it under the same terms as Perl itself.
74              
75             =head1 SEE ALSO
76              
77             L<Dist::Zilla>
78              
79             =cut