[Catalyst-commits] r10311 - in
Catalyst-Devel/1.00/branches/helper_refactor: lib/Catalyst t
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Wed May 27 09:33:13 GMT 2009
Author: dhoss
Date: 2009-05-27 09:33:13 +0000 (Wed, 27 May 2009)
New Revision: 10311
Added:
Catalyst-Devel/1.00/branches/helper_refactor/t/create_files.t
Modified:
Catalyst-Devel/1.00/branches/helper_refactor/lib/Catalyst/Helper.pm
Log:
added test file for new file dealings, as well as get_template_files, get_image, and get_version dir. Now using Moose, Path::Class and File::ShareDir
Modified: Catalyst-Devel/1.00/branches/helper_refactor/lib/Catalyst/Helper.pm
===================================================================
--- Catalyst-Devel/1.00/branches/helper_refactor/lib/Catalyst/Helper.pm 2009-05-27 08:33:17 UTC (rev 10310)
+++ Catalyst-Devel/1.00/branches/helper_refactor/lib/Catalyst/Helper.pm 2009-05-27 09:33:13 UTC (rev 10311)
@@ -2,7 +2,6 @@
use strict;
use warnings;
-use base 'Class::Accessor::Fast';
use Config;
use File::Spec;
use File::Path;
@@ -13,7 +12,13 @@
use Catalyst::Devel;
use Catalyst::Utils;
use Catalyst::Exception;
+use Moose;
+use File::ShareDir qw/dist_dir/;
+use Path::Class qw/file dir/;
+#use Method::Signatures::Simple;
+#use namespace::autoclean;
+
my %cache;
=head1 NAME
@@ -33,7 +38,7 @@
$cache{$class} = eval "package $class; <DATA>";
}
my $data = $cache{$class};
- my @files = split /^__(.+)__\r?\n/m, $data;
+ my @files = $self->get_files;
shift @files;
while (@files) {
my ( $name, $content ) = splice @files, 0, 2;
@@ -457,6 +462,55 @@
}
}
+
+=head2 get_version_dir
+get the version of the dist specified and return a Path::Class::Dir object
+=cut
+
+sub get_version_dir {
+ my ( $self, $version ) = @_;
+
+ return dir( dist_dir('Catalyst-Devel'), $version );
+
+}
+
+=head2 get_files
+
+open up our File::ShareDir directory, loop through, and get our template files
+
+=cut
+
+sub get_template_files {
+ my ($self, $version) = @_;
+
+ my $dir = $self->get_version_dir($version);
+
+ my $dh = $dir->open or die "Can't open: $!";
+ my @files = ();
+ # get everything with a .tt/.tt2 extension
+ while (my $file = $dh->read) {
+ $file = $dir->file($file); # Turn into Path::Class::File object
+
+ if ( $file =~ /+\.(tt|tt2)/ ) {
+ push @files, $file;
+ }
+ }
+
+ return @files;
+
+}
+
+=head2 get_images
+
+get all of our image files
+
+=cut
+sub get_images {
+ my ( $self, $version, $name ) = shift;
+ my $dir = $self->get_version_dir($version);
+ return file($dir, $name);
+}
+
=head1 DESCRIPTION
This module is used by B<catalyst.pl> to create a set of scripts for a
Added: Catalyst-Devel/1.00/branches/helper_refactor/t/create_files.t
===================================================================
--- Catalyst-Devel/1.00/branches/helper_refactor/t/create_files.t (rev 0)
+++ Catalyst-Devel/1.00/branches/helper_refactor/t/create_files.t 2009-05-27 09:33:13 UTC (rev 10311)
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+
+use FindBin qw/$Bin/;
+
+use Test::More tests => 1;
+
+use Catalyst::Helper;
+
+my $helper = Catalyst::Helper->new;
+
+
More information about the Catalyst-commits
mailing list