Enbld/Definition/Mysql.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 74 SCAR 24.8
CC
3
Cov
0%
set_url
12.0
initialize
2.0
set_versionlist
2.0
CRAP 12.0
1 package Enbld::Definition::Mysql;
2  
3 use strict;
4 use warnings;
5  
6 use parent qw/Enbld::Definition/;
7  
8 use version;
9  
10 require Enbld::HTTP;
11  
12 sub initialize {
13 my $self = shift;
14  
15 $self->SUPER::initialize;
16  
17 $self->{defined}{IndexSite} =
18 'http://downloads.mysql.com/archives/community/';
19 $self->{defined}{ArchiveName} = 'mysql';
20 $self->{defined}{WebSite} = 'http://www.mysql.com';
21 $self->{defined}{VersionForm} = '5\.\d\.\d{1,2}';
22 $self->{defined}{DownloadSite} = 'http://www.mysql.com/';
23  
24 $self->{defined}{Dependencies} = [ 'cmake' ];
25  
26 $self->{defined}{VersionList} = \&set_versionlist;
27  
28 $self->{defined}{URL} = \&set_url;
29  
30 $self->{defined}{Prefix} = '-DCMAKE_INSTALL_PREFIX=';
31  
32 $self->{defined}{TestAction} = 'test';
33  
34 $self->{defined}{CommandConfigure} = 'cmake .';
35  
36 return $self;
37 }
38  
39 sub set_versionlist {
40 my $attributes = shift;
41  
42 my $indexsite_latest = 'http://dev.mysql.com/downloads/';
43 my $latest_html = Enbld::HTTP->get_html( $indexsite_latest );
44 my $latest = $latest_html->parse_version(
45 'Current Generally Available Release: '. $attributes->VersionForm,
46 $attributes->VersionForm,
47 );
48  
49 my @versionlist;
50 push @versionlist, @{ $latest };
51  
52 push @versionlist, @{ archived_versions( $attributes ) };
53  
54 return \@versionlist;
55 }
56  
57 sub archived_versions {
58 my $attributes = shift;
59  
60 my $html = Enbld::HTTP->get_html( $attributes->IndexSite );
61 my $list =
62 $html->parse_version(
63 quotemeta( '<option label="' ) . $attributes->VersionForm . '"',
64 $attributes->VersionForm
65 );
66  
67 return $list;
68 }
69  
70 sub set_url {
71 my $attributes = shift;
72  
73 my $list = $attributes->VersionList;
74  
75 my @versions = sort {
76 version->declare( $a ) cmp version->declare( $b )
77 } @{ $list };
78  
79 my $major;
80 if ( $attributes->Version =~ /(5\.\d)\.\d{1,2}/ ) {
81 $major = $1;
82 }
83  
84 my $url;
85 if ( $attributes->Version eq $versions[-1] ) {
86  
87 $url = 'http://dev.mysql.com/get/Downloads/MySQL-' . $major .
88 '/mysql-' . $attributes->Version .
89 '.tar.gz/from/http://cdn.mysql.com/';
90  
91 } else {
92 $url = 'http://downloads.mysql.com/archives/mysql-' . $major .
93 '/mysql-' . $attributes->Version . '.tar.gz';
94 }
95  
96 return $url;
97 }
98  
99 1;
100  
101 =pod
102  
103 =head1 NAME
104  
105 Enbld::Definition::Mysql - definition module for MySQL
106  
107 =head1 SEE ALSO
108  
109 L<MySQL|http://downloads.mysql.com/archives/community/>
110  
111 L<Enbld::Definition>
112  
113 =head1 COPYRIGHT
114  
115 copyright 2013- Magnolia C<< <magnolia.k@me.com> >>.
116  
117 =head1 LICENSE
118  
119 This is free software; you can redistribute it and/or modify it under
120 the same terms as the Perl 5 programming language system itself.
121  
122 =cut