aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-02-23 17:46:46 +0000
committerEdmund von der Burg <evdb@mysociety.org>2011-02-23 17:46:46 +0000
commitfe18ee66aa7d97a070990731316152b74b132e65 (patch)
treec46f792435e1cbe7a3f18d9b538240b570e0b772
parent1498dfdec73becf769c3596bf41185f003c2a4cf (diff)
FMS util module and tests
-rw-r--r--perllib/FixMyStreet.pm39
-rw-r--r--t/fixmystreet.t16
2 files changed, 55 insertions, 0 deletions
diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm
new file mode 100644
index 000000000..25c4599d3
--- /dev/null
+++ b/perllib/FixMyStreet.pm
@@ -0,0 +1,39 @@
+package FixMyStreet;
+
+use strict;
+use warnings;
+
+use Path::Class;
+
+=head1 NAME
+
+FixMyStreet
+
+=head1 DESCRIPTION
+
+FixMyStreet is a webite where you can report issues and have them routed to the
+correct authority so that they can be fixed.
+
+Thus module has utility functions for the FMS project.
+
+=head1 METHODS
+
+=head2 path_to
+
+ $path = FixMyStreet->path_to( 'conf/general' );
+
+Returns an absolute Path::Class object representing the path to the arguments in
+the FixMyStreet directory.
+
+=cut
+
+my $ROOT_DIR = file(__FILE__)->parent->parent->absolute;
+
+sub path_to {
+ my $self = shift;
+ return $ROOT_DIR->file(@_);
+}
+
+
+
+1;
diff --git a/t/fixmystreet.t b/t/fixmystreet.t
new file mode 100644
index 000000000..c1b3f0075
--- /dev/null
+++ b/t/fixmystreet.t
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+use Path::Class;
+
+use Test::More tests => 4;
+
+use_ok 'FixMyStreet';
+
+# check that the path_to works
+my $file_path = file(__FILE__)->absolute->stringify;
+my $path_to_path = FixMyStreet->path_to('t/fixmystreet.t');
+
+isa_ok $path_to_path, 'Path::Class::File';
+ok $path_to_path->is_absolute, "path is absolute";
+is "$path_to_path", $file_path, "got $file_path";
+