utopia 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2de92361694a0d93055b13141f7373bdca9ba4c8
4
- data.tar.gz: abf743ebf57a07d8850fb22719ee62085e4c1166
3
+ metadata.gz: d79188e4c82a0e063f4d4d322b9c9f6ede2abac6
4
+ data.tar.gz: 066c1fd1bece542a5a6e310bfdcff65670a0e91e
5
5
  SHA512:
6
- metadata.gz: bdeeca349e075376b9a5a65c97195e92e4e67c3b6c21077ab93fbf86395dd4745b41c63cc0362371a9af1b8162ece2a7c65011c081b617ef6e1cd05c0920280d
7
- data.tar.gz: 0a135fa1fd8069f1a8b90ea8f040bd1dad4f71891e37735099184a3579d2191f21a8e8bf0b87955ffe6d4835561ce28f9b21d97423ba7b423b9a8b0d4afaeec7
6
+ metadata.gz: 39c11885cf3802fd246bcc6b551afc9164d4d9e3f13f27823be4a59f9a1a8212517f81c9b630f8706ef565adfead313209f28e37a81180b086f8081aeec9e1c3
7
+ data.tar.gz: abb2c8242bcfd5d9a4213de4458756b78d4dbc1be049800100e888c0487e367112a277a40a5c19e74c374a2000fada23b3dde9b89a2176df75c2b71d1877587b
@@ -45,7 +45,7 @@ module Utopia
45
45
  return [400, {"Content-Type" => "text/html"}, body]
46
46
  end
47
47
 
48
- def redirect(env, ex)
48
+ def redirect(env, exception)
49
49
  return @app.call(env.merge('PATH_INFO' => @location, 'REQUEST_METHOD' => 'GET'))
50
50
  end
51
51
 
@@ -58,19 +58,19 @@ module Utopia
58
58
 
59
59
  log.error "Exception #{exception.to_s.dump}!"
60
60
 
61
- ex.backtrace.each do |bt|
62
- log.error bt
61
+ exception.backtrace.each do |line|
62
+ log.error line
63
63
  end
64
64
 
65
65
  # If the error occurred while accessing the error handler, we finish with a fatal error:
66
66
  if env['PATH_INFO'] == @location
67
- return fatal_error(env, ex)
67
+ return fatal_error(env, exception)
68
68
  else
69
69
  # If redirection fails, we also finish with a fatal error:
70
70
  begin
71
- return redirect(env, ex)
71
+ return redirect(env, exception)
72
72
  rescue
73
- return fatal_error(env, ex)
73
+ return fatal_error(env, exception)
74
74
  end
75
75
  end
76
76
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.0.0"
22
+ VERSION = "1.0.1"
23
23
  end
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ # Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require_relative 'spec_helper'
24
+
25
+ require 'rack/mock'
26
+ require 'rack/test'
27
+
28
+ require 'utopia/exception_handler'
29
+
30
+ module Utopia::ExceptionHandlerSpec
31
+ describe Utopia::ExceptionHandler do
32
+ include Rack::Test::Methods
33
+
34
+ let(:app) {Rack::Builder.parse_file(File.expand_path('../exception_handler_spec.ru', __FILE__)).first}
35
+
36
+ it "should successfully call the controller method" do
37
+ get "/controller/blow"
38
+
39
+ expect(last_response.status).to be == 400
40
+ expect(last_response.body).to be_include 'Fatal Error'
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,6 @@
1
+
2
+ use Utopia::ExceptionHandler, '/controller/exception'
3
+
4
+ use Utopia::Controller, root: File.expand_path('../pages', __FILE__)
5
+
6
+ run lambda {|env| [404, {}, []]}
@@ -25,4 +25,15 @@ end
25
25
 
26
26
  on 'index' do
27
27
  success! content: 'Hello World'
28
+ end
29
+
30
+ class TharSheBlows < StandardError
31
+ end
32
+
33
+ on 'blow' do
34
+ raise TharSheBlows.new("Arrrh!")
35
+ end
36
+
37
+ on 'exception' do
38
+ raise TharSheBlows.new("Yarrh!")
28
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-29 00:00:00.000000000 Z
11
+ date: 2015-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -228,6 +228,8 @@ files:
228
228
  - spec/utopia/content_spec.ru
229
229
  - spec/utopia/controller_spec.rb
230
230
  - spec/utopia/controller_spec.ru
231
+ - spec/utopia/exception_handler_spec.rb
232
+ - spec/utopia/exception_handler_spec.ru
231
233
  - spec/utopia/extensions_spec.rb
232
234
  - spec/utopia/localization_spec.rb
233
235
  - spec/utopia/localization_spec.ru
@@ -305,6 +307,8 @@ test_files:
305
307
  - spec/utopia/content_spec.ru
306
308
  - spec/utopia/controller_spec.rb
307
309
  - spec/utopia/controller_spec.ru
310
+ - spec/utopia/exception_handler_spec.rb
311
+ - spec/utopia/exception_handler_spec.ru
308
312
  - spec/utopia/extensions_spec.rb
309
313
  - spec/utopia/localization_spec.rb
310
314
  - spec/utopia/localization_spec.ru