File Coverage

blib/lib/ShipIt/ProjectType.pm
Criterion Covered Total %
statement 12 33 36.3
branch 0 8 0.0
condition n/a
subroutine 4 9 44.4
pod 4 5 80.0
total 20 55 36.3


line stmt bran cond sub pod time code
1             package ShipIt::ProjectType;
2 2     2   12 use strict;
  2         2  
  2         59  
3 2     2   11 use ShipIt::ProjectType::Perl;
  2         3  
  2         51  
4 2     2   785 use ShipIt::ProjectType::AutoConf;
  2         18  
  2         122  
5 2     2   11 use ShipIt::Util qw(find_subclasses);
  2         3  
  2         780  
6              
7             =head1 NAME
8              
9             ShipIt::ProjectType - abstract base class for different types of projects
10              
11             =head1 OVERVIEW
12              
13             Different types of projects (Perl, C, ...) have different conventions
14             and quirks which this abstract base class aims to hide.
15              
16             =head1 SYNOPSIS
17              
18             $pt = $state->pt; # get a ShipIt::ProjectType instance
19              
20             $ver = $pt->find_version;
21             $pt->update_version("1.53");
22             $pt->disttest;
23              
24             =head1 METHODS
25              
26             =cut
27              
28             sub new {
29 0     0 0   my ($class) = @_;
30 0           my $pt;
31              
32             # when called as a factory, return the appropriate subtype
33 0 0         if ($class eq "ShipIt::ProjectType") {
34             # returns undef if not a perl project,
35 0           $pt = ShipIt::ProjectType::Perl->new;
36 0 0         return $pt if $pt;
37              
38 0           $pt = ShipIt::ProjectType::AutoConf->new;
39 0 0         return $pt if $pt;
40              
41 0           for my $class (grep {!/::(Perl|AutoConf)$/} find_subclasses($class)) {
  0            
42 0           eval "CORE::require $class";
43 0           $pt = $class->new;
44 0 0         return $pt if $pt;
45             }
46              
47 0           die "Unknown project type. Can't find Makefile.PL, Build.PL, configure.ac, etc..";
48             }
49              
50             # if we're being called via ->SUPER::new from child class,
51             # give them their blessed object
52 0           return bless {}, $class;
53             }
54              
55             =head2 find_version
56              
57             Returns current version of project.
58              
59             =cut
60              
61             sub find_version {
62 0     0 1   die "ABSTRACT find_version in $_[0]\n";
63             }
64              
65             =head2 update_version($new_ver)
66              
67             Updates version number on disk with provided new version.
68              
69             =cut
70              
71             sub update_version {
72 0     0 1   my ($self, $newver) = @_;
73 0           die "ABSTRACT update_version in $self\n";
74             }
75              
76             =head2 disttest
77              
78             Make a dist, then untars that in a temp directory, and does a full
79             build & test on the extracted archive. Returns true if everything
80             succeeds, or dies on failure.
81              
82             =cut
83              
84             sub disttest {
85 0     0 1   my ($self) = @_;
86 0           die "ABSTRACT distest in $self\n";
87             }
88              
89             =head2 makedist
90              
91             Runs "make dist" or equivalent, to build the resultant archive to give
92             to users. Dies on failure, or returns the path (relative or absolute)
93             to the dist file.
94              
95             =cut
96              
97             sub makedist {
98 0     0 1   my ($self) = @_;
99 0           die "ABSTRACT makedist in $self\n";
100             }
101              
102              
103             1;