line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Swim::Plugin::badge; |
2
|
|
|
|
|
|
|
our $VERSION = '0.1.7'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Swim::Pod; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub phrase_func_badge { |
7
|
1
|
|
|
1
|
0
|
111
|
my ($self, $args) = @_; |
8
|
1
|
|
|
|
|
9
|
my @args = split / +/, $args; |
9
|
1
|
50
|
|
|
|
4
|
$args = pop @args or return; |
10
|
1
|
50
|
|
|
|
5
|
return unless @args; |
11
|
1
|
50
|
|
|
|
6
|
return unless $args =~ /^(\S+)\/(\S+)$/; |
12
|
1
|
|
|
|
|
2
|
my $out = "=for html\n"; |
13
|
1
|
|
|
|
|
2
|
for my $type (@args) { |
14
|
2
|
|
|
|
|
3
|
my $method = "_badge_$type"; |
15
|
2
|
50
|
|
|
|
7
|
if ($self->can($method)) { |
16
|
2
|
|
|
|
|
6
|
$out .= $self->$method($1, $2) . "\n"; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
1
|
|
|
|
|
5
|
return "$out\n"; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub phrase_func_badge_travis { |
23
|
1
|
|
|
1
|
0
|
201
|
my ($self, $args) = @_; |
24
|
1
|
50
|
|
|
|
10
|
return unless $args =~ /^(\S+)\/(\S+)$/; |
25
|
1
|
|
|
|
|
5
|
sprintf "=for html\n%s\n\n", $self->_badge_travis($1, $2); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub phrase_func_badge_coveralls { |
29
|
1
|
|
|
1
|
0
|
148
|
my ($self, $args) = @_; |
30
|
1
|
50
|
|
|
|
9
|
return unless $args =~ /^(\S+)\/(\S+)$/; |
31
|
1
|
|
|
|
|
6
|
sprintf "=for html\n%s\n\n", $self->_badge_coveralls($1, $2); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _badge_travis { |
35
|
2
|
|
|
2
|
|
7
|
my ($self, $owner, $repo) = @_; |
36
|
2
|
|
|
|
|
23
|
qq{<a href="https://travis-ci.org/$owner/$repo"><img src="https://travis-ci.org/$owner/$repo.png" alt="$repo"></a>}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _badge_coveralls { |
40
|
2
|
|
|
2
|
|
5
|
my ($self, $owner, $repo) = @_; |
41
|
2
|
|
|
|
|
26
|
qq{<a href="https://coveralls.io/r/$owner/$repo?branch=master"><img src="https://coveralls.io/repos/$owner/$repo/badge.png" alt="$repo"></a>}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Swim::Markdown; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub phrase_func_badge { |
47
|
1
|
|
|
1
|
0
|
118
|
my ($self, $args) = @_; |
48
|
1
|
|
|
|
|
12
|
my @args = split / +/, $args; |
49
|
1
|
50
|
|
|
|
8
|
$args = pop @args or return; |
50
|
1
|
50
|
|
|
|
4
|
return unless @args; |
51
|
1
|
50
|
|
|
|
8
|
return unless $args =~ /^(\S+)\/(\S+)$/; |
52
|
1
|
|
|
|
|
3
|
my $out = ""; |
53
|
1
|
|
|
|
|
2
|
for my $type (@args) { |
54
|
2
|
|
|
|
|
4
|
my $method = "_badge_$type"; |
55
|
2
|
50
|
|
|
|
10
|
if ($self->can($method)) { |
56
|
2
|
|
|
|
|
6
|
$out .= $self->$method($1, $2) . "\n"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
1
|
|
|
|
|
3
|
chomp $out; |
60
|
1
|
|
|
|
|
5
|
return $out; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub phrase_func_badge_travis { |
64
|
1
|
|
|
1
|
0
|
25
|
my ($self, $args) = @_; |
65
|
1
|
50
|
|
|
|
9
|
return unless $args =~ /^(\S+)\/(\S+)$/; |
66
|
1
|
|
|
|
|
6
|
$self->_badge_travis($1, $2); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub phrase_func_badge_coveralls { |
70
|
1
|
|
|
1
|
0
|
138
|
my ($self, $args) = @_; |
71
|
1
|
50
|
|
|
|
8
|
return unless $args =~ /^(\S+)\/(\S+)$/; |
72
|
1
|
|
|
|
|
4
|
$self->_badge_coveralls($1, $2); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _badge_travis { |
76
|
2
|
|
|
2
|
|
8
|
my ($self, $owner, $repo) = @_; |
77
|
2
|
|
|
|
|
16
|
qq{[![Travis build status](https://travis-ci.org/$owner/$repo.png?branch=master)](https://travis-ci.org/$owner/$repo)}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _badge_coveralls { |
81
|
2
|
|
|
2
|
|
5
|
my ($self, $owner, $repo) = @_; |
82
|
2
|
|
|
|
|
15
|
qq{[![Coverage Status](https://coveralls.io/repos/$owner/$repo/badge.png?branch=master)](https://coveralls.io/r/$owner/$repo?branch=master)}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |