jsender 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -0
- data/README.md +6 -6
- data/lib/jsender/rack.rb +6 -3
- data/lib/jsender/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a14bbcd279afde03c506cc4a5bd4be23db94f26d28d5649745b841b6e7bc840
|
4
|
+
data.tar.gz: 0e3696217fb4486c78ccf74a7e2f134180c12447ae540764fd83d8c1c677af58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84ea80faa3985e0d1d85f63b1e98dda0f9214a21f4bee729ac162933453e3e6722b9beacc5b508b2277ed75e435b89ce39938dba83ffb41301a7270a4d0c5fb
|
7
|
+
data.tar.gz: 364f94307b12cda69e4ba7d59f9bacd6919cbb92d18e5699734de995737f11bc69d79f8752e10c3806776879bec07e46ed3d971a88ea61b12fdfb85f4a543ad9
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -64,13 +64,13 @@ Basic usage without any parameters yielding default json encoded jsend format in
|
|
64
64
|
|
65
65
|
```ruby
|
66
66
|
Jsender::Rack.success
|
67
|
-
=> [200, {"Content-Type"=>"application/json"
|
67
|
+
=> [200, {"Content-Type"=>"application/json"}, "{\"status\":\"success\",\"data\":null}"]
|
68
68
|
|
69
69
|
Jsender::Rack.failure
|
70
|
-
=> [400, {"Content-Type"=>"application/json"
|
70
|
+
=> [400, {"Content-Type"=>"application/json"}, "{\"status\":\"fail\",\"data\":{\"message\":\"A failure has occurred\"}}"]
|
71
71
|
|
72
72
|
Jsender::Rack.error
|
73
|
-
=> [500, {"Content-Type"=>"application/json"
|
73
|
+
=> [500, {"Content-Type"=>"application/json"}, "{\"status\":\"error\",\"message\":\"An error has occurred\"}"]
|
74
74
|
```
|
75
75
|
|
76
76
|
Or with parameters yielding the correct json encoded jsend format in a Rack tuple for use in controllers (including Sinatra):
|
@@ -79,10 +79,10 @@ Or with parameters yielding the correct json encoded jsend format in a Rack tupl
|
|
79
79
|
Jsender::Rack.success(data: {'key' => 'value'}, code: 201, flow_id: '123')
|
80
80
|
=> [201, {"Content-Type"=>"application/json", "X-Flow-Identifier"=>"123"}, "{\"status\":\"success\",\"data\":{\"key\":\"value\"}}"]
|
81
81
|
|
82
|
-
|
82
|
+
Jsender::Rack.failure(message: 'some custom failure message', code: 201, flow_id: '123')
|
83
83
|
=> [201, {"Content-Type"=>"application/json", "X-Flow-Identifier"=>"123"}, "{\"status\":\"fail\",\"data\":{\"message\":\"some custom failure message\"}}"]
|
84
84
|
|
85
|
-
|
85
|
+
Jsender::Rack.error(message: 'some custom failure message', code: 201, flow_id: '123')
|
86
86
|
=> [201, {"Content-Type"=>"application/json", "X-Flow-Identifier"=>"123"}, "{\"status\":\"error\",\"message\":\"some custom failure message\"}"]
|
87
87
|
```
|
88
88
|
|
@@ -92,7 +92,7 @@ Rack middlware responses require that the body of the response tuple is in an ar
|
|
92
92
|
|
93
93
|
```ruby
|
94
94
|
Jsender::Rack.error(body_as_array: true)
|
95
|
-
=> [500, {"Content-Type"=>"application/json"
|
95
|
+
=> [500, {"Content-Type"=>"application/json"}, ["{\"status\":\"error\",\"message\":\"An error has occurred\"}"]]
|
96
96
|
```
|
97
97
|
|
98
98
|
## Development
|
data/lib/jsender/rack.rb
CHANGED
@@ -34,10 +34,13 @@ module Jsender
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def headers(flow_id:)
|
37
|
-
{
|
38
|
-
'Content-Type' => 'application/json'
|
39
|
-
'X-Flow-Identifier' => flow_id
|
37
|
+
headers = {
|
38
|
+
'Content-Type' => 'application/json'
|
40
39
|
}
|
40
|
+
|
41
|
+
headers.merge!('X-Flow-Identifier' => flow_id) if flow_id
|
42
|
+
|
43
|
+
headers
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
data/lib/jsender/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst Van Graan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.7.6
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: JSender facilitates a simple jsend implementation for ruby
|