carioca 1.4 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +18 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +58 -0
- data/README.md +123 -190
- data/Rakefile +5 -66
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/carioca.gemspec +37 -23
- data/config/locales/en.yml +23 -0
- data/config/locales/fr.yml +23 -0
- data/lib/carioca/configuration.rb +61 -0
- data/lib/carioca/constants.rb +68 -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} +5 -4
- data/lib/carioca/rake/tasks/config.tasks +46 -0
- data/lib/carioca/rake/tasks/gem.tasks +15 -0
- data/lib/carioca/rake/tasks/registry.tasks +64 -0
- data/lib/carioca/registry.rb +94 -0
- data/lib/carioca/registry_file.rb +62 -0
- data/lib/carioca/services/config.rb +141 -0
- data/lib/carioca/services/debug.rb +48 -61
- data/lib/carioca/services/i18n.rb +20 -0
- data/lib/carioca/services/init.rb +2 -0
- data/lib/carioca/services/output.rb +189 -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 +118 -0
- metadata +77 -143
- data/AUTHORS +0 -8
- data/COPYRIGHT +0 -24
- data/ChangeLog +0 -10
- data/INSTALL +0 -7
- data/doc/manual.rdoc +0 -225
- data/lib/carioca/exceptions.rb +0 -9
- data/lib/carioca/private.rb +0 -168
- data/lib/carioca/services/configuration.rb +0 -203
- data/lib/carioca/services/logger.rb +0 -58
- data/lib/carioca/services.rb +0 -143
- data/lib/carioca/tasks/registry_init.rake +0 -12
- data/spec/carioca_spec.rb +0 -468
- data/spec/config/.config +0 -14
- data/spec/config/services.registry +0 -55
- data/spec/init_spec.rb +0 -2
- data/spec/samples/dummy.rb +0 -11
- data/spec/samples/otherdummy.rb +0 -11
- data/spec/samples/requireddummy.rb +0 -11
- data/spec/spec_helper.rb +0 -18
- data/ultragreen_roodi_coding_convention.yml +0 -25
metadata
CHANGED
@@ -1,234 +1,169 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.3
|
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-06 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: 13.0.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.9.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 3.9.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: yard
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.9.24
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.9.24
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rdoc
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 6.2.1
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 6.2.1
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: roodi
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 5.0.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 5.0.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: code_statistics
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.2.13
|
90
|
-
type: :development
|
19
|
+
version: 0.23.1
|
20
|
+
type: :runtime
|
91
21
|
prerelease: false
|
92
22
|
version_requirements: !ruby/object:Gem::Requirement
|
93
23
|
requirements:
|
94
24
|
- - "~>"
|
95
25
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
26
|
+
version: 0.23.1
|
97
27
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
28
|
+
name: pastel
|
99
29
|
requirement: !ruby/object:Gem::Requirement
|
100
30
|
requirements:
|
101
31
|
- - "~>"
|
102
32
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
-
type: :
|
33
|
+
version: 0.8.0
|
34
|
+
type: :runtime
|
105
35
|
prerelease: false
|
106
36
|
version_requirements: !ruby/object:Gem::Requirement
|
107
37
|
requirements:
|
108
38
|
- - "~>"
|
109
39
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
40
|
+
version: 0.8.0
|
111
41
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
42
|
+
name: i18n
|
113
43
|
requirement: !ruby/object:Gem::Requirement
|
114
44
|
requirements:
|
115
45
|
- - "~>"
|
116
46
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
type: :
|
47
|
+
version: '1.10'
|
48
|
+
type: :runtime
|
119
49
|
prerelease: false
|
120
50
|
version_requirements: !ruby/object:Gem::Requirement
|
121
51
|
requirements:
|
122
52
|
- - "~>"
|
123
53
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
54
|
+
version: '1.10'
|
125
55
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
56
|
+
name: locale
|
127
57
|
requirement: !ruby/object:Gem::Requirement
|
128
58
|
requirements:
|
129
59
|
- - "~>"
|
130
60
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1
|
61
|
+
version: '2.1'
|
132
62
|
type: :runtime
|
133
63
|
prerelease: false
|
134
64
|
version_requirements: !ruby/object:Gem::Requirement
|
135
65
|
requirements:
|
136
66
|
- - "~>"
|
137
67
|
- !ruby/object:Gem::Version
|
138
|
-
version: '1
|
68
|
+
version: '2.1'
|
139
69
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
70
|
+
name: deep_merge
|
141
71
|
requirement: !ruby/object:Gem::Requirement
|
142
72
|
requirements:
|
143
73
|
- - "~>"
|
144
74
|
- !ruby/object:Gem::Version
|
145
|
-
version: '1.
|
146
|
-
- - ">="
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '1.3'
|
75
|
+
version: '1.2'
|
149
76
|
type: :runtime
|
150
77
|
prerelease: false
|
151
78
|
version_requirements: !ruby/object:Gem::Requirement
|
152
79
|
requirements:
|
153
80
|
- - "~>"
|
154
81
|
- !ruby/object:Gem::Version
|
155
|
-
version: '1.
|
156
|
-
- - ">="
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '1.3'
|
82
|
+
version: '1.2'
|
159
83
|
- !ruby/object:Gem::Dependency
|
160
|
-
name:
|
84
|
+
name: rake
|
161
85
|
requirement: !ruby/object:Gem::Requirement
|
162
86
|
requirements:
|
163
87
|
- - "~>"
|
164
88
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
166
|
-
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
version: 1.1.5
|
169
|
-
type: :runtime
|
89
|
+
version: '13.0'
|
90
|
+
type: :development
|
170
91
|
prerelease: false
|
171
92
|
version_requirements: !ruby/object:Gem::Requirement
|
172
93
|
requirements:
|
173
94
|
- - "~>"
|
174
95
|
- !ruby/object:Gem::Version
|
175
|
-
version: '
|
176
|
-
- - ">="
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
version: 1.1.5
|
96
|
+
version: '13.0'
|
179
97
|
- !ruby/object:Gem::Dependency
|
180
|
-
name:
|
98
|
+
name: rspec
|
181
99
|
requirement: !ruby/object:Gem::Requirement
|
182
100
|
requirements:
|
183
101
|
- - "~>"
|
184
102
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
186
|
-
type: :
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
187
105
|
prerelease: false
|
188
106
|
version_requirements: !ruby/object:Gem::Requirement
|
189
107
|
requirements:
|
190
108
|
- - "~>"
|
191
109
|
- !ruby/object:Gem::Version
|
192
|
-
version:
|
193
|
-
description: 'Carioca : provide a full IoC light Container
|
194
|
-
|
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
|
195
116
|
executables: []
|
196
117
|
extensions: []
|
197
118
|
extra_rdoc_files: []
|
198
119
|
files:
|
199
|
-
-
|
200
|
-
-
|
201
|
-
-
|
120
|
+
- ".github/workflows/main.yml"
|
121
|
+
- ".gitignore"
|
122
|
+
- ".rspec"
|
202
123
|
- Gemfile
|
203
|
-
-
|
124
|
+
- Gemfile.lock
|
204
125
|
- README.md
|
205
126
|
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
206
129
|
- carioca.gemspec
|
207
|
-
-
|
130
|
+
- config/locales/en.yml
|
131
|
+
- config/locales/fr.yml
|
208
132
|
- lib/carioca.rb
|
209
|
-
- lib/carioca/
|
133
|
+
- lib/carioca/configuration.rb
|
134
|
+
- lib/carioca/constants.rb
|
135
|
+
- lib/carioca/container.rb
|
136
|
+
- lib/carioca/dependencies.rb
|
210
137
|
- lib/carioca/helpers.rb
|
211
|
-
- lib/carioca/
|
212
|
-
- lib/carioca/
|
213
|
-
- lib/carioca/
|
138
|
+
- lib/carioca/mixin.rb
|
139
|
+
- lib/carioca/rake/manage.rb
|
140
|
+
- lib/carioca/rake/tasks/config.tasks
|
141
|
+
- lib/carioca/rake/tasks/gem.tasks
|
142
|
+
- lib/carioca/rake/tasks/registry.tasks
|
143
|
+
- lib/carioca/registry.rb
|
144
|
+
- lib/carioca/registry_file.rb
|
145
|
+
- lib/carioca/services/config.rb
|
214
146
|
- lib/carioca/services/debug.rb
|
215
|
-
- lib/carioca/services/
|
216
|
-
- lib/carioca/
|
217
|
-
- lib/carioca/
|
218
|
-
-
|
219
|
-
-
|
220
|
-
-
|
221
|
-
-
|
222
|
-
-
|
223
|
-
-
|
224
|
-
-
|
225
|
-
-
|
226
|
-
- ultragreen_roodi_coding_convention.yml
|
147
|
+
- lib/carioca/services/i18n.rb
|
148
|
+
- lib/carioca/services/init.rb
|
149
|
+
- lib/carioca/services/output.rb
|
150
|
+
- lib/carioca/validator.rb
|
151
|
+
- samples/Rakefile
|
152
|
+
- samples/config/carioca.registry
|
153
|
+
- samples/config/locales/en.yml
|
154
|
+
- samples/config/locales/es.yml
|
155
|
+
- samples/config/locales/fr.yml
|
156
|
+
- samples/config/settings.yml
|
157
|
+
- samples/test.rb
|
227
158
|
homepage: https://github.com/Ultragreen/carioca
|
228
159
|
licenses:
|
229
|
-
- BSD-
|
230
|
-
metadata:
|
231
|
-
|
160
|
+
- BSD-3-Clause
|
161
|
+
metadata:
|
162
|
+
allowed_push_host: https://rubygems.org
|
163
|
+
homepage_uri: https://github.com/Ultragreen/carioca
|
164
|
+
source_code_uri: https://github.com/Ultragreen/carioca
|
165
|
+
changelog_uri: https://github.com/Ultragreen/carioca
|
166
|
+
post_install_message:
|
232
167
|
rdoc_options: []
|
233
168
|
require_paths:
|
234
169
|
- lib
|
@@ -236,16 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
236
171
|
requirements:
|
237
172
|
- - ">="
|
238
173
|
- !ruby/object:Gem::Version
|
239
|
-
version:
|
174
|
+
version: 2.3.0
|
240
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
176
|
requirements:
|
242
177
|
- - ">="
|
243
178
|
- !ruby/object:Gem::Version
|
244
179
|
version: '0'
|
245
180
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
247
|
-
signing_key:
|
181
|
+
rubygems_version: 3.2.3
|
182
|
+
signing_key:
|
248
183
|
specification_version: 4
|
249
|
-
summary: 'Carioca :
|
250
|
-
your Applications'
|
184
|
+
summary: 'Carioca : Container And Registry with Inversion Of Control for your Applications'
|
251
185
|
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
|
-
|