rocketio 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocketio/application.rb +1 -1
- data/lib/rocketio/controller.rb +30 -22
- data/lib/rocketio/controller/error_handlers.rb +0 -6
- data/lib/rocketio/version.rb +1 -1
- data/test/cache_control_test.rb +1 -2
- data/test/content_type_test.rb +1 -3
- data/test/error_handlers_test.rb +3 -5
- data/test/etag_test.rb +1 -3
- data/test/halt_test.rb +1 -3
- metadata +4 -5
- data/lib/rocketio/error_templates/500.html +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36eba071bea110611c309b5fe6aa7ff394e7bbd2
|
4
|
+
data.tar.gz: 23f34bab298dbe32d802a727bffc2e9d34203672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f95ee86bbb12c1ceec9d8288e526940dd8ea036f6c9566162dcfa7a03583b159ecee1e0fed8fc3a962bc4b589c01be2ad149408e47195c1ac7b718e5ebe128a
|
7
|
+
data.tar.gz: 613c888e3704cddb848c36a177428b09de78934a26e1d96335e2994af4075eac17622ad03c943fb1b000b79b086ace61376c76360fc4e8fc8197f82046b14759
|
data/lib/rocketio/application.rb
CHANGED
@@ -4,7 +4,7 @@ module RocketIO
|
|
4
4
|
def initialize *args, &block
|
5
5
|
controllers = args.empty? ? RocketIO.controllers : args.flatten
|
6
6
|
if block
|
7
|
-
controllers.each {|c| c.class_exec {define_method(:
|
7
|
+
controllers.each {|c| c.class_exec {private define_method(:__run__, block)}}
|
8
8
|
end
|
9
9
|
@router = Router.new(*controllers)
|
10
10
|
end
|
data/lib/rocketio/controller.rb
CHANGED
@@ -26,33 +26,41 @@ module RocketIO
|
|
26
26
|
#
|
27
27
|
def call env
|
28
28
|
catch :__response__ do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
response.body = public_send(requested_method, *path_params_array)
|
39
|
-
}
|
40
|
-
invoke_after_filter
|
41
|
-
}
|
42
|
-
response.body ||= RocketIO::EMPTY_ARRAY
|
43
|
-
response.body = [] if head? # dropping body on HEAD requests
|
44
|
-
response.finish
|
45
|
-
rescue Exception => e
|
46
|
-
if RocketIO.development?
|
47
|
-
puts "\e[0;31m%s\e[0m" % e.inspect
|
48
|
-
e.backtrace.each {|l| puts " \e[0;36m%s\e[0m" % l}
|
29
|
+
if error_handlers[500]
|
30
|
+
begin
|
31
|
+
__call__(env)
|
32
|
+
rescue Exception => e
|
33
|
+
if RocketIO.development?
|
34
|
+
puts "\e[0;31m%s\e[0m" % e.inspect
|
35
|
+
e.backtrace.each {|l| puts " \e[0;36m%s\e[0m" % l}
|
36
|
+
end
|
37
|
+
error(500, e)
|
49
38
|
end
|
50
|
-
|
39
|
+
else
|
40
|
+
__call__(env)
|
51
41
|
end
|
52
42
|
end
|
53
43
|
end
|
54
44
|
|
55
|
-
def
|
45
|
+
private def __call__ env
|
46
|
+
self.env = env
|
47
|
+
validate_or_request_authentication_if_needed
|
48
|
+
validate_or_request_authorization_if_needed
|
49
|
+
validate_parameters
|
50
|
+
|
51
|
+
__run__ proc {
|
52
|
+
invoke_before_filter
|
53
|
+
invoke_around_filter proc {
|
54
|
+
response.body = public_send(requested_method, *path_params_array)
|
55
|
+
}
|
56
|
+
invoke_after_filter
|
57
|
+
}
|
58
|
+
response.body ||= RocketIO::EMPTY_ARRAY
|
59
|
+
response.body = [] if head? # dropping body on HEAD requests
|
60
|
+
response.finish
|
61
|
+
end
|
62
|
+
|
63
|
+
private def __run__ app
|
56
64
|
app.call
|
57
65
|
end
|
58
66
|
|
@@ -75,12 +75,6 @@ module RocketIO
|
|
75
75
|
})
|
76
76
|
end
|
77
77
|
|
78
|
-
# 500: Fatal Error
|
79
|
-
error 500 do |error|
|
80
|
-
error = StandardError.new(error) unless Exception === error
|
81
|
-
RocketIO.error_renderer(500, xhr?, env: env, error: error)
|
82
|
-
end
|
83
|
-
|
84
78
|
# 501: Not Implemented
|
85
79
|
error 501 do
|
86
80
|
RocketIO.error_renderer(501, xhr?, env: env)
|
data/lib/rocketio/version.rb
CHANGED
data/test/cache_control_test.rb
CHANGED
data/test/content_type_test.rb
CHANGED
data/test/error_handlers_test.rb
CHANGED
@@ -65,13 +65,11 @@ spec :ErrorHandlers do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
context '500: Fatal Error' do
|
68
|
-
it '
|
68
|
+
it 'raises when no handler defined' do
|
69
69
|
app mock_controller {
|
70
70
|
def get; raise end
|
71
71
|
}
|
72
|
-
get
|
73
|
-
assert(last_response.status) == 500
|
74
|
-
assert(last_response.body) =~ /500.+fatal/i
|
72
|
+
assert {get}.raise RuntimeError
|
75
73
|
end
|
76
74
|
|
77
75
|
it 'uses custom handler' do
|
@@ -94,7 +92,7 @@ spec :ErrorHandlers do
|
|
94
92
|
get
|
95
93
|
assert(called) == true
|
96
94
|
assert(last_response.status) == 500
|
97
|
-
assert(last_response.body) =~ /
|
95
|
+
assert(last_response.body) =~ /badgirl/im
|
98
96
|
end
|
99
97
|
end
|
100
98
|
|
data/test/etag_test.rb
CHANGED
@@ -438,8 +438,6 @@ spec :etag do
|
|
438
438
|
|
439
439
|
it 'raises an ArgumentError for an invalid strength' do
|
440
440
|
run_with(:get, "that's weak, dude.") {etag 'FOO', :w00t}
|
441
|
-
get
|
442
|
-
assert(last_response.status) == 500
|
443
|
-
assert(last_response.body) =~ /:strong or :weak expected/
|
441
|
+
assert {get}.raise ArgumentError, /:strong or :weak expected/
|
444
442
|
end
|
445
443
|
end
|
data/test/halt_test.rb
CHANGED
@@ -59,9 +59,7 @@ spec :HaltTest do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'returns a fatal error unless given array\'s second element is a Hash' do
|
62
|
-
halt_app [200, 'wrong headers', 'boby']
|
63
|
-
assert(last_response.status) == 500
|
64
|
-
assert(last_response.body) =~ /no implicit conversion of String into Hash/
|
62
|
+
assert {halt_app [200, 'wrong headers', 'boby']}.raise TypeError, /no implicit conversion of String into Hash/
|
65
63
|
end
|
66
64
|
|
67
65
|
it 'halts right away ignoring other arguments if a Rack::Response passed as first argument' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slee Woo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -146,7 +146,6 @@ files:
|
|
146
146
|
- lib/rocketio/controller/websocket.rb
|
147
147
|
- lib/rocketio/error_templates/404.html
|
148
148
|
- lib/rocketio/error_templates/409.html
|
149
|
-
- lib/rocketio/error_templates/500.html
|
150
149
|
- lib/rocketio/error_templates/501.html
|
151
150
|
- lib/rocketio/error_templates/layout.html
|
152
151
|
- lib/rocketio/exceptions.rb
|
@@ -208,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
207
|
version: '0'
|
209
208
|
requirements: []
|
210
209
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.5.1
|
212
211
|
signing_key:
|
213
212
|
specification_version: 4
|
214
|
-
summary: '["rocketio-0.0.
|
213
|
+
summary: '["rocketio-0.0.2", "Simple, fast, scalable web framework for Ruby"]'
|
215
214
|
test_files: []
|