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