lydia 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/lib/lydia/response.rb +13 -0
- data/lib/lydia/version.rb +1 -1
- data/spec/middleware_spec.rb +3 -3
- data/spec/response_spec.rb +12 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55cecde25fdd99b6c28cc496d6601b3272dcc98c
|
4
|
+
data.tar.gz: 07bcf6ebe3fb947b7b4acd65ff6cbe4d5a17b3d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1537f5c0912af847b86abe97a89cef2eb2c904752cb30acba86c0573fd42a4b4b144344d262f79d5651ef630d6b25b7cce3045d72f06a86444e5d35c55d25cf
|
7
|
+
data.tar.gz: db7d800dfd02255d7c734d3d00b425da53264880f4671bf3f6e009e9051b030053d28574a660a44289c4f82b0358a93aaddda4861716e69b98b409e7103d8558
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/lib/lydia/response.rb
CHANGED
@@ -30,5 +30,18 @@ module Lydia
|
|
30
30
|
end
|
31
31
|
finish
|
32
32
|
end
|
33
|
+
|
34
|
+
def finish(&block)
|
35
|
+
@block = block
|
36
|
+
|
37
|
+
if [204, 205, 304].include?(status.to_i)
|
38
|
+
headers.delete 'Content-Length'
|
39
|
+
headers.delete 'Content-Type'
|
40
|
+
close
|
41
|
+
[status.to_i, header, []]
|
42
|
+
else
|
43
|
+
[status.to_i, header, @body]
|
44
|
+
end
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
data/lib/lydia/version.rb
CHANGED
data/spec/middleware_spec.rb
CHANGED
@@ -13,9 +13,9 @@ describe "Middleware" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
status, headers, body = @app.call(env)
|
17
|
+
upcased_body = body.map { |chunk| chunk.upcase }
|
18
|
+
[status, headers, upcased_body]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/spec/response_spec.rb
CHANGED
@@ -27,8 +27,8 @@ describe 'Response' do
|
|
27
27
|
expect(result[0]).to eq(200)
|
28
28
|
expect(result[1]).to include('Content-Type' => 'text/html')
|
29
29
|
expect(result[1]).to include('Content-Length' => body.length.to_s)
|
30
|
-
expect(result[2]
|
31
|
-
expect(result[2]
|
30
|
+
expect(result[2]).to be_an(Array)
|
31
|
+
expect(result[2][0]).to eq(body)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'builds using a fixnum (status)' do
|
@@ -51,8 +51,8 @@ describe 'Response' do
|
|
51
51
|
expect(result[0]).to eq(200)
|
52
52
|
expect(result[1]).to include('Content-Type' => 'application/json')
|
53
53
|
expect(result[1]).to include('Content-Length' => body.to_json.length.to_s)
|
54
|
-
expect(result[2]
|
55
|
-
expect(result[2]
|
54
|
+
expect(result[2]).to be_an(Array)
|
55
|
+
expect(result[2][0]).to eq(body.to_json)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'builds using an array of two (body is array)' do
|
@@ -63,8 +63,8 @@ describe 'Response' do
|
|
63
63
|
expect(result[0]).to eq(201)
|
64
64
|
expect(result[1]).to include('Content-Type' => 'text/html')
|
65
65
|
expect(result[1]).to include('Content-Length' => body[1][0].length.to_s)
|
66
|
-
expect(result[2]
|
67
|
-
expect(result[2]
|
66
|
+
expect(result[2]).to be_an(Array)
|
67
|
+
expect(result[2][0]).to eq(body[1][0])
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'builds using an array of two (body is noy an array)' do
|
@@ -75,8 +75,8 @@ describe 'Response' do
|
|
75
75
|
expect(result[0]).to eq(201)
|
76
76
|
expect(result[1]).to include('Content-Type' => 'text/html')
|
77
77
|
expect(result[1]).to include('Content-Length' => body[1].length.to_s)
|
78
|
-
expect(result[2]
|
79
|
-
expect(result[2]
|
78
|
+
expect(result[2]).to be_an(Array)
|
79
|
+
expect(result[2][0]).to eq(body[1])
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'builds using an array of three' do
|
@@ -88,8 +88,8 @@ describe 'Response' do
|
|
88
88
|
expect(result[1]).to include('Content-Type' => 'text/html')
|
89
89
|
expect(result[1]).to include('Content-Length' => body[2].length.to_s)
|
90
90
|
expect(result[1]).to include('Authentication' => '12345')
|
91
|
-
expect(result[2]
|
92
|
-
expect(result[2]
|
91
|
+
expect(result[2]).to be_an(Array)
|
92
|
+
expect(result[2][0]).to eq(body[2])
|
93
93
|
end
|
94
94
|
|
95
95
|
class Stream
|
@@ -113,8 +113,8 @@ describe 'Response' do
|
|
113
113
|
expect(result[0]).to eq(200)
|
114
114
|
expect(result[1]).to include('Content-Type' => 'text/html')
|
115
115
|
expect(result[1]).to include('Content-Length')
|
116
|
-
expect(result[2]
|
117
|
-
expect(result[2]
|
116
|
+
expect(result[2]).to be_an(Array)
|
117
|
+
expect(result[2][0]).to_not be_nil
|
118
118
|
end
|
119
119
|
|
120
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lydia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mirko Mignini
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.2.2
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Lightweight, fast and easy to use small ruby web framework.
|