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.014';
13             # ABSTRACT: A little more than Dist::Zilla::Role::Git::Repo
14              
15 3     3   266454 use Moose::Role;
  3         104282  
  3         16  
16 3     3   10915 use namespace::autoclean;
  3         5268  
  3         53  
17 3     3   1119 use MooseX::AttributeShortcuts;
  3         493907  
  3         14  
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   572 require Git::Wrapper;
26 7         9152 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   7 my ($self) = @_;
51              
52 3         16 local $/ = "\n"; # Force record separator to be single newline
53              
54 3         9 require Git::Wrapper;
55 3         77 my $git = Git::Wrapper->new( $self->repo_root );
56 3         56 my $regexp = $self->version_regexp;
57              
58 3         166 my @tags = $git->tag;
59 3 0       12854 @tags = map { /$regexp/ ? $1 : () } @tags;
  0         0  
60              
61             # find tagged versions; sort least to greatest
62             my @versions =
63 0         0 sort { version->parse($a) <=> version->parse($b) }
64 3         15 grep { eval { version->parse($_) } }
  0         0  
  0         0  
65             @tags;
66              
67 3         257 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.014 of Dist::Zilla::Role::Git::Repo::More - released October 10, 2016 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 BUGS
136              
137             Please report any bugs or feature requests on the bugtracker website
138             L<https://github.com/RsrchBoy/dist-zilla-pluginbundle-git-checkfor/issues>
139              
140             When submitting a bug or request, please include a test-file or a
141             patch to an existing test-file that illustrates the bug or desired
142             feature.
143              
144             =head1 AUTHOR
145              
146             Chris Weyl <cweyl@alumni.drew.edu>
147              
148             =head2 I'm a material boy in a material world
149              
150             =begin html
151              
152             <a href="https://gratipay.com/RsrchBoy/"><img src="http://img.shields.io/gratipay/RsrchBoy.svg" /></a>
153             <a href="http://bit.ly/rsrchboys-wishlist"><img src="http://wps.io/wp-content/uploads/2014/05/amazon_wishlist.resized.png" /></a>
154             <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>
155              
156             =end html
157              
158             Please note B<I do not expect to be gittip'ed or flattr'ed for this work>,
159             rather B<it is simply a very pleasant surprise>. I largely create and release
160             works like this because I need them or I find it enjoyable; however, don't let
161             that stop you if you feel like it ;)
162              
163             L<Flattr|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>,
164             L<Gratipay|https://gratipay.com/RsrchBoy/>, or indulge my
165             L<Amazon Wishlist|http://bit.ly/rsrchboys-wishlist>... If and *only* if you so desire.
166              
167             =head1 COPYRIGHT AND LICENSE
168              
169             This software is Copyright (c) 2012 by Chris Weyl.
170              
171             This is free software, licensed under:
172              
173             The GNU Lesser General Public License, Version 2.1, February 1999
174              
175             =cut