File Coverage

lib/Module/Provision/TraitFor/Badges.pm
Criterion Covered Total %
statement 9 27 33.3
branch n/a
condition n/a
subroutine 3 6 50.0
pod 1 1 100.0
total 13 34 38.2


line stmt bran cond sub pod time code
1             package Module::Provision::TraitFor::Badges;
2              
3 1     1   914 use namespace::autoclean;
  1         4  
  1         12  
4              
5 1     1   100 use Class::Usul::Constants qw( OK TRUE );
  1         3  
  1         10  
6 1     1   908 use Moo::Role;
  1         64  
  1         9  
7              
8             requires qw( output quiet select_method stash );
9              
10             around 'select_method' => sub {
11             my ($orig, $self, @args) = @_; my $method = $orig->( $self, @args );
12              
13             $method eq 'get_badge_markup' and $self->quiet( TRUE );
14              
15             return $method;
16             };
17              
18             sub get_badge_markup : method {
19 0     0 1   my $self = shift;
20 0           my $s = $self->stash;
21 0           my $distname = $s->{distname};
22 0           my $distdir = $s->{lc_distname};
23 0           my $reponame = $s->{pub_repo_prefix}.$distdir;
24 0           my $coverage = $self->config->coverage_server;
25 0           my $travis = 'https://travis-ci.org/'.$s->{author_id};
26 0     0     my $args = sub { { cl => $_[ 0 ], nl => $_[ 0 ], no_lead => TRUE } };
  0            
27 0     0     my $out = sub { $self->output( $_[ 0 ], $args->( $_[ 1 ] ) ) };
  0            
28              
29 0           $out->( '=begin html', TRUE );
30 0           $out->( "<a href=\"${travis}/${reponame}\">"
31             . "<img src=\"${travis}/${reponame}.svg?branch=master\""
32             . ' alt="Travis CI Badge"></a>' );
33 0           $out->( "<a href=\"${coverage}/report/${distdir}/latest\">"
34             . "<img src=\"${coverage}/badge/${distdir}/latest\""
35             . ' alt="Coverage Badge"></a>' );
36 0           $out->( "<a href=\"http://badge.fury.io/pl/${distname}\">"
37             . "<img src=\"https://badge.fury.io/pl/${distname}.svg\""
38             . ' alt="CPAN Badge"></a>' );
39 0           $out->( "<a href=\"http://cpants.cpanauthors.org/dist/${distname}\">"
40             . "<img src=\"http://cpants.cpanauthors.org/dist/${distname}.png\""
41             . ' alt="Kwalitee Badge"></a>' );
42 0           $out->( '=end html', TRUE );
43 0           return OK;
44             }
45              
46             1;
47              
48             __END__
49              
50             =pod
51              
52             =encoding utf-8
53              
54             =head1 Name
55              
56             Module::Provision::TraitFor::Badges - Generate badge markup to paste into POD
57              
58             =head1 Synopsis
59              
60             use Moo;
61              
62             extends 'Module::Provision::Base';
63             with 'Module::Provision::TraitFor::Badges';
64              
65             =head1 Description
66              
67             Generate badge markup to paste into POD
68              
69             =head1 Configuration and Environment
70              
71             Defines no attributes
72              
73             =head1 Subroutines/Methods
74              
75             =head2 C<get_badge_markup> - Generate badge markup to paste into POD
76              
77             Prints the markup for badges in POD to standard output for ease of cut and
78             paste
79              
80             =head1 Diagnostics
81              
82             None
83              
84             =head1 Dependencies
85              
86             =over 3
87              
88             =item L<Class::Usul>
89              
90             =back
91              
92             =head1 Incompatibilities
93              
94             There are no known incompatibilities in this module
95              
96             =head1 Bugs and Limitations
97              
98             There are no known bugs in this module. Please report problems to
99             http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Provision.
100             Patches are welcome
101              
102             =head1 Acknowledgements
103              
104             Larry Wall - For the Perl programming language
105              
106             =head1 Author
107              
108             Peter Flanigan, C<< <pjfl@cpan.org> >>
109              
110             =head1 License and Copyright
111              
112             Copyright (c) 2017 Peter Flanigan. All rights reserved
113              
114             This program is free software; you can redistribute it and/or modify it
115             under the same terms as Perl itself. See L<perlartistic>
116              
117             This program is distributed in the hope that it will be useful,
118             but WITHOUT WARRANTY; without even the implied warranty of
119             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
120              
121             =cut
122              
123             # Local Variables:
124             # mode: perl
125             # tab-width: 3
126             # End:
127             # vim: expandtab shiftwidth=3: