Permalink
Browse files

refactored project structure

  • Loading branch information...
1 parent 62d5813 commit 1be9fa9416db05464d9bae1df25e8f654c86fac1 @dann committed Mar 11, 2009
@@ -67,7 +67,7 @@ requires(
# Script
'Pod::Simple::Text' => 0,
- 'MouseX::Getopt' => '0.04',
+ 'MouseX::Getopt' => '0.05',
'IPC::System::Simple' => 0,
'App::Cmd' => '0.202',
'Module::Setup' => 0,
@@ -43,7 +43,7 @@ sub plugins {
return $plugin;
}
}
- return undef;
+ return;
}
return wantarray ? @{$plugins} : $plugins;
}
@@ -62,7 +62,7 @@ sub mixins {
return $mixin;
}
}
- return undef;
+ return;
}
return wantarray ? @{$mixins} : $mixins;
}
@@ -116,7 +116,7 @@ sub _get {
my $section = shift;
my $var = shift;
unless ( $self->{config}->{$section} ) {
- return undef;
+ return;
}
unless ($var) {
@@ -1,63 +0,0 @@
-package Angelos::I18N::Localizer::LocaleMaketextSimple;
-use Angelos::Class;
-use Angelos::Exceptions;
-with 'Angelos::I18N::Localizer::Role';
-
-has '_loc' => ( is => 'rw', );
-
-has '_loc_lang' => ( is => 'rw', );
-
-=head1 NAME
-
-
-=head1 SYNOPSIS
-
-
-=head1 Methods
-
-=head2 loc("string [_1]", $arg)
-
-See Locale::Maketext::Simple.
-
-=cut
-
-=head2 loc_lang
-
-Set the locale.
-See Locale::Maketext::Simple.
-
-=head1 Localization Files
-
-The .po files are kept in conf/locales.
-
-=cut
-
-sub BUILD {
- my $self = shift;
- require Locale::Maketext::Simple;
- my $config = {
- Path => $self->po_dir,
- Style => 'maketext',
- Export => 'loc',
- Subclass => 'I18N',
- };
- my ( $loc, $loc_lang ) = Locale::Maketext::Simple->load_loc(%$config);
- $loc ||= Locale::Maketext::Simple->default_loc(%$config);
- $self->_loc($loc);
- $self->_loc_lang($loc_lang);
- $self;
-}
-
-sub loc {
- my ( $self, $message, @arg ) = @_;
- $self->_loc->( $message, @arg );
-}
-
-sub loc_lang {
- my ( $self, $lang ) = @_;
- $self->_loc_lang->($lang);
-}
-
-__END_OF_CLASS__
-
-__END__
@@ -1,27 +1,33 @@
package Angelos::ProjectStructure;
use Angelos::Class;
+use Path::Class;
has 'home' => (
is => 'rw',
isa => 'Angelos::Home',
);
+sub conf_dir {
+ my $self = shift;
+ $self->home->path_to('conf');
+}
+
sub logger_config_file_path {
my $self = shift;
- $self->home->path_to( 'conf', 'log.yaml' );
+ file( $self->conf_dir, 'log.yaml' );
}
sub routes_config_file_path {
my $self = shift;
- $self->home->path_to( 'conf', 'routes.pl' );
+ file( $self->conf_dir, 'routes.pl' );
}
sub config_file_path {
my ( $self, $environment ) = @_;
my $extension = '.yaml';
$environment ||= $self->environment;
my $config_filename = $environment . $extension;
- $self->home->path_to( 'conf', 'environments', $config_filename ),;
+ file( $self->conf_dir, 'environments', $config_filename );
}
sub environment {
@@ -38,14 +44,14 @@ sub root_dir {
$self->home->path_to( 'share', 'root' );
}
-sub po_dir {
+sub po_dir {
my $self = shift;
$self->home->path_to( 'share', 'po' );
}
sub templates_dir {
my $self = shift;
- $self->home->path_to( $self->root_dir, 'templates' );
+ dir( $self->root_dir, 'templates' );
}
__END_OF_CLASS__
@@ -6,40 +6,50 @@ use UNIVERSAL::require;
with 'MouseX::Getopt';
has 'host' => (
+ metaclass => 'Getopt',
is => 'rw',
isa => 'Str',
default => 0,
+ cmd_aliases => [qw(h)],
);
has 'server' => (
+ metaclass => 'Getopt',
is => 'rw',
isa => 'Str',
default => 'ServerSimple',
+ cmd_aliases => [qw(s)],
);
has 'port' => (
+ metaclass => 'Getopt',
is => 'rw',
isa => 'Int',
default => 3000,
required => 1,
+ cmd_aliases => [qw(h)],
);
has 'debug' => (
+ metaclass => 'Getopt',
is => 'rw',
isa => 'Bool',
- default => 0
+ default => 0,
+ cmd_aliases => [qw(d)],
);
has 'app' => (
+ metaclass => 'Getopt',
is => 'rw',
isa => 'Str',
required => 1,
);
has 'help' => (
+ metaclass => 'Getopt',
is => 'rw',
isa => 'Bool',
- default => 0
+ default => 0,
);
sub run {
@@ -19,10 +19,8 @@ has 'types' => (
has 'root' => (
is => 'rw',
- default => sub {
- my $self = shift;
- Angelos::Utils::context->project_structure->templates_dir;
- },
+ lazy => 1,
+ builder => 'build_root',
);
has 'CONTENT_TYPE' => (
@@ -43,6 +41,11 @@ sub BUILD {
$self->engine($template_engine) if $template_engine;
}
+sub build_root {
+ my $self = shift;
+ $self->context->project_structure->templates_dir;
+}
+
sub context {
Angelos::Registrar::context();
}
@@ -76,12 +79,12 @@ sub RENDER {
my $c = $self->context;
my $template = $self->_template( $c, $opts->{template} );
my $template_path = $self->_template_path( $c, $opts->{template} );
- return undef unless $template || $template_path;
+ return unless $template || $template_path;
$self->_build_stash($c);
my $vars = $self->_build_template_vars( $c, $opts->{params} );
my $output = $self->_do_render( $c, $vars );
- return undef unless $output;
+ return unless $output;
$self->_build_response( $c, $output );
return 1;

0 comments on commit 1be9fa9

Please sign in to comment.