rocketio 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51fdeef94b06a674a04316766088ddff1366635a
4
- data.tar.gz: 8804955067cd66dbbbe011f53481484f69d072fb
3
+ metadata.gz: 36eba071bea110611c309b5fe6aa7ff394e7bbd2
4
+ data.tar.gz: 23f34bab298dbe32d802a727bffc2e9d34203672
5
5
  SHA512:
6
- metadata.gz: 178ba8589ad57652cd19595dbddef2fe6d4b06e3aa999cc7ea170eafffbb59f9e96e385fa598b11df833ffbea49f241d5a8fe3c8f93eeb8f18d0f658b16db9c3
7
- data.tar.gz: c86a96c3d50ba9bc0cb466958550a1b06945f3f040d29225e1e0653b45bb132d2b0fd0dd799b01c58761255a9d54a560667a74888e20383539405fb417630e7f
6
+ metadata.gz: 2f95ee86bbb12c1ceec9d8288e526940dd8ea036f6c9566162dcfa7a03583b159ecee1e0fed8fc3a962bc4b589c01be2ad149408e47195c1ac7b718e5ebe128a
7
+ data.tar.gz: 613c888e3704cddb848c36a177428b09de78934a26e1d96335e2994af4075eac17622ad03c943fb1b000b79b086ace61376c76360fc4e8fc8197f82046b14759
@@ -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(:call!, block)}}
7
+ controllers.each {|c| c.class_exec {private define_method(:__run__, block)}}
8
8
  end
9
9
  @router = Router.new(*controllers)
10
10
  end
@@ -26,33 +26,41 @@ module RocketIO
26
26
  #
27
27
  def call env
28
28
  catch :__response__ do
29
- begin
30
- self.env = env
31
- validate_or_request_authentication_if_needed
32
- validate_or_request_authorization_if_needed
33
- validate_parameters
34
-
35
- call! proc {
36
- invoke_before_filter
37
- invoke_around_filter proc {
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
- error(500, e)
39
+ else
40
+ __call__(env)
51
41
  end
52
42
  end
53
43
  end
54
44
 
55
- def call! app
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)
@@ -1,3 +1,3 @@
1
1
  module RocketIO
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -108,8 +108,7 @@ spec 'expires' do
108
108
  end
109
109
 
110
110
  it 'fails when Time.parse raises an ArgumentError' do
111
- get '/boom'
112
- assert(last_response.status) == 500
111
+ assert {get '/boom'}.raise ArgumentError, /argument out of range/
113
112
  end
114
113
  end
115
114
 
@@ -104,9 +104,7 @@ spec :ContentType do
104
104
  "I AM FOO"
105
105
  end
106
106
  }
107
- get
108
- assert(last_response.status) == 500
109
- assert(last_response.body) =~ /Unknown media type: :bizzle/
107
+ assert { get }.raise ArgumentError, /Unknown media type: :bizzle/
110
108
  end
111
109
 
112
110
 
@@ -65,13 +65,11 @@ spec :ErrorHandlers do
65
65
  end
66
66
 
67
67
  context '500: Fatal Error' do
68
- it 'uses default handler' do
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) =~ /500.+badgirl/im
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.1
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: 2015-12-23 00:00:00.000000000 Z
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.4.5.1
210
+ rubygems_version: 2.5.1
212
211
  signing_key:
213
212
  specification_version: 4
214
- summary: '["rocketio-0.0.1", "Simple, fast, scalable web framework for Ruby"]'
213
+ summary: '["rocketio-0.0.2", "Simple, fast, scalable web framework for Ruby"]'
215
214
  test_files: []
@@ -1,3 +0,0 @@
1
- <h1>500: Fatal Error</h1>
2
- <hr>
3
- <h4>{{error.message}}</h4>