carioca 2.1.2 → 2.1.4

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: 29233bcd6718731dae76436b23f4a2d0f4cba32630c2fa11009b5c44cba63453
4
+ data.tar.gz: caea68819fafbe93e864dd63da838806afbdbb14da4d2415af644826afb64cf6
5
5
  SHA512:
6
- metadata.gz: b313b4231fb1cfa5c0d64f13c6c9ac21a94adc16a2ef43404b06ced4667461302b06e18de275d54b55600686c9d0e5c6926ae63e9f921b89814f5da66f221e9d
7
- data.tar.gz: 5fb2116c63723ffded942c036e5f42f62de73f1abbeac62c18cb0303b8b1b8b7e66b315f2503f8a34d66f2f158bb8db9b8228bbf8a19f320a3f9d82dff7f53b9
6
+ metadata.gz: e2ce4b9ba9e0744e20ff4e11bbb2fda7b2813dd4589ec5a950a71799b7c2aa7cfb638bd5f38cd9e2c14b95730b3bd70b31282da9756075a23933842dcf652ce6
7
+ data.tar.gz: 9650779eed46522a43c7ebd0ff0089ac97b22b481a7c45885bcd2410d45f639808cd3d5eafe6ed37c1badf157d91d60f12a8324a02cc6b8170974884eb1cb9b7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.1.4
data/lib/carioca/mixin.rb CHANGED
@@ -6,7 +6,7 @@ module Carioca
6
6
  create_methods(service) { return Carioca::Registry.get.get_service name: service }
7
7
  end
8
8
 
9
- def register(service:, definition:)
9
+ def add(service:, definition:)
10
10
  Carioca::Registry.get.add service: service, definition: definition
11
11
  end
12
12
 
@@ -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/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "carioca", "~> 2.1"
4
+
5
+ gem "uuid", "~> 2.3"
data/samples/test.rb CHANGED
@@ -157,16 +157,19 @@ sanitycheck = Carioca::Registry.get.get_service name: :sanitycheck
157
157
  sanitycheck.run
158
158
 
159
159
  puts "\nTest 14 : Service SecureStore init or access"
160
- securestore = Carioca::Registry.get.get_service name: :securestore
160
+ puts "skipped"
161
+ #securestore = Carioca::Registry.get.get_service name: :securestore
161
162
 
162
163
 
163
164
  puts "\nTest 15 : Service SecureStore getting previous data"
164
- res = (securestore.data.empty?)? "first time" : securestore.data.to_s
165
- output.info res
165
+ #res = (securestore.data.empty?)? "first time" : securestore.data.to_s
166
+ #output.info res
167
+ puts "skipped"
166
168
 
167
169
  puts "\nTest 16 : Service SecureStore setting new data"
168
- securestore.data[:time] = Time.now
169
- securestore.save!
170
+ #securestore.data[:time] = Time.now
171
+ #securestore.save!
172
+ puts "skipped"
170
173
 
171
174
  puts "\nTest 17 : Service finisher : test all cases"
172
175
  output.item "flat api return, no-json, no-structured"
@@ -188,12 +191,21 @@ test = finisher.secure_api_return(return_case: :status_ok, structured: true, jso
188
191
  finisher.secure_raise message: "error !", error_case: :status_ko
189
192
  "test"
190
193
  end
191
- puts test
194
+ puts test[:status]
195
+ puts test[:data]
192
196
 
193
197
  output.item "api return, json, structured"
194
198
  test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true) do
195
199
  "test"
196
200
  end
201
+ puts test[:status]
202
+ puts test[:data]
203
+
204
+
205
+ output.item "api return, json, structured with status=false"
206
+ test = finisher.secure_api_return(return_case: :status_ok, structured: true, json: true, status: false) do
207
+ "test"
208
+ end
197
209
  puts test
198
210
 
199
211
  puts "\nTest 18 : Service finisher : exit case in success"
@@ -202,4 +214,4 @@ finisher.secure_execute! exit_case: :success_exit do
202
214
  puts 'finishing action'
203
215
  #finisher.secure_raise message: "error !", error_case: :status_ko
204
216
  'message'
205
- end
217
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2024-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge
@@ -235,7 +235,6 @@ files:
235
235
  - ".rspec"
236
236
  - ".rubocop.yml"
237
237
  - Gemfile
238
- - Gemfile.lock
239
238
  - LICENSE.txt
240
239
  - README.md
241
240
  - Rakefile
@@ -284,6 +283,7 @@ files:
284
283
  - lib/carioca/services/toolbox.rb
285
284
  - lib/carioca/validator.rb
286
285
  - lib/carioca/version.rb
286
+ - samples/Gemfile
287
287
  - samples/Rakefile
288
288
  - samples/config/carioca.registry
289
289
  - samples/config/locales/en.yml
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
315
  - !ruby/object:Gem::Version
316
316
  version: '0'
317
317
  requirements: []
318
- rubygems_version: 3.3.5
318
+ rubygems_version: 3.4.19
319
319
  signing_key:
320
320
  specification_version: 4
321
321
  summary: 'Carioca : Container And Registry with Inversion Of Control for your Applications'
