hobbit 0.4.0 → 0.4.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: 790649ff947ec7ea93289cc41f241ae04a2b60ea
4
- data.tar.gz: af6820dcde77d613276b8f80a5a0bbef188c82c9
3
+ metadata.gz: e8b15402755a98818b63e15b8ee601d015b895b6
4
+ data.tar.gz: 2cdbe4db16ad8da597f06fa81286ddf8b08fb5a6
5
5
  SHA512:
6
- metadata.gz: 7a6f43952d33eb86244c7345b43a6490d487a1cc6934d428ebd0316433eaa7be801f0cc05a915cce7bf797fefe1b2184058974ddd10d9ef2aadbf114c56513b2
7
- data.tar.gz: ea115f7eeb26199d18839cdfd1f03a6e05270effce2f95710e8694ccdbd7de8e24c89c18ceffa81256931e48231084dd61ed52e934280b073d0fa2da49707c26
6
+ metadata.gz: 4ee1eb6bade97d609f0728a57a1f48ca0abe2629f71479a43bb4f04126e444d629118b47d7a89da13ce272eed024bec0133c668e3b8ee1a848b6f68c74fec001
7
+ data.tar.gz: 7c5aa60e620e81fa6338f473bb756c94c8b4d01fd07d0ef7df8f90eb601e25a0ebc8001fa4f1004f239135e6755bdfe15cf356f8b091758850b5e8fadae02d94
@@ -1,3 +1,7 @@
1
+ # 0.4.1
2
+
3
+ * `Hobbit::Response` now returns the `Content-Length` header as a string.
4
+
1
5
  # 0.4.0
2
6
 
3
7
  * Add halt method.
@@ -55,16 +55,16 @@ module Hobbit
55
55
  @response.finish
56
56
  end
57
57
 
58
- # Stops the execution and return a response
59
- #
60
- # status | Number - HTTP status code
61
- # body | Response body
62
- # headers | Response headers
58
+ # Stops the execution and returns a response.
63
59
  #
60
+ # @param status [Fixnum] HTTP status code.
61
+ # @param headers [Hash] Response headers.
62
+ # @param body [Array] Response body.
63
+ # @return [Hobbit::Response] The Response.
64
64
  def halt(status, headers: {}, body: [])
65
- response.status = status # Without a default, the user must know why is using halt
65
+ response.status = status
66
66
  response.headers = headers
67
- response.body = Array(body) # With this we support strings, arrays or hashes
67
+ response.body = Array(body)
68
68
 
69
69
  throw :halt, response
70
70
  end
@@ -11,7 +11,7 @@ module Hobbit
11
11
  end
12
12
 
13
13
  def finish
14
- headers['Content-Length'] = body.each.map(&:size).inject { |memo, current| memo += current }
14
+ headers['Content-Length'] = body.each.map(&:size).inject { |memo, current| memo += current }.to_s
15
15
  [status, headers, body]
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module Hobbit
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -233,7 +233,7 @@ EOS
233
233
 
234
234
  it 'return the response given to halt function' do
235
235
  get '/halt'
236
- last_response.headers.must_equal({ 'Content-Length' => nil })
236
+ last_response.headers.must_equal({ 'Content-Length' => '' })
237
237
  last_response.body.must_equal ''
238
238
  last_response.status.must_equal 501
239
239
  end
@@ -258,7 +258,7 @@ EOS
258
258
 
259
259
  it 'accepts headers' do
260
260
  get '/halt_headers'
261
- last_response.headers.must_equal({ header: 'OK', 'Content-Length' => nil })
261
+ last_response.headers.must_equal({ header: 'OK', 'Content-Length' => '' })
262
262
  last_response.status.must_equal 501
263
263
  end
264
264
  end
@@ -59,7 +59,7 @@ describe Hobbit::Response do
59
59
  response = Hobbit::Response.new body, status, headers
60
60
  s, h, b = response.finish
61
61
  h.must_include 'Content-Length'
62
- h['Content-Length'].must_equal body.each.map(&:size).inject { |m, s| m += s }
62
+ h['Content-Length'].must_equal '17'
63
63
  end
64
64
  end
65
65
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
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: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2013-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler