Merge lp:~emaadmanzoor/mvhub/move-out-update-cpan-libs into lp:mvhub

Proposed by Emaad Ahmed Manzoor
Status: Merged
Merged at revision: 599
Proposed branch: lp:~emaadmanzoor/mvhub/move-out-update-cpan-libs
Merge into: lp:mvhub
Diff against target: 252 lines (+128/-53)
6 files modified
app-mvhub/project-tools/bin/mv_update_development (+1/-1)
app-mvhub/project-tools/bin/mv_update_production (+1/-1)
app-mvhub/project-tools/bin/mv_update_staging (+1/-1)
lib-mvhub/lib/MVHub/Utils/Setup.pm (+0/-50)
lib-mvhub/lib/MVHub/Utils/Setup/CPANLibs.pm (+120/-0)
lib-mvhub/t/01-load.t (+5/-0)
To merge this branch: bzr merge lp:~emaadmanzoor/mvhub/move-out-update-cpan-libs
Reviewer Review Type Date Requested Status
Dan MacNeil Needs Fixing
Review via email: mp+71513@code.launchpad.net

Commit message

moved cpan lib fetching to a separate module
added the Foo::Bar::Baz::Roo test case to lib-mvhub/t/01-load.t

Description of the change

* Moved update_cpan_libs(), _get_cpan_libs and _get_cpan_install_fails from Setup.pm to Setup/CPANLibs.pm.
* added the Foo::Bar::Baz::Roo test case to lib-mvhub/t/01-load.t

To post a comment you must log in.
Revision history for this message
Dan MacNeil (omacneil) wrote :

Looks pretty good (love the POD!)

Before merging, the various mv_update_* scripts need to be modified.

review: Needs Fixing
591. By Emaad Ahmed Manzoor

updated mv_* scripts to use Setup::CPANLibs

Revision history for this message
Emaad Ahmed Manzoor (emaadmanzoor) wrote :

Done

Revision history for this message
Dan MacNeil (omacneil) wrote :

Need also to update mv_update_staging and mv_update_production

when these are done, ok to merge w/o further review.

review: Needs Fixing
592. By Emaad Ahmed Manzoor

merged from trunk

593. By Emaad Ahmed Manzoor

modified test to recognize modules 4 directories deep

594. By Emaad Ahmed Manzoor

fixed my mistake

595. By Emaad Ahmed Manzoor

