carioca 2.1.8 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.debride_withelist +1 -1
- data/.rubocop.yml +5 -0
- data/VERSION +1 -1
- data/carioca.gemspec +2 -1
- data/lib/carioca/services/finisher.rb +9 -13
- data/lib/carioca/services/output.rb +4 -4
- data/samples/test.rb +11 -15
- metadata +29 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4b9f0de3ab110e59c5c5f7f9a37149d0c29dfab987770b4d6e7e6241e9d1845
|
4
|
+
data.tar.gz: 50e15e047298d831a454abfcafedbd69ce54d8b77d2e4c744bbb71e438b389c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc6a2f28e899dc0a8e5b57ffcf7df165cdf80f369c59c3a250f0584b79d6c613982e54aea1892ccda80a154ec19af46c61e27dc5f8d63d34d5a094f1ada13a5
|
7
|
+
data.tar.gz: 0f00db3ff79e1e668b49fbca89fbe737761db87ce783e0ee9cb4a80bb01b8ff4ce3dae817756f26caf29dfa5a58865e0ddf66fcdae7353cdb3a527e5b9b0cd77
|
data/.debride_withelist
CHANGED
data/.rubocop.yml
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.9
|
data/carioca.gemspec
CHANGED
@@ -37,14 +37,15 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency 'tty-prompt', '~>0.23.1'
|
38
38
|
spec.add_development_dependency 'bundle-audit', '~> 0.1.0'
|
39
39
|
spec.add_development_dependency 'code_statistics', '~> 0.2.13'
|
40
|
+
spec.add_development_dependency 'diff-lcs', '~> 1.5.1'
|
40
41
|
spec.add_development_dependency 'rake', '~> 13.0'
|
41
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
43
|
spec.add_development_dependency 'rubocop', '~> 1.32'
|
43
44
|
spec.add_development_dependency 'yard', '~> 0.9.27'
|
44
45
|
spec.add_development_dependency 'yard-rspec', '~> 0.1'
|
45
|
-
spec.add_development_dependency 'diff-lcs', '~> 1.5.1'
|
46
46
|
spec.metadata['rubygems_mfa_required'] = 'false'
|
47
47
|
spec.add_dependency 'version', '~> 1.1'
|
48
48
|
spec.add_runtime_dependency 'ps-ruby', '~> 0.0.4'
|
49
49
|
spec.add_development_dependency 'cyclonedx-ruby', '~> 1.1'
|
50
|
+
spec.add_development_dependency 'debride', '~> 1.12'
|
50
51
|
end
|
@@ -12,7 +12,6 @@ module Carioca
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
15
|
class AlternativeCatcher < StandardError
|
17
16
|
attr_reader :return_case, :data
|
18
17
|
|
@@ -106,15 +105,13 @@ module Carioca
|
|
106
105
|
data = yield if block_given?
|
107
106
|
result = structured ? do_return(return_case:).merge({ data: }) : data
|
108
107
|
rescue StandardError => e
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
result = do_return(return_case: :status_ko, more: "#{e.class.to_s} : #{e.message}")
|
117
|
-
end
|
108
|
+
result = if e.respond_to?(:error_case)
|
109
|
+
do_return(return_case: e.error_case, more: e.message)
|
110
|
+
elsif e.respond_to?(:return_case)
|
111
|
+
structured ? do_return(return_case: e.return_case, more: e.message).merge({ data: e.data }) : e.data
|
112
|
+
else
|
113
|
+
do_return(return_case: :status_ko, more: "#{e.class} : #{e.message}")
|
114
|
+
end
|
118
115
|
end
|
119
116
|
if status && structured && json
|
120
117
|
{ status: result[:code], data: JSON.pretty_generate(JSON.parse(result.to_json)) }
|
@@ -125,11 +122,10 @@ module Carioca
|
|
125
122
|
end
|
126
123
|
end
|
127
124
|
|
128
|
-
def secure_alternative(message
|
129
|
-
raise AlternativeCatcher.new(message, return_case
|
125
|
+
def secure_alternative(message:, data:, return_case: :accepted)
|
126
|
+
raise AlternativeCatcher.new(message, return_case:, data:)
|
130
127
|
end
|
131
128
|
|
132
|
-
|
133
129
|
def secure_execute!(exit_case: :success_exit)
|
134
130
|
begin
|
135
131
|
more = yield
|
@@ -183,10 +183,10 @@ module Carioca
|
|
183
183
|
block = proc { save }
|
184
184
|
@logger.send target_level, source, &block
|
185
185
|
end
|
186
|
-
if @target == :stderr
|
187
|
-
|
188
|
-
|
189
|
-
$stdout.puts message
|
186
|
+
if @target == :stderr
|
187
|
+
warn message if (@mode == :mono) || (@mode == :dual)
|
188
|
+
elsif (@mode == :mono) || (@mode == :dual)
|
189
|
+
$stdout.puts message
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
data/samples/test.rb
CHANGED
@@ -152,17 +152,15 @@ sanitycheck = Carioca::Registry.get.get_service name: :sanitycheck
|
|
152
152
|
sanitycheck.run
|
153
153
|
|
154
154
|
puts "\nTest 14 : Service SecureStore init or access"
|
155
|
-
|
155
|
+
securestore = Carioca::Registry.get.get_service name: :securestore
|
156
156
|
|
157
157
|
puts "\nTest 15 : Service SecureStore getting previous data"
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
res = securestore.data.empty? ? 'first time' : securestore.data.to_s
|
159
|
+
output.info res
|
161
160
|
|
162
161
|
puts "\nTest 16 : Service SecureStore setting new data"
|
163
|
-
|
164
|
-
|
165
|
-
|
162
|
+
securestore.data[:time] = Time.now.to_s
|
163
|
+
securestore.save!
|
166
164
|
|
167
165
|
puts "\nTest 17 : Service finisher : test all cases"
|
168
166
|
output.item 'flat api return, no-json, no-structured'
|
@@ -175,14 +173,14 @@ puts test
|
|
175
173
|
output.item 'api return, no-json, no-structured but with secure_raise'
|
176
174
|
test = finisher.secure_api_return(return_case: :status_ok, structured: false, json: false) do
|
177
175
|
finisher.secure_raise message: 'error !', error_case: :status_ko
|
178
|
-
|
176
|
+
{ test: 'test' }
|
179
177
|
end
|
180
178
|
puts test
|
181
179
|
|
182
180
|
output.item 'api return, json, structured but with secure_raise'
|
183
181
|
test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true) do
|
184
182
|
finisher.secure_raise message: 'error !', error_case: :status_ko
|
185
|
-
test = { test: 'test'}
|
183
|
+
test = { test: 'test' }
|
186
184
|
test
|
187
185
|
end
|
188
186
|
puts test[:status]
|
@@ -196,34 +194,32 @@ end
|
|
196
194
|
puts test[:status]
|
197
195
|
puts test[:data]
|
198
196
|
|
199
|
-
|
200
197
|
output.item 'api return, json, structured with alternative'
|
201
198
|
test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true) do
|
202
199
|
test = { test: 'test' }
|
203
|
-
finisher.secure_alternative message:
|
200
|
+
finisher.secure_alternative message: 'test alernative', return_case: :accepted, data: test
|
204
201
|
test
|
205
202
|
end
|
206
203
|
puts test[:status]
|
207
204
|
puts test[:data]
|
208
205
|
|
209
|
-
|
210
206
|
output.item 'api return, json, structured with alternative'
|
211
207
|
test = finisher.secure_api_return(return_case: :status_ok, structured: false, json: false) do
|
212
208
|
test = { test: 'test' }
|
213
|
-
finisher.secure_alternative message:
|
209
|
+
finisher.secure_alternative message: 'test alernative', return_case: :accepted, data: test
|
214
210
|
test
|
215
211
|
end
|
216
212
|
puts test
|
217
213
|
|
218
214
|
output.item 'api return, json, structured with status=false'
|
219
215
|
test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true, status: false) do
|
220
|
-
{ test: 'test'}
|
216
|
+
{ test: 'test' }
|
221
217
|
end
|
222
218
|
puts test
|
223
219
|
|
224
220
|
output.item 'api return, json, structured but raising unknown case'
|
225
221
|
test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true, status: false) do
|
226
|
-
raise
|
222
|
+
raise 'Boom'
|
227
223
|
end
|
228
224
|
puts test
|
229
225
|
|
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.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain GEORGES
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.2.13
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: diff-lcs
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.5.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.5.1
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rake
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,20 +192,6 @@ dependencies:
|
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0.1'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: diff-lcs
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: 1.5.1
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: 1.5.1
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: version
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '1.1'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: debride
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '1.12'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '1.12'
|
237
251
|
description: 'Carioca 2: is a complete rewrite who provide a full IoC/DI light Container
|
238
252
|
and a services registry, build with logs, config and Internationalization facilities
|
239
253
|
for designing your applications'
|