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