Permalink
Browse files

Basename,realpathをフレームワーク側に移動

  • Loading branch information...
1 parent ec8b278 commit a59980807229104a6cfa42dd726a6c5a2cb9a50f @kazeburo committed Jul 8, 2010
Showing with 14 additions and 7 deletions.
  1. +2 −0 Makefile.PL
  2. +10 −0 lib/Shirahata.pm
  3. +2 −7 nonopaste.psgi
View
@@ -20,6 +20,8 @@ requires 'Router::Simple';
requires 'Text::MicroTempate::DataSection';
requires 'Text::MicroTempate::Extended', 0.11;
requires 'HTML::FillInForm::Lite', 1.09;
+requires 'Cwd';
+requires 'File::Basename';
requires 'DBI';
requires 'DBD::SQLite', 1.25;
View
@@ -7,6 +7,8 @@ use Scalar::Util qw/blessed/;
use base qw/Class::Accessor::Fast/;
use Plack::Builder;
use Router::Simple;
+use Cwd qw/realpath/;
+use File::Basename qw/dirname/;
use Path::Class;
use Net::IP;
@@ -35,11 +37,19 @@ sub import {
sub new {
my $class = shift;
my $root_dir = shift;
+ my @caller = caller;
+ $root_dir ||= dirname( realpath($caller[1]) );
$class->SUPER::new({ root_dir => $root_dir });
}
sub psgi {
my $self = shift;
+ if ( ! ref $self ) {
+ my $root_dir = shift;
+ my @caller = caller;
+ $root_dir ||= dirname( realpath($caller[1]) );
+ $self = $self->new($root_dir);
+ }
my @allowfrom = map { s/\s//g } split(/,/, $ENV{ACCESS_ALLOW_FROM} || "");
my @frontproxy = map { s/\s//g } split(/,/, $ENV{FRONT_PROXY} || "");
View
@@ -1,12 +1,7 @@
#!/usr/bin/perl
-use strict;
-use warnings;
-use Cwd qw/realpath/;
-use File::Basename qw/dirname/;
use NoNoPaste;
-my $root_dir = dirname( realpath(__FILE__) );
-my $web = NoNoPaste->new($root_dir);
-$web->psgi;
+NoNoPaste->psgi();
+

0 comments on commit a599808

Please sign in to comment.