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