pancake 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +95 -0
- data/Rakefile +56 -0
- data/TODO +17 -0
- data/bin/jeweler +19 -0
- data/bin/pancake-gen +17 -0
- data/bin/rubyforge +19 -0
- data/lib/pancake/bootloaders.rb +180 -0
- data/lib/pancake/configuration.rb +145 -0
- data/lib/pancake/constants.rb +5 -0
- data/lib/pancake/core_ext/class.rb +44 -0
- data/lib/pancake/core_ext/object.rb +22 -0
- data/lib/pancake/core_ext/symbol.rb +15 -0
- data/lib/pancake/defaults/configuration.rb +22 -0
- data/lib/pancake/defaults/middlewares.rb +1 -0
- data/lib/pancake/errors.rb +61 -0
- data/lib/pancake/generators/base.rb +12 -0
- data/lib/pancake/generators/micro_generator.rb +17 -0
- data/lib/pancake/generators/short_generator.rb +17 -0
- data/lib/pancake/generators/stack_generator.rb +17 -0
- data/lib/pancake/generators/templates/common/dotgitignore +22 -0
- data/lib/pancake/generators/templates/common/dothtaccess +17 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt +8 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +12 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/pancake.init.tt +1 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/public/.empty_directory +0 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/tmp/.empty_directory +0 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/views/root.html.haml +1 -0
- data/lib/pancake/generators/templates/short/%stack_name%/LICENSE.tt +20 -0
- data/lib/pancake/generators/templates/short/%stack_name%/README.tt +7 -0
- data/lib/pancake/generators/templates/short/%stack_name%/Rakefile.tt +50 -0
- data/lib/pancake/generators/templates/short/%stack_name%/VERSION.tt +1 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt +6 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +10 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/views/root.html.haml +2 -0
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +5 -0
- data/lib/pancake/generators/templates/short/%stack_name%/pancake.init.tt +1 -0
- data/lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt +7 -0
- data/lib/pancake/generators/templates/short/%stack_name%/spec/spec_helper.rb.tt +9 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/LICENSE.tt +20 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/README.tt +7 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/Rakefile.tt +50 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/VERSION.tt +1 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +18 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +18 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/router.rb.tt +6 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config.ru.tt +12 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/gems/cache/.empty_directory +0 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%.rb.tt +3 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/pancake.init.tt +1 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/spec/%stack_name%_spec.rb.tt +7 -0
- data/lib/pancake/generators/templates/stack/%stack_name%/spec/spec_helper.rb.tt +9 -0
- data/lib/pancake/generators.rb +8 -0
- data/lib/pancake/hooks/inheritable_inner_classes.rb +60 -0
- data/lib/pancake/hooks/on_inherit.rb +34 -0
- data/lib/pancake/logger.rb +200 -0
- data/lib/pancake/master.rb +123 -0
- data/lib/pancake/middleware.rb +347 -0
- data/lib/pancake/middlewares/logger.rb +16 -0
- data/lib/pancake/middlewares/static.rb +38 -0
- data/lib/pancake/mime_types.rb +265 -0
- data/lib/pancake/mixins/publish/action_options.rb +104 -0
- data/lib/pancake/mixins/publish.rb +125 -0
- data/lib/pancake/mixins/render/render.rb +168 -0
- data/lib/pancake/mixins/render/template.rb +23 -0
- data/lib/pancake/mixins/render/view_context.rb +21 -0
- data/lib/pancake/mixins/render.rb +109 -0
- data/lib/pancake/mixins/request_helper.rb +100 -0
- data/lib/pancake/mixins/stack_helper.rb +46 -0
- data/lib/pancake/mixins/url.rb +10 -0
- data/lib/pancake/paths.rb +218 -0
- data/lib/pancake/router.rb +99 -0
- data/lib/pancake/stack/app.rb +10 -0
- data/lib/pancake/stack/bootloader.rb +79 -0
- data/lib/pancake/stack/configuration.rb +44 -0
- data/lib/pancake/stack/middleware.rb +0 -0
- data/lib/pancake/stack/router.rb +21 -0
- data/lib/pancake/stack/stack.rb +66 -0
- data/lib/pancake/stacks/short/bootloaders.rb +13 -0
- data/lib/pancake/stacks/short/controller.rb +116 -0
- data/lib/pancake/stacks/short/default/views/base.html.haml +5 -0
- data/lib/pancake/stacks/short/stack.rb +187 -0
- data/lib/pancake/stacks/short.rb +3 -0
- data/lib/pancake.rb +58 -0
- data/spec/helpers/helpers.rb +20 -0
- data/spec/helpers/matchers.rb +25 -0
- data/spec/pancake/bootloaders_spec.rb +109 -0
- data/spec/pancake/configuration_spec.rb +177 -0
- data/spec/pancake/constants_spec.rb +7 -0
- data/spec/pancake/defaults/configuration_spec.rb +58 -0
- data/spec/pancake/fixtures/foo_stack/pancake.init +0 -0
- data/spec/pancake/fixtures/middlewares/other_public/two.html +1 -0
- data/spec/pancake/fixtures/middlewares/public/foo#bar.html +1 -0
- data/spec/pancake/fixtures/middlewares/public/one.html +1 -0
- data/spec/pancake/fixtures/paths/controllers/controller1.rb +0 -0
- data/spec/pancake/fixtures/paths/controllers/controller2.rb +0 -0
- data/spec/pancake/fixtures/paths/controllers/controller3.rb +0 -0
- data/spec/pancake/fixtures/paths/models/model1.rb +0 -0
- data/spec/pancake/fixtures/paths/models/model2.rb +0 -0
- data/spec/pancake/fixtures/paths/models/model3.rb +0 -0
- data/spec/pancake/fixtures/paths/stack/controllers/controller1.rb +0 -0
- data/spec/pancake/fixtures/paths/stack/models/model3.rb +0 -0
- data/spec/pancake/fixtures/paths/stack/views/view1.erb +0 -0
- data/spec/pancake/fixtures/paths/stack/views/view1.rb +0 -0
- data/spec/pancake/fixtures/paths/stack/views/view2.erb +0 -0
- data/spec/pancake/fixtures/paths/stack/views/view2.haml +0 -0
- data/spec/pancake/fixtures/render_templates/context_template.html.erb +2 -0
- data/spec/pancake/fixtures/render_templates/erb_template.html.erb +1 -0
- data/spec/pancake/fixtures/render_templates/erb_template.json.erb +1 -0
- data/spec/pancake/fixtures/render_templates/haml_template.html.haml +1 -0
- data/spec/pancake/fixtures/render_templates/haml_template.xml.haml +1 -0
- data/spec/pancake/fixtures/render_templates/templates/context.erb +2 -0
- data/spec/pancake/fixtures/render_templates/view_context/capture_erb.erb +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/capture_haml.haml +4 -0
- data/spec/pancake/fixtures/render_templates/view_context/concat_erb.erb +2 -0
- data/spec/pancake/fixtures/render_templates/view_context/concat_haml.haml +2 -0
- data/spec/pancake/fixtures/render_templates/view_context/context.erb +3 -0
- data/spec/pancake/fixtures/render_templates/view_context/context2.erb +3 -0
- data/spec/pancake/fixtures/render_templates/view_context/helper_methods.erb +3 -0
- data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_from_haml.erb +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_level_0.erb +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_level_1.erb +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_from_erb.haml +4 -0
- data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_level_0.haml +4 -0
- data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_level_1.haml +4 -0
- data/spec/pancake/fixtures/render_templates/view_context/nested_content_level_0.haml +6 -0
- data/spec/pancake/fixtures/render_templates/view_context/nested_content_level_1.haml +4 -0
- data/spec/pancake/fixtures/render_templates/view_context/nested_inner.erb +1 -0
- data/spec/pancake/fixtures/render_templates/view_context/nested_outer.erb +3 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_erb_0.erb +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_erb_1.erb +6 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_haml_0.erb +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_haml_1.erb +6 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_erb_0.haml +4 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_erb_1.haml +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_haml_0.haml +5 -0
- data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_haml_1.haml +5 -0
- data/spec/pancake/fixtures/stacks/short/foobar/other_root/views/base.html.haml +4 -0
- data/spec/pancake/fixtures/stacks/short/foobar/views/basic.html.haml +1 -0
- data/spec/pancake/fixtures/stacks/short/foobar/views/inherited_from_base.html.haml +5 -0
- data/spec/pancake/hooks/on_inherit_spec.rb +65 -0
- data/spec/pancake/inheritance_spec.rb +100 -0
- data/spec/pancake/middleware_spec.rb +401 -0
- data/spec/pancake/middlewares/logger_spec.rb +29 -0
- data/spec/pancake/middlewares/static_spec.rb +83 -0
- data/spec/pancake/mime_types_spec.rb +234 -0
- data/spec/pancake/mixins/publish_spec.rb +94 -0
- data/spec/pancake/mixins/render/template_spec.rb +69 -0
- data/spec/pancake/mixins/render/view_context_spec.rb +248 -0
- data/spec/pancake/mixins/render_spec.rb +56 -0
- data/spec/pancake/mixins/request_helper_spec.rb +27 -0
- data/spec/pancake/mixins/stack_helper_spec.rb +46 -0
- data/spec/pancake/pancake_spec.rb +90 -0
- data/spec/pancake/paths_spec.rb +210 -0
- data/spec/pancake/stack/app_spec.rb +28 -0
- data/spec/pancake/stack/bootloader_spec.rb +41 -0
- data/spec/pancake/stack/middleware_spec.rb +0 -0
- data/spec/pancake/stack/router_spec.rb +282 -0
- data/spec/pancake/stack/stack_configuration_spec.rb +101 -0
- data/spec/pancake/stack/stack_spec.rb +60 -0
- data/spec/pancake/stacks/short/controller_spec.rb +322 -0
- data/spec/pancake/stacks/short/middlewares_spec.rb +22 -0
- data/spec/pancake/stacks/short/router_spec.rb +136 -0
- data/spec/pancake/stacks/short/stack_spec.rb +64 -0
- data/spec/spec_helper.rb +23 -0
- metadata +294 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
module Pancake
|
2
|
+
module Errors
|
3
|
+
class HttpError < StandardError
|
4
|
+
class_inheritable_accessor :name, :code, :description
|
5
|
+
|
6
|
+
def name; self.class.name; end
|
7
|
+
|
8
|
+
def code; self.class.code; end
|
9
|
+
|
10
|
+
def description; self.class.description; end
|
11
|
+
end
|
12
|
+
|
13
|
+
class NotFound < HttpError
|
14
|
+
self.name = "Not Found"
|
15
|
+
self.code = 404
|
16
|
+
self.description = "The requested resource could not be found but may be available again in the future."
|
17
|
+
end
|
18
|
+
|
19
|
+
class UnknownRouter < NotFound
|
20
|
+
self.description = "The router could not be found"
|
21
|
+
end
|
22
|
+
|
23
|
+
class UnknownConfiguration < NotFound
|
24
|
+
self.description = "The configuration could not be found"
|
25
|
+
end
|
26
|
+
|
27
|
+
class Unauthorized < HttpError
|
28
|
+
self.name = "Unauthorized"
|
29
|
+
self.code = 401
|
30
|
+
self.description = "Authentication is required to access this resource."
|
31
|
+
end
|
32
|
+
|
33
|
+
class Forbidden < HttpError
|
34
|
+
self.name = "Forbidden"
|
35
|
+
self.code = 403
|
36
|
+
self.description = "Access to this resource is denied."
|
37
|
+
end
|
38
|
+
|
39
|
+
class Server < HttpError
|
40
|
+
attr_accessor :exceptions
|
41
|
+
|
42
|
+
self.name = "Server Error"
|
43
|
+
self.code = 500
|
44
|
+
self.description = "An internal server error"
|
45
|
+
|
46
|
+
def initialize(*args)
|
47
|
+
super
|
48
|
+
@exceptions = []
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class NotAcceptable < HttpError
|
53
|
+
self.name = "Not Acceptable"
|
54
|
+
self.code = 406
|
55
|
+
self.description = "The requeseted format could not be provided"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pancake
|
2
|
+
module Generators
|
3
|
+
class Micro < Base
|
4
|
+
argument :stack_name, :banner => "Name of stack"
|
5
|
+
|
6
|
+
desc "Generates a stack"
|
7
|
+
def stack
|
8
|
+
say "Creating The Stack For #{stack_name}"
|
9
|
+
directory "micro/%stack_name%", stack_name
|
10
|
+
template File.join(self.class.source_root, "common/dotgitignore"), "#{stack_name}/.gitignore"
|
11
|
+
template File.join(self.class.source_root, "common/dothtaccess"), "#{stack_name}/public/.htaccess"
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pancake
|
2
|
+
module Generators
|
3
|
+
class Short < Base
|
4
|
+
argument :stack_name, :banner => "Name of stack"
|
5
|
+
|
6
|
+
desc "Generates a short stack"
|
7
|
+
def stack
|
8
|
+
say "Creating The Short Stack For #{stack_name}"
|
9
|
+
directory "short/%stack_name%", stack_name
|
10
|
+
template File.join(self.class.source_root, "common/dotgitignore"), "#{stack_name}/.gitignore"
|
11
|
+
template File.join(self.class.source_root, "common/dothtaccess"), "#{stack_name}/lib/#{stack_name}/public/.htaccess"
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pancake
|
2
|
+
module Generators
|
3
|
+
class Stack < Base
|
4
|
+
argument :stack_name, :banner => "Name of stack"
|
5
|
+
|
6
|
+
desc "Generates a stack"
|
7
|
+
def stack
|
8
|
+
say "Creating The Stack For #{stack_name}"
|
9
|
+
directory "stack/%stack_name%", stack_name
|
10
|
+
template File.join(self.class.source_root, "common/dotgitignore"), "#{stack_name}/.gitignore"
|
11
|
+
template File.join(self.class.source_root, "common/dothtaccess"), "#{stack_name}/lib/#{stack_name}/public/.htaccess"
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
.DS_Store
|
2
|
+
log/*
|
3
|
+
tmp/*
|
4
|
+
TAGS
|
5
|
+
*~
|
6
|
+
.#*
|
7
|
+
schema/schema.rb
|
8
|
+
schema/*_structure.sql
|
9
|
+
schema/*.sqlite3
|
10
|
+
schema/*.sqlite
|
11
|
+
schema/*.db
|
12
|
+
*.sqlite
|
13
|
+
*.sqlite3
|
14
|
+
*.db
|
15
|
+
src/*
|
16
|
+
.hgignore
|
17
|
+
.hg/*
|
18
|
+
.svn/*
|
19
|
+
gems/gems/*/
|
20
|
+
gems/specifications/*
|
21
|
+
!gems/gems/thor*/
|
22
|
+
!gems/specifications/thor*
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Sets the default handler for FastCGI scripts
|
2
|
+
AddHandler fastcgi-script .fcgi
|
3
|
+
|
4
|
+
# If Apache2 is used together with mod_fcgid,
|
5
|
+
# uncomment the line below and comment in the line
|
6
|
+
# above to set the correct script handler
|
7
|
+
#AddHandler fcgid-script .fcgi
|
8
|
+
|
9
|
+
RewriteEngine On
|
10
|
+
|
11
|
+
RewriteRule ^$ index.html [QSA]
|
12
|
+
RewriteRule ^([^.]+)$ $1.html [QSA]
|
13
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
14
|
+
RewriteRule ^(.*)$ merb.fcgi [QSA,L]
|
15
|
+
|
16
|
+
|
17
|
+
ErrorDocument 500 "<h2>Application Error</h2>Merb could not be reached"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require 'pancake'
|
4
|
+
require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "<%= stack_name %>")
|
5
|
+
|
6
|
+
# get the application to run. The applicadtion in the Pancake.start block
|
7
|
+
# is the master application. It will have all requests directed to it through the
|
8
|
+
# pancake middleware
|
9
|
+
# This should be a very minimal file, but should be used when any stand alone code needs to be included
|
10
|
+
app = Pancake.start(:root => Pancake.get_root(__FILE__)){ <%= stack_name.camel_case %>.stackup }
|
11
|
+
|
12
|
+
run app
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__), "<%= stack_name %>"))
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
- inherits_from :base
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) <%= Date.today.year %> <YOUR NAME HERE>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "<%= stack_name %>"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "TODO"
|
10
|
+
gem.homepage = "TODO"
|
11
|
+
gem.authors = ["TODO"]
|
12
|
+
gem.add_dependency "pancake", ">=0.1.8"
|
13
|
+
gem.files = FileList["[A-Z]*", "pancake.init", "{lib,spec,rails}/**/*"]
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
if File.exist?('VERSION.yml')
|
39
|
+
config = YAML.load(File.read('VERSION.yml'))
|
40
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
41
|
+
else
|
42
|
+
version = ""
|
43
|
+
end
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "foo #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'pancake'
|
2
|
+
require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "..", "<%= stack_name %>")
|
3
|
+
|
4
|
+
# get the application to run. The applicadtion in the Pancake.start block
|
5
|
+
# is the master application. It will have all requests directed to it through the
|
6
|
+
# pancake middleware
|
7
|
+
# This should be a very minimal file, but should be used when any stand alone code needs to be included
|
8
|
+
app = Pancake.start(:root => Pancake.get_root(__FILE__)){ <%= stack_name.camel_case %>.stackup }
|
9
|
+
|
10
|
+
run app
|
data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory
ADDED
File without changes
|
data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory
ADDED
File without changes
|
data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "lib", "<%= stack_name %>")
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) <%= Date.today.year %> <YOUR NAME HERE>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "<%= stack_name %>"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "TODO"
|
10
|
+
gem.homepage = "TODO"
|
11
|
+
gem.authors = ["TODO"]
|
12
|
+
gem.add_dependency "pancake", ">=0.1.8"
|
13
|
+
gem.files = FileList["[A-Z]*", "pancake.init", "{lib,spec,rails}/**/*"]
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
if File.exist?('VERSION.yml')
|
39
|
+
config = YAML.load(File.read('VERSION.yml'))
|
40
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
41
|
+
else
|
42
|
+
version = ""
|
43
|
+
end
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "foo #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,18 @@
|
|
1
|
+
puts "Loading Development Environment"
|
2
|
+
|
3
|
+
# Get Access
|
4
|
+
Pancake.configuration.configs(<%= stack_name.camel_case %> ) do |config|
|
5
|
+
config.foo = :foo
|
6
|
+
end
|
7
|
+
|
8
|
+
# Allows Pancake to selectively apply middlewares in the stack.
|
9
|
+
# If a middleware is not declared with a specific stack label then it will always be loaded
|
10
|
+
# You can specify Middleware to be active under particular stack labels only however.
|
11
|
+
#
|
12
|
+
# Example
|
13
|
+
# <%= stack_name.camel_case %>.stack(:my_middlware, :labels => [:demo, :development]).use(Middlware, :with => :opts)
|
14
|
+
#
|
15
|
+
# This would only include the middleware Middlware in stacks with either the :demo, or :development label
|
16
|
+
#
|
17
|
+
# Setting The Pancake.stack_labels will use any relevant stacks
|
18
|
+
Pancake.stack_labels = [:development]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
puts "Loading Production Environment"
|
2
|
+
|
3
|
+
# Get Access
|
4
|
+
Pancake.configuration.configs(<%= stack_name.camel_case %> ) do |config|
|
5
|
+
# config.foo = :foo
|
6
|
+
end
|
7
|
+
|
8
|
+
# Allows Pancake to selectively apply middlewares in the stack.
|
9
|
+
# If a middleware is not declared with a specific stack label then it will always be loaded
|
10
|
+
# You can specify Middleware to be active under particular stack labels only however.
|
11
|
+
#
|
12
|
+
# Example
|
13
|
+
# <%= stack_name.camel_case %>.stack(:my_middlware, :labels => [:demo, :development]).use(Middlware, :with => :opts)
|
14
|
+
#
|
15
|
+
# This would only include the middleware Middlware in stacks with either the :demo, or :development label
|
16
|
+
#
|
17
|
+
# Setting The Pancake.stack_labels will use any relevant stacks
|
18
|
+
Pancake.stack_labels = [:production]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require 'pancake'
|
4
|
+
require Pancake.get_root(__FILE__, "<%= stack_name %>")
|
5
|
+
|
6
|
+
# get the application to run. The applicadtion in the Pancake.start block
|
7
|
+
# is the master application. It will have all requests directed to it through the
|
8
|
+
# pancake middleware
|
9
|
+
# This should be a very minimal file, but should be used when any stand alone code needs to be included
|
10
|
+
app = Pancake.start(:root => Pancake.get_root(__FILE__)){ <%= stack_name.camel_case %>.stackup }
|
11
|
+
|
12
|
+
run app
|
File without changes
|
data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/mounts/.empty_directory
ADDED
File without changes
|
data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/public/.empty_directory
ADDED
File without changes
|
data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/tmp/.empty_directory
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "lib", "<%= stack_name %>")
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Pancake
|
2
|
+
module Hooks
|
3
|
+
module InheritableInnerClasses
|
4
|
+
def self.extended(base)
|
5
|
+
base.class_eval do
|
6
|
+
class_inheritable_reader :_inhertiable_inner_classes
|
7
|
+
@_inhertiable_inner_classes = []
|
8
|
+
end
|
9
|
+
end # extended
|
10
|
+
|
11
|
+
# Declare inner classes to be inherited when the outer class in inherited
|
12
|
+
# The best way to show this is by example:
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# class Foo
|
16
|
+
# inheritable_inner_class :Bar
|
17
|
+
#
|
18
|
+
# class Bar
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# class Baz < Foo
|
23
|
+
# # When Foo is inherited, the following occurs
|
24
|
+
# class Bar < Foo::Bar; end
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# This provides a more organic inheritance where the child gets their own
|
28
|
+
# version of the inner class which is actually inherited from the parents inner class.
|
29
|
+
# The inheritance chain remains intact.
|
30
|
+
#
|
31
|
+
# @api public
|
32
|
+
# @since 0.1.0
|
33
|
+
# @author Daniel Neighman
|
34
|
+
def inheritable_inner_classes(*classes)
|
35
|
+
_inhertiable_inner_classes
|
36
|
+
unless classes.empty?
|
37
|
+
_inhertiable_inner_classes << classes
|
38
|
+
_inhertiable_inner_classes.flatten!
|
39
|
+
end
|
40
|
+
_inhertiable_inner_classes
|
41
|
+
end
|
42
|
+
|
43
|
+
# The inherited hook that sets up inherited inner classes. Remember if you overwrite this method, you should
|
44
|
+
# call super!
|
45
|
+
#
|
46
|
+
# @api private
|
47
|
+
# @since 0.1.0
|
48
|
+
# @author Daniel Neighman
|
49
|
+
def inherited(base)
|
50
|
+
super
|
51
|
+
class_defs = inheritable_inner_classes.map do |klass|
|
52
|
+
"class #{klass} < superclass::#{klass}; end\n"
|
53
|
+
end
|
54
|
+
# puts "#{base.name} is INHERITING INNER CLASSES #{class_defs.inspect}"
|
55
|
+
base.class_eval(class_defs.join)
|
56
|
+
end
|
57
|
+
|
58
|
+
end # InheritableInnerClasses
|
59
|
+
end # Hooks
|
60
|
+
end # Pancake
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pancake
|
2
|
+
module Hooks
|
3
|
+
module OnInherit
|
4
|
+
def self.extended(base)
|
5
|
+
base.class_eval do
|
6
|
+
class_inheritable_reader :_on_inherit
|
7
|
+
@_on_inherit = []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Provides an inheritance hook to all extended classes
|
12
|
+
# Allows ou to hook into the inheritance
|
13
|
+
def inherited(base)
|
14
|
+
super
|
15
|
+
_on_inherit.each{|b| b.call(base,self)}
|
16
|
+
end
|
17
|
+
|
18
|
+
# A hook to add code when the stack is inherited
|
19
|
+
# The code will be executed when the class is inherited
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# MyClass.on_inherit do |base, parent|
|
23
|
+
# # do stuff here between the child and parent
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# @api public
|
27
|
+
# @author Daniel Neighman
|
28
|
+
def on_inherit(&block)
|
29
|
+
_on_inherit << block if block
|
30
|
+
_on_inherit
|
31
|
+
end
|
32
|
+
end # OnInherit
|
33
|
+
end # Hooks
|
34
|
+
end # Pancake
|