pancake 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/pancake +96 -0
- data/lib/pancake.rb +5 -7
- data/lib/pancake/configuration.rb +2 -23
- data/lib/pancake/core_ext/object.rb +1 -1
- data/lib/pancake/defaults/configuration.rb +21 -1
- data/lib/pancake/generators.rb +0 -3
- data/lib/pancake/hooks/inheritable_inner_classes.rb +15 -2
- data/lib/pancake/master.rb +34 -1
- data/lib/pancake/mixins/render.rb +1 -2
- data/lib/pancake/mixins/stack_helper.rb +1 -1
- data/lib/pancake/router.rb +18 -63
- data/lib/pancake/stack/configuration.rb +3 -5
- data/lib/pancake/stack/router.rb +10 -33
- data/lib/pancake/stack/stack.rb +70 -50
- data/{spec/helpers → lib/pancake/test}/helpers.rb +3 -3
- data/lib/pancake/test/matchers.rb +20 -0
- data/lib/pancake/vendor/hashie/.document +5 -0
- data/lib/pancake/vendor/hashie/.gitignore +7 -0
- data/lib/pancake/vendor/hashie/Gemfile +11 -0
- data/lib/pancake/vendor/hashie/Gemfile.lock +25 -0
- data/lib/pancake/{generators/templates/short/%stack_name%/LICENSE.tt → vendor/hashie/LICENSE} +1 -1
- data/lib/pancake/vendor/hashie/README.rdoc +101 -0
- data/lib/pancake/{generators/templates/micro/%stack_name%/Rakefile.tt → vendor/hashie/Rakefile} +3 -13
- data/lib/pancake/vendor/hashie/VERSION +1 -0
- data/lib/pancake/vendor/hashie/hashie.gemspec +33 -0
- data/lib/pancake/vendor/hashie/lib/hashie.rb +5 -0
- data/lib/pancake/vendor/hashie/lib/hashie/clash.rb +86 -0
- data/lib/pancake/vendor/hashie/lib/hashie/dash.rb +108 -0
- data/lib/pancake/vendor/hashie/lib/hashie/hash.rb +22 -0
- data/lib/pancake/vendor/hashie/lib/hashie/hash_extensions.rb +49 -0
- data/lib/pancake/vendor/hashie/lib/hashie/mash.rb +148 -0
- data/lib/pancake/vendor/hashie/spec/hashie/clash_spec.rb +42 -0
- data/lib/pancake/vendor/hashie/spec/hashie/dash_spec.rb +103 -0
- data/lib/pancake/vendor/hashie/spec/hashie/hash_spec.rb +22 -0
- data/lib/pancake/vendor/hashie/spec/hashie/mash_spec.rb +135 -0
- data/lib/pancake/vendor/hashie/spec/spec.opts +2 -0
- data/lib/pancake/{generators/templates/short/%stack_name%/spec/spec_helper.rb.tt → vendor/hashie/spec/spec_helper.rb} +7 -7
- data/spec/pancake/configuration_spec.rb +1 -1
- data/spec/pancake/constants_spec.rb +1 -1
- data/spec/pancake/defaults/configuration_spec.rb +1 -1
- data/spec/pancake/hooks/on_inherit_spec.rb +13 -13
- data/spec/pancake/inheritance_spec.rb +22 -22
- data/spec/pancake/middleware_spec.rb +6 -5
- data/spec/pancake/middlewares/logger_spec.rb +1 -1
- data/spec/pancake/middlewares/static_spec.rb +1 -1
- data/spec/pancake/mime_types_spec.rb +1 -1
- data/spec/pancake/mixins/publish_spec.rb +24 -24
- data/spec/pancake/mixins/render/template_spec.rb +1 -1
- data/spec/pancake/mixins/render/view_context_spec.rb +1 -1
- data/spec/pancake/mixins/render_spec.rb +1 -1
- data/spec/pancake/mixins/request_helper_spec.rb +1 -1
- data/spec/pancake/mixins/stack_helper_spec.rb +3 -3
- data/spec/pancake/pancake_spec.rb +1 -1
- data/spec/pancake/paths_spec.rb +30 -30
- data/spec/pancake/stack/router_spec.rb +24 -62
- data/spec/pancake/stack/stack_configuration_spec.rb +1 -1
- data/spec/pancake/stack/stack_spec.rb +47 -4
- data/spec/spec_helper.rb +3 -3
- metadata +56 -128
- data/bin/pancake-gen +0 -30
- data/lib/pancake/bootloaders.rb +0 -187
- data/lib/pancake/generators/base.rb +0 -12
- data/lib/pancake/generators/micro_generator.rb +0 -17
- data/lib/pancake/generators/short_generator.rb +0 -18
- data/lib/pancake/generators/templates/common/dotgitignore +0 -22
- data/lib/pancake/generators/templates/common/dothtaccess +0 -17
- data/lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt +0 -8
- data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +0 -12
- data/lib/pancake/generators/templates/micro/%stack_name%/pancake_init.rb.tt +0 -1
- 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 +0 -1
- data/lib/pancake/generators/templates/short/%stack_name%/README.tt +0 -7
- data/lib/pancake/generators/templates/short/%stack_name%/Rakefile.tt +0 -56
- data/lib/pancake/generators/templates/short/%stack_name%/VERSION.tt +0 -1
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +0 -12
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt +0 -6
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +0 -10
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/config.rb.tt +0 -23
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +0 -15
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +0 -16
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config/environments/staging.rb.tt +0 -17
- data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/models/.empty_directory +0 -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%/tasks/%stack_name%.rake.tt +0 -4
- 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 +0 -2
- data/lib/pancake/generators/templates/short/%stack_name%/pancake_init.rb.tt +0 -1
- data/lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt +0 -11
- data/lib/pancake/stack/app.rb +0 -10
- data/lib/pancake/stack/bootloader.rb +0 -114
- data/lib/pancake/stack/middleware.rb +0 -0
- data/lib/pancake/stacks/short.rb +0 -3
- data/lib/pancake/stacks/short/bootloaders.rb +0 -5
- data/lib/pancake/stacks/short/controller.rb +0 -184
- data/lib/pancake/stacks/short/default/views/base.html.haml +0 -5
- data/lib/pancake/stacks/short/default/views/error.html.haml +0 -12
- data/lib/pancake/stacks/short/stack.rb +0 -207
- data/spec/helpers/matchers.rb +0 -25
- data/spec/pancake/bootloaders_spec.rb +0 -119
- data/spec/pancake/stack/app_spec.rb +0 -28
- data/spec/pancake/stack/bootloader_spec.rb +0 -41
- data/spec/pancake/stack/middleware_spec.rb +0 -0
- data/spec/pancake/stacks/short/controller_spec.rb +0 -442
- data/spec/pancake/stacks/short/middlewares_spec.rb +0 -22
- data/spec/pancake/stacks/short/router_spec.rb +0 -150
- data/spec/pancake/stacks/short/stack_spec.rb +0 -117
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
-
|
3
|
-
describe "short stack middleware" do
|
4
|
-
before do
|
5
|
-
class ::FooBar < Pancake::Stacks::Short
|
6
|
-
add_root(__FILE__)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
clear_constants :FooBar
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should include the Pancake::Middlewares::Static middleware" do
|
15
|
-
FooBar.stackup
|
16
|
-
middleware = FooBar.middlewares.detect do |m|
|
17
|
-
m.middleware == Pancake::Middlewares::Static
|
18
|
-
end
|
19
|
-
middleware.should_not be_nil
|
20
|
-
middleware.args.should == [FooBar]
|
21
|
-
end
|
22
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)),'..', '..', '..', 'spec_helper')
|
2
|
-
|
3
|
-
describe Pancake::Stacks::Short, "routes" do
|
4
|
-
before do
|
5
|
-
class ::RoutedShortStack < Pancake::Stacks::Short
|
6
|
-
roots << Pancake.get_root(__FILE__)
|
7
|
-
|
8
|
-
get "/", :_name => :root do
|
9
|
-
"get - /"
|
10
|
-
end
|
11
|
-
|
12
|
-
get "/foo", :_name => :foo do
|
13
|
-
"get - foo"
|
14
|
-
end
|
15
|
-
|
16
|
-
get "/bar", :_name => :bar do
|
17
|
-
"get - bar"
|
18
|
-
end
|
19
|
-
|
20
|
-
post "/foo" do
|
21
|
-
"post - foo"
|
22
|
-
end
|
23
|
-
|
24
|
-
post "/bar" do
|
25
|
-
"post - bar"
|
26
|
-
end
|
27
|
-
|
28
|
-
put "/foo" do
|
29
|
-
"put - foo"
|
30
|
-
end
|
31
|
-
|
32
|
-
put "/bar" do
|
33
|
-
"put - bar"
|
34
|
-
end
|
35
|
-
|
36
|
-
delete "/foo" do
|
37
|
-
"delete - foo"
|
38
|
-
end
|
39
|
-
|
40
|
-
delete "/bar" do
|
41
|
-
"delete - bar"
|
42
|
-
end
|
43
|
-
|
44
|
-
any "/any/foo" do
|
45
|
-
"any - foo"
|
46
|
-
end
|
47
|
-
|
48
|
-
get "/baz/:var(/:date)" do
|
49
|
-
"done: var == #{params[:var]} : date == #{params[:date]}"
|
50
|
-
end.name(:baz)
|
51
|
-
end
|
52
|
-
@app = RoutedShortStack.stackup
|
53
|
-
end
|
54
|
-
after do
|
55
|
-
clear_constants "RoutedShortStack", "FooApp", "BarApp"
|
56
|
-
end
|
57
|
-
|
58
|
-
def app
|
59
|
-
@app
|
60
|
-
end
|
61
|
-
|
62
|
-
%w(foo bar).each do |item|
|
63
|
-
%w(get post put delete).each do |method|
|
64
|
-
it "should #{method} /#{item}" do
|
65
|
-
result = self.send(method, "/#{item}")
|
66
|
-
result.status.should == 200
|
67
|
-
result.body.should == "#{method} - #{item}"
|
68
|
-
end
|
69
|
-
end # get post put delete
|
70
|
-
end # foo bar
|
71
|
-
|
72
|
-
it "should return a not found if we try to get an action that has not been defined" do
|
73
|
-
result = get "/blah"
|
74
|
-
result.status.should == 404
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
it "should handle tricky routes" do
|
79
|
-
result = get "/baz/hassox"
|
80
|
-
result.status.should == 200
|
81
|
-
result.body.should == "done: var == hassox : date == "
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should handle tricky routes with optional parameters" do
|
85
|
-
result = get "/baz/hassox/2009-08-21"
|
86
|
-
result.status.should == 200
|
87
|
-
result.body.should == "done: var == hassox : date == 2009-08-21"
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should handle the any request method" do
|
91
|
-
[:get, :post, :put, :delete].each do |meth|
|
92
|
-
result = self.send(meth, "/any/foo")
|
93
|
-
result.status.should == 200
|
94
|
-
result.body.should == "any - foo"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "url generation" do
|
99
|
-
it "should generate a simple named url" do
|
100
|
-
Pancake.url(RoutedShortStack, :foo).should == "/foo"
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should generate a complex named url" do
|
104
|
-
Pancake.url(RoutedShortStack, :baz, :var => "bar").should == "/baz/bar"
|
105
|
-
Pancake.url(RoutedShortStack, :baz, :var => "bar", :date => "today").should == "/baz/bar/today"
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should generate it's url when it's nested" do
|
109
|
-
class ::FooApp < Pancake::Stack; end
|
110
|
-
FooApp.router.mount(RoutedShortStack, "/short/stack")
|
111
|
-
FooApp.router.mount_applications!
|
112
|
-
Pancake.url(RoutedShortStack, :foo).should == "/short/stack/foo"
|
113
|
-
Pancake.url(RoutedShortStack, :baz, :var => "var", :date => "today").should == "/short/stack/baz/var/today"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "inherited route generation" do
|
118
|
-
before do
|
119
|
-
class ::FooApp < RoutedShortStack; end
|
120
|
-
@app = FooApp.stackup
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should generate an inherited simple url" do
|
124
|
-
Pancake.url(FooApp, :foo).should == "/foo"
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should generate a complex url" do
|
128
|
-
Pancake.url(FooApp, :baz, :var => "the_var", :date => "today").should == "/baz/the_var/today"
|
129
|
-
end
|
130
|
-
|
131
|
-
%w(foo bar).each do |item|
|
132
|
-
%w(get post put delete).each do |method|
|
133
|
-
it "should #{method} /#{item}" do
|
134
|
-
result = self.send(method, "/#{item}")
|
135
|
-
result.status.should == 200
|
136
|
-
result.body.should == "#{method} - #{item}"
|
137
|
-
end
|
138
|
-
end # get post put delete
|
139
|
-
end # foo bar
|
140
|
-
|
141
|
-
it "should match the nested route without affecting the parent" do
|
142
|
-
class ::BarApp < Pancake::Stack; end
|
143
|
-
BarApp.router.mount(FooApp, "/mount/point")
|
144
|
-
BarApp.router.mount_applications!
|
145
|
-
|
146
|
-
Pancake.url(FooApp, :foo).should == "/mount/point/foo"
|
147
|
-
Pancake.url(RoutedShortStack, :foo).should == "/foo"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
-
|
3
|
-
describe Pancake::Stacks::Short do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@master_before = [Pancake.master_stack, Pancake.master_templates]
|
7
|
-
$captures = []
|
8
|
-
class ::ShortMiddle
|
9
|
-
attr_accessor :app
|
10
|
-
def initialize(app)
|
11
|
-
@app = app
|
12
|
-
end
|
13
|
-
|
14
|
-
def call(env)
|
15
|
-
$captures << ShortMiddle
|
16
|
-
@app.call(env)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class ::ShortFoo < Pancake::Stacks::Short
|
21
|
-
roots << Pancake.get_root(__FILE__)
|
22
|
-
add_root(__FILE__, "..", "..", "fixtures", "stacks", "short", "foobar")
|
23
|
-
add_root(__FILE__, "..", "..", "fixtures", "stacks", "short", "foobar", "other_root")
|
24
|
-
use ShortMiddle
|
25
|
-
|
26
|
-
|
27
|
-
get "/foo" do
|
28
|
-
"HERE"
|
29
|
-
end
|
30
|
-
|
31
|
-
get "/" do
|
32
|
-
$captures << self.class
|
33
|
-
render :inherited_from_base
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
@app = ShortFoo
|
38
|
-
Pancake.master_stack = ShortFoo
|
39
|
-
Pancake.master_templates = ShortFoo
|
40
|
-
end
|
41
|
-
|
42
|
-
after do
|
43
|
-
clear_constants :ShortFoo, :ShortMiddle, :OtherFoo, "ShortFoo::Router"
|
44
|
-
Pancake.master_stack, Pancake.master_templates = @master_before
|
45
|
-
end
|
46
|
-
|
47
|
-
def app
|
48
|
-
@app.stackup
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should provide access through the stack interface to the templates" do
|
52
|
-
ShortFoo.template(:inherited_from_base).should be_an_instance_of(Pancake::Mixins::Render::Template)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should go through the middleware to get to the actions" do
|
56
|
-
get "/foo"
|
57
|
-
$captures.should == [ShortMiddle]
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "inheritance" do
|
61
|
-
before do
|
62
|
-
class ::OtherFoo < ShortFoo; end
|
63
|
-
ShortFoo.router.mount(OtherFoo, "/other")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should render the same template in the child as it does in the parent" do
|
67
|
-
get "/"
|
68
|
-
$captures.pop.should == ShortFoo::Controller
|
69
|
-
last_response.should match(/inherited from base/)
|
70
|
-
result = get "/other/"
|
71
|
-
$captures.pop.should == OtherFoo::Controller
|
72
|
-
last_response.should match(/inherited from base/)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "helpers" do
|
77
|
-
before do
|
78
|
-
$captures = []
|
79
|
-
class ::ShortFoo
|
80
|
-
helpers do
|
81
|
-
def in_helper?
|
82
|
-
$captures << :in_helper?
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should allow me to setup a helper method in the stack" do
|
89
|
-
ShortFoo.get("/with_helper"){ in_helper?; "OK" }
|
90
|
-
result = get "/with_helper"
|
91
|
-
result.should be_successful
|
92
|
-
$captures.should include(:in_helper?)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should provide the helpers in child stacks" do
|
96
|
-
class ::OtherFoo < ShortFoo; end
|
97
|
-
OtherFoo.get("/helper_action"){ in_helper?; "OK" }
|
98
|
-
@app = OtherFoo
|
99
|
-
result = get "/helper_action"
|
100
|
-
result.should be_successful
|
101
|
-
$captures.should include(:in_helper?)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should let me mixin modules to the helpers" do
|
105
|
-
module ::OtherFoo
|
106
|
-
def other_helper
|
107
|
-
$captures << :other_helper
|
108
|
-
end
|
109
|
-
end
|
110
|
-
ShortFoo.helpers{ include OtherFoo }
|
111
|
-
ShortFoo.get("/foo"){ other_helper; "OK" }
|
112
|
-
result = get "/foo"
|
113
|
-
result.should be_successful
|
114
|
-
$captures.should include(:other_helper)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|