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