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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba27dac2bea807bb25e736cc7c7434195f88d923
4
- data.tar.gz: 9c04e21b41ebea5084eccb794d0a76c2f986e8bd
3
+ metadata.gz: 29d73317a40a33d6fcf69c6ad49150fa70ef72b3
4
+ data.tar.gz: 8bf31d0dada2d170f0402aef0552d5beb53f906a
5
5
  SHA512:
6
- metadata.gz: 250a1cc17556504c69ad5e0d43a751ae5a431bce48819d82bacccb2f5c5047fd3928f18c291c0e3c9f1ae9b753cf041f23e7737daa41d77c83a346ead1f98332
7
- data.tar.gz: b50979f85f54764f2422419273407a46fec4f0ce9973a61ad4534e349f6c31ec407f1b11b6809042c8d062ed3a6260a052e66738f8cb7c07feb63879f6003547
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
@@ -1,5 +1,5 @@
1
1
  module Hobbit
2
2
  module Contrib
3
- VERSION = '0.4.2'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
@@ -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
- body = instance_eval &self.class.errors[rescued]
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 = '/', &block| filters[kind.to_sym] << compile_filter(path, &block) }
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(status, headers: {}, body: [])
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 wont be the body'
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
@@ -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.2
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-02-19 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler