watts 0.0.4 → 0.0.5
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/Rakefile +1 -1
- data/lib/watts.rb +15 -3
- metadata +3 -3
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ spec = Gem::Specification.new { |s|
|
|
22
22
|
"Resource-oriented, Rack-based, minimalist web framework."
|
23
23
|
s.homepage = "http://debu.gs/#{s.name}"
|
24
24
|
%w(metaid).each &s.method(:add_dependency)
|
25
|
-
s.version = '0.0.
|
25
|
+
s.version = '0.0.5'
|
26
26
|
}
|
27
27
|
|
28
28
|
Rake::RDocTask.new(:doc) { |t|
|
data/lib/watts.rb
CHANGED
@@ -159,6 +159,7 @@ module Watts
|
|
159
159
|
resource_class, args = match req_path
|
160
160
|
|
161
161
|
if resource_class
|
162
|
+
env = env.merge :watts_app => self
|
162
163
|
res = resource_class.new(env)
|
163
164
|
res.send(rm, *args)
|
164
165
|
else
|
@@ -253,10 +254,13 @@ module Watts
|
|
253
254
|
|
254
255
|
to_instance :http_methods
|
255
256
|
attr_new Rack::Response, :response
|
256
|
-
attr_accessor :env, :response
|
257
|
+
attr_accessor :env, :response, :app
|
257
258
|
|
258
259
|
# Every resource, on being instantiated, is given the Rack env.
|
259
260
|
def initialize(env)
|
261
|
+
if app = env.delete(:watts_app)
|
262
|
+
self.app = app
|
263
|
+
end
|
260
264
|
self.env = env
|
261
265
|
self.response = Rack::Response.new
|
262
266
|
end
|
@@ -275,11 +279,19 @@ module Watts
|
|
275
279
|
]
|
276
280
|
end
|
277
281
|
|
282
|
+
def request
|
283
|
+
@request ||= Rack::Request.new(env)
|
284
|
+
end
|
285
|
+
|
278
286
|
# By default, we return "405 Method Not Allowed" and set the Allow:
|
279
287
|
# header appropriately.
|
280
288
|
def default_http_method(*args)
|
289
|
+
s = 'Method not allowed.'
|
281
290
|
[405,
|
282
|
-
{ 'Allow' => http_methods.join(', ')
|
291
|
+
{ 'Allow' => http_methods.join(', '),
|
292
|
+
'Content-Type' => 'text/plain',
|
293
|
+
'Content-Length' => s.bytesize.to_s,
|
294
|
+
},
|
283
295
|
['Method not allowed.']]
|
284
296
|
end
|
285
297
|
end
|
@@ -304,7 +316,7 @@ module Watts
|
|
304
316
|
body = view_class.new.send(view_method, *args)
|
305
317
|
[200,
|
306
318
|
{'Content-Type' => 'text/html',
|
307
|
-
'Content-Length' => body.
|
319
|
+
'Content-Length' => body.bytesize.to_s},
|
308
320
|
[body]]
|
309
321
|
end
|
310
322
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pete Elmore
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-10 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|