carioca 1.3 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +44 -40
- data/README.md +123 -190
- data/Rakefile +5 -59
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/carioca.gemspec +45 -32
- data/config/locales/en.yml +19 -0
- data/config/locales/fr.yml +19 -0
- data/lib/carioca/configuration.rb +60 -0
- data/lib/carioca/constants.rb +60 -0
- data/lib/carioca/container.rb +16 -0
- data/lib/carioca/dependencies.rb +20 -0
- data/lib/carioca/helpers.rb +44 -31
- data/lib/carioca/mixin.rb +32 -0
- data/lib/carioca/{tasks/rake.rb → rake/manage.rb} +4 -6
- data/lib/carioca/rake/tasks/registry.tasks +57 -0
- data/lib/carioca/registry.rb +94 -0
- data/lib/carioca/registry_file.rb +62 -0
- data/lib/carioca/services/config.rb +140 -0
- data/lib/carioca/services/i18n.rb +20 -0
- data/lib/carioca/services/init.rb +2 -0
- data/lib/carioca/services/output.rb +175 -0
- data/lib/carioca/validator.rb +49 -0
- data/lib/carioca.rb +2 -319
- data/samples/Rakefile +2 -0
- data/samples/config/carioca.registry +22 -0
- data/samples/config/locales/en.yml +2 -0
- data/samples/config/locales/es.yml +2 -0
- data/samples/config/locales/fr.yml +2 -0
- data/samples/config/settings.yml +24 -0
- data/samples/test.rb +98 -0
- metadata +76 -168
- data/AUTHORS +0 -8
- data/COPYRIGHT +0 -24
- data/ChangeLog +0 -7
- data/INSTALL +0 -7
- data/doc/manual.rdoc +0 -225
- data/lib/carioca/exceptions.rb +0 -9
- data/lib/carioca/private.rb +0 -170
- data/lib/carioca/services/configuration.rb +0 -201
- data/lib/carioca/services/debug.rb +0 -73
- data/lib/carioca/services/logger.rb +0 -58
- data/lib/carioca/services.rb +0 -143
- data/lib/carioca/tasks/registry_init.rake +0 -11
- data/spec/carioca_spec.rb +0 -474
- data/spec/config/services.registry +0 -55
- data/spec/init_spec.rb +0 -1
- data/spec/samples/dummy.rb +0 -10
- data/spec/samples/otherdummy.rb +0 -10
- data/spec/samples/requireddummy.rb +0 -10
- data/spec/spec_helper.rb +0 -18
- data/test.rb +0 -12
- data/ultragreen_roodi_coding_convention.yml +0 -25
metadata
CHANGED
@@ -1,274 +1,182 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain GEORGES
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: tty-prompt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.5'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.5'
|
34
|
-
type: :development
|
19
|
+
version: 0.23.1
|
20
|
+
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
26
|
+
version: 0.23.1
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
28
|
+
name: pastel
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 2.14.1
|
51
|
-
type: :development
|
33
|
+
version: 0.8.0
|
34
|
+
type: :runtime
|
52
35
|
prerelease: false
|
53
36
|
version_requirements: !ruby/object:Gem::Requirement
|
54
37
|
requirements:
|
55
38
|
- - "~>"
|
56
39
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 2.14.1
|
40
|
+
version: 0.8.0
|
61
41
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
42
|
+
name: i18n
|
63
43
|
requirement: !ruby/object:Gem::Requirement
|
64
44
|
requirements:
|
65
45
|
- - "~>"
|
66
46
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 0.8.7.2
|
71
|
-
type: :development
|
47
|
+
version: '1.10'
|
48
|
+
type: :runtime
|
72
49
|
prerelease: false
|
73
50
|
version_requirements: !ruby/object:Gem::Requirement
|
74
51
|
requirements:
|
75
52
|
- - "~>"
|
76
53
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 0.8.7.2
|
54
|
+
version: '1.10'
|
81
55
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
56
|
+
name: locale
|
83
57
|
requirement: !ruby/object:Gem::Requirement
|
84
58
|
requirements:
|
85
59
|
- - "~>"
|
86
60
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
88
|
-
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 4.0.1
|
91
|
-
type: :development
|
61
|
+
version: '2.1'
|
62
|
+
type: :runtime
|
92
63
|
prerelease: false
|
93
64
|
version_requirements: !ruby/object:Gem::Requirement
|
94
65
|
requirements:
|
95
66
|
- - "~>"
|
96
67
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
98
|
-
- - ">="
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version: 4.0.1
|
68
|
+
version: '2.1'
|
101
69
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
70
|
+
name: deep_merge
|
103
71
|
requirement: !ruby/object:Gem::Requirement
|
104
72
|
requirements:
|
105
73
|
- - "~>"
|
106
74
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
108
|
-
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 3.1.1
|
111
|
-
type: :development
|
75
|
+
version: '1.2'
|
76
|
+
type: :runtime
|
112
77
|
prerelease: false
|
113
78
|
version_requirements: !ruby/object:Gem::Requirement
|
114
79
|
requirements:
|
115
80
|
- - "~>"
|
116
81
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: 3.1.1
|
82
|
+
version: '1.2'
|
121
83
|
- !ruby/object:Gem::Dependency
|
122
|
-
name:
|
84
|
+
name: rake
|
123
85
|
requirement: !ruby/object:Gem::Requirement
|
124
86
|
requirements:
|
125
87
|
- - "~>"
|
126
88
|
- !ruby/object:Gem::Version
|
127
|
-
version: '0
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: 0.2.13
|
89
|
+
version: '13.0'
|
131
90
|
type: :development
|
132
91
|
prerelease: false
|
133
92
|
version_requirements: !ruby/object:Gem::Requirement
|
134
93
|
requirements:
|
135
94
|
- - "~>"
|
136
95
|
- !ruby/object:Gem::Version
|
137
|
-
version: '0
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 0.2.13
|
96
|
+
version: '13.0'
|
141
97
|
- !ruby/object:Gem::Dependency
|
142
|
-
name:
|
98
|
+
name: rspec
|
143
99
|
requirement: !ruby/object:Gem::Requirement
|
144
100
|
requirements:
|
145
101
|
- - "~>"
|
146
102
|
- !ruby/object:Gem::Version
|
147
|
-
version: '0
|
103
|
+
version: '3.0'
|
148
104
|
type: :development
|
149
105
|
prerelease: false
|
150
106
|
version_requirements: !ruby/object:Gem::Requirement
|
151
107
|
requirements:
|
152
108
|
- - "~>"
|
153
109
|
- !ruby/object:Gem::Version
|
154
|
-
version: '0
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '1.0'
|
162
|
-
type: :runtime
|
163
|
-
prerelease: false
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
-
requirements:
|
166
|
-
- - "~>"
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
version: '1.0'
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: methodic
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - "~>"
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: '1.2'
|
176
|
-
- - ">="
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
version: '1.2'
|
179
|
-
type: :runtime
|
180
|
-
prerelease: false
|
181
|
-
version_requirements: !ruby/object:Gem::Requirement
|
182
|
-
requirements:
|
183
|
-
- - "~>"
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '1.2'
|
186
|
-
- - ">="
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
version: '1.2'
|
189
|
-
- !ruby/object:Gem::Dependency
|
190
|
-
name: xml-simple
|
191
|
-
requirement: !ruby/object:Gem::Requirement
|
192
|
-
requirements:
|
193
|
-
- - "~>"
|
194
|
-
- !ruby/object:Gem::Version
|
195
|
-
version: '1.1'
|
196
|
-
- - ">="
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
version: 1.1.5
|
199
|
-
type: :runtime
|
200
|
-
prerelease: false
|
201
|
-
version_requirements: !ruby/object:Gem::Requirement
|
202
|
-
requirements:
|
203
|
-
- - "~>"
|
204
|
-
- !ruby/object:Gem::Version
|
205
|
-
version: '1.1'
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: 1.1.5
|
209
|
-
description: 'Carioca : provide a full IoC light Container for designing your applications'
|
210
|
-
email: romain@ultragreen.net
|
110
|
+
version: '3.0'
|
111
|
+
description: 'Carioca 2: is a complete rewrite who provide a full IoC/DI light Container
|
112
|
+
and a services registry, build with logs, config and Internationalization facilities
|
113
|
+
for designing your applications'
|
114
|
+
email:
|
115
|
+
- romain@ultragreen.net
|
211
116
|
executables: []
|
212
117
|
extensions: []
|
213
118
|
extra_rdoc_files: []
|
214
119
|
files:
|
215
|
-
-
|
216
|
-
-
|
217
|
-
-
|
120
|
+
- ".github/workflows/main.yml"
|
121
|
+
- ".gitignore"
|
122
|
+
- ".rspec"
|
218
123
|
- Gemfile
|
219
124
|
- Gemfile.lock
|
220
|
-
- INSTALL
|
221
125
|
- README.md
|
222
126
|
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
223
129
|
- carioca.gemspec
|
224
|
-
-
|
130
|
+
- config/locales/en.yml
|
131
|
+
- config/locales/fr.yml
|
225
132
|
- lib/carioca.rb
|
226
|
-
- lib/carioca/
|
133
|
+
- lib/carioca/configuration.rb
|
134
|
+
- lib/carioca/constants.rb
|
135
|
+
- lib/carioca/container.rb
|
136
|
+
- lib/carioca/dependencies.rb
|
227
137
|
- lib/carioca/helpers.rb
|
228
|
-
- lib/carioca/
|
229
|
-
- lib/carioca/
|
230
|
-
- lib/carioca/
|
231
|
-
- lib/carioca/
|
232
|
-
- lib/carioca/
|
233
|
-
- lib/carioca/
|
234
|
-
- lib/carioca/
|
235
|
-
-
|
236
|
-
-
|
237
|
-
-
|
238
|
-
-
|
239
|
-
-
|
240
|
-
-
|
241
|
-
-
|
242
|
-
-
|
243
|
-
-
|
244
|
-
|
138
|
+
- lib/carioca/mixin.rb
|
139
|
+
- lib/carioca/rake/manage.rb
|
140
|
+
- lib/carioca/rake/tasks/registry.tasks
|
141
|
+
- lib/carioca/registry.rb
|
142
|
+
- lib/carioca/registry_file.rb
|
143
|
+
- lib/carioca/services/config.rb
|
144
|
+
- lib/carioca/services/i18n.rb
|
145
|
+
- lib/carioca/services/init.rb
|
146
|
+
- lib/carioca/services/output.rb
|
147
|
+
- lib/carioca/validator.rb
|
148
|
+
- samples/Rakefile
|
149
|
+
- samples/config/carioca.registry
|
150
|
+
- samples/config/locales/en.yml
|
151
|
+
- samples/config/locales/es.yml
|
152
|
+
- samples/config/locales/fr.yml
|
153
|
+
- samples/config/settings.yml
|
154
|
+
- samples/test.rb
|
155
|
+
homepage: https://github.com/Ultragreen/carioca
|
245
156
|
licenses:
|
246
|
-
- BSD-
|
247
|
-
metadata:
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
- "--line-numbers"
|
157
|
+
- BSD-3-Clause
|
158
|
+
metadata:
|
159
|
+
allowed_push_host: https://rubygems.org
|
160
|
+
homepage_uri: https://github.com/Ultragreen/carioca
|
161
|
+
source_code_uri: https://github.com/Ultragreen/carioca
|
162
|
+
changelog_uri: https://github.com/Ultragreen/carioca
|
163
|
+
post_install_message:
|
164
|
+
rdoc_options: []
|
255
165
|
require_paths:
|
256
166
|
- lib
|
257
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
258
168
|
requirements:
|
259
169
|
- - ">="
|
260
170
|
- !ruby/object:Gem::Version
|
261
|
-
version:
|
171
|
+
version: 2.3.0
|
262
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
173
|
requirements:
|
264
174
|
- - ">="
|
265
175
|
- !ruby/object:Gem::Version
|
266
176
|
version: '0'
|
267
177
|
requirements: []
|
268
|
-
|
269
|
-
|
270
|
-
signing_key:
|
178
|
+
rubygems_version: 3.2.3
|
179
|
+
signing_key:
|
271
180
|
specification_version: 4
|
272
|
-
summary: 'Carioca :
|
273
|
-
your Applications'
|
181
|
+
summary: 'Carioca : Container And Registry with Inversion Of Control for your Applications'
|
274
182
|
test_files: []
|
data/AUTHORS
DELETED
data/COPYRIGHT
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
carioca Copyright (c) 2013 Ultragreen Software, Romain GEORGES
|
2
|
-
All rights reserved.
|
3
|
-
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
5
|
-
modification, are permitted provided that the following conditions
|
6
|
-
are met:
|
7
|
-
1. Redistributions of source code must retain the above copyright
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
9
|
-
2. Redistributions in binary form must reproduce the above copyright
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
11
|
-
documentation and/or other materials provided with the distribution.
|
12
|
-
|
13
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
14
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
15
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
16
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
17
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
18
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
19
|
-
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
20
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
21
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
22
|
-
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
23
|
-
SUCH DAMAGE.
|
24
|
-
|
data/ChangeLog
DELETED
data/INSTALL
DELETED
data/doc/manual.rdoc
DELETED
@@ -1,225 +0,0 @@
|
|
1
|
-
= Carioca
|
2
|
-
|
3
|
-
== Content
|
4
|
-
|
5
|
-
Author:: Romain GEORGES <romain@ultragreen.net>
|
6
|
-
Version:: 1.0
|
7
|
-
WWW:: http://www.ultragreen.net/projects/carioca
|
8
|
-
|
9
|
-
== Description
|
10
|
-
|
11
|
-
CARIOCA is Configuration Agent and Registry with Inversion Of Control for your Applications
|
12
|
-
Carioca provide a full IoC light Container for designing your applications
|
13
|
-
Carioca provide :
|
14
|
-
- a complete Configuration Agent
|
15
|
-
- A service Registry (base on IOC/DI pattern)
|
16
|
-
|
17
|
-
|
18
|
-
== Installation
|
19
|
-
|
20
|
-
In a valid Ruby environment :
|
21
|
-
|
22
|
-
$ sudo zsh
|
23
|
-
# gem ins carioca
|
24
|
-
|
25
|
-
== Implementation
|
26
|
-
|
27
|
-
* [Carioca]
|
28
|
-
* [Carioca::Services]
|
29
|
-
* [Carioca:Services::Registry]
|
30
|
-
|
31
|
-
== Utilisation
|
32
|
-
|
33
|
-
Carioca may be used to create Ruby applications, based on a service registry
|
34
|
-
Carioca come with somes builtin services :
|
35
|
-
* logger : an Internal logger based on the logger gem.
|
36
|
-
* Configuration : a Configuration Service, with Yaml percistance, and pretty accessors.
|
37
|
-
* Debug : a Class Debugger, based on Proxy Design pattern and meta-programation like method_missing
|
38
|
-
|
39
|
-
|
40
|
-
=== Getting start
|
41
|
-
|
42
|
-
==== Preparing Gem
|
43
|
-
|
44
|
-
Just after Installation, Carioca :
|
45
|
-
|
46
|
-
$ gem ins bundler # if needed
|
47
|
-
$ bunlde gem myapp
|
48
|
-
$ cd myapp
|
49
|
-
|
50
|
-
|
51
|
-
Edit your myapp.gemspec, add this line in Gem::Specification bloc :
|
52
|
-
|
53
|
-
gem.add_dependency 'carioca'
|
54
|
-
gem.add_development_dependency 'rake'
|
55
|
-
gem.add_development_dependency 'carioca'
|
56
|
-
|
57
|
-
Description and summary need to be changed to be correctly displayed on Rubygems.
|
58
|
-
|
59
|
-
so, execute bundle :
|
60
|
-
|
61
|
-
$ bundle
|
62
|
-
|
63
|
-
Your environment, is ready to create your app
|
64
|
-
|
65
|
-
==== Prepare Carioca
|
66
|
-
|
67
|
-
|
68
|
-
$ mkdir config
|
69
|
-
$ mkdir bin
|
70
|
-
|
71
|
-
edit bin/myapp :
|
72
|
-
|
73
|
-
require 'rubygems'
|
74
|
-
require 'carioca'
|
75
|
-
|
76
|
-
registry = Carioca::Services::Registry.init :file => 'config/myservices.registry'
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
After, you could Run Carioca and discover Builtins Services, you need the write access to config path
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
$ ruby -e 'require "rubygems"; require "carioca"; reg = Carioca::Services::Registry.init :file => "config/myservices.registry"; reg.discover_builtins; reg.save!'
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
this create you, a New Registry config, with all builtins registered.
|
89
|
-
Default path :
|
90
|
-
* config file : ./.config
|
91
|
-
* log file : /tmp/log.file
|
92
|
-
Carioca Registry is a Singleton, and services also be unique instance.
|
93
|
-
|
94
|
-
Now you could continue coding your bin/myapp
|
95
|
-
|
96
|
-
==== Using Configuration Service
|
97
|
-
|
98
|
-
|
99
|
-
require 'rubygems'
|
100
|
-
require 'carioca'
|
101
|
-
|
102
|
-
registry = Carioca::Services::Registry.init :file => 'config/myservices.registry'
|
103
|
-
config = registry.start_service :name => 'configuration'
|
104
|
-
config.setings.db = { :name => 'mydb' }
|
105
|
-
config.settings.db.host = "myhost"
|
106
|
-
config.settings.db.port = "4545"
|
107
|
-
config.settings.email = "my@email.com"
|
108
|
-
config.save!
|
109
|
-
|
110
|
-
|
111
|
-
==== Using Logger Service
|
112
|
-
|
113
|
-
logger is automatically loaded with Carioca, loading registry with :debug => true, let you see the Carioca traces.
|
114
|
-
|
115
|
-
|
116
|
-
require 'rubygems'
|
117
|
-
require 'carioca'
|
118
|
-
|
119
|
-
registry = Carioca::Services::Registry.init :file => 'config/myservices.registry' :debug => true
|
120
|
-
log = registry.get_service :name => 'logger'
|
121
|
-
log.info('myapp') {'my message' }
|
122
|
-
|
123
|
-
|
124
|
-
==== Creating and using your own service
|
125
|
-
|
126
|
-
before create your own service :
|
127
|
-
|
128
|
-
|
129
|
-
$ mkdir services
|
130
|
-
|
131
|
-
|
132
|
-
Services, must be a class, if not do a wrapper
|
133
|
-
edit services/myservice.rb
|
134
|
-
|
135
|
-
class MyService
|
136
|
-
def initialize
|
137
|
-
end
|
138
|
-
|
139
|
-
def test(arg = nil)
|
140
|
-
return 'OK'
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
You could use the #service_register API (See spec for all details)
|
147
|
-
but, you could write it directly in YAML in your config/myservices.registry :
|
148
|
-
add the following lines :
|
149
|
-
|
150
|
-
...
|
151
|
-
myservice:
|
152
|
-
:type: :file
|
153
|
-
:resource: services/myservice.rb
|
154
|
-
:description: a test service
|
155
|
-
:service: MyServices
|
156
|
-
...
|
157
|
-
|
158
|
-
So in your app :
|
159
|
-
|
160
|
-
|
161
|
-
require 'rubygems'
|
162
|
-
require 'carioca'
|
163
|
-
|
164
|
-
registry = Carioca::Services::Registry.init :file => 'config/myservices.registry'
|
165
|
-
service = registry.start_service :name => 'myservice'
|
166
|
-
service.test('titi')
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
==== Using Debug in multiple service instance
|
171
|
-
|
172
|
-
|
173
|
-
in your app, for debug you could use the Proxy Debug (you need to run Carioca Registry in debug mode ) :
|
174
|
-
(Using "debug_", you create an instance of service debug, so with this syntaxe you could create multiple services instances, with different parameters calling.)
|
175
|
-
|
176
|
-
|
177
|
-
require 'rubygems'
|
178
|
-
require 'carioca'
|
179
|
-
|
180
|
-
registry = Carioca::Services::Registry.init :file => 'config/myservices.registry' :debug => true
|
181
|
-
proxy1 = registry.get_service :name => 'debug_myservice', :params => {:service => 'myservice'}
|
182
|
-
proxy1.test('titi')
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
see the log /tmp/log.file :
|
187
|
-
|
188
|
-
|
189
|
-
D, [2013-03-23T18:20:39.839826 #76641] DEBUG -- ProxyDebug: BEGIN CALL for mapped service myservice
|
190
|
-
D, [2013-03-23T18:20:39.839875 #76641] DEBUG -- ProxyDebug: called: test
|
191
|
-
D, [2013-03-23T18:20:39.839920 #76641] DEBUG -- ProxyDebug: args : titi
|
192
|
-
D, [2013-03-23T18:20:39.839970 #76641] DEBUG -- ProxyDebug: => returned: OK
|
193
|
-
D, [2013-03-23T18:20:39.840014 #76641] DEBUG -- ProxyDebug: END CALL
|
194
|
-
|
195
|
-
==== Using Gem for a service
|
196
|
-
|
197
|
-
|
198
|
-
For exemple install uuid gem :
|
199
|
-
|
200
|
-
$ gem ins uuid
|
201
|
-
|
202
|
-
|
203
|
-
add to your YAML config config/myservices.registry :
|
204
|
-
|
205
|
-
uuid:
|
206
|
-
:type: :gem
|
207
|
-
:resource: uuid
|
208
|
-
:description: a Rubygems called uuid to build UUID ids.
|
209
|
-
:service: UUID
|
210
|
-
|
211
|
-
|
212
|
-
in your app :
|
213
|
-
|
214
|
-
require 'rubygems'
|
215
|
-
require 'carioca'
|
216
|
-
|
217
|
-
registry = Carioca::Services::Registry.init :file => 'config/myservices.registry' :debug => true
|
218
|
-
uuid = registry.get_service :name => 'uuid'
|
219
|
-
uuid.generate
|
220
|
-
|
221
|
-
|
222
|
-
== Copyright
|
223
|
-
|
224
|
-
<pre>carioca (c) 2012-2013 Romain GEORGES <romain@ultragreen.net> for Ultragreen Software </pre>
|
225
|
-
|