blib/lib/Dist/Zilla/Plugin/Git/DescribeVersion.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 98.0% 49 / 50 CC 3 SCAR 4.7
CC
3
Cov
100%
provide_version
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
↑ Summary
1 # vim: set ts=2 sts=2 sw=2 expandtab smarttab:
2 #
3 # This file is part of Dist-Zilla-Plugin-Git-DescribeVersion
4 #
5 # This software is copyright (c) 2010 by Randy Stauner.
6 #
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 #
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package Dist::Zilla::Plugin::Git::DescribeVersion;
14 {
15 2 $Dist::Zilla::Plugin::Git::DescribeVersion::VERSION = '1.004';
16 }
17 # git description: v1.003-5-gff644eb
18  
19 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 $Dist::Zilla::Plugin::Git::DescribeVersion::AUTHORITY = 'cpan:RWSTAUNER';
21 }
22 # ABSTRACT: Provide version using git-describe
23  
24 2 ▶use Dist::Zilla 4 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use Git::DescribeVersion ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 2 with 'Dist::Zilla::Role::VersionProvider';
29  
30 2 ▶while( my ($name, $default) = each %Git::DescribeVersion::Defaults ){
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Git::DescribeVersion::Defaults) 6 2 8
31 6 has $name => ( is => 'ro', isa=>'Str', default => $default );
32 }
33  
34 7 ▶sub provide_version {
Subroutine provide_version: called CC=3 SCAR=11.0
Pod undocumented
35 7 my ($self) = @_;
36  
37 # override (or maybe needed to initialize)
38 7 ▶ return $ENV{V} if exists $ENV{V};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"V"} 1 6 7
39  
40 # less overhead to use %Defaults than MOP meta API
41 6 my $opts = { map { $_ => $self->$_() }
42 keys %Git::DescribeVersion::Defaults };
43  
44 6 my $new_ver = eval {
45 6 Git::DescribeVersion->new($opts)->version;
46 };
47  
48 6 ▶ $self->log_fatal("Could not determine version from tags: $@")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $new_ver 1 5 6
49 unless defined $new_ver;
50  
51 5 $self->log("Git described version as $new_ver");
52  
53 5 $self->zilla->version("$new_ver");
54 }
55  
56 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 __PACKAGE__->meta->make_immutable;
58 2 1;
59  
60  
61 __END__
↑ Summary