line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Readme::Plugin::version; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
498
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = 'v1.2.1'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1039
|
use ExtUtils::MakeMaker; |
|
1
|
|
|
|
|
88128
|
|
|
1
|
|
|
|
|
100
|
|
8
|
1
|
|
|
1
|
|
7
|
use Types::Standard qw/ Bool Str /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
669
|
use Pod::Readme::Types qw/ File HeadingLevel /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
362
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Pod::Readme::Plugin::version - Include version in README |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=for readme plugin version |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This is a plugin for L that includes the release version. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 ARGUMENTS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 C |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=for readme plugin version file='lib/My/App.pm' |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
By default, it will extract the version from the same file that the |
31
|
|
|
|
|
|
|
F is being extracted from. If this is a different file, then |
32
|
|
|
|
|
|
|
it should be specified. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 C |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=for readme plugin version title='VERSION' |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
This argument allows you to change the title of the heading. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
requires 'parse_cmd_args'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'version_file' => ( |
45
|
|
|
|
|
|
|
is => 'rw', |
46
|
|
|
|
|
|
|
isa => File, |
47
|
|
|
|
|
|
|
required => 0, |
48
|
|
|
|
|
|
|
coerce => sub { File->coerce(@_) }, |
49
|
|
|
|
|
|
|
lazy => 1, |
50
|
|
|
|
|
|
|
default => sub { |
51
|
|
|
|
|
|
|
my ($self) = @_; |
52
|
|
|
|
|
|
|
$self->input_file; |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has 'version_title' => ( |
57
|
|
|
|
|
|
|
is => 'rw', |
58
|
|
|
|
|
|
|
isa => Str, |
59
|
|
|
|
|
|
|
default => 'VERSION', |
60
|
|
|
|
|
|
|
lazy => 1, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'version_heading_level' => ( |
64
|
|
|
|
|
|
|
is => 'rw', |
65
|
|
|
|
|
|
|
isa => HeadingLevel, |
66
|
|
|
|
|
|
|
default => 1, |
67
|
|
|
|
|
|
|
lazy => 1, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has 'version_run' => ( |
71
|
|
|
|
|
|
|
is => 'rw', |
72
|
|
|
|
|
|
|
isa => Bool, |
73
|
|
|
|
|
|
|
default => 0, |
74
|
|
|
|
|
|
|
lazy => 1, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
around 'depends_on' => sub { |
78
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
79
|
|
|
|
|
|
|
return ($self->version_file, $self->$orig); |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub cmd_version { |
83
|
3
|
|
|
3
|
0
|
6
|
my ( $self, @args ) = @_; |
84
|
|
|
|
|
|
|
|
85
|
3
|
50
|
|
|
|
69
|
die "The version plugin can only be used once" if $self->version_run; |
86
|
|
|
|
|
|
|
|
87
|
3
|
|
|
|
|
57
|
my $res = $self->parse_cmd_args( [qw/ file title heading-level /], @args ); |
88
|
3
|
|
|
|
|
7
|
foreach my $key ( keys %{$res} ) { |
|
3
|
|
|
|
|
7
|
|
89
|
4
|
|
|
|
|
61
|
( my $name = "version_${key}" ) =~ s/-/_/g; |
90
|
4
|
50
|
|
|
|
15
|
if ( my $method = $self->can($name) ) { |
91
|
4
|
|
|
|
|
65
|
$self->$method( $res->{$key} ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
0
|
|
|
|
|
0
|
die "Invalid key: '${key}'"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
3
|
50
|
|
|
|
90
|
if ( my $file = $self->version_file ) { |
99
|
|
|
|
|
|
|
|
100
|
3
|
50
|
|
|
|
112
|
my $heading = $self->can( "write_head" . $self->version_heading_level ) |
101
|
|
|
|
|
|
|
or die "Invalid heading level: " . $self->version_heading_level; |
102
|
|
|
|
|
|
|
|
103
|
3
|
|
|
|
|
90
|
$self->$heading( $self->version_title ); |
104
|
3
|
|
|
|
|
130
|
$self->write_para( MM->parse_version($file) ); |
105
|
|
|
|
|
|
|
|
106
|
3
|
|
|
|
|
103
|
$self->version_run(1); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
else { |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
die "Don't know what file to determine the version from"; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
1
|
|
8
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |