pakada 0.0.0 → 0.0.1
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.
- data/.rspec +1 -0
- data/Gemfile +2 -9
- data/Rakefile +7 -2
- data/lib/pakada/module.rb +41 -57
- data/lib/pakada/version.rb +1 -1
- data/lib/pakada.rb +80 -96
- data/pakada.gemspec +27 -0
- data/spec/module_spec.rb +180 -0
- data/spec/pakada_spec.rb +272 -0
- data/spec/spec_helper.rb +15 -0
- metadata +53 -61
- data/README.rdoc +0 -1
- data/lib/pakada/application.rb +0 -23
- data/lib/pakada/boot.rb +0 -7
- data/lib/pakada/support/aliasing.rb +0 -8
- data/lib/pakada/support/inflection.rb +0 -35
- data/lib/pakada/support/instance_exec.rb +0 -27
- data/lib/pakada/support.rb +0 -9
- data/lib/pakada/tasks.rb +0 -22
- data/lib/pakada/test.rb +0 -14
- data/lib/pakada/test_case.rb +0 -69
- data/tasks/test.rb +0 -73
- data/test/files.rb +0 -60
- data/test/helper.rb +0 -1
- data/test/module_test.rb +0 -81
- data/test/pakada_test.rb +0 -80
data/spec/pakada_spec.rb
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Pakada do
|
4
|
+
subject { Pakada.instance }
|
5
|
+
|
6
|
+
it "is a hooking container" do
|
7
|
+
Pakada.should respond_to(:hookable)
|
8
|
+
Pakada.should respond_to(:hook)
|
9
|
+
Pakada.instance.should respond_to(:hooked=)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "forwards all messages to the Singleton instance" do
|
13
|
+
Pakada.instance.should_receive(:message)
|
14
|
+
Pakada.message
|
15
|
+
|
16
|
+
proc { Pakada.other_message }.should raise_error(NoMethodError, /`other_message'/)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "forwards .respond_to? to the Singleton instance" do
|
20
|
+
Pakada.instance.should_receive(:respond_to?).with(:message) { true }
|
21
|
+
Pakada.respond_to?(:message).should be_true
|
22
|
+
|
23
|
+
Pakada.instance.should_not_receive(:respond_to?).with(:instance)
|
24
|
+
Pakada.respond_to?(:instance)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "::DEFAULT_APP" do
|
28
|
+
it "prints a tender welcome greeting" do
|
29
|
+
Pakada::DEFAULT_APP.call({})[2].to_a.to_s.should =~ /Pakada #{Pakada::VERSION}/
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".instance" do
|
34
|
+
it "creates a new Singleton instance and returns it" do
|
35
|
+
Pakada.stub(:new) { double "a Pakada instance" }
|
36
|
+
Pakada.instance.should == Pakada.instance
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe ".reset_instance" do
|
41
|
+
it "unsets the Singleton instance" do
|
42
|
+
instance = Pakada.instance
|
43
|
+
Pakada.reset_instance
|
44
|
+
Pakada.instance.should_not == instance
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".boot" do
|
49
|
+
def stub_load_methods
|
50
|
+
subject.stub :load_env
|
51
|
+
subject.stub :load_modules
|
52
|
+
subject.stub :load_hooks
|
53
|
+
subject.stub(:hooks) { double "hooks", :invoke => 123 }
|
54
|
+
end
|
55
|
+
|
56
|
+
it "calls .load_env" do
|
57
|
+
stub_load_methods
|
58
|
+
subject.should_receive :load_env
|
59
|
+
subject.boot
|
60
|
+
end
|
61
|
+
|
62
|
+
it "calls .load_modules" do
|
63
|
+
stub_load_methods
|
64
|
+
subject.should_receive :load_modules
|
65
|
+
subject.boot
|
66
|
+
end
|
67
|
+
|
68
|
+
it "calls .load_hooks" do
|
69
|
+
stub_load_methods
|
70
|
+
subject.should_receive :load_hooks
|
71
|
+
subject.boot
|
72
|
+
end
|
73
|
+
|
74
|
+
it "invokes the :boot hookable" do
|
75
|
+
stub_load_methods
|
76
|
+
obj = Object.new
|
77
|
+
subject.stub(:hooks) { obj }
|
78
|
+
subject.hooks.should_receive(:invoke).with(:boot)
|
79
|
+
subject.boot
|
80
|
+
end
|
81
|
+
|
82
|
+
it "doesn't invoke the :boot hookable in testing environment" do
|
83
|
+
stub_load_methods
|
84
|
+
subject.stub(:env) { :testing }
|
85
|
+
obj = Object.new
|
86
|
+
subject.stub(:hooks) { obj }
|
87
|
+
subject.hooks.should_not_receive(:invoke).with(:boot)
|
88
|
+
subject.boot
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe ".hookable(:boot)" do
|
93
|
+
it "does nothing" do; end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ".load_env" do
|
97
|
+
before :each do
|
98
|
+
@env = ENV["RACK_ENV"]
|
99
|
+
end
|
100
|
+
|
101
|
+
after :each do
|
102
|
+
ENV["RACK_ENV"] = @env
|
103
|
+
end
|
104
|
+
|
105
|
+
it "uses RACK_ENV to determine the runtime environment" do
|
106
|
+
ENV["RACK_ENV"] = "something"
|
107
|
+
subject.load_env
|
108
|
+
subject.env.should == :something
|
109
|
+
end
|
110
|
+
|
111
|
+
it "is uses 'development' as the default environment" do
|
112
|
+
ENV.delete "RACK_ENV"
|
113
|
+
subject.load_env
|
114
|
+
subject.env.should == :development
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe ".load_modules!" do
|
119
|
+
it "loads the modules" do
|
120
|
+
mod = double "module"
|
121
|
+
modcls = double "module class", :module_name => :foo
|
122
|
+
modcls.should_receive(:new) { mod }
|
123
|
+
Pakada::Module.stub(:descendants) { {:foo => modcls} }
|
124
|
+
|
125
|
+
subject.load_modules
|
126
|
+
subject.modules[:foo].should == mod
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe ".load_hooks" do
|
131
|
+
it "initializes the hooking controller" do
|
132
|
+
subject.stub(:modules) { {} }
|
133
|
+
subject.load_hooks
|
134
|
+
subject.hooks.should respond_to(:invoke)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "adds itself to the hooking controller" do
|
138
|
+
subject.stub(:modules) { {} }
|
139
|
+
subject.load_hooks
|
140
|
+
subject.hooks.should have(1).containers
|
141
|
+
subject.hooks.containers[0].should == subject
|
142
|
+
end
|
143
|
+
|
144
|
+
it "adds the modules to the hooking controller" do
|
145
|
+
modcls = double "module klass", :hookables => [], :hooks => {}
|
146
|
+
mod = double "module", :hooked= => nil, :class => modcls
|
147
|
+
subject.stub(:modules) { {:foo => mod} }
|
148
|
+
subject.load_hooks
|
149
|
+
subject.hooks.should have(2).containers
|
150
|
+
subject.hooks.containers[1].should == mod
|
151
|
+
end
|
152
|
+
|
153
|
+
it "fails if the modules have not been loaded" do
|
154
|
+
subject.stub(:modules) { nil }
|
155
|
+
proc { subject.load_hooks }.should raise_error(RuntimeError, "modules have not been loaded")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe ".development?" do
|
160
|
+
it "is a shortcut for .env == :development" do
|
161
|
+
subject.stub(:env) { :development }
|
162
|
+
subject.development?.should be_true
|
163
|
+
|
164
|
+
subject.stub(:env) { :something }
|
165
|
+
subject.development?.should be_false
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe ".testing?" do
|
170
|
+
it "is a shortcut for .env == :testing" do
|
171
|
+
subject.stub(:env) { :testing }
|
172
|
+
subject.testing?.should be_true
|
173
|
+
|
174
|
+
subject.stub(:env) { :something }
|
175
|
+
subject.testing?.should be_false
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe ".production?" do
|
180
|
+
it "is a shortcut for .env == :production" do
|
181
|
+
subject.stub(:env) { :production }
|
182
|
+
subject.production?.should be_true
|
183
|
+
|
184
|
+
subject.stub(:env) { :something }
|
185
|
+
subject.production?.should be_false
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe ".middleware" do
|
190
|
+
it "is a simple Array" do
|
191
|
+
Array.should === subject.middleware
|
192
|
+
end
|
193
|
+
|
194
|
+
it "is empty initially" do
|
195
|
+
subject.middleware.should be_empty
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe ".to_app" do
|
200
|
+
it "builds a Rack endpoint with .middleware and .handle_request" do
|
201
|
+
@builder = Rack::Builder.new
|
202
|
+
Rack::Builder.stub(:new) { @builder }
|
203
|
+
|
204
|
+
mw1 = Class.new do
|
205
|
+
attr_reader :app
|
206
|
+
def initialize(app); @app = app; end
|
207
|
+
end
|
208
|
+
mw2 = mw1.clone
|
209
|
+
subject.middleware << mw1 << mw2
|
210
|
+
|
211
|
+
prc = nil
|
212
|
+
@builder.should_receive(:use).with(mw1).once
|
213
|
+
@builder.should_receive(:use).with(mw2).once
|
214
|
+
@builder.should_receive(:run).with(duck_type(:call)).once {|p| prc = p }
|
215
|
+
subject.to_app
|
216
|
+
|
217
|
+
req_env = {"key" => "value"}
|
218
|
+
res = [200, {}, ""]
|
219
|
+
subject.should_receive(:handle_request).with(req_env) {|r_e| res }
|
220
|
+
prc.call(req_env).should == res
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe ".call" do
|
225
|
+
it "forwards to .to_app.call" do
|
226
|
+
req = {"key" => "value"}
|
227
|
+
resp = Rack::Response.new("hello!").finish
|
228
|
+
app = double "app"
|
229
|
+
subject.should_receive(:to_app) { app }
|
230
|
+
app.should_receive(:call).with(req) { resp }
|
231
|
+
subject.call(req).should == resp
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe ".handle_request" do
|
236
|
+
it "invokes the :request hookable" do
|
237
|
+
req = Rack::Request.new "key" => "value"
|
238
|
+
Rack::Request.stub(:new).with(req.env) { req }
|
239
|
+
res = Rack::Response.new
|
240
|
+
subject.boot
|
241
|
+
subject.hooks.should_receive(:invoke).with(:request, req) {|r_e| res }
|
242
|
+
subject.handle_request(req.env).should == res.finish
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe ".hookable(:request)" do
|
247
|
+
before :each do
|
248
|
+
subject.boot
|
249
|
+
@req = Rack::Request.new "key" => "value"
|
250
|
+
@resp = Rack::Response.new("foo!", 201)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "calls .app's return value with the request environment" do
|
254
|
+
subject.app = stub "app"
|
255
|
+
subject.app.should_receive(:call).with(@req.env) { @resp.finish }
|
256
|
+
subject.hooks.invoke(:request, @req)
|
257
|
+
end
|
258
|
+
|
259
|
+
it "calls DEFAULT_APP if .app isn't set" do
|
260
|
+
Pakada::DEFAULT_APP.should_receive(:call).with(@req.env) { @resp.finish }
|
261
|
+
subject.hooks.invoke(:request, @req)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "returns a Rack-compliant response" do
|
265
|
+
Pakada.app = stub "app", :call => @resp.finish
|
266
|
+
resp = subject.hooks.invoke(:request, @req)
|
267
|
+
resp.status.should == @resp.status
|
268
|
+
resp.headers.should == @resp.headers
|
269
|
+
resp.body.to_s.should == @resp.body.to_s
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup :default, :development
|
3
|
+
|
4
|
+
require "pakada"
|
5
|
+
|
6
|
+
require "fakefs/safe"
|
7
|
+
require "fakefs/require"
|
8
|
+
|
9
|
+
begin
|
10
|
+
require "awesome_print"
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.before(:each) { Pakada.reset_instance }
|
15
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakada
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 31
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Lars Gierth
|
@@ -15,96 +14,101 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-28 00:00:00 +01:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
23
|
-
prerelease: false
|
21
|
+
name: rack
|
24
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
|
-
- -
|
25
|
+
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
27
|
segments:
|
31
|
-
-
|
32
|
-
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 1
|
31
|
+
version: 1.2.1
|
33
32
|
type: :runtime
|
33
|
+
prerelease: false
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
37
|
-
prerelease: false
|
36
|
+
name: hooked
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
41
|
-
- -
|
40
|
+
- - ~>
|
42
41
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 3
|
44
42
|
segments:
|
45
43
|
- 0
|
46
|
-
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
version: 0.1.0
|
47
47
|
type: :runtime
|
48
|
+
prerelease: false
|
48
49
|
version_requirements: *id002
|
49
50
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
51
|
-
prerelease: false
|
51
|
+
name: rspec
|
52
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
hash: 3
|
58
57
|
segments:
|
59
|
-
-
|
60
|
-
|
61
|
-
|
58
|
+
- 2
|
59
|
+
- 3
|
60
|
+
version: "2.3"
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
62
63
|
version_requirements: *id003
|
63
64
|
- !ruby/object:Gem::Dependency
|
64
65
|
name: mocha
|
65
|
-
prerelease: false
|
66
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
67
|
none: false
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ~>
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
hash: 3
|
72
71
|
segments:
|
73
72
|
- 0
|
74
|
-
|
73
|
+
- 9
|
74
|
+
- 10
|
75
|
+
version: 0.9.10
|
75
76
|
type: :development
|
77
|
+
prerelease: false
|
76
78
|
version_requirements: *id004
|
77
79
|
- !ruby/object:Gem::Dependency
|
78
80
|
name: fakefs
|
79
|
-
prerelease: false
|
80
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
81
82
|
none: false
|
82
83
|
requirements:
|
83
|
-
- -
|
84
|
+
- - ~>
|
84
85
|
- !ruby/object:Gem::Version
|
85
|
-
hash: 3
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
|
88
|
+
- 3
|
89
|
+
- 1
|
90
|
+
version: 0.3.1
|
89
91
|
type: :development
|
92
|
+
prerelease: false
|
90
93
|
version_requirements: *id005
|
91
94
|
- !ruby/object:Gem::Dependency
|
92
95
|
name: fakefs-require
|
93
|
-
prerelease: false
|
94
96
|
requirement: &id006 !ruby/object:Gem::Requirement
|
95
97
|
none: false
|
96
98
|
requirements:
|
97
|
-
- -
|
99
|
+
- - ~>
|
98
100
|
- !ruby/object:Gem::Version
|
99
|
-
hash: 3
|
100
101
|
segments:
|
101
102
|
- 0
|
102
|
-
|
103
|
+
- 2
|
104
|
+
- 1
|
105
|
+
version: 0.2.1
|
103
106
|
type: :development
|
107
|
+
prerelease: false
|
104
108
|
version_requirements: *id006
|
105
109
|
description:
|
106
110
|
email:
|
107
|
-
-
|
111
|
+
- lars.gierth@gmail.com
|
108
112
|
executables: []
|
109
113
|
|
110
114
|
extensions: []
|
@@ -112,29 +116,19 @@ extensions: []
|
|
112
116
|
extra_rdoc_files: []
|
113
117
|
|
114
118
|
files:
|
115
|
-
-
|
116
|
-
- lib/pakada/support.rb
|
117
|
-
- lib/pakada/boot.rb
|
118
|
-
- lib/pakada/tasks.rb
|
119
|
-
- lib/pakada/test.rb
|
120
|
-
- lib/pakada/test_case.rb
|
121
|
-
- lib/pakada/application.rb
|
122
|
-
- lib/pakada/module.rb
|
123
|
-
- lib/pakada/support/aliasing.rb
|
124
|
-
- lib/pakada/support/instance_exec.rb
|
125
|
-
- lib/pakada/support/inflection.rb
|
126
|
-
- lib/pakada.rb
|
127
|
-
- tasks/test.rb
|
128
|
-
- test/pakada_test.rb
|
129
|
-
- test/files.rb
|
130
|
-
- test/module_test.rb
|
131
|
-
- test/helper.rb
|
119
|
+
- .rspec
|
132
120
|
- Gemfile
|
133
121
|
- LICENSE
|
134
122
|
- Rakefile
|
135
|
-
-
|
123
|
+
- lib/pakada.rb
|
124
|
+
- lib/pakada/module.rb
|
125
|
+
- lib/pakada/version.rb
|
126
|
+
- pakada.gemspec
|
127
|
+
- spec/module_spec.rb
|
128
|
+
- spec/pakada_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
136
130
|
has_rdoc: true
|
137
|
-
homepage: http://
|
131
|
+
homepage: http://rubygems.org/gems/pakada
|
138
132
|
licenses: []
|
139
133
|
|
140
134
|
post_install_message:
|
@@ -147,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
141
|
requirements:
|
148
142
|
- - ">="
|
149
143
|
- !ruby/object:Gem::Version
|
150
|
-
hash:
|
144
|
+
hash: -431018637
|
151
145
|
segments:
|
152
146
|
- 0
|
153
147
|
version: "0"
|
@@ -156,18 +150,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
150
|
requirements:
|
157
151
|
- - ">="
|
158
152
|
- !ruby/object:Gem::Version
|
159
|
-
hash:
|
153
|
+
hash: -431018637
|
160
154
|
segments:
|
161
|
-
-
|
162
|
-
|
163
|
-
- 6
|
164
|
-
version: 1.3.6
|
155
|
+
- 0
|
156
|
+
version: "0"
|
165
157
|
requirements: []
|
166
158
|
|
167
159
|
rubyforge_project:
|
168
160
|
rubygems_version: 1.3.7
|
169
161
|
signing_key:
|
170
162
|
specification_version: 3
|
171
|
-
summary:
|
163
|
+
summary: Very Extensible HTTP Container For Ruby
|
172
164
|
test_files: []
|
173
165
|
|
data/README.rdoc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
= Drupal-like awesomeness on Ruby
|
data/lib/pakada/application.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class Pakada
|
2
|
-
class Application
|
3
|
-
class << self
|
4
|
-
attr_reader :request, :response
|
5
|
-
|
6
|
-
def call(request_env)
|
7
|
-
Pakada.hook(:reset)
|
8
|
-
|
9
|
-
request = Rack::Request.new(request_env)
|
10
|
-
response = Rack::Response.new
|
11
|
-
|
12
|
-
@request, @response = request, response
|
13
|
-
Pakada.hook(:request)
|
14
|
-
|
15
|
-
response.write("Hi, I'm Pakada!") if response.length == 0
|
16
|
-
|
17
|
-
Pakada.hook(:response)
|
18
|
-
@request, @response = nil, nil
|
19
|
-
return response.finish
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/pakada/boot.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
|
3
|
-
def classify()
|
4
|
-
Extlib::Inflection.classify(self)
|
5
|
-
end
|
6
|
-
|
7
|
-
def camelize()
|
8
|
-
Extlib::Inflection.camelize(self)
|
9
|
-
end
|
10
|
-
|
11
|
-
def underscore()
|
12
|
-
Extlib::Inflection.underscore(self)
|
13
|
-
end
|
14
|
-
|
15
|
-
def humanize()
|
16
|
-
Extlib::Inflection.humanize(self)
|
17
|
-
end
|
18
|
-
|
19
|
-
def demodulize()
|
20
|
-
Extlib::Inflection.demodulize(self)
|
21
|
-
end
|
22
|
-
|
23
|
-
def tableize()
|
24
|
-
Extlib::Inflection.tableize(self)
|
25
|
-
end
|
26
|
-
|
27
|
-
def foreign_key()
|
28
|
-
Extlib::Inflection.foreign_key(self)
|
29
|
-
end
|
30
|
-
|
31
|
-
def constantize()
|
32
|
-
Extlib::Inflection.constantize(self)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
|
3
|
-
module InstanceExecHelper
|
4
|
-
end
|
5
|
-
|
6
|
-
include InstanceExecHelper
|
7
|
-
|
8
|
-
# this leaks memory
|
9
|
-
# see http://eigenclass.org/hiki/bounded+space+instance_exec
|
10
|
-
def instance_exec(*args, &block)
|
11
|
-
begin
|
12
|
-
old_critical, Thread.critical = Thread.critical, true
|
13
|
-
n = 0
|
14
|
-
n += 1 while respond_to?(mname = "__instance_exec#{n}")
|
15
|
-
InstanceExecHelper.module_eval { define_method(mname, &block) }
|
16
|
-
ensure
|
17
|
-
Thread.critical = old_critical
|
18
|
-
end
|
19
|
-
begin
|
20
|
-
ret = send(mname, *args)
|
21
|
-
ensure
|
22
|
-
InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
|
23
|
-
end
|
24
|
-
return ret
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
data/lib/pakada/support.rb
DELETED
data/lib/pakada/tasks.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require "pakada"
|
2
|
-
|
3
|
-
dirs = []
|
4
|
-
|
5
|
-
# core's tasks
|
6
|
-
dirs << Gem.loaded_specs["pakada"].full_gem_path
|
7
|
-
|
8
|
-
# modules' tasks
|
9
|
-
ENV["RACK_ENV"] ||= "development"
|
10
|
-
Bundler.setup(:modules, :default, ENV["RACK_ENV"].to_sym)
|
11
|
-
Pakada::Module.load
|
12
|
-
Pakada::Module.descendants.each do |name, mod|
|
13
|
-
dirs << mod[:gemspec].full_gem_path
|
14
|
-
end
|
15
|
-
|
16
|
-
# project's tasks
|
17
|
-
dirs << Dir.pwd
|
18
|
-
|
19
|
-
# load the tasks
|
20
|
-
dirs.uniq.each do |dir|
|
21
|
-
Dir["#{dir}/tasks/*"].each {|f| require(f) }
|
22
|
-
end
|
data/lib/pakada/test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
ENV["RACK_ENV"] = "testing"
|
2
|
-
require "bundler"
|
3
|
-
Bundler.setup(:pakada, :modules, :default, ENV["RACK_ENV"].to_sym)
|
4
|
-
|
5
|
-
require "pakada"
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "pakada/test_case"
|
9
|
-
Test::Unit::TestCase.class_eval { include(Pakada::TestCase) }
|
10
|
-
|
11
|
-
require "mocha"
|
12
|
-
require "fakefs/safe"
|
13
|
-
require "fakefs/require"
|
14
|
-
require "rack"
|