data/Gemfile.lock DELETED
@@ -1,132 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- carioca (2.1.0)
5
- deep_merge (~> 1.2)
6
- i18n (~> 1.10)
7
- locale (~> 2.1)
8
- pastel (~> 0.8.0)
9
- ps-ruby (~> 0.0.4)
10
- tty-prompt (~> 0.23.1)
11
- version (~> 1.1)
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- ast (2.4.2)
17
- bundle-audit (0.1.0)
18
- bundler-audit
19
- bundler-audit (0.9.1)
20
- bundler (>= 1.2.0, < 3)
21
- thor (~> 1.0)
22
- code_statistics (0.2.13)
23
- concurrent-ruby (1.2.2)
24
- cyclonedx-ruby (1.1.0)
25
- json (~> 2.2)
26
- nokogiri (~> 1.8)
27
- ostruct (~> 0.1)
28
- rest-client (~> 2.0)
29
- deep_merge (1.2.2)
30
- diff-lcs (1.5.0)
31
- domain_name (0.5.20190701)
32
- unf (>= 0.0.5, < 1.0.0)
33
- http-accept (1.7.0)
34
- http-cookie (1.0.5)
35
- domain_name (~> 0.5)
36
- i18n (1.14.1)
37
- concurrent-ruby (~> 1.0)
38
- json (2.6.2)
39
- locale (2.1.3)
40
- mime-types (3.4.1)
41
- mime-types-data (~> 3.2015)
42
- mime-types-data (3.2023.0218.1)
43
- mini_portile2 (2.8.2)
44
- netrc (0.11.0)
45
- nokogiri (1.15.2)
46
- mini_portile2 (~> 2.8.2)
47
- racc (~> 1.4)
48
- nokogiri (1.15.2-arm64-darwin)
49
- racc (~> 1.4)
50
- ostruct (0.5.5)
51
- parallel (1.22.1)
52
- parser (3.1.2.0)
53
- ast (~> 2.4.1)
54
- pastel (0.8.0)
55
- tty-color (~> 0.5)
56
- ps-ruby (0.0.4)
57
- racc (1.7.1)
58
- rainbow (3.1.1)
59
- rake (13.0.6)
60
- regexp_parser (2.5.0)
61
- rest-client (2.1.0)
62
- http-accept (>= 1.7.0, < 2.0)
63
- http-cookie (>= 1.0.2, < 2.0)
64
- mime-types (>= 1.16, < 4.0)
65
- netrc (~> 0.8)
66
- rexml (3.2.5)
67
- rspec (3.9.0)
68
- rspec-core (~> 3.9.0)
69
- rspec-expectations (~> 3.9.0)
70
- rspec-mocks (~> 3.9.0)
71
- rspec-core (3.9.3)
72
- rspec-support (~> 3.9.3)
73
- rspec-expectations (3.9.4)
74
- diff-lcs (>= 1.2.0, < 2.0)
75
- rspec-support (~> 3.9.0)
76
- rspec-mocks (3.9.1)
77
- diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.9.0)
79
- rspec-support (3.9.4)
80
- rubocop (1.32.0)
81
- json (~> 2.3)
82
- parallel (~> 1.10)
83
- parser (>= 3.1.0.0)
84
- rainbow (>= 2.2.2, < 4.0)
85
- regexp_parser (>= 1.8, < 3.0)
86
- rexml (>= 3.2.5, < 4.0)
87
- rubocop-ast (>= 1.19.1, < 2.0)
88
- ruby-progressbar (~> 1.7)
89
- unicode-display_width (>= 1.4.0, < 3.0)
90
- rubocop-ast (1.19.1)
91
- parser (>= 3.1.1.0)
92
- ruby-progressbar (1.11.0)
93
- thor (1.2.2)
94
- tty-color (0.6.0)
95
- tty-cursor (0.7.1)
96
- tty-prompt (0.23.1)
97
- pastel (~> 0.8)
98
- tty-reader (~> 0.8)
99
- tty-reader (0.9.0)
100
- tty-cursor (~> 0.7)
101
- tty-screen (~> 0.8)
102
- wisper (~> 2.0)
103
- tty-screen (0.8.1)
104
- unf (0.1.4)
105
- unf_ext
106
- unf_ext (0.0.8.2)
107
- unicode-display_width (2.2.0)
108
- version (1.1.1)
109
- webrick (1.7.0)
110
- wisper (2.0.1)
111
- yard (0.9.28)
112
- webrick (~> 1.7.0)
113
- yard-rspec (0.1)
114
- yard
115
-
116
- PLATFORMS
117
- arm64-darwin-20
118
- ruby
119
-
120
- DEPENDENCIES
121
- bundle-audit (~> 0.1.0)
122
- carioca!
123
- code_statistics (~> 0.2.13)
124
- cyclonedx-ruby (~> 1.1)
125
- rake (~> 13.0)
126
- rspec (~> 3.0)
127
- rubocop (~> 1.32)
128
- yard (~> 0.9.27)
129
- yard-rspec (~> 0.1)
130
-
131
- BUNDLED WITH
132
- 2.3.24