Merge lp:~philsf/mmrrsim/fix-lp-1255148 into lp:mmrrsim

Proposed by Felipe Figueiredo
Status: Merged
Merged at revision: 224
Proposed branch: lp:~philsf/mmrrsim/fix-lp-1255148
Merge into: lp:mmrrsim
Diff against target: 128 lines (+54/-2)
4 files modified
ChangeLog (+17/-0)
MANIFEST (+2/-0)
Makefile.PL (+13/-0)
lib/MMRRSim/Config.pm (+22/-2)
To merge this branch: bzr merge lp:~philsf/mmrrsim/fix-lp-1255148
Reviewer Review Type Date Requested Status
Felipe Figueiredo Approve
Review via email: mp+197308@code.launchpad.net
To post a comment you must log in.
lp:~philsf/mmrrsim/fix-lp-1255148 updated
234. By Felipe Figueiredo

* ChangeLog: File updated.

Revision history for this message
Felipe Figueiredo (philsf) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-10-22 04:04:45 +0000
3+++ ChangeLog 2013-12-02 03:32:16 +0000
4@@ -1,3 +1,20 @@
5+2013-12-01 Felipe Figueiredo <philsf79@gmail.com>
6+
7+ * lib/MMRRSim/Config.pm (read_traps_file, read_acs_file): Provide
8+ a more useful error message when aborting because of missing files.
9+
10+ * lib/MMRRSim/Config.pm (read_traps_file, read_acs_file): Provide
11+ default files in distribution as shared data files. Don't
12+ abort if they can be used when no local traps or ACs file is
13+ available.
14+
15+ * lib/MMRRSim/Config.pm: Include dependency File::ShareDir;
16+
17+ * Makefile.PL: Include new build-dependency
18+ File::ShareDir::Install.
19+
20+ * MANIFEST: File updated.
21+
22 2013-10-22 Felipe Figueiredo <philsf79@gmail.com> MMRRSim 0.6.0
23
24 * lib/MMRRSim.pm, lib/MMRRSim/Config.pm: Add new dependencies:
25
26=== modified file 'MANIFEST'
27--- MANIFEST 2013-10-16 22:00:20 +0000
28+++ MANIFEST 2013-12-02 03:32:16 +0000
29@@ -11,4 +11,6 @@
30 MANIFEST.SKIP
31 mmrrsim.ini
32 README
33+share/ac.csv
34+share/traps.csv
35 Traps_5_and_ACs_15.png
36
37=== modified file 'Makefile.PL'
38--- Makefile.PL 2013-10-22 03:49:28 +0000
39+++ Makefile.PL 2013-12-02 03:32:16 +0000
40@@ -2,18 +2,27 @@
41
42 use ExtUtils::MakeMaker;
43
44+use File::ShareDir::Install;
45+install_share dist => "share";
46+
47 WriteMakefile (
48 NAME => 'MMRRSim',
49 VERSION_FROM => 'lib/MMRRSim.pm',
50 ABSTRACT_FROM => 'lib/MMRRSim.pm',
51 MIN_PERL_VERSION => '5.010',
52
53+ CONFIGURE_REQUIRES => {
54+ ExtUtils::MakeMaker => 0,
55+ File::ShareDir::Install => "0.03"
56+ },
57+
58 PREREQ_PM => {
59 Config::Simple => 0,
60 Moose => 0,
61 Log::Handler => 0,
62 Text::CSV => 0,
63 POSIX => 0,
64+ File::ShareDir => 0,
65 },
66
67 EXE_FILES => [ 'bin/mmrrsim' ],
68@@ -21,3 +30,7 @@
69 DISTNAME => 'MMRRSim',
70 AUTHOR => 'Felipe Figueiredo <ffigueiredo@fiocruz.br>',
71 );
72+{
73+ package MY;
74+ use File::ShareDir::Install qw(postamble);
75+}
76
77=== modified file 'lib/MMRRSim/Config.pm'
78--- lib/MMRRSim/Config.pm 2013-10-22 02:59:43 +0000
79+++ lib/MMRRSim/Config.pm 2013-12-02 03:32:16 +0000
80@@ -6,6 +6,7 @@
81 use Moose;
82 use Config::Simple;
83 use Text::CSV;
84+use File::ShareDir;
85
86 has config_file => (is => 'ro', isa => 'Str', default => 'mmrrsim.ini' );
87 has params => (is => 'rw', isa => 'HashRef', default => sub { {} } );
88@@ -39,7 +40,16 @@
89
90 sub read_traps_file {
91 my $self = shift;
92- open(my $fh, "<", $self->traps_file) or die $!;
93+
94+ my $traps_file = $self->traps_file;
95+
96+## If no traps file is present in the local dir, fall back to module
97+## provided default file
98+ if ( (! -r $traps_file) ) {
99+ $traps_file = File::ShareDir::dist_file('MMRRSim','traps.csv');
100+ }
101+
102+ open(my $fh, "<", $traps_file) or die "Problem opening traps file: $!";
103 my @traps;
104 my $csv = Text::CSV->new({ eol => $\});
105 while ( my $row = $csv->getline( $fh ) ) {
106@@ -52,7 +62,17 @@
107
108 sub read_acs_file {
109 my $self = shift;
110- open(my $fh, "<", $self->acs_file) or die $!;
111+ my $acs_file = $self->acs_file;
112+
113+## If no ACs file is present in the local dir, fall back to module
114+## provided default file
115+ if ( (! -r $acs_file) ) {
116+ $acs_file = File::ShareDir::dist_file('MMRRSim','ac.csv');
117+ }
118+## If flight mode is not AC, we don't need an ACs file.
119+ return if ( (! -r $acs_file) && ($self->params->{flight_mode} ne "AC") );
120+
121+ open(my $fh, "<", $acs_file) or die "Problem opening ACs file: $!";
122 my @acs;
123 my $csv = Text::CSV->new({ eol => $\});
124 while ( my $row = $csv->getline( $fh ) ) {
125
126=== added directory 'share'
127=== renamed file 'ac.csv' => 'share/ac.csv'
128=== renamed file 'traps.csv' => 'share/traps.csv'

Subscribers

People subscribed via source and target branches