pancake 0.1.27 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +2 -3
- data/lib/pancake/bootloaders.rb +7 -0
- data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +1 -1
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +1 -1
- data/lib/pancake/router.rb +6 -3
- data/lib/pancake/stack/bootloader.rb +1 -1
- data/lib/pancake/stacks/short/stack.rb +1 -2
- data/lib/pancake.rb +1 -1
- data/spec/pancake/bootloaders_spec.rb +9 -0
- metadata +3 -2
data/TODO
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
TODO:
|
2
2
|
|
3
3
|
* Add default middleware to the short stack
|
4
|
-
* Add
|
5
|
-
*
|
6
|
-
* Do some introductory posts
|
4
|
+
* Add before/after filters to the short stack
|
5
|
+
* move the mount apps bootloader to after the before_build_stack bootloader which will allow us to mount application later and allow devs to add new things just before building the stack.
|
7
6
|
* optimise template lookup
|
8
7
|
|
data/lib/pancake/bootloaders.rb
CHANGED
@@ -71,6 +71,12 @@ module Pancake
|
|
71
71
|
_bootloaders[name]
|
72
72
|
end
|
73
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
|
+
|
74
80
|
# Add a bootloader. Inside the block we're inside a class definition.
|
75
81
|
# Requirements: define a +run!+ method
|
76
82
|
#
|
@@ -119,6 +125,7 @@ module Pancake
|
|
119
125
|
options[:stack_class] ||= stack
|
120
126
|
|
121
127
|
each(conditions) do |name, bl|
|
128
|
+
next if bl.nil?
|
122
129
|
bl.call(options)
|
123
130
|
end
|
124
131
|
end
|
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'pancake'
|
4
4
|
require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "<%= stack_name %>")
|
5
5
|
|
6
|
-
# get the application to run. The
|
6
|
+
# get the application to run. The application in the Pancake.start block
|
7
7
|
# is the master application. It will have all requests directed to it through the
|
8
8
|
# pancake middleware
|
9
9
|
# This should be a very minimal file, but should be used when any stand alone code needs to be included
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'pancake'
|
2
2
|
require ::File.join(::File.expand_path(::File.dirname(__FILE__)), "..", "<%= stack_name %>")
|
3
3
|
|
4
|
-
# get the application to run. The
|
4
|
+
# get the application to run. The application in the Pancake.start block
|
5
5
|
# is the master application. It will have all requests directed to it through the
|
6
6
|
# pancake middleware
|
7
7
|
# This should be a very minimal file, but should be used when any stand alone code needs to be included
|
data/lib/pancake/router.rb
CHANGED
@@ -37,7 +37,7 @@ module Pancake
|
|
37
37
|
# @see http://github.com/joshbuddy/usher
|
38
38
|
# @since 0.1.2
|
39
39
|
# @author Daniel Neighman
|
40
|
-
class Router < Usher::Interface::
|
40
|
+
class Router < Usher::Interface::Rack
|
41
41
|
attr_writer :router
|
42
42
|
|
43
43
|
CONFIGURATION_KEY = "pancake.request.configuration".freeze
|
@@ -113,7 +113,7 @@ module Pancake
|
|
113
113
|
end
|
114
114
|
|
115
115
|
# Adds a route to the router.
|
116
|
-
# @see Usher::Interface::
|
116
|
+
# @see Usher::Interface::Rack#add
|
117
117
|
def add(path, opts = {}, &block)
|
118
118
|
opts = cooerce_options_to_usher(opts)
|
119
119
|
route = super(path, opts)
|
@@ -162,13 +162,16 @@ module Pancake
|
|
162
162
|
opts
|
163
163
|
end
|
164
164
|
|
165
|
-
# Overwrites the method in Rack::Interface::
|
165
|
+
# Overwrites the method in Rack::Interface::Rack to mash
|
166
166
|
# the usher.params into the rack request.params
|
167
167
|
# @api private
|
168
168
|
def after_match(request, response)
|
169
169
|
super
|
170
170
|
consume_path!(request, response) if !response.partial_match? && response.path.route.consuming
|
171
171
|
request.params.merge!(request.env['usher.params']) unless request.env['usher.params'].empty?
|
172
|
+
|
173
|
+
request.params.merge!(response.destination) if response.destination.is_a?(Hash)
|
174
|
+
|
172
175
|
request.env[ROUTE_KEY] = response.path.route
|
173
176
|
request.env['rack.request.query_hash'] = Hashie::Mash.new(request.params) unless request.params.kind_of?(Hashie::Mash)
|
174
177
|
end
|
@@ -25,7 +25,7 @@ end
|
|
25
25
|
Pancake::Stack::BootLoader.add(:load_mounted_inits, :level => :init) do
|
26
26
|
def run!
|
27
27
|
# Mount any stacks this stack may have in it.
|
28
|
-
stack_class.paths_for(:mounts).each{|f| require f}
|
28
|
+
stack_class.paths_for(:mounts).each{|f| require f.join}
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -170,8 +170,7 @@ module Pancake
|
|
170
170
|
name = options.delete(:_name)
|
171
171
|
options[:conditions] ||= {}
|
172
172
|
options[:conditions][:request_method] = method.to_s.upcase unless method == :any
|
173
|
-
options[:
|
174
|
-
options[:default_values][:action] = action_name
|
173
|
+
options[:action] ||= action_name
|
175
174
|
r = router.add(path, options)
|
176
175
|
r.name(name) if name
|
177
176
|
r
|
data/lib/pancake.rb
CHANGED
@@ -30,6 +30,15 @@ describe "Pancake::Stack::BootLoader" do
|
|
30
30
|
FooStack::BootLoader[:my_initializer].should inherit_from(Pancake::BootLoaderMixin::Base)
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should allow me to remove a bootloader from another bootloader" do
|
34
|
+
FooStack::BootLoader.add(:foo){ def run!; $captures << :foo; end}
|
35
|
+
FooStack::BootLoader.add(:bar){ def run!; FooStack::BootLoader.delete(:removed); end }
|
36
|
+
FooStack::BootLoader.add(:removed){ def run!; $captures << :removed; end}
|
37
|
+
FooStack.new
|
38
|
+
|
39
|
+
$captures.should == [:foo]
|
40
|
+
end
|
41
|
+
|
33
42
|
it "should allow me to add multiple boot loaders" do
|
34
43
|
FooStack::BootLoader.add(:foo){ def run!; :foo; end}
|
35
44
|
FooStack::BootLoader.add(:bar){ def run!; :bar; end}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pancake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
@@ -9,7 +9,7 @@ autorequire: pancake
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-18 00:00:00 +11:00
|
13
13
|
default_executable: pancake-gen
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -101,6 +101,7 @@ extensions: []
|
|
101
101
|
extra_rdoc_files:
|
102
102
|
- LICENSE
|
103
103
|
- README.textile
|
104
|
+
- TODO
|
104
105
|
files:
|
105
106
|
- LICENSE
|
106
107
|
- README.textile
|