pakada 0.0.1 → 0.0.2

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/Gemfile CHANGED
@@ -3,3 +3,4 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "awesome_print"
6
+ gem "rake"
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ Very Extensible HTTP Container For Ruby
2
+ =======================================
3
+
4
+ TODO: Write documentation
@@ -1,3 +1,3 @@
1
1
  class Pakada
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/pakada.rb CHANGED
@@ -11,7 +11,7 @@ class Pakada
11
11
  Rack::Response.new("Hi, I'm Pakada #{VERSION}").finish
12
12
  end
13
13
 
14
- attr_reader :env, :modules, :hooks, :middleware
14
+ attr_reader :env, :modules, :hooking, :middleware
15
15
  attr_accessor :app
16
16
 
17
17
  def initialize
@@ -33,9 +33,9 @@ class Pakada
33
33
  def boot
34
34
  load_env
35
35
  load_modules
36
- load_hooks
36
+ load_hooking
37
37
 
38
- hooks.invoke(:boot) unless testing?
38
+ hooking.invoke(:boot) unless testing?
39
39
  end
40
40
 
41
41
  def load_env
@@ -48,9 +48,9 @@ class Pakada
48
48
  end
49
49
  end
50
50
 
51
- def load_hooks
51
+ def load_hooking
52
52
  raise "modules have not been loaded" unless modules.respond_to? :values
53
- @hooks = Hooked::Controller.new self, *modules.values
53
+ @hooking = Hooked::Controller.new self, *modules.values
54
54
  end
55
55
 
56
56
  def call(req_env)
@@ -66,7 +66,7 @@ class Pakada
66
66
 
67
67
  def handle_request(req_env)
68
68
  req = Rack::Request.new req_env
69
- hooks.invoke(:request, req).finish
69
+ hooking.invoke(:request, req).finish
70
70
  end
71
71
 
72
72
  hookable :boot do |nothing|; end
@@ -90,8 +90,8 @@ class Pakada
90
90
  instance.send m, *args, &block
91
91
  end
92
92
 
93
- def respond_to?(m)
94
- super(m) || instance.respond_to?(m)
93
+ def respond_to?(m, private = false)
94
+ super(m, private) || instance.respond_to?(m, private)
95
95
  end
96
96
  end
97
97
  end
data/spec/pakada_spec.rb CHANGED
@@ -4,8 +4,8 @@ describe Pakada do
4
4
  subject { Pakada.instance }
5
5
 
6
6
  it "is a hooking container" do
7
- Pakada.should respond_to(:hookable)
8
- Pakada.should respond_to(:hook)
7
+ Pakada.should respond_to(:hookables)
8
+ Pakada.should respond_to(:hooks)
9
9
  Pakada.instance.should respond_to(:hooked=)
10
10
  end
11
11
 
@@ -17,8 +17,8 @@ describe Pakada do
17
17
  end
18
18
 
19
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
20
+ Pakada.instance.should_receive(:respond_to?).with(:message, true) { true }
21
+ Pakada.respond_to?(:message, true).should be_true
22
22
 
23
23
  Pakada.instance.should_not_receive(:respond_to?).with(:instance)
24
24
  Pakada.respond_to?(:instance)
@@ -49,8 +49,8 @@ describe Pakada do
49
49
  def stub_load_methods
50
50
  subject.stub :load_env
51
51
  subject.stub :load_modules
52
- subject.stub :load_hooks
53
- subject.stub(:hooks) { double "hooks", :invoke => 123 }
52
+ subject.stub :load_hooking
53
+ subject.stub(:hooking) { double "hooks", :invoke => 123 }
54
54
  end
55
55
 
56
56
  it "calls .load_env" do
@@ -65,17 +65,17 @@ describe Pakada do
65
65
  subject.boot
66
66
  end
67
67
 
68
- it "calls .load_hooks" do
68
+ it "calls .load_hooking" do
69
69
  stub_load_methods
70
- subject.should_receive :load_hooks
70
+ subject.should_receive :load_hooking
71
71
  subject.boot
72
72
  end
73
73
 
74
74
  it "invokes the :boot hookable" do
75
75
  stub_load_methods
76
76
  obj = Object.new
77
- subject.stub(:hooks) { obj }
78
- subject.hooks.should_receive(:invoke).with(:boot)
77
+ subject.stub(:hooking) { obj }
78
+ subject.hooking.should_receive(:invoke).with(:boot)
79
79
  subject.boot
80
80
  end
81
81
 
@@ -83,8 +83,8 @@ describe Pakada do
83
83
  stub_load_methods
84
84
  subject.stub(:env) { :testing }
85
85
  obj = Object.new
86
- subject.stub(:hooks) { obj }
87
- subject.hooks.should_not_receive(:invoke).with(:boot)
86
+ subject.stub(:hooking) { obj }
87
+ subject.hooking.should_not_receive(:invoke).with(:boot)
88
88
  subject.boot
89
89
  end
90
90
  end
@@ -127,32 +127,32 @@ describe Pakada do
127
127
  end
128
128
  end
129
129
 
130
- describe ".load_hooks" do
130
+ describe ".load_hooking" do
131
131
  it "initializes the hooking controller" do
132
132
  subject.stub(:modules) { {} }
133
- subject.load_hooks
134
- subject.hooks.should respond_to(:invoke)
133
+ subject.load_hooking
134
+ subject.hooking.should respond_to(:invoke)
135
135
  end
136
136
 
137
137
  it "adds itself to the hooking controller" do
138
138
  subject.stub(:modules) { {} }
139
- subject.load_hooks
140
- subject.hooks.should have(1).containers
141
- subject.hooks.containers[0].should == subject
139
+ subject.load_hooking
140
+ subject.hooking.should have(1).containers
141
+ subject.hooking.containers[0].should == subject
142
142
  end
143
143
 
144
144
  it "adds the modules to the hooking controller" do
145
145
  modcls = double "module klass", :hookables => [], :hooks => {}
146
146
  mod = double "module", :hooked= => nil, :class => modcls
147
147
  subject.stub(:modules) { {:foo => mod} }
148
- subject.load_hooks
149
- subject.hooks.should have(2).containers
150
- subject.hooks.containers[1].should == mod
148
+ subject.load_hooking
149
+ subject.hooking.should have(2).containers
150
+ subject.hooking.containers[1].should == mod
151
151
  end
152
152
 
153
153
  it "fails if the modules have not been loaded" do
154
154
  subject.stub(:modules) { nil }
155
- proc { subject.load_hooks }.should raise_error(RuntimeError, "modules have not been loaded")
155
+ proc { subject.load_hooking }.should raise_error(RuntimeError, "modules have not been loaded")
156
156
  end
157
157
  end
158
158
 
@@ -238,7 +238,7 @@ describe Pakada do
238
238
  Rack::Request.stub(:new).with(req.env) { req }
239
239
  res = Rack::Response.new
240
240
  subject.boot
241
- subject.hooks.should_receive(:invoke).with(:request, req) {|r_e| res }
241
+ subject.hooking.should_receive(:invoke).with(:request, req) {|r_e| res }
242
242
  subject.handle_request(req.env).should == res.finish
243
243
  end
244
244
  end
@@ -253,17 +253,17 @@ describe Pakada do
253
253
  it "calls .app's return value with the request environment" do
254
254
  subject.app = stub "app"
255
255
  subject.app.should_receive(:call).with(@req.env) { @resp.finish }
256
- subject.hooks.invoke(:request, @req)
256
+ subject.hooking.invoke(:request, @req)
257
257
  end
258
258
 
259
259
  it "calls DEFAULT_APP if .app isn't set" do
260
260
  Pakada::DEFAULT_APP.should_receive(:call).with(@req.env) { @resp.finish }
261
- subject.hooks.invoke(:request, @req)
261
+ subject.hooking.invoke(:request, @req)
262
262
  end
263
263
 
264
264
  it "returns a Rack-compliant response" do
265
265
  Pakada.app = stub "app", :call => @resp.finish
266
- resp = subject.hooks.invoke(:request, @req)
266
+ resp = subject.hooking.invoke(:request, @req)
267
267
  resp.status.should == @resp.status
268
268
  resp.headers.should == @resp.headers
269
269
  resp.body.to_s.should == @resp.body.to_s
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lars Gierth
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-28 00:00:00 +01:00
17
+ date: 2010-12-30 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,7 @@ files:
119
119
  - .rspec
120
120
  - Gemfile
121
121
  - LICENSE
122
+ - README.md
122
123
  - Rakefile
123
124
  - lib/pakada.rb
124
125
  - lib/pakada/module.rb
@@ -141,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
142
  requirements:
142
143
  - - ">="
143
144
  - !ruby/object:Gem::Version
144
- hash: -431018637
145
+ hash: -781941123
145
146
  segments:
146
147
  - 0
147
148
  version: "0"
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
152
  - - ">="
152
153
  - !ruby/object:Gem::Version
153
- hash: -431018637
154
+ hash: -781941123
154
155
  segments:
155
156
  - 0
156
157
  version: "0"