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
=== modified file 'ChangeLog'
--- ChangeLog 2013-10-22 04:04:45 +0000
+++ ChangeLog 2013-12-02 03:32:16 +0000
@@ -1,3 +1,20 @@
12013-12-01 Felipe Figueiredo <philsf79@gmail.com>
2
3 * lib/MMRRSim/Config.pm (read_traps_file, read_acs_file): Provide
4 a more useful error message when aborting because of missing files.
5
6 * lib/MMRRSim/Config.pm (read_traps_file, read_acs_file): Provide
7 default files in distribution as shared data files. Don't
8 abort if they can be used when no local traps or ACs file is
9 available.
10
11 * lib/MMRRSim/Config.pm: Include dependency File::ShareDir;
12
13 * Makefile.PL: Include new build-dependency
14 File::ShareDir::Install.
15
16 * MANIFEST: File updated.
17
12013-10-22 Felipe Figueiredo <philsf79@gmail.com> MMRRSim 0.6.0182013-10-22 Felipe Figueiredo <philsf79@gmail.com> MMRRSim 0.6.0
219
3 * lib/MMRRSim.pm, lib/MMRRSim/Config.pm: Add new dependencies:20 * lib/MMRRSim.pm, lib/MMRRSim/Config.pm: Add new dependencies:
421
=== modified file 'MANIFEST'
--- MANIFEST 2013-10-16 22:00:20 +0000
+++ MANIFEST 2013-12-02 03:32:16 +0000
@@ -11,4 +11,6 @@
11MANIFEST.SKIP11MANIFEST.SKIP
12mmrrsim.ini12mmrrsim.ini
13README13README
14share/ac.csv
15share/traps.csv
14Traps_5_and_ACs_15.png16Traps_5_and_ACs_15.png
1517
=== modified file 'Makefile.PL'
--- Makefile.PL 2013-10-22 03:49:28 +0000
+++ Makefile.PL 2013-12-02 03:32:16 +0000
@@ -2,18 +2,27 @@
22
3use ExtUtils::MakeMaker;3use ExtUtils::MakeMaker;
44
5use File::ShareDir::Install;
6install_share dist => "share";
7
5WriteMakefile (8WriteMakefile (
6 NAME => 'MMRRSim',9 NAME => 'MMRRSim',
7 VERSION_FROM => 'lib/MMRRSim.pm',10 VERSION_FROM => 'lib/MMRRSim.pm',
8 ABSTRACT_FROM => 'lib/MMRRSim.pm',11 ABSTRACT_FROM => 'lib/MMRRSim.pm',
9 MIN_PERL_VERSION => '5.010',12 MIN_PERL_VERSION => '5.010',
1013
14 CONFIGURE_REQUIRES => {
15 ExtUtils::MakeMaker => 0,
16 File::ShareDir::Install => "0.03"
17 },
18
11 PREREQ_PM => {19 PREREQ_PM => {
12 Config::Simple => 0,20 Config::Simple => 0,
13 Moose => 0,21 Moose => 0,
14 Log::Handler => 0,22 Log::Handler => 0,
15 Text::CSV => 0,23 Text::CSV => 0,
16 POSIX => 0,24 POSIX => 0,
25 File::ShareDir => 0,
17 },26 },
18 27
19 EXE_FILES => [ 'bin/mmrrsim' ],28 EXE_FILES => [ 'bin/mmrrsim' ],
@@ -21,3 +30,7 @@
21 DISTNAME => 'MMRRSim',30 DISTNAME => 'MMRRSim',
22 AUTHOR => 'Felipe Figueiredo <ffigueiredo@fiocruz.br>',31 AUTHOR => 'Felipe Figueiredo <ffigueiredo@fiocruz.br>',
23 );32 );
33{
34 package MY;
35 use File::ShareDir::Install qw(postamble);
36}
2437
=== modified file 'lib/MMRRSim/Config.pm'
--- lib/MMRRSim/Config.pm 2013-10-22 02:59:43 +0000
+++ lib/MMRRSim/Config.pm 2013-12-02 03:32:16 +0000
@@ -6,6 +6,7 @@
6use Moose;6use Moose;
7use Config::Simple;7use Config::Simple;
8use Text::CSV;8use Text::CSV;
9use File::ShareDir;
910
10has config_file => (is => 'ro', isa => 'Str', default => 'mmrrsim.ini' );11has config_file => (is => 'ro', isa => 'Str', default => 'mmrrsim.ini' );
11has params => (is => 'rw', isa => 'HashRef', default => sub { {} } );12has params => (is => 'rw', isa => 'HashRef', default => sub { {} } );
@@ -39,7 +40,16 @@
3940
40sub read_traps_file {41sub read_traps_file {
41 my $self = shift;42 my $self = shift;
42 open(my $fh, "<", $self->traps_file) or die $!;43
44 my $traps_file = $self->traps_file;
45
46## If no traps file is present in the local dir, fall back to module
47## provided default file
48 if ( (! -r $traps_file) ) {
49 $traps_file = File::ShareDir::dist_file('MMRRSim','traps.csv');
50 }
51
52 open(my $fh, "<", $traps_file) or die "Problem opening traps file: $!";
43 my @traps;53 my @traps;
44 my $csv = Text::CSV->new({ eol => $\});54 my $csv = Text::CSV->new({ eol => $\});
45 while ( my $row = $csv->getline( $fh ) ) {55 while ( my $row = $csv->getline( $fh ) ) {
@@ -52,7 +62,17 @@
5262
53sub read_acs_file {63sub read_acs_file {
54 my $self = shift;64 my $self = shift;
55 open(my $fh, "<", $self->acs_file) or die $!;65 my $acs_file = $self->acs_file;
66
67## If no ACs file is present in the local dir, fall back to module
68## provided default file
69 if ( (! -r $acs_file) ) {
70 $acs_file = File::ShareDir::dist_file('MMRRSim','ac.csv');
71 }
72## If flight mode is not AC, we don't need an ACs file.
73 return if ( (! -r $acs_file) && ($self->params->{flight_mode} ne "AC") );
74
75 open(my $fh, "<", $acs_file) or die "Problem opening ACs file: $!";
56 my @acs;76 my @acs;
57 my $csv = Text::CSV->new({ eol => $\});77 my $csv = Text::CSV->new({ eol => $\});
58 while ( my $row = $csv->getline( $fh ) ) {78 while ( my $row = $csv->getline( $fh ) ) {
5979
=== added directory 'share'
=== renamed file 'ac.csv' => 'share/ac.csv'
=== renamed file 'traps.csv' => 'share/traps.csv'

Subscribers

People subscribed via source and target branches