File Coverage

blib/lib/Badge/Depot/Plugin/Gratipay.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 29 30 96.6


line stmt bran cond sub pod time code
1 1     1   13947 use strict;
  1         2  
  1         34  
2 1     1   3 use warnings;
  1         2  
  1         36  
3              
4             package Badge::Depot::Plugin::Gratipay;
5              
6 1     1   436 use Moose;
  1         307437  
  1         8  
7 1     1   5553 use namespace::autoclean;
  1         1042  
  1         4  
8 1     1   492 use Types::Standard qw/Str/;
  1         43862  
  1         15  
9 1     1   1094 use Types::URI qw/Uri/;
  1         188380  
  1         13  
10             with 'Badge::Depot';
11              
12             our $VERSION = '0.0102'; # VERSION
13             # ABSTRACT: Gratipay plugin for Badge::Depot
14              
15             has user => (
16             is => 'ro',
17             isa => Str,
18             required => 1,
19             );
20             has custom_image_url => (
21             is => 'ro',
22             isa => Uri,
23             coerce => 1,
24             default => 'https://img.shields.io/gratipay/%s.svg',
25             );
26              
27              
28             sub BUILD {
29 2     2 0 6612 my $self = shift;
30 2         64 $self->link_url(sprintf 'https://gratipay.com/%s', $self->user);
31 2         227 $self->image_url(sprintf $self->custom_image_url, $self->user);
32 2         233 $self->image_alt('Gratipay');
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =encoding UTF-8
42              
43             =head1 NAME
44              
45             Badge::Depot::Plugin::Gratipay - Gratipay plugin for Badge::Depot
46              
47             =head1 VERSION
48              
49             Version 0.0102, released 2015-03-19.
50              
51             =head1 SYNOPSIS
52              
53             use Badge::Depot::Plugin::Gratipay;
54              
55             my $badge = Badge::Depot::Plugin::Gratipay->new(user => 'my_name');
56              
57             print $badge->to_html;
58             # prints '<a href="https://gratipay.com/my_name"><img src="https://img.shields.io/my_name.svg" /></a>'
59              
60             =head1 DESCRIPTION
61              
62             Create a L<Gratipay|https://gratipay.com> badge for a Gratipay user.
63              
64             This class consumes the L<Badge::Depot> role.
65              
66             =head1 ATTRIBUTES
67              
68             =head2 user
69              
70             The Gratipay user name.
71              
72             =head2 custom_image_url
73              
74             By default, this module shows an image from L<shields.io|https://shields.io>. Use this attribute to override that with a custom url. Use a C<%s> placeholder where the user name should be inserted.
75              
76             =head1 SEE ALSO
77              
78             =over 4
79              
80             =item *
81              
82             L<Badge::Depot>
83              
84             =item *
85              
86             L<Task::Badge::Depot>
87              
88             =back
89              
90             =head1 SOURCE
91              
92             L<https://github.com/Csson/p5-Badge-Depot-Plugin-Gratipay>
93              
94             =head1 HOMEPAGE
95              
96             L<https://metacpan.org/release/Badge-Depot-Plugin-Gratipay>
97              
98             =head1 AUTHOR
99              
100             Erik Carlsson <info@code301.com>
101              
102             =head1 COPYRIGHT AND LICENSE
103              
104             This software is copyright (c) 2015 by Erik Carlsson <info@code301.com>.
105              
106             This is free software; you can redistribute it and/or modify it under
107             the same terms as the Perl 5 programming language system itself.
108              
109             =cut