Enbld/Definition.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 66.6% 2 / 3 totaltotal 97.6% 41 / 42 SCAR 11.0
CC
3
Cov
100%
new
2.0
parse
2.0
BEGIN
1.0
CRAP 3.0
« Enbld/Target/Attribute/IndexParserForm.pm ↑ Summary Enbld/Deployed.pm »
1 package Enbld::Definition;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Module::Load::Conditional qw/can_load/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 require Enbld::Error;
10  
11 sub new {
12 48 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
13 48 my $name = shift;
14  
15 48 my $self = {
16 defined => {
17 DefaultArgument => undef,
18 DarwinArgument => undef,
19  
20 AdditionalArgument => undef,
21  
22 AllowedCondition => undef,
23 ArchiveName => undef,
24 CopyFiles => undef,
25 Dependencies => undef,
26 DistName => undef,
27 DownloadSite => undef,
28 Extension => undef,
29 Filename => undef,
30 IndexParserForm => undef,
31 IndexSite => undef,
32 PatchFiles => undef,
33 Prefix => undef,
34 URL => undef,
35 SortedVersionList => undef,
36 Version => undef,
37 VersionList => undef,
38 # VersionCondition => undef,
39 VersionForm => undef,
40 WebSite => undef,
41
42 TestAction => undef,
43  
44 CommandConfigure => undef,
45 CommandMake => undef,
46 CommandTest => undef,
47 CommandInstall => undef,
48 },
49 };
50  
51 48 my $module = 'Enbld::Definition::' . ucfirst( $name );
52  
53 48 ▶ if ( can_load( modules => { $module => undef } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (can_load("modules", {$module, undef})) 47 1 48
54 47 bless $self, $module;
55  
56 47 $self->initialize;
57  
58 47 return $self;
59 }
60  
61 1 die( Enbld::Error->new( "no definition for target '$name'" ));
62 }
63  
64 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
Pod undocumented
65  
66 # do nothing ... virtual method
67  
68 }
69  
70 sub parse {
71 46 ▶ my $self = shift;
Subroutine parse: called CC=2 SCAR=6.9
Pod documented
72  
73 46 require Enbld::Target::AttributeCollector;
74 46 my $attributes = Enbld::Target::AttributeCollector->new;
75  
76 46 foreach my $attribute ( keys %{ $self->{defined} } ) {
77 1196 $attributes->add( $attribute, $self->{defined}{ $attribute } );
78 }
79  
80 46 return $attributes;
81 }
82  
83 3 1;
84  
85 =pod
86  
87 =head1 NAME
88  
89 Enbld::Definition - stores target software' attributes.
90  
91 =head1 SYNOPSIS
92  
93 require Enbld::Definition;
94  
95 my $attributes = Enbld::Definition->new( 'git' )->parse;
96  
97 $attributes->add( 'VersionCondition', '1.8.5' );
98  
99 $attributes->ArchiveName; # git
100 $attributes->Vesion; # 1.8.5
101 $attributes->URL; # http://git-core.googlecode.com/files/git-1.8.5.tar.gz
102  
103 =head1 DESCRIPTION
104  
105 Enbld::Definition stores target software' attributes.
106  
107 =head1 METHODS
108  
109 =over 2
110  
111 =item new
112  
113 my $def = Enbld::Definition->new( 'git' );
114  
115 Returns a new definition object for target software.
116  
117 The return value is a Enbld::Definition::[target software] object.
118  
119 When the definition module of the target software specified as the argument does not exist, undef is returned.
120  
121 =item parse
122  
123 my $def = Enbld::Definition->new( 'git' );
124 my $attributes = $def->parse;
125 $attributes->ArchiveName; # -> git
126 $attributes->Extension; # -> tar.gz
127  
128 Returns a new attributes collector for target software.
129  
130 The return value is a Enbld::Target::AttributeCollector object.
131  
132 =back
133  
134 =head1 COPYRIGHT
135  
136 copyright 2013- Magnolia C<< <magnolia.k@me.com> >>.
137  
138 =head1 LICENSE
139  
140 This is free software; you can redistribute it and/or modify it under
141 the same terms as the Perl 5 programming language system itself.
142  
143 =cut
« Enbld/Target/Attribute/IndexParserForm.pm ↑ Summary Enbld/Deployed.pm »