Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 8c72c65d31e1978e991dd74b4ee4661fb32f730e 0 parents
Yusuke Wada authored
12 .gitignore
@@ -0,0 +1,12 @@
+cover_db
+META.yml
+Makefile
+blib
+inc
+pm_to_blib
+MANIFEST
+Makefile.old
+tmon.out
+cover_db_view
+nytprof
+.DS_Store
2  .shipit
@@ -0,0 +1,2 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
+svk.tagpattern = release-%v
4 Changes
@@ -0,0 +1,4 @@
+Revision history for Perl extension Noe
+
+0.01 Tue Sep 8 23:10:55 2009
+ - original version
19 MANIFEST.SKIP
@@ -0,0 +1,19 @@
+\bRCS\b
+\bCVS\b
+^MANIFEST\.
+^Makefile$
+~$
+^#
+\.old$
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+\.gz$
+\.cvsignore
+^t/9\d_.*\.t
+^t/perlcritic
+^tools/
+\.svn/
+^[^/]+\.yaml$
+^[^/]+\.pl$
+^\.shipit$
13 Makefile.PL
@@ -0,0 +1,13 @@
+use inc::Module::Install;
+name 'Noe';
+all_from 'lib/Noe.pm';
+
+# requires '';
+
+tests 't/*.t';
+author_tests 'xt';
+
+build_requires 'Test::More';
+use_test_base;
+auto_include;
+WriteAll;
27 README
@@ -0,0 +1,27 @@
+This is Perl module Noe.
+
+INSTALLATION
+
+Noe installation is straightforward. If your CPAN shell is set up,
+you should just be able to do
+
+ % cpan Noe
+
+Download it, unpack it, then build it as per the usual:
+
+ % perl Makefile.PL
+ % make && make test
+
+Then install it:
+
+ % make install
+
+DOCUMENTATION
+
+Noe documentation is available as in POD. So you can do:
+
+ % perldoc Noe
+
+to read the documentation online with your favorite pager.
+
+Yusuke Wada
5 eg/MyApp/lib/MyApp.pm
@@ -0,0 +1,5 @@
+package MyApp;
+use Mouse;
+extends 'Noe';
+
+1;
12 eg/MyApp/lib/MyApp/Controller/Root.pm
@@ -0,0 +1,12 @@
+package MyApp::Controller::Root;
+use Mouse;
+with 'Noe::Controller';
+
+sub root {
+ my $req = shift;
+ render('index.tt2');
+}
+
+1;
+
+__END__
7 eg/MyApp/lib/MyApp/Dispatcher.pm
@@ -0,0 +1,7 @@
+package MyApp::Dispatcher;
+use Mouse;
+use HTTPx::Dispatcher;
+
+connect '' => {controller => 'Root', action => 'root'};
+
+1;
13 eg/MyApp/tmpl/index.tt2
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
+<title>Hello, Noe!</title>
+</head>
+
+<body>
+<h1>Hello, Noe!</h1>
+<hr>
+<address></address>
+<!-- hhmts start -->Last modified: Wed Sep 9 01:22:58 JST 2009 <!-- hhmts end -->
+</body> </html>
36 lib/Noe.pm
@@ -0,0 +1,36 @@
+package Noe;
+use Mouse;
+our $VERSION = '0.01';
+use Noe::Plack::Adapter;
+
+sub plack_adapter {
+ return '+Noe::Plack::Adapter';
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Noe -
+
+=head1 SYNOPSIS
+
+ use Noe;
+
+=head1 DESCRIPTION
+
+Noe is
+
+=head1 AUTHOR
+
+Yusuke Wada E<lt>yusuke at kamawada.comE<gt>
+
+=head1 SEE ALSO
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
18 lib/Noe/Controller.pm
@@ -0,0 +1,18 @@
+package Noe::Controller;
+use Mouse::Role;
+use Template;
+use Path::Class;
+
+sub render {
+ my ( $tmpl, %args ) = @_;
+ my $config = { INCLUDE_PATH => [ Noe::c->base_dir->subdir('tmpl') ], };
+ my $template = Template->new($config);
+ my $out;
+ $template->process( 'index.tt2', \%args, \$out )
+ || die $template->error(), "\n";
+ return [ 200, [ 'Content-Type' => 'text/html' ], [ $out ], ];
+}
+
+1;
+
+__END__
49 lib/Noe/Plack/Adapter.pm
@@ -0,0 +1,49 @@
+package Noe::Plack::Adapter;
+use Mouse;
+use Plack::Request;
+use Path::Class;
+use UNIVERSAL::require;
+
+has app => ( is => 'ro', isa => 'Str', required => 1 );
+has base_dir => (
+ is => 'rw',
+ isa => 'Path::Class::Dir',
+ lazy_build => 1,
+);
+
+sub _build_base_dir {
+ my $self = shift;
+ my $p = $self->app() . ".pm";
+ $p =~ s!::!/!g;
+ my $path = $INC{$p};
+ $path =~ s!lib/$p$!!;
+ dir($path);
+}
+
+sub BUILDARGS {
+ my ( $class, $app ) = @_;
+ return +{ app => $app };
+}
+
+sub handler {
+ my $self = shift;
+ return sub {
+ my $req = Plack::Request->new(shift);
+ local *Noe::c = sub { $self };
+ my $app = $self->app;
+ my $dispatcher = "${app}::Dispatcher";
+ $dispatcher->require or die $@;
+ my $rule = $dispatcher->match($req);
+ if ($rule) {
+ my $controller = "${app}::Controller::$rule->{controller}";
+ $controller->require;
+ my $method = $rule->{action};
+ return $controller->$method($req);
+ }
+ else {
+ }
+ }
+}
+
+1;
+__END__
4 t/00_compile.t
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Noe' }
10 xt/01_podspell.t
@@ -0,0 +1,10 @@
+use Test::More;
+eval q{ use Test::Spelling };
+plan skip_all => "Test::Spelling is not installed." if $@;
+add_stopwords(map { split /[\s\:\-]/ } <DATA>);
+$ENV{LANG} = 'C';
+all_pod_files_spelling_ok('lib');
+__DATA__
+Yusuke Wada
+yusuke at kamawada.com
+Noe
8 xt/02_perlcritic.t
@@ -0,0 +1,8 @@
+use strict;
+use Test::More;
+eval {
+ require Test::Perl::Critic;
+ Test::Perl::Critic->import( -profile => 'xt/perlcriticrc');
+};
+plan skip_all => "Test::Perl::Critic is not installed." if $@;
+all_critic_ok('lib');
4 xt/03_pod.t
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
2  xt/perlcriticrc
@@ -0,0 +1,2 @@
+[TestingAndDebugging::ProhibitNoStrict]
+allow=refs
Please sign in to comment.
Something went wrong with that request. Please try again.