perltidy fix

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app-mvhub/project-tools/bin/mv_update_development'
2--- app-mvhub/project-tools/bin/mv_update_development 2011-08-11 03:24:54 +0000
3+++ app-mvhub/project-tools/bin/mv_update_development 2011-09-03 14:01:26 +0000
4@@ -122,7 +122,7 @@
5
6 $prompt = "Update CPAN libraries? (Y/N):";
7 if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
8- MVHub::Utils::Setup::update_cpan_libs();
9+ MVHub::Utils::Setup::CPANLibs::update_cpan_libs();
10 }
11 }
12 }
13
14=== modified file 'app-mvhub/project-tools/bin/mv_update_production'
15--- app-mvhub/project-tools/bin/mv_update_production 2010-11-28 02:03:11 +0000
16+++ app-mvhub/project-tools/bin/mv_update_production 2011-09-03 14:01:26 +0000
17@@ -79,7 +79,7 @@
18 }
19 $prompt = "Update CPAN libraries? (Y/N):";
20 if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
21- MVHub::Utils::Setup::update_cpan_libs();
22+ MVHub::Utils::Setup::CPANLibs::update_cpan_libs();
23 }
24
25 }
26
27=== modified file 'app-mvhub/project-tools/bin/mv_update_staging'
28--- app-mvhub/project-tools/bin/mv_update_staging 2010-11-28 02:03:11 +0000
29+++ app-mvhub/project-tools/bin/mv_update_staging 2011-09-03 14:01:26 +0000
30@@ -94,7 +94,7 @@
31
32 $prompt = "Update CPAN libraries? (Y/N):";
33 if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
34- MVHub::Utils::Setup::update_cpan_libs();
35+ MVHub::Utils::Setup::CPANLibs::update_cpan_libs();
36 }
37
38 }
39
40=== added directory 'lib-mvhub/lib/MVHub/Utils/Setup'
41=== modified file 'lib-mvhub/lib/MVHub/Utils/Setup.pm'
42--- lib-mvhub/lib/MVHub/Utils/Setup.pm 2011-08-13 13:02:47 +0000
43+++ lib-mvhub/lib/MVHub/Utils/Setup.pm 2011-09-03 14:01:26 +0000
44@@ -5,7 +5,6 @@
45
46 use Carp;
47 use DateTime;
48-use CPANPLUS::Backend;
49 use DBI;
50 use IO::File;
51 use IO::Prompt;
52@@ -42,7 +41,6 @@
53 remove_cron_jobs
54 restart_services
55 update_etc_files
56- update_cpan_libs
57 );
58
59 our @SITE_CODES = qw/ mvh nsp /;
60@@ -919,51 +917,3 @@
61 my $cmd = "cp -vur $etc_path /";
62 ( system($cmd) == 0 ) or die "Failed to copy etc files\n";
63 }
64-
65-sub update_cpan_libs {
66-
67- my $cb = CPANPLUS::Backend->new(
68- conf => {
69- allow_build_interactivity => 'false',
70- prereqs => 1,
71- verbose => 'false',
72- }
73- );
74-
75- my @modules = _get_cpan_modules();
76- my $result = $cb->install( modules => \@modules );
77-
78- if ( !$result ) {
79- my $msg = "\n FAILED to install/update following cpan modules:\n";
80- $msg .= _get_cpan_install_fails( $result->rv() );
81- warn "$msg\n";
82- }
83- else {
84- print "\nupdated cpan libs successfully\n";
85- }
86-}
87-
88-sub _get_cpan_modules {
89- return qw /
90- Devel::NYTProf
91- DBIx::XHTML_Table
92- Search::Sitemap
93- Set::Array
94- SQL::Library
95- Test::HTML::Lint
96- Test::WWW::Mechanize
97- Text::xSV
98- WWW::Mechanize
99- /;
100-}
101-
102-sub _get_cpan_install_fails {
103- my $modules_href = shift;
104-
105- my $failed_mods;
106- foreach my $module_name ( sort keys %$modules_href ) {
107- $failed_mods .= ' ' x 10 . "$module_name\n"
108- if not $$modules_href{$module_name};
109- }
110- return $failed_mods;
111-}
112
113=== added file 'lib-mvhub/lib/MVHub/Utils/Setup/CPANLibs.pm'
114--- lib-mvhub/lib/MVHub/Utils/Setup/CPANLibs.pm 1970-01-01 00:00:00 +0000
115+++ lib-mvhub/lib/MVHub/Utils/Setup/CPANLibs.pm 2011-09-03 14:01:26 +0000
116@@ -0,0 +1,120 @@
117+package MVHub::Utils::Setup::CPANLibs;
118+
119+use strict;
120+use warnings;
121+
122+use CPANPLUS::Backend;
123+
124+use autodie qw/ :all /;
125+
126+our @EXPORT = qw(
127+ update_cpan_libs
128+);
129+
130+sub update_cpan_libs {
131+
132+ my $cb = CPANPLUS::Backend->new(
133+ conf => {
134+ allow_build_interactivity => 'false',
135+ prereqs => 1,
136+ verbose => 'false',
137+ }
138+ );
139+
140+ my @modules = _get_cpan_modules();
141+ my $result = $cb->install( modules => \@modules );
142+
143+ if ( !$result ) {
144+ my $msg = "\n FAILED to install/update following cpan modules:\n";
145+ $msg .= _get_cpan_install_fails( $result->rv() );
146+ warn "$msg\n";
147+ }
148+ else {
149+ print "\nupdated cpan libs successfully\n";
150+ }
151+}
152+
153+sub _get_cpan_modules {
154+ return qw /
155+ Devel::NYTProf
156+ DBIx::XHTML_Table
157+ Search::Sitemap
158+ Set::Array
159+ SQL::Library
160+ Test::HTML::Lint
161+ Test::WWW::Mechanize
162+ Text::xSV
163+ WWW::Mechanize
164+ /;
165+}
166+
167+sub _get_cpan_install_fails {
168+ my $modules_href = shift;
169+
170+ my $failed_mods;
171+ foreach my $module_name ( sort keys %$modules_href ) {
172+ $failed_mods .= ' ' x 10 . "$module_name\n"
173+ if not $$modules_href{$module_name};
174+ }
175+ return $failed_mods;
176+}
177+
178+1;
179+__END__
180+
181+=head1 NAME
182+
183+MVHub::Utils::Setup::CPANLibs - Downloads and installs the CPAN modules MVHub requires
184+
185+=head1 SYNOPSIS
186+
187+ use MVHub::Utils::Setup::CPANLibs;
188+ MVHub::Utils::Setup::CPANLibs::update_cpan_libs()
189+ or die "Could not update CPAN libraries.\n";
190+
191+=head1 DESCRIPTION
192+
193+ Downloads and installs the CPAN modules required by MVHub.
194+ The modules to download are listed within the module code.
195+
196+=head1 SEE ALSO
197+
198+ MVHub::Utils::Setup
199+
200+=head1 SUBROUTINES
201+
202+=head2 _get_cpan_libs()
203+
204+ Private method that provides the names of the CPAN
205+ modules to download and install; modify this method
206+ to add/remove additional modules.
207+
208+=head2 update_cpan_libs()
209+
210+ Downloads and installs the CPAN modules retrieved
211+ from _get_cpan_libs.
212+
213+=head2 _get_cpan_install_fails()
214+
215+ Provides the error message to update_cpan_libs()
216+ for failed modules.
217+
218+=head1 DEPENDENCIES
219+
220+CPANPLUS::Backend (core module)
221+
222+=head1 LAST MODIFIED
223+
224+Last modified on $Date: 2011-08-12 12:00:00 +0530 (Sat, 12 Aug 2011) $ by $Author: emaadmanzoor $
225+
226+=head1 AUTHOR
227+
228+Community Software Lab E<lt>help@thecsl.org<gt>
229+
230+=head1 COPYRIGHT AND LICENSE
231+
232+The GNU Affero General Public License, version 3.0 or later
233+
234+Copyright (c) 2004-2008 Community Software Lab, Inc ( http://thecsl.org )
235+
236+=cut
237
238=== modified file 'lib-mvhub/t/01-load.t'
239--- lib-mvhub/t/01-load.t 2010-09-27 13:28:16 +0000
240+++ lib-mvhub/t/01-load.t 2011-09-03 14:01:26 +0000
241@@ -50,6 +50,11 @@
242 $module = ( split '\.', $module )[0];
243 push @modules, $module;
244 }
245+ elsif ( $file =~ m|lib/\w+/\w+/\w+/\w+\.pm$| ) {
246+ $module = join '::', ( split '/', $file )[ -4 .. -1 ];
247+ $module = ( split '\.', $module )[0];
248+ push @modules, $module;
249+ }
250 else {
251 warn "\n'$file'\n not matched \n";
252 }

Subscribers

People subscribed via source and target branches