File Coverage

blib/lib/Dist/Zilla/Stash/Contributors/Contributor.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::Stash::Contributors::Contributor;
2             our $AUTHORITY = 'cpan:YANICK';
3             # ABSTRACT: a Contributors stash element
4             $Dist::Zilla::Stash::Contributors::Contributor::VERSION = '0.1.1';
5 1     1   7 use strict;
  1         2  
  1         25  
6 1     1   5 use warnings;
  1         3  
  1         20  
7              
8 1     1   6 use Moose;
  1         2  
  1         5  
9              
10 1     1   5199 use overload '""' => \&stringify;
  1         3  
  1         9  
11              
12              
13             has name => (
14             isa => 'Str',
15             is => 'ro',
16             required => 1,
17             );
18              
19              
20             has email => (
21             is => 'ro',
22             required => 0,
23             );
24              
25              
26 15     15 1 888 sub stringify { sprintf '%s <%s>', $_[0]->name, $_[0]->email }
27              
28             __PACKAGE__->meta->make_immutable;
29             1;
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             Dist::Zilla::Stash::Contributors::Contributor - a Contributors stash element
40              
41             =head1 VERSION
42              
43             version 0.1.1
44              
45             =head1 SYNOPSIS
46              
47             if( my $contrib_stash = $self->zilla->stash_named('%Contributors') ) {
48             my @collaborators = sort { $a->email cmp $b->email }
49             $contrib_stash->all_contributors;
50              
51             $self->log( "contributor: " . $_->stringify ) for @collaborators;
52             }
53              
54             =head1 DESCRIPTION
55              
56             Collaborator objects used in the L<Dist::Zilla::Stash::Contributors> stash.
57              
58             =head1 METHODS
59              
60             =head2 new( name => $name, email => $address )
61              
62             Creates a new C<Dist::Zilla::Stash::Contributors::Contributor> object.
63              
64             =head2 name()
65              
66             Returns the name of the contributor.
67              
68             =head2 email()
69              
70             Returns the email address of the contributor.
71              
72             =head2 stringify()
73              
74             Returns the canonical string for the collaborator, of the form
75             "Full Name <email@address.org>".
76              
77             The object will automatically call this function is used
78             as a string.
79              
80             say $_ for $stash->all_contributors;
81              
82             =head1 AUTHOR
83              
84             Yanick Champoux <yanick@cpan.org>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2019, 2013 by Yanick Champoux.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut