carioca 1.1 → 2.0.1

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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +18 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +3 -0
  5. data/Gemfile +6 -1
  6. data/Gemfile.lock +42 -34
  7. data/README.md +12 -220
  8. data/Rakefile +5 -59
  9. data/bin/console +15 -0
  10. data/bin/setup +8 -0
  11. data/carioca.gemspec +41 -25
  12. data/config/locales/en.yml +15 -0
  13. data/config/locales/fr.yml +19 -0
  14. data/lib/carioca/configuration.rb +47 -0
  15. data/lib/carioca/constants.rb +45 -0
  16. data/lib/carioca/container.rb +16 -0
  17. data/lib/carioca/dependencies.rb +19 -0
  18. data/lib/carioca/helpers.rb +44 -31
  19. data/lib/carioca/mixin.rb +32 -0
  20. data/lib/carioca/{tasks/rake.rb → rake/manage.rb} +4 -6
  21. data/lib/carioca/rake/tasks/registry.tasks +57 -0
  22. data/lib/carioca/registry.rb +93 -0
  23. data/lib/carioca/registry_file.rb +62 -0
  24. data/lib/carioca/services/config.rb +140 -0
  25. data/lib/carioca/services/i18n.rb +20 -0
  26. data/lib/carioca/services/init.rb +2 -0
  27. data/lib/carioca/validator.rb +49 -0
  28. data/lib/carioca.rb +2 -319
  29. data/samples/Rakefile +2 -0
  30. data/samples/config/carioca.registry +22 -0
  31. data/samples/config/locales/en.yml +2 -0
  32. data/samples/config/locales/es.yml +2 -0
  33. data/samples/config/locales/fr.yml +2 -0
  34. data/samples/config/settings.yml +24 -0
  35. data/samples/test.rb +71 -0
  36. metadata +59 -152
  37. data/AUTHORS +0 -8
  38. data/COPYRIGHT +0 -24
  39. data/ChangeLog +0 -7
  40. data/INSTALL +0 -7
  41. data/doc/manual.rdoc +0 -225
  42. data/lib/carioca/exceptions.rb +0 -9
  43. data/lib/carioca/private.rb +0 -170
  44. data/lib/carioca/services/configuration.rb +0 -187
  45. data/lib/carioca/services/debug.rb +0 -73
  46. data/lib/carioca/services/logger.rb +0 -58
  47. data/lib/carioca/services.rb +0 -143
  48. data/lib/carioca/tasks/registry_init.rake +0 -11
  49. data/spec/carioca_spec.rb +0 -459
  50. data/spec/config/services.registry +0 -55
  51. data/spec/init_spec.rb +0 -1
  52. data/spec/samples/dummy.rb +0 -10
  53. data/spec/samples/otherdummy.rb +0 -10
  54. data/spec/samples/requireddummy.rb +0 -10
  55. data/spec/spec_helper.rb +0 -11
  56. data/test.rb +0 -12
  57. data/ultragreen_roodi_coding_convention.yml +0 -25
metadata CHANGED
@@ -1,201 +1,108 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carioca
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2013-02-18 00:00:00.000000000 Z
11
+ date: 2022-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: tty-prompt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: yard
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rdoc
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: roodi
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: uuid
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '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'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: yard-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: dorsal
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
19
+ version: 0.23.1
118
20
  type: :runtime
119
21
  prerelease: false
120
22
  version_requirements: !ruby/object:Gem::Requirement
121
23
  requirements:
122
- - - '>='
24
+ - - "~>"
123
25
  - !ruby/object:Gem::Version
124
- version: '0'
26
+ version: 0.23.1
125
27
  - !ruby/object:Gem::Dependency
126
- name: methodic
28
+ name: pastel
127
29
  requirement: !ruby/object:Gem::Requirement
128
30
  requirements:
129
- - - '>='
31
+ - - "~>"
130
32
  - !ruby/object:Gem::Version
131
- version: '0'
33
+ version: 0.8.0
132
34
  type: :runtime
133
35
  prerelease: false
134
36
  version_requirements: !ruby/object:Gem::Requirement
135
37
  requirements:
136
- - - '>='
38
+ - - "~>"
137
39
  - !ruby/object:Gem::Version
138
- version: '0'
40
+ version: 0.8.0
139
41
  description: 'Carioca : provide a full IoC light Container for designing your applications'
140
- email: romain@ultragreen.net
42
+ email:
43
+ - romain@ultragreen.net
141
44
  executables: []
142
45
  extensions: []
143
46
  extra_rdoc_files: []
144
47
  files:
145
- - lib/carioca/tasks/rake.rb
146
- - lib/carioca/tasks/registry_init.rake
147
- - lib/carioca/services/configuration.rb
148
- - lib/carioca/services/debug.rb
149
- - lib/carioca/services/logger.rb
150
- - spec/samples/dummy.rb
151
- - spec/samples/requireddummy.rb
152
- - spec/samples/otherdummy.rb
153
- - spec/config/services.registry
154
- - lib/carioca/services.rb
155
- - lib/carioca/private.rb
156
- - lib/carioca/exceptions.rb
157
- - lib/carioca/helpers.rb
158
- - doc/manual.rdoc
159
- - spec/init_spec.rb
160
- - spec/spec_helper.rb
161
- - spec/carioca_spec.rb
162
- - lib/carioca.rb
163
- - Gemfile.lock
48
+ - ".github/workflows/main.yml"
49
+ - ".gitignore"
50
+ - ".rspec"
164
51
  - Gemfile
165
- - ChangeLog
166
- - COPYRIGHT
167
- - ultragreen_roodi_coding_convention.yml
168
- - AUTHORS
52
+ - Gemfile.lock
169
53
  - README.md
170
- - test.rb
171
- - carioca.gemspec
172
54
  - Rakefile
173
- - INSTALL
174
- homepage: http://www.ultragreen.net
175
- licenses: []
176
- metadata: {}
55
+ - bin/console
56
+ - bin/setup
57
+ - carioca.gemspec
58
+ - config/locales/en.yml
59
+ - config/locales/fr.yml
60
+ - lib/carioca.rb
61
+ - lib/carioca/configuration.rb
62
+ - lib/carioca/constants.rb
63
+ - lib/carioca/container.rb
64
+ - lib/carioca/dependencies.rb
65
+ - lib/carioca/helpers.rb
66
+ - lib/carioca/mixin.rb
67
+ - lib/carioca/rake/manage.rb
68
+ - lib/carioca/rake/tasks/registry.tasks
69
+ - lib/carioca/registry.rb
70
+ - lib/carioca/registry_file.rb
71
+ - lib/carioca/services/config.rb
72
+ - lib/carioca/services/i18n.rb
73
+ - lib/carioca/services/init.rb
74
+ - lib/carioca/validator.rb
75
+ - samples/Rakefile
76
+ - samples/config/carioca.registry
77
+ - samples/config/locales/en.yml
78
+ - samples/config/locales/es.yml
79
+ - samples/config/locales/fr.yml
80
+ - samples/config/settings.yml
81
+ - samples/test.rb
82
+ homepage: https://github.com/Ultragreen/carioca
83
+ licenses:
84
+ - BSD-3-Clause
85
+ metadata:
86
+ allowed_push_host: https://rubygems.org
87
+ homepage_uri: https://github.com/Ultragreen/carioca
88
+ source_code_uri: https://github.com/Ultragreen/carioca
89
+ changelog_uri: https://github.com/Ultragreen/carioca
177
90
  post_install_message:
178
- rdoc_options:
179
- - --title
180
- - 'Carioca : Gem documentation'
181
- - --main
182
- - doc/manual.rdoc
183
- - --line-numbers
91
+ rdoc_options: []
184
92
  require_paths:
185
93
  - lib
186
94
  required_ruby_version: !ruby/object:Gem::Requirement
187
95
  requirements:
188
- - - '>='
96
+ - - ">="
189
97
  - !ruby/object:Gem::Version
190
- version: 1.8.1
98
+ version: 2.3.0
191
99
  required_rubygems_version: !ruby/object:Gem::Requirement
192
100
  requirements:
193
- - - '>='
101
+ - - ">="
194
102
  - !ruby/object:Gem::Version
195
103
  version: '0'
196
104
  requirements: []
197
- rubyforge_project: nowarning
198
- rubygems_version: 2.0.7
105
+ rubygems_version: 3.1.2
199
106
  signing_key:
200
107
  specification_version: 4
201
108
  summary: 'Carioca : Configuration Agent and Registry with Inversion Of Control for
data/AUTHORS DELETED
@@ -1,8 +0,0 @@
1
- Author :
2
- Romain GEORGES <romain@ultragreen.net>
3
- - code
4
- - inline documentation
5
- - specs
6
- - Documentation
7
- Ruby Gem maintener :
8
- Romain GEORGES <romain@ultragreen.net>
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
@@ -1,7 +0,0 @@
1
- carioca :
2
- - initial dev. version
3
- - version 0.1 (unstable)
4
- Romain GEORGES
5
- - initial stable version
6
- - version 1.0 (stable)
7
- Romain GEORGES
data/INSTALL DELETED
@@ -1,7 +0,0 @@
1
- How to install carioca ?
2
- =========================
3
-
4
- Please install the gem version via RubyGems :
5
-
6
- $ su -
7
- # gem ins carioca
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
-
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #---
3
- # Author : Romain GEORGES
4
- # type : gem component library
5
- # obj : Carioca Exceptions definition Module
6
- #---
7
-
8
- # Exception overload class for Carioca
9
- class RegistryError < Exception; end