line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
16514
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Badge::Depot::Plugin::Travis; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
580
|
use Moose; |
|
1
|
|
|
|
|
371656
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
5147
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
875
|
use Types::Standard qw/Str HashRef/; |
|
1
|
|
|
|
|
50198
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
1808
|
use Path::Tiny; |
|
1
|
|
|
|
|
8200
|
|
|
1
|
|
|
|
|
53
|
|
10
|
1
|
|
|
1
|
|
455
|
use JSON::MaybeXS 'decode_json'; |
|
1
|
|
|
|
|
4656
|
|
|
1
|
|
|
|
|
412
|
|
11
|
|
|
|
|
|
|
with 'Badge::Depot'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Travis plugin for Badge::Depot |
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
15
|
|
|
|
|
|
|
our $VERSION = '0.0203'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has user => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => Str, |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
default => sub { |
22
|
|
|
|
|
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
if($self->has_meta) { |
24
|
|
|
|
|
|
|
return $self->_meta->{'username'} if exists $self->_meta->{'username'}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
has repo => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => Str, |
31
|
|
|
|
|
|
|
lazy => 1, |
32
|
|
|
|
|
|
|
default => sub { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
if($self->has_meta) { |
35
|
|
|
|
|
|
|
return $self->_meta->{'repo'} if exists $self->_meta->{'repo'}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
has branch => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => Str, |
42
|
|
|
|
|
|
|
default => 'master', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
has _meta => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => HashRef, |
47
|
|
|
|
|
|
|
predicate => 'has_meta', |
48
|
|
|
|
|
|
|
builder => '_build_meta', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build_meta { |
52
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
0
|
return {} if !path('META.json')->exists; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
my $json = path('META.json')->slurp_utf8; |
57
|
0
|
|
|
|
|
0
|
my $data = decode_json($json); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
0
|
return {} if !exists $data->{'resources'}{'repository'}{'web'}; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
my $repository = $data->{'resources'}{'repository'}{'web'}; |
62
|
0
|
0
|
|
|
|
0
|
return {} if $repository !~ m{^https://(?:www\.)?github\.com/([^/]+)/(.*)(?:\.git)?$}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return { |
65
|
0
|
|
|
|
|
0
|
username => $1, |
66
|
|
|
|
|
|
|
repo => $2, |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub BUILD { |
71
|
1
|
|
|
1
|
0
|
1862
|
my $self = shift; |
72
|
1
|
|
|
|
|
40
|
$self->link_url(sprintf 'https://travis-ci.org/%s/%s', $self->user, $self->repo); |
73
|
1
|
|
|
|
|
3648
|
$self->image_url(sprintf 'https://api.travis-ci.org/%s/%s.svg?branch=%s', $self->user, $self->repo, $self->branch); |
74
|
1
|
|
|
|
|
122
|
$self->image_alt('Travis status'); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Badge::Depot::Plugin::Travis - Travis plugin for Badge::Depot |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=begin html |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
<p> |
94
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/perl-5.10+-blue.svg" alt="Requires Perl 5.10+" /> |
95
|
|
|
|
|
|
|
<a href="https://travis-ci.org/Csson/p5-Badge-Depot-Plugin-Travis"><img src="https://api.travis-ci.org/Csson/p5-Badge-Depot-Plugin-Travis.svg?branch=master" alt="Travis status" /></a> |
96
|
|
|
|
|
|
|
<a href="http://cpants.cpanauthors.org/dist/Badge-Depot-Plugin-Travis-0.0203"><img src="https://badgedepot.code301.com/badge/kwalitee/Badge-Depot-Plugin-Travis/0.0203" alt="Distribution kwalitee" /></a> |
97
|
|
|
|
|
|
|
<a href="http://matrix.cpantesters.org/?dist=Badge-Depot-Plugin-Travis%200.0203"><img src="https://badgedepot.code301.com/badge/cpantesters/Badge-Depot-Plugin-Travis/0.0203" alt="CPAN Testers result" /></a> |
98
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/coverage-67.3%-red.svg" alt="coverage 67.3%" /> |
99
|
|
|
|
|
|
|
</p> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=end html |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Version 0.0203, released 2016-04-09. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SYNOPSIS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
use Badge::Depot::Plugin::Travis; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $badge = Badge::Depot::Plugin::Travis->new(user => 'my_name', repo => 'the_repo', branch => 'master'); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
print $badge->to_html; |
114
|
|
|
|
|
|
|
# prints '<a href="https://travis-ci.org/my_name/my_repo"><img src="https://api.travis-ci.org/my_name/my_repo.svg?branch=master" /></a>' |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 DESCRIPTION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Create a L<Travis|https://travis-ci.org> badge for a github repository. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This class consumes the L<Badge::Depot> role. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The C<user> and C<repo> attributes are required or optional, depending on your configuration. It looks for the C<resources/repository/web> setting in C<META.json>: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
If C<META.json> doesn't exist in the dist root, C<user> and C<repo> are required. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
If C<resources/repository/web> doesn't exist (or is not a github url), C<user> and C<repo> are required. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 user |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Github username. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 repo |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Github repository. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 branch |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Github branch. Optional, C<master> by default. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L<Badge::Depot> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SOURCE |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-Badge-Depot-Plugin-Travis> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 HOMEPAGE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L<https://metacpan.org/release/Badge-Depot-Plugin-Travis> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
177
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |