pancake 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/bin/pancake +96 -0
  2. data/lib/pancake.rb +5 -7
  3. data/lib/pancake/configuration.rb +2 -23
  4. data/lib/pancake/core_ext/object.rb +1 -1
  5. data/lib/pancake/defaults/configuration.rb +21 -1
  6. data/lib/pancake/generators.rb +0 -3
  7. data/lib/pancake/hooks/inheritable_inner_classes.rb +15 -2
  8. data/lib/pancake/master.rb +34 -1
  9. data/lib/pancake/mixins/render.rb +1 -2
  10. data/lib/pancake/mixins/stack_helper.rb +1 -1
  11. data/lib/pancake/router.rb +18 -63
  12. data/lib/pancake/stack/configuration.rb +3 -5
  13. data/lib/pancake/stack/router.rb +10 -33
  14. data/lib/pancake/stack/stack.rb +70 -50
  15. data/{spec/helpers → lib/pancake/test}/helpers.rb +3 -3
  16. data/lib/pancake/test/matchers.rb +20 -0
  17. data/lib/pancake/vendor/hashie/.document +5 -0
  18. data/lib/pancake/vendor/hashie/.gitignore +7 -0
  19. data/lib/pancake/vendor/hashie/Gemfile +11 -0
  20. data/lib/pancake/vendor/hashie/Gemfile.lock +25 -0
  21. data/lib/pancake/{generators/templates/short/%stack_name%/LICENSE.tt → vendor/hashie/LICENSE} +1 -1
  22. data/lib/pancake/vendor/hashie/README.rdoc +101 -0
  23. data/lib/pancake/{generators/templates/micro/%stack_name%/Rakefile.tt → vendor/hashie/Rakefile} +3 -13
  24. data/lib/pancake/vendor/hashie/VERSION +1 -0
  25. data/lib/pancake/vendor/hashie/hashie.gemspec +33 -0
  26. data/lib/pancake/vendor/hashie/lib/hashie.rb +5 -0
  27. data/lib/pancake/vendor/hashie/lib/hashie/clash.rb +86 -0
  28. data/lib/pancake/vendor/hashie/lib/hashie/dash.rb +108 -0
  29. data/lib/pancake/vendor/hashie/lib/hashie/hash.rb +22 -0
  30. data/lib/pancake/vendor/hashie/lib/hashie/hash_extensions.rb +49 -0
  31. data/lib/pancake/vendor/hashie/lib/hashie/mash.rb +148 -0
  32. data/lib/pancake/vendor/hashie/spec/hashie/clash_spec.rb +42 -0
  33. data/lib/pancake/vendor/hashie/spec/hashie/dash_spec.rb +103 -0
  34. data/lib/pancake/vendor/hashie/spec/hashie/hash_spec.rb +22 -0
  35. data/lib/pancake/vendor/hashie/spec/hashie/mash_spec.rb +135 -0
  36. data/lib/pancake/vendor/hashie/spec/spec.opts +2 -0
  37. data/lib/pancake/{generators/templates/short/%stack_name%/spec/spec_helper.rb.tt → vendor/hashie/spec/spec_helper.rb} +7 -7
  38. data/spec/pancake/configuration_spec.rb +1 -1
  39. data/spec/pancake/constants_spec.rb +1 -1
  40. data/spec/pancake/defaults/configuration_spec.rb +1 -1
  41. data/spec/pancake/hooks/on_inherit_spec.rb +13 -13
  42. data/spec/pancake/inheritance_spec.rb +22 -22
  43. data/spec/pancake/middleware_spec.rb +6 -5
  44. data/spec/pancake/middlewares/logger_spec.rb +1 -1
  45. data/spec/pancake/middlewares/static_spec.rb +1 -1
  46. data/spec/pancake/mime_types_spec.rb +1 -1
  47. data/spec/pancake/mixins/publish_spec.rb +24 -24
  48. data/spec/pancake/mixins/render/template_spec.rb +1 -1
  49. data/spec/pancake/mixins/render/view_context_spec.rb +1 -1
  50. data/spec/pancake/mixins/render_spec.rb +1 -1
  51. data/spec/pancake/mixins/request_helper_spec.rb +1 -1
  52. data/spec/pancake/mixins/stack_helper_spec.rb +3 -3
  53. data/spec/pancake/pancake_spec.rb +1 -1
  54. data/spec/pancake/paths_spec.rb +30 -30
  55. data/spec/pancake/stack/router_spec.rb +24 -62
  56. data/spec/pancake/stack/stack_configuration_spec.rb +1 -1
  57. data/spec/pancake/stack/stack_spec.rb +47 -4
  58. data/spec/spec_helper.rb +3 -3
  59. metadata +56 -128
  60. data/bin/pancake-gen +0 -30
  61. data/lib/pancake/bootloaders.rb +0 -187
  62. data/lib/pancake/generators/base.rb +0 -12
  63. data/lib/pancake/generators/micro_generator.rb +0 -17
  64. data/lib/pancake/generators/short_generator.rb +0 -18
  65. data/lib/pancake/generators/templates/common/dotgitignore +0 -22
  66. data/lib/pancake/generators/templates/common/dothtaccess +0 -17
  67. data/lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt +0 -8
  68. data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +0 -12
  69. data/lib/pancake/generators/templates/micro/%stack_name%/pancake_init.rb.tt +0 -1
  70. data/lib/pancake/generators/templates/micro/%stack_name%/public/.empty_directory +0 -0
  71. data/lib/pancake/generators/templates/micro/%stack_name%/tmp/.empty_directory +0 -0
  72. data/lib/pancake/generators/templates/micro/%stack_name%/views/root.html.haml +0 -1
  73. data/lib/pancake/generators/templates/short/%stack_name%/README.tt +0 -7
  74. data/lib/pancake/generators/templates/short/%stack_name%/Rakefile.tt +0 -56
  75. data/lib/pancake/generators/templates/short/%stack_name%/VERSION.tt +0 -1
  76. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +0 -12
  77. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt +0 -6
  78. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +0 -10
  79. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/config.rb.tt +0 -23
  80. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +0 -15
  81. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +0 -16
  82. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/staging.rb.tt +0 -17
  83. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/models/.empty_directory +0 -0
  84. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  85. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  86. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tasks/%stack_name%.rake.tt +0 -4
  87. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  88. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/views/root.html.haml +0 -2
  89. data/lib/pancake/generators/templates/short/%stack_name%/pancake_init.rb.tt +0 -1
  90. data/lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt +0 -11
  91. data/lib/pancake/stack/app.rb +0 -10
  92. data/lib/pancake/stack/bootloader.rb +0 -114
  93. data/lib/pancake/stack/middleware.rb +0 -0
  94. data/lib/pancake/stacks/short.rb +0 -3
  95. data/lib/pancake/stacks/short/bootloaders.rb +0 -5
  96. data/lib/pancake/stacks/short/controller.rb +0 -184
  97. data/lib/pancake/stacks/short/default/views/base.html.haml +0 -5
  98. data/lib/pancake/stacks/short/default/views/error.html.haml +0 -12
  99. data/lib/pancake/stacks/short/stack.rb +0 -207
  100. data/spec/helpers/matchers.rb +0 -25
  101. data/spec/pancake/bootloaders_spec.rb +0 -119
  102. data/spec/pancake/stack/app_spec.rb +0 -28
  103. data/spec/pancake/stack/bootloader_spec.rb +0 -41
  104. data/spec/pancake/stack/middleware_spec.rb +0 -0
  105. data/spec/pancake/stacks/short/controller_spec.rb +0 -442
  106. data/spec/pancake/stacks/short/middlewares_spec.rb +0 -22
  107. data/spec/pancake/stacks/short/router_spec.rb +0 -150
  108. data/spec/pancake/stacks/short/stack_spec.rb +0 -117
@@ -1,187 +0,0 @@
1
- require 'set'
2
- module Pancake
3
- module BootLoaderMixin
4
- include Enumerable
5
- class Base
6
- # :api: :public
7
- attr_accessor :config
8
-
9
- # Sets options for the bootloder
10
- # By including conditions in the bootloader when you declare it
11
- # You can selectively run bootloaders later
12
- # :api: private
13
- def self.options=(opts={}) # :nodoc:
14
- @options = opts
15
- @options[:level] ||= :default
16
- end
17
-
18
- # Provides access to the bootloader options
19
- # :api: private
20
- def self.options # :nodoc:
21
- @options ||= {}
22
- end
23
-
24
- def stack
25
- raise "No Stack Configured" unless @config[:stack]
26
- @config[:stack]
27
- end
28
-
29
- def stack_class
30
- raise "No Stack Class Configured" unless @config[:stack_class]
31
- @config[:stack_class]
32
- end
33
-
34
- def initialize(config)
35
- @config = config
36
- end
37
-
38
- # Creates a new instance and runs it
39
- # :api: private
40
- def self.call(config)
41
- new(config).run!
42
- end
43
-
44
- # Checks the conditions with the options of the bootloader
45
- # To see if this one should be run
46
- # Only the central bootloaders with the conditions will be checked
47
- # :api: private
48
- def self.run?(conditions = {})
49
- opts = options
50
- if conditions.keys.include?(:only)
51
- return conditions[:only].all?{|k,v| opts[k] == v}
52
- end
53
- if conditions.keys.include?(:except)
54
- return conditions[:except].all?{|k,v| opts[k] != v}
55
- end
56
- true
57
- end
58
- end
59
-
60
- def self.extended(base)
61
- base.class_eval do
62
- extlib_inheritable_reader :_bootloaders, :_central_bootloaders, :_bootloader_map
63
- @_bootloaders, @_central_bootloaders = {}, []
64
- @_bootloader_map = Hash.new{|h,k| h[k] = {:before => [], :after => []}}
65
- end
66
- end
67
-
68
- # Provides access to an individual bootloader
69
- # :api: public
70
- def [](name)
71
- _bootloaders[name]
72
- end
73
-
74
- # Provides removal of a bootloader, by replacing it as an empty lambda
75
- # :api: public
76
- def delete(name)
77
- !!self[name] && _bootloaders[name] = nil
78
- end
79
-
80
- # Add a bootloader. Inside the block we're inside a class definition.
81
- # Requirements: define a +run!+ method
82
- #
83
- # Example
84
- # FooStack::BootLoader.add(:foo) do
85
- # def run!
86
- # # stuff
87
- # end
88
- # end
89
- #
90
- # :api: public
91
- def add(name, opts = {}, &block)
92
- _bootloaders[name] = Class.new(Pancake::BootLoaderMixin::Base, &block)
93
- raise "You must declare a #run! method on your bootloader" unless _bootloaders[name].method_defined?(:run!)
94
- before = opts[:before]
95
- after = opts[:after]
96
-
97
- if opts[:level]
98
- levels << opts[:level]
99
- levels.uniq!
100
- end
101
-
102
- # If there are no before or after keys, add it to the central bootloaders
103
- if before
104
- _bootloader_map[before][:before] << name
105
- elsif after
106
- _bootloader_map[after][:after] << name
107
- else
108
- _central_bootloaders << name unless _central_bootloaders.include?(name)
109
- end
110
- _bootloaders[name].options = opts
111
- _bootloaders[name]
112
- end
113
-
114
- # Runs the bootloaders in order
115
- # :api: private
116
- def run!(options = {}) # :nodoc:
117
- unless options.keys.include?(:only) || options.keys.include?(:except)
118
- options[:only] = {:level => :default}
119
- end
120
- conditions = if options[:only]
121
- {:only => options.delete(:only)}
122
- else
123
- {:except => options.delete(:except)}
124
- end
125
- options[:stack_class] ||= stack
126
-
127
- each(conditions) do |name, bl|
128
- next if bl.nil?
129
- bl.call(options)
130
- end
131
- end
132
-
133
- # Set the stack that this bootloader is responsible for.
134
- # :api: private
135
- def stack=(stack) # :nodoc:
136
- @stack = stack
137
- end
138
-
139
- # Access to the stack that this bootloader is responsible for
140
- # :api: public
141
- def stack
142
- @stack ||= self.name.split("::")[0..-2].join("::").constantize
143
- end
144
-
145
- # Resets the bootloaders on the stack
146
- # :api: public
147
- def reset!
148
- _central_bootloaders.clear
149
- _bootloaders.clear
150
- _bootloader_map.clear
151
- end
152
-
153
- # Yields each bootloader in order along with it's name
154
- #
155
- # Example
156
- # FooStack::BootLoader.each do |name, bootloader|
157
- # # do stuff
158
- # end
159
- #
160
- # :api: public
161
- def each(conditions = {})
162
- _map_bootloaders(_central_bootloaders, conditions).each do |n|
163
- yield n, _bootloaders[n]
164
- end
165
- end
166
-
167
- private
168
- # Map out the bootloaders by name to run.
169
- # :api: private
170
- def _map_bootloaders(*names)
171
- conditions = Hash === names.last ? names.pop : {}
172
- names.flatten.map do |name|
173
- if _bootloaders[name].run?(conditions)
174
- r = []
175
- r << _map_bootloaders(_bootloader_map[name][:before])
176
- r << name
177
- r << _map_bootloaders(_bootloader_map[name][:after])
178
- end
179
- end.flatten.compact
180
- end
181
-
182
- def levels
183
- @levels ||= [:default]
184
- end
185
-
186
- end # BootLoaders
187
- end # Pancake
@@ -1,12 +0,0 @@
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
@@ -1,17 +0,0 @@
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
@@ -1,18 +0,0 @@
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
-
13
- end
14
-
15
-
16
- end
17
- end
18
- end
@@ -1,22 +0,0 @@
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*
@@ -1,17 +0,0 @@
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"
@@ -1,8 +0,0 @@
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
-
@@ -1,12 +0,0 @@
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 application 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(:master => true) }
11
-
12
- run app
@@ -1 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), "<%= stack_name %>")
@@ -1,7 +0,0 @@
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.
@@ -1,56 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'pancake'
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "<%= stack_name %>"
9
- gem.summary = %Q{TODO}
10
- gem.email = "TODO"
11
- gem.homepage = "TODO"
12
- gem.authors = ["TODO"]
13
- gem.add_dependency "pancake", ">=0.1.8"
14
- gem.files = FileList["[A-Z]*", "pancake.init", "{lib,spec,rails}/**/*"]
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
- end
17
-
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
- end
21
-
22
- require File.join(File.dirname(__FILE__), "lib", "<%= stack_name %>")
23
- Pancake.root = Pancake.get_root(__FILE__, "lib", "<%= stack_name %>")
24
- THIS_STACK = <%= stack_name.camel_case %>
25
- <%= stack_name.camel_case %>.load_rake_tasks!(:master => true)
26
-
27
- require 'spec/rake/spectask'
28
- Spec::Rake::SpecTask.new(:spec) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.spec_files = FileList['spec/**/*_spec.rb']
31
- end
32
-
33
- Spec::Rake::SpecTask.new(:rcov) do |spec|
34
- spec.libs << 'lib' << 'spec'
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
38
-
39
-
40
- task :default => :spec
41
-
42
- require 'rake/rdoctask'
43
- Rake::RDocTask.new do |rdoc|
44
- if File.exist?('VERSION.yml')
45
- config = YAML.load(File.read('VERSION.yml'))
46
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
- else
48
- version = ""
49
- end
50
-
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "foo #{version}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
55
- end
56
-
@@ -1,12 +0,0 @@
1
- require 'pancake'
2
- class <%= stack_name.camel_case %> < Pancake::Stacks::Short
3
- add_root(__FILE__, "<%= stack_name %>")
4
-
5
- # Hook to use before we mount any applications
6
- # before_mount_applications do
7
- # end
8
-
9
- initialize_stack
10
- end
11
-
12
- require ::File.join(Pancake.get_root(__FILE__, "<%= stack_name %>"), "<%= stack_name %>")
@@ -1,6 +0,0 @@
1
- class <%= stack_name.camel_case %>
2
- get "/" do
3
- render :root
4
- end
5
- end
6
-
@@ -1,10 +0,0 @@
1
- require 'pancake'
2
- require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "..", "<%= stack_name %>")
3
-
4
- # get the application to run. The application 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(:master => true) }
9
-
10
- run app
@@ -1,23 +0,0 @@
1
- # Enter any global configuration for the stack in this file.
2
-
3
- class <%= stack_name.camel_case %>
4
- # include middleware for the development stack
5
- # Labels can be set in the config/environments/<env>.rb file to limit
6
- # middleware loading.
7
- # stack(:middleware_name, :labels => [:development, :production]).use(MiddlewareClass)
8
-
9
- class self::Configuration
10
- # Add defaults to your stack configuration.
11
- # This is scoped to this stack, and is inhertied into child stacks
12
- #
13
- # Fixed value defaults:
14
- # default :var_name, :value, "A description of the variable"
15
- #
16
- # Lazy Defaults:
17
- # default :var_name, lambda{ configuration_method }, "Some Description"
18
-
19
- # Declare methods on your configuraiton
20
- # def configuration_method; #stuff; end
21
- end
22
- end
23
-
@@ -1,15 +0,0 @@
1
- Pancake.logger.info "Loading Development Environment"
2
-
3
- # Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
4
-
5
- class <%= stack_name.camel_case %>
6
- # include middleware for the development stack
7
- # stack(:middleware_name).use(MiddlewareClass)
8
- end
9
-
10
- # Add code to hooks. Default available hooks:
11
- # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
12
-
13
- # <%= stack_name.camel_case %>.before_build_stack do
14
- # # stuff to do
15
- # end