hobbit-contrib 0.4.2 → 0.5.0
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/hobbit/contrib/version.rb +1 -1
- data/lib/hobbit/error_handling.rb +1 -2
- data/lib/hobbit/filter.rb +3 -3
- data/spec/error_handling_and_filter_spec.rb +2 -2
- data/spec/error_handling_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d73317a40a33d6fcf69c6ad49150fa70ef72b3
|
4
|
+
data.tar.gz: 8bf31d0dada2d170f0402aef0552d5beb53f906a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a0cca20cec9f5c7afb3050e76848ffb70d558a763a8715b6cc3039582c6c79dba10b5240fb24e206743b7b3a54f32927b39cd3a493124678fc9d317deb8fbc3
|
7
|
+
data.tar.gz: 498a8dbd9edca5dd63f45ac8b3e0111f71966af2f26b83ef2844da0430e347e82e402d6067862ba8dfbd0dfb3f42caa7ecf6ba454fd33069a7f2b51b3373667a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.5.0
|
2
|
+
|
3
|
+
* Refactor `Hobbit::ErrorHandling` according to the recent changes on
|
4
|
+
`Hobbit::Response`.
|
5
|
+
* Fix tests.
|
6
|
+
* Fix `Hobbit::Filter`. It wasn't filtering actions if an empty before (or
|
7
|
+
after) filter was defined.
|
8
|
+
|
1
9
|
# 0.4.2
|
2
10
|
|
3
11
|
* Make `environment`, `development?`, `production?` and `test?` available
|
@@ -16,8 +16,7 @@ module Hobbit
|
|
16
16
|
rescued = self.class.errors.keys.detect { |k| e.kind_of?(k) }
|
17
17
|
|
18
18
|
env['hobbit.error'] = e
|
19
|
-
|
20
|
-
response.body = [body]
|
19
|
+
response.write instance_eval(&self.class.errors[rescued])
|
21
20
|
response.finish
|
22
21
|
end
|
23
22
|
|
data/lib/hobbit/filter.rb
CHANGED
@@ -2,7 +2,7 @@ module Hobbit
|
|
2
2
|
module Filter
|
3
3
|
module ClassMethods
|
4
4
|
%w(after before).each do |kind|
|
5
|
-
define_method(kind) { |path = '
|
5
|
+
define_method(kind) { |path = '', &block| filters[kind.to_sym] << compile_filter(path, &block) }
|
6
6
|
end
|
7
7
|
|
8
8
|
def filters
|
@@ -39,7 +39,7 @@ module Hobbit
|
|
39
39
|
@response.finish
|
40
40
|
end
|
41
41
|
|
42
|
-
def halt(
|
42
|
+
def halt(*res)
|
43
43
|
@halted = true
|
44
44
|
super
|
45
45
|
end
|
@@ -59,7 +59,7 @@ module Hobbit
|
|
59
59
|
|
60
60
|
def find_filter(kind)
|
61
61
|
filter = self.class.filters[kind].detect do |f|
|
62
|
-
f[:compiled_path] =~ request.path_info
|
62
|
+
f[:compiled_path] =~ request.path_info || f[:compiled_path] =~ ''
|
63
63
|
end
|
64
64
|
|
65
65
|
if filter
|
@@ -91,7 +91,7 @@ describe 'combine Hobbit::ErrorHandling and Hobbit::Filter' do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
get '/' do
|
94
|
-
'this
|
94
|
+
'this is written in the body. '
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -99,7 +99,7 @@ describe 'combine Hobbit::ErrorHandling and Hobbit::Filter' do
|
|
99
99
|
it 'must call the before filter' do
|
100
100
|
get '/'
|
101
101
|
last_response.must_be :ok?
|
102
|
-
last_response.body.must_equal 'Sorry'
|
102
|
+
last_response.body.must_equal 'this is written in the body. Sorry'
|
103
103
|
last_request.env.must_include 'hobbit.before'
|
104
104
|
end
|
105
105
|
end
|
data/spec/error_handling_spec.rb
CHANGED
@@ -31,28 +31,28 @@ describe Hobbit::ErrorHandling do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
get '/raises' do
|
34
|
-
'not this'
|
35
34
|
raise StandardError, 'StandardError'
|
35
|
+
'not this'
|
36
36
|
end
|
37
37
|
|
38
38
|
get '/other_raises' do
|
39
|
-
response.write 'not this'
|
40
39
|
raise NotFoundException
|
40
|
+
response.write 'not this'
|
41
41
|
end
|
42
42
|
|
43
43
|
get '/same_other_raises' do
|
44
|
-
response.write 'not this'
|
45
44
|
raise SpecificNotFoundException
|
45
|
+
response.write 'not this'
|
46
46
|
end
|
47
47
|
|
48
48
|
get '/uncaught_raise' do
|
49
|
-
response.write 'not this'
|
50
49
|
raise UnknownException
|
50
|
+
response.write 'not this'
|
51
51
|
end
|
52
52
|
|
53
53
|
get '/must_use_response' do
|
54
|
-
response.write 'not this'
|
55
54
|
raise MustUseResponseException
|
55
|
+
response.write 'not this'
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobbit-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Mac Adden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|