pancake 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. data/LICENSE +20 -0
  2. data/README.textile +95 -0
  3. data/Rakefile +56 -0
  4. data/TODO +17 -0
  5. data/bin/jeweler +19 -0
  6. data/bin/pancake-gen +17 -0
  7. data/bin/rubyforge +19 -0
  8. data/lib/pancake/bootloaders.rb +180 -0
  9. data/lib/pancake/configuration.rb +145 -0
  10. data/lib/pancake/constants.rb +5 -0
  11. data/lib/pancake/core_ext/class.rb +44 -0
  12. data/lib/pancake/core_ext/object.rb +22 -0
  13. data/lib/pancake/core_ext/symbol.rb +15 -0
  14. data/lib/pancake/defaults/configuration.rb +22 -0
  15. data/lib/pancake/defaults/middlewares.rb +1 -0
  16. data/lib/pancake/errors.rb +61 -0
  17. data/lib/pancake/generators/base.rb +12 -0
  18. data/lib/pancake/generators/micro_generator.rb +17 -0
  19. data/lib/pancake/generators/short_generator.rb +17 -0
  20. data/lib/pancake/generators/stack_generator.rb +17 -0
  21. data/lib/pancake/generators/templates/common/dotgitignore +22 -0
  22. data/lib/pancake/generators/templates/common/dothtaccess +17 -0
  23. data/lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt +8 -0
  24. data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +12 -0
  25. data/lib/pancake/generators/templates/micro/%stack_name%/pancake.init.tt +1 -0
  26. data/lib/pancake/generators/templates/micro/%stack_name%/public/.empty_directory +0 -0
  27. data/lib/pancake/generators/templates/micro/%stack_name%/tmp/.empty_directory +0 -0
  28. data/lib/pancake/generators/templates/micro/%stack_name%/views/root.html.haml +1 -0
  29. data/lib/pancake/generators/templates/short/%stack_name%/LICENSE.tt +20 -0
  30. data/lib/pancake/generators/templates/short/%stack_name%/README.tt +7 -0
  31. data/lib/pancake/generators/templates/short/%stack_name%/Rakefile.tt +50 -0
  32. data/lib/pancake/generators/templates/short/%stack_name%/VERSION.tt +1 -0
  33. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt +6 -0
  34. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +10 -0
  35. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  36. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  37. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  38. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/views/root.html.haml +2 -0
  39. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +5 -0
  40. data/lib/pancake/generators/templates/short/%stack_name%/pancake.init.tt +1 -0
  41. data/lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt +7 -0
  42. data/lib/pancake/generators/templates/short/%stack_name%/spec/spec_helper.rb.tt +9 -0
  43. data/lib/pancake/generators/templates/stack/%stack_name%/LICENSE.tt +20 -0
  44. data/lib/pancake/generators/templates/stack/%stack_name%/README.tt +7 -0
  45. data/lib/pancake/generators/templates/stack/%stack_name%/Rakefile.tt +50 -0
  46. data/lib/pancake/generators/templates/stack/%stack_name%/VERSION.tt +1 -0
  47. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +18 -0
  48. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +18 -0
  49. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/router.rb.tt +6 -0
  50. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config.ru.tt +12 -0
  51. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/gems/cache/.empty_directory +0 -0
  52. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  53. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  54. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  55. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%.rb.tt +3 -0
  56. data/lib/pancake/generators/templates/stack/%stack_name%/pancake.init.tt +1 -0
  57. data/lib/pancake/generators/templates/stack/%stack_name%/spec/%stack_name%_spec.rb.tt +7 -0
  58. data/lib/pancake/generators/templates/stack/%stack_name%/spec/spec_helper.rb.tt +9 -0
  59. data/lib/pancake/generators.rb +8 -0
  60. data/lib/pancake/hooks/inheritable_inner_classes.rb +60 -0
  61. data/lib/pancake/hooks/on_inherit.rb +34 -0
  62. data/lib/pancake/logger.rb +200 -0
  63. data/lib/pancake/master.rb +123 -0
  64. data/lib/pancake/middleware.rb +347 -0
  65. data/lib/pancake/middlewares/logger.rb +16 -0
  66. data/lib/pancake/middlewares/static.rb +38 -0
  67. data/lib/pancake/mime_types.rb +265 -0
  68. data/lib/pancake/mixins/publish/action_options.rb +104 -0
  69. data/lib/pancake/mixins/publish.rb +125 -0
  70. data/lib/pancake/mixins/render/render.rb +168 -0
  71. data/lib/pancake/mixins/render/template.rb +23 -0
  72. data/lib/pancake/mixins/render/view_context.rb +21 -0
  73. data/lib/pancake/mixins/render.rb +109 -0
  74. data/lib/pancake/mixins/request_helper.rb +100 -0
  75. data/lib/pancake/mixins/stack_helper.rb +46 -0
  76. data/lib/pancake/mixins/url.rb +10 -0
  77. data/lib/pancake/paths.rb +218 -0
  78. data/lib/pancake/router.rb +99 -0
  79. data/lib/pancake/stack/app.rb +10 -0
  80. data/lib/pancake/stack/bootloader.rb +79 -0
  81. data/lib/pancake/stack/configuration.rb +44 -0
  82. data/lib/pancake/stack/middleware.rb +0 -0
  83. data/lib/pancake/stack/router.rb +21 -0
  84. data/lib/pancake/stack/stack.rb +66 -0
  85. data/lib/pancake/stacks/short/bootloaders.rb +13 -0
  86. data/lib/pancake/stacks/short/controller.rb +116 -0
  87. data/lib/pancake/stacks/short/default/views/base.html.haml +5 -0
  88. data/lib/pancake/stacks/short/stack.rb +187 -0
  89. data/lib/pancake/stacks/short.rb +3 -0
  90. data/lib/pancake.rb +58 -0
  91. data/spec/helpers/helpers.rb +20 -0
  92. data/spec/helpers/matchers.rb +25 -0
  93. data/spec/pancake/bootloaders_spec.rb +109 -0
  94. data/spec/pancake/configuration_spec.rb +177 -0
  95. data/spec/pancake/constants_spec.rb +7 -0
  96. data/spec/pancake/defaults/configuration_spec.rb +58 -0
  97. data/spec/pancake/fixtures/foo_stack/pancake.init +0 -0
  98. data/spec/pancake/fixtures/middlewares/other_public/two.html +1 -0
  99. data/spec/pancake/fixtures/middlewares/public/foo#bar.html +1 -0
  100. data/spec/pancake/fixtures/middlewares/public/one.html +1 -0
  101. data/spec/pancake/fixtures/paths/controllers/controller1.rb +0 -0
  102. data/spec/pancake/fixtures/paths/controllers/controller2.rb +0 -0
  103. data/spec/pancake/fixtures/paths/controllers/controller3.rb +0 -0
  104. data/spec/pancake/fixtures/paths/models/model1.rb +0 -0
  105. data/spec/pancake/fixtures/paths/models/model2.rb +0 -0
  106. data/spec/pancake/fixtures/paths/models/model3.rb +0 -0
  107. data/spec/pancake/fixtures/paths/stack/controllers/controller1.rb +0 -0
  108. data/spec/pancake/fixtures/paths/stack/models/model3.rb +0 -0
  109. data/spec/pancake/fixtures/paths/stack/views/view1.erb +0 -0
  110. data/spec/pancake/fixtures/paths/stack/views/view1.rb +0 -0
  111. data/spec/pancake/fixtures/paths/stack/views/view2.erb +0 -0
  112. data/spec/pancake/fixtures/paths/stack/views/view2.haml +0 -0
  113. data/spec/pancake/fixtures/render_templates/context_template.html.erb +2 -0
  114. data/spec/pancake/fixtures/render_templates/erb_template.html.erb +1 -0
  115. data/spec/pancake/fixtures/render_templates/erb_template.json.erb +1 -0
  116. data/spec/pancake/fixtures/render_templates/haml_template.html.haml +1 -0
  117. data/spec/pancake/fixtures/render_templates/haml_template.xml.haml +1 -0
  118. data/spec/pancake/fixtures/render_templates/templates/context.erb +2 -0
  119. data/spec/pancake/fixtures/render_templates/view_context/capture_erb.erb +5 -0
  120. data/spec/pancake/fixtures/render_templates/view_context/capture_haml.haml +4 -0
  121. data/spec/pancake/fixtures/render_templates/view_context/concat_erb.erb +2 -0
  122. data/spec/pancake/fixtures/render_templates/view_context/concat_haml.haml +2 -0
  123. data/spec/pancake/fixtures/render_templates/view_context/context.erb +3 -0
  124. data/spec/pancake/fixtures/render_templates/view_context/context2.erb +3 -0
  125. data/spec/pancake/fixtures/render_templates/view_context/helper_methods.erb +3 -0
  126. data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_from_haml.erb +5 -0
  127. data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_level_0.erb +5 -0
  128. data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_level_1.erb +5 -0
  129. data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_from_erb.haml +4 -0
  130. data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_level_0.haml +4 -0
  131. data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_level_1.haml +4 -0
  132. data/spec/pancake/fixtures/render_templates/view_context/nested_content_level_0.haml +6 -0
  133. data/spec/pancake/fixtures/render_templates/view_context/nested_content_level_1.haml +4 -0
  134. data/spec/pancake/fixtures/render_templates/view_context/nested_inner.erb +1 -0
  135. data/spec/pancake/fixtures/render_templates/view_context/nested_outer.erb +3 -0
  136. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_erb_0.erb +5 -0
  137. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_erb_1.erb +6 -0
  138. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_haml_0.erb +5 -0
  139. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_haml_1.erb +6 -0
  140. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_erb_0.haml +4 -0
  141. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_erb_1.haml +5 -0
  142. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_haml_0.haml +5 -0
  143. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_haml_1.haml +5 -0
  144. data/spec/pancake/fixtures/stacks/short/foobar/other_root/views/base.html.haml +4 -0
  145. data/spec/pancake/fixtures/stacks/short/foobar/views/basic.html.haml +1 -0
  146. data/spec/pancake/fixtures/stacks/short/foobar/views/inherited_from_base.html.haml +5 -0
  147. data/spec/pancake/hooks/on_inherit_spec.rb +65 -0
  148. data/spec/pancake/inheritance_spec.rb +100 -0
  149. data/spec/pancake/middleware_spec.rb +401 -0
  150. data/spec/pancake/middlewares/logger_spec.rb +29 -0
  151. data/spec/pancake/middlewares/static_spec.rb +83 -0
  152. data/spec/pancake/mime_types_spec.rb +234 -0
  153. data/spec/pancake/mixins/publish_spec.rb +94 -0
  154. data/spec/pancake/mixins/render/template_spec.rb +69 -0
  155. data/spec/pancake/mixins/render/view_context_spec.rb +248 -0
  156. data/spec/pancake/mixins/render_spec.rb +56 -0
  157. data/spec/pancake/mixins/request_helper_spec.rb +27 -0
  158. data/spec/pancake/mixins/stack_helper_spec.rb +46 -0
  159. data/spec/pancake/pancake_spec.rb +90 -0
  160. data/spec/pancake/paths_spec.rb +210 -0
  161. data/spec/pancake/stack/app_spec.rb +28 -0
  162. data/spec/pancake/stack/bootloader_spec.rb +41 -0
  163. data/spec/pancake/stack/middleware_spec.rb +0 -0
  164. data/spec/pancake/stack/router_spec.rb +282 -0
  165. data/spec/pancake/stack/stack_configuration_spec.rb +101 -0
  166. data/spec/pancake/stack/stack_spec.rb +60 -0
  167. data/spec/pancake/stacks/short/controller_spec.rb +322 -0
  168. data/spec/pancake/stacks/short/middlewares_spec.rb +22 -0
  169. data/spec/pancake/stacks/short/router_spec.rb +136 -0
  170. data/spec/pancake/stacks/short/stack_spec.rb +64 -0
  171. data/spec/spec_helper.rb +23 -0
  172. 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,12 @@
1
+ module Pancake
2
+ module Generators
3
+ class Base < Thor::Group
4
+ include Thor::Actions
5
+
6
+ def self.source_root
7
+ File.join(File.dirname(__FILE__), "templates")
8
+ end
9
+
10
+ end
11
+ end
12
+ 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,8 @@
1
+ class <%= stack_name.camel_case %> < Pancake::Stacks::Short
2
+ add_root(__FILE__)
3
+
4
+ get "/" do
5
+ render :root
6
+ end
7
+ end
8
+
@@ -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 %>"))
@@ -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,7 @@
1
+ = <%= stack_name %>
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) <%= Date.today.year %> <YOUR NAME HERE>. See LICENSE for details.
@@ -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,6 @@
1
+ class <%= stack_name.camel_case %>
2
+ get "/" do
3
+ render :root
4
+ end
5
+ end
6
+
@@ -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
@@ -0,0 +1,5 @@
1
+ class <%= stack_name.camel_case %> < Pancake::Stacks::Short
2
+ add_root(__FILE__, "<%= stack_name %>")
3
+ end
4
+
5
+ require ::File.join(Pancake.get_root(__FILE__, "<%= stack_name %>"), "<%= stack_name %>")
@@ -0,0 +1 @@
1
+ require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "lib", "<%= stack_name %>")
@@ -0,0 +1,7 @@
1
+ require ::File.expand_path(::File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "<%= stack_name %>" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require '<%= stack_name -%>'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -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,7 @@
1
+ = <%= stack_name %>
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) <%= Date.today.year %> <YOUR NAME HERE>. See LICENSE for details.
@@ -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,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,6 @@
1
+ <%= stack_name.camel_case %>.router do |r|
2
+ # Add your routes here
3
+ r.add("/") do |e|
4
+ Rack::Response.new("Hi From <%= stack_name.camel_case %>").finish
5
+ end
6
+ end
@@ -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
@@ -0,0 +1,3 @@
1
+ class <%= stack_name.camel_case %> < Pancake::Stack
2
+ add_root __FILE__, "<%= stack_name %>"
3
+ end
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), "lib", "<%= stack_name %>")
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "<%= stack_name %>" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require '<%= stack_name -%>'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,8 @@
1
+ require 'thor'
2
+ require 'extlib'
3
+
4
+ require File.join(File.dirname(__FILE__), "generators", "base.rb")
5
+
6
+ Dir[File.join(File.dirname(__FILE__), "generators", "*.rb")].each do |f|
7
+ require f unless f == 'base.rb'
8
+ end
@@ -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