File Coverage

blib/lib/Dist/Zilla/Role/Git/Repo/More.pm
Criterion Covered Total %
statement 20 24 83.3
branch 0 2 0.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 25 31 80.6


line stmt bran cond sub pod time code
1             #
2             # This file is part of Dist-Zilla-PluginBundle-Git-CheckFor
3             #
4             # This software is Copyright (c) 2012 by Chris Weyl.
5             #
6             # This is free software, licensed under:
7             #
8             # The GNU Lesser General Public License, Version 2.1, February 1999
9             #
10             package Dist::Zilla::Role::Git::Repo::More;
11             our $AUTHORITY = 'cpan:RSRCHBOY';
12             $Dist::Zilla::Role::Git::Repo::More::VERSION = '0.012';
13             # ABSTRACT: A little more than Dist::Zilla::Role::Git::Repo
14              
15 3     3   615480 use Moose::Role;
  3         6  
  3         19  
16 3     3   12121 use namespace::autoclean;
  3         1056  
  3         21  
17 3     3   1172 use MooseX::AttributeShortcuts;
  3         464835  
  3         23  
18              
19             with
20             'Dist::Zilla::Role::Git::Repo',
21             ;
22              
23             has _repo => (is => 'lazy', isa => 'Git::Wrapper');
24             sub _build__repo {
25 7     7   880 require Git::Wrapper;
26 7         11569 Git::Wrapper->new(shift->repo_root)
27             }
28              
29              
30             # -- attributes
31              
32             #has version_regexp => (is => 'rwp', isa=>'Str', lazy => 1, predicate => 1, builder => sub { '^v(.+)$' });
33             #has first_version => (is => 'rwp', isa=>'Str', lazy => 1, predicate => 1, default => sub { '0.001' });
34              
35             has _previous_versions => (
36              
37             traits => ['Array'],
38             is => 'lazy',
39             isa => 'ArrayRef[Str]',
40             handles => {
41              
42             has_previous_versions => 'count',
43             previous_versions => 'elements',
44             earliest_version => [ get => 0 ],
45             last_version => [ get => -1 ],
46             },
47             );
48              
49             sub _build__previous_versions {
50 3     3   5 my ($self) = @_;
51              
52 3         23 local $/ = "\n"; # Force record separator to be single newline
53              
54 3         17 require Git::Wrapper;
55 3         104 my $git = Git::Wrapper->new( $self->repo_root );
56 3         84 my $regexp = $self->version_regexp;
57              
58 3         248 my @tags = $git->tag;
59 3 0       21594 @tags = map { /$regexp/ ? $1 : () } @tags;
  0         0  
60              
61             # find tagged versions; sort least to greatest
62 0         0 my @versions =
63             sort { version->parse($a) <=> version->parse($b) }
64 3         21 grep { eval { version->parse($_) } }
  0         0  
  0         0  
65             @tags;
66              
67 3         370 return [ @versions ];
68             }
69              
70             # -- role implementation
71              
72             #sub provide_version {
73             #my ($self) = @_;
74              
75             ## override (or maybe needed to initialize)
76             #return $ENV{V} if exists $ENV{V};
77              
78             #return $self->first_version
79             #unless $self->has_previous_versions;
80              
81             #my $last_ver = $self->last_version;
82             #my $new_ver = Version::Next::next_version($last_ver);
83             #$self->log("Bumping version from $last_ver to $new_ver");
84              
85             #return "$new_ver";
86             #}
87              
88             !!42;
89              
90             __END__
91              
92             =pod
93              
94             =encoding UTF-8
95              
96             =for :stopwords Chris Weyl Christian Doherty Etheridge Karen Mengué Mike Olivier Walde
97              
98             =for :stopwords Wishlist flattr flattr'ed gittip gittip'ed
99              
100             =head1 NAME
101              
102             Dist::Zilla::Role::Git::Repo::More - A little more than Dist::Zilla::Role::Git::Repo
103              
104             =head1 VERSION
105              
106             This document describes version 0.012 of Dist::Zilla::Role::Git::Repo::More - released February 23, 2015 as part of Dist-Zilla-PluginBundle-Git-CheckFor.
107              
108             =head1 SYNOPSIS
109              
110             # ta-da!
111             with 'Dist::Zilla::Role::Git::Repo::More';
112              
113             =head1 DESCRIPTION
114              
115             This is a role that extends L<Dist::Zilla::Role::Git::Repo> to provide an
116             additional private attribute. There's probably nothing here you'd be terribly
117             interested in.
118              
119             =head1 SEE ALSO
120              
121             Please see those modules/websites for more information related to this module.
122              
123             =over 4
124              
125             =item *
126              
127             L<Dist::Zilla::PluginBundle::Git::CheckFor|Dist::Zilla::PluginBundle::Git::CheckFor>
128              
129             =item *
130              
131             L<Dist::Zilla::Role::Git::Repo>
132              
133             =back
134              
135             =head1 SOURCE
136              
137             The development version is on github at L<http://https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor>
138             and may be cloned from L<git://https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor.git>
139              
140             =head1 BUGS
141              
142             Please report any bugs or feature requests on the bugtracker website
143             https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor/issues
144              
145             When submitting a bug or request, please include a test-file or a
146             patch to an existing test-file that illustrates the bug or desired
147             feature.
148              
149             =head1 AUTHOR
150              
151             Chris Weyl <cweyl@alumni.drew.edu>
152              
153             =head2 I'm a material boy in a material world
154              
155             =begin html
156              
157             <a href="https://www.gittip.com/RsrchBoy/"><img src="https://raw.githubusercontent.com/gittip/www.gittip.com/master/www/assets/%25version/logo.png" /></a>
158             <a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a>
159             <a href="https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fdist-zilla-pluginbundle-git-checkfor&title=RsrchBoy's%20CPAN%20Dist-Zilla-PluginBundle-Git-CheckFor&tags=%22RsrchBoy's%20Dist-Zilla-PluginBundle-Git-CheckFor%20in%20the%20CPAN%22"><img src="http://api.flattr.com/button/flattr-badge-large.png" /></a>
160              
161             =end html
162              
163             Please note B<I do not expect to be gittip'ed or flattr'ed for this work>,
164             rather B<it is simply a very pleasant surprise>. I largely create and release
165             works like this because I need them or I find it enjoyable; however, don't let
166             that stop you if you feel like it ;)
167              
168             L<Flattr this|https://flattr.com/submit/auto?user_id=RsrchBoy&url=https%3A%2F%2Fgithub.com%2FRsrchBoy%2Fdist-zilla-pluginbundle-git-checkfor&title=RsrchBoy's%20CPAN%20Dist-Zilla-PluginBundle-Git-CheckFor&tags=%22RsrchBoy's%20Dist-Zilla-PluginBundle-Git-CheckFor%20in%20the%20CPAN%22>,
169             L<gittip me|https://www.gittip.com/RsrchBoy/>, or indulge my
170             L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If you so desire.
171              
172             =head1 COPYRIGHT AND LICENSE
173              
174             This software is Copyright (c) 2012 by Chris Weyl.
175              
176             This is free software, licensed under:
177              
178             The GNU Lesser General Public License, Version 2.1, February 1999
179              
180             =cut