carioca 2.1.2 → 2.1.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/carioca/services/finisher.rb +9 -3
- data/samples/test.rb +10 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e25d909400997565234d097e571a9600cca99dca0880e493ea74a6547573ae
|
4
|
+
data.tar.gz: 6c3f581e92b5e9e2f6e91f9f466f2d22ec462ef20ca6799eb1a0304d039a44b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9f9bda2f074633447842b10c9cde5ffdf8c157fc9a3e78398b7a70311425b5a2ce8243ef685b03333b9be850d1103bffab5fc2dba69d51fecc6810b74dfce82
|
7
|
+
data.tar.gz: 4baf6ce65f7efc84e72c13b66a8ccbacf08a68c4d783770736c5f344d6848440dc11d2894d07474da38e73b777ac668dff5cfb18f3f5f4d29b77ab115df65022
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
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
|
-
|
106
|
-
|
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"
|