carioca 2.1.2 → 2.1.3

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
  SHA256:
3
- metadata.gz: be2b88dd938c21c9b0daaec80430070451b11375dcf39e88de5eb2315f4150e2
4
- data.tar.gz: af8b96e10bb4a5ab5d55d445fe17a82408ac04bc587df94261b2b636269cd78e
3
+ metadata.gz: 99e25d909400997565234d097e571a9600cca99dca0880e493ea74a6547573ae
4
+ data.tar.gz: 6c3f581e92b5e9e2f6e91f9f466f2d22ec462ef20ca6799eb1a0304d039a44b6
5
5
  SHA512:
6
- metadata.gz: b313b4231fb1cfa5c0d64f13c6c9ac21a94adc16a2ef43404b06ced4667461302b06e18de275d54b55600686c9d0e5c6926ae63e9f921b89814f5da66f221e9d
7
- data.tar.gz: 5fb2116c63723ffded942c036e5f42f62de73f1abbeac62c18cb0303b8b1b8b7e66b315f2503f8a34d66f2f158bb8db9b8228bbf8a19f320a3f9d82dff7f53b9
6
+ metadata.gz: b9f9bda2f074633447842b10c9cde5ffdf8c157fc9a3e78398b7a70311425b5a2ce8243ef685b03333b9be850d1103bffab5fc2dba69d51fecc6810b74dfce82
7
+ data.tar.gz: 4baf6ce65f7efc84e72c13b66a8ccbacf08a68c4d783770736c5f344d6848440dc11d2894d07474da38e73b777ac668dff5cfb18f3f5f4d29b77ab115df65022
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.1.3
@@ -92,7 +92,7 @@ module Carioca
92
92
  end
93
93
 
94
94
 
95
- def secure_api_return(data: nil, return_case: nil, structured: false, json: true)
95
+ def secure_api_return(data: nil, return_case: nil, structured: false, json: true, status: true)
96
96
  result = {}
97
97
  begin
98
98
  data = yield if block_given?
@@ -102,8 +102,14 @@ module Carioca
102
102
  more = (e.respond_to? :error_case)? e.message : "#{e.class.to_s} : #{e.message}"
103
103
  result = do_return return_case: key, more: more
104
104
  end
105
- result = JSON.pretty_generate(JSON.parse(result.to_json)) if json
106
- return result
105
+ if status and structured and json then
106
+ p result
107
+ return {status: result[:code], data: JSON.pretty_generate(JSON.parse(result.to_json))}
108
+ elsif json then
109
+ return JSON.pretty_generate(JSON.parse(result.to_json)) if json
110
+ else
111
+ return result
112
+ end
107
113
  end
108
114
 
109
115
 
data/samples/test.rb CHANGED
@@ -188,12 +188,21 @@ test = finisher.secure_api_return(return_case: :status_ok, structured: true, jso
188
188
  finisher.secure_raise message: "error !", error_case: :status_ko
189
189
  "test"
190
190
  end
191
- puts test
191
+ puts test[:status]
192
+ puts test[:data]
192
193
 
193
194
  output.item "api return, json, structured"
194
195
  test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true) do
195
196
  "test"
196
197
  end
198
+ puts test[:status]
199
+ puts test[:data]
200
+
201
+
202
+ output.item "api return, json, structured with status=false"
203
+ test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true, status: false) do
204
+ "test"
205
+ end
197
206
  puts test
198
207
 
199
208
  puts "\nTest 18 : Service finisher : exit case in success"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carioca
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES