File Coverage

lib/Dist/Zilla/Util/Git/Tags/Tag.pm
Criterion Covered Total %
statement 11 13 84.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 16 18 88.8


line stmt bran cond sub pod time code
1 1     1   7714 use strict;
  1         3  
  1         53  
2 1     1   7 use warnings;
  1         2  
  1         44  
3 1     1   1231 use utf8;
  1         12  
  1         6  
4              
5             package Dist::Zilla::Util::Git::Tags::Tag;
6             BEGIN {
7 1     1   107 $Dist::Zilla::Util::Git::Tags::Tag::AUTHORITY = 'cpan:KENTNL';
8             }
9             {
10             $Dist::Zilla::Util::Git::Tags::Tag::VERSION = '0.004000';
11             }
12              
13             # ABSTRACT: A single tag object
14              
15 1     1   509 use Moose;
  0            
  0            
16              
17             extends 'Dist::Zilla::Util::Git::Refs::Ref';
18              
19              
20             sub new_from_Ref {
21             my ( $class, $object ) = @_;
22             if ( not $object->can('name') ) {
23             require Carp;
24             return Carp::croak("Object $object does not respond to ->name, cannot Ref -> Tag");
25             }
26             my $name = $object->name;
27             if ( $name =~ qr{\Arefs/tags/(.+\z)}msx ) {
28             return $class->new(
29             git => $object->git,
30             name => $1,
31             );
32             }
33             require Carp;
34             Carp::croak("Path $name is not in refs/tags/*, cannot convert to Tag object");
35             }
36              
37              
38             sub refname {
39             my ($self) = @_;
40             return 'refs/tags/' . $self->name;
41             }
42              
43              
44             sub verify {
45             my ( $self, ) = @_;
46             return $self->git->tag( '-v', $self->name );
47             }
48              
49              
50             ## no critic (ProhibitBuiltinHomonyms)
51              
52             sub delete {
53             my ( $self, ) = @_;
54             return $self->git->tag( '-d', $self->name );
55             }
56              
57             no Moose;
58             __PACKAGE__->meta->make_immutable;
59             1;
60              
61             __END__
62              
63             =pod
64              
65             =encoding UTF-8
66              
67             =head1 NAME
68              
69             Dist::Zilla::Util::Git::Tags::Tag - A single tag object
70              
71             =head1 VERSION
72              
73             version 0.004000
74              
75             =head1 METHODS
76              
77             =head2 C<new_from_Ref>
78              
79             Convert a Git::Refs::Ref to a Git::Tags::Tag
80              
81             my $tag = $class->new_from_Ref( $ref );
82              
83             =head2 C<verify>
84              
85             =head2 C<delete>
86              
87             =head1 ATTRIBUTES
88              
89             =head2 C<name>
90              
91             =head2 C<git>
92              
93             =head1 AUTHOR
94              
95             Kent Fredric <kentfredric@gmail.com>
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is copyright (c) 2013 by Kent Fredric <kentfredric@gmail.com>.
100              
101             This is free software; you can redistribute it and/or modify it under
102             the same terms as the Perl 5 programming language system itself.
103              
104             =cut