line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
21644
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Badge::Depot::Plugin::Perl; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
887
|
use Moose; |
|
1
|
|
|
|
|
479741
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
7863
|
use namespace::autoclean; |
|
1
|
|
|
|
|
8441
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
1048
|
use MooseX::AttributeShortcuts; |
|
1
|
|
|
|
|
3535099
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
36692
|
use Types::Standard qw/Str Bool/; |
|
1
|
|
|
|
|
64650
|
|
|
1
|
|
|
|
|
12
|
|
10
|
1
|
|
|
1
|
|
1627
|
use Types::URI qw/Uri/; |
|
1
|
|
|
|
|
146948
|
|
|
1
|
|
|
|
|
17
|
|
11
|
1
|
|
|
1
|
|
1140
|
use JSON::MaybeXS 'decode_json'; |
|
1
|
|
|
|
|
24731
|
|
|
1
|
|
|
|
|
100
|
|
12
|
1
|
|
|
1
|
|
12
|
use Path::Tiny; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
794
|
|
13
|
|
|
|
|
|
|
with 'Badge::Depot'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.0103'; # VERSION |
16
|
|
|
|
|
|
|
# ABSTRACT: Perl version plugin for Badge::Depot |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has version => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Str, |
21
|
|
|
|
|
|
|
builder => 1, |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
predicate => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
has trailing => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => Str, |
28
|
|
|
|
|
|
|
default => '+', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
has custom_image_url => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => Uri, |
33
|
|
|
|
|
|
|
coerce => 1, |
34
|
|
|
|
|
|
|
default => 'https://img.shields.io/badge/perl-%s-brightgreen.svg', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub BUILD { |
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self->image_url(sprintf $self->custom_image_url, $self->version); |
41
|
0
|
|
|
|
|
|
$self->image_alt(sprintf 'Requires Perl %s', $self->version); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _build_version { |
45
|
0
|
|
|
0
|
|
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
return 'unknown' if !path('META.json')->exists; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $json = path('META.json')->slurp_utf8; |
50
|
0
|
|
|
|
|
|
my $data = decode_json($json); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
return 'unknown' if !exists $data->{'prereqs'}{'runtime'}{'requires'}{'perl'}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $version = $data->{'prereqs'}{'runtime'}{'requires'}{'perl'}; |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if($version =~ m{^5\.(\d{3})(\d{3})$}) { |
|
|
0
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $major = $1; |
58
|
0
|
|
|
|
|
|
my $minor = $2; |
59
|
0
|
|
|
|
|
|
$major =~ s{^0+}{}; |
60
|
0
|
|
|
|
|
|
$minor =~ s{^0+}{}; |
61
|
0
|
0
|
|
|
|
|
$version = "5.$major" . ($minor ? ".$minor" : ''); |
62
|
0
|
|
|
|
|
|
$version .= $self->trailing; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif($version =~ m{^5\.(\d+)(?:\.(\d+))?$}) { |
65
|
0
|
|
|
|
|
|
$version =~ s{\.0+}{.}g; |
66
|
0
|
|
|
|
|
|
$version =~ s{\.+$}{}; |
67
|
0
|
|
|
|
|
|
$version .= $self->trailing; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
0
|
|
|
|
|
|
$version = 'unknown'; |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
|
return $version; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Badge::Depot::Plugin::Perl - Perl version plugin for Badge::Depot |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Version 0.0103, released 2016-01-13. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
If used standalone: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use Badge::Depot::Plugin::Perl; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $badge = Badge::Depot::Plugin::Perl->new(version => '5.8.5+'); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
print $badge->to_html; |
101
|
|
|
|
|
|
|
# prints '<img src="https://img.shields.io/badge/perl-5.8.5+-brightgreen.svg" />' |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
If used with L<Pod::Weaver::Section::Badges>, in weaver.ini: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
[Badges] |
106
|
|
|
|
|
|
|
; other settings |
107
|
|
|
|
|
|
|
badge = Perl |
108
|
|
|
|
|
|
|
-perl_version = 5.8.5 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Creates a Perl version badge, like this: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=for HTML <img src="https://img.shields.io/badge/perl-5.8.5+-brightgreen.svg" /> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=for markdown ![Requires Perl 5.8+](https://img.shields.io/badge/perl-5.8.5+-brightgreen.svg) |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This class consumes the L<Badge::Depot> role. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
All attributes are optional. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 version |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The minimum supported Perl version. If it isn't given, it looks for a C<prereqs/runtime/requires/perl> entry in C<META.json> and uses that. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
It is set to 'unknown' if it is neither given or exists in C<META.json>. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 trailing |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
A string to add after the version, if the version is fetched from C<META.json>. Defaults to C<+>. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Not used if C<version> is explicitly set. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 custom_image_url |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
By default, this module shows an image from L<shields.io|https://shields.io>. Use this attribute to override that with a custom url. Use a C<%s> placeholder where the version should be inserted. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SEE ALSO |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<Badge::Depot> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SOURCE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Badge-Depot-Plugin-Perl> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 HOMEPAGE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L<https://metacpan.org/release/Badge-Depot-Plugin-Perl> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
167
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |