carioca 1.4 → 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 +4 -4
  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 +49 -0
  7. data/README.md +12 -220
  8. data/Rakefile +5 -66
  9. data/bin/console +15 -0
  10. data/bin/setup +8 -0
  11. data/carioca.gemspec +32 -23
  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} +2 -4
  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 +46 -187
  37. data/AUTHORS +0 -8
  38. data/COPYRIGHT +0 -24
  39. data/ChangeLog +0 -10
  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 -168
  44. data/lib/carioca/services/configuration.rb +0 -203
  45. data/lib/carioca/services/debug.rb +0 -71
  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 -12
  49. data/spec/carioca_spec.rb +0 -468
  50. data/spec/config/.config +0 -14
  51. data/spec/config/services.registry +0 -55
  52. data/spec/init_spec.rb +0 -2
  53. data/spec/samples/dummy.rb +0 -11
  54. data/spec/samples/otherdummy.rb +0 -11
  55. data/spec/samples/requireddummy.rb +0 -11
  56. data/spec/spec_helper.rb +0 -18
  57. data/ultragreen_roodi_coding_convention.yml +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9be0e1efee67cbc15309f5eb56a72208681b14d84c3c1f3666474c28798c1c51
4
- data.tar.gz: 66033e08a911cd0b537eb7ca1114a8aca2d445f8cae79e9d04e62190e27d0a0c
3
+ metadata.gz: c349ebcb566a9571f7cd424b6cb3a95dd3b6871a99caf992ac04af996a35259a
4
+ data.tar.gz: d4f4a5db811c978fe0390f41a757a352452c844f72775c21435c6ca1656213c1
5
5
  SHA512:
6
- metadata.gz: 85c41d310a6ad5f7704b2f244a1616160569dd389939c4ed389b08d81520f15f1c304e5ece750e29205043544bcca886ad39a6925be24c941044acaf5a3c8cbd
7
- data.tar.gz: 95cdb63add808821f358742e1fbd6ef611ebc49f062901405ec37cc972dcf7c8695a88583f16685b020df3f08485c8bc1dec83d2868c44641a67fd53c5c0ecef
6
+ metadata.gz: d05baa11c7379fe052161140fef4a17dd075ce2998c600ad5023d947edf76769fe2020829438863bc4adf4ee4c62f50da2bfb73c2937a5837fe6a48be87de1fb
7
+ data.tar.gz: 1e12daba542a3e103205f1f7f7fcd71f82a924b2e247fc48ca6a0ee0feb9e4fca85e3a22d2b6baf9c2b7c705b6ef71d0e70611cd9509928eb25584b423a8578a
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.3
17
+ bundle install
18
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem "rake", "~> 13.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem 'i18n', "~> 1.10"
8
+ gem 'locale', "~> 2.1"
9
+ gem "deep_merge", "~> 1.2"
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ carioca (2.0.0)
5
+ tty-prompt (~> 0.23.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.5.0)
11
+ pastel (0.8.0)
12
+ tty-color (~> 0.5)
13
+ rake (13.0.6)
14
+ rspec (3.9.0)
15
+ rspec-core (~> 3.9.0)
16
+ rspec-expectations (~> 3.9.0)
17
+ rspec-mocks (~> 3.9.0)
18
+ rspec-core (3.9.3)
19
+ rspec-support (~> 3.9.3)
20
+ rspec-expectations (3.9.4)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-mocks (3.9.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.9.0)
26
+ rspec-support (3.9.4)
27
+ tty-color (0.6.0)
28
+ tty-cursor (0.7.1)
29
+ tty-prompt (0.23.1)
30
+ pastel (~> 0.8)
31
+ tty-reader (~> 0.8)
32
+ tty-reader (0.9.0)
33
+ tty-cursor (~> 0.7)
34
+ tty-screen (~> 0.8)
35
+ wisper (~> 2.0)
36
+ tty-screen (0.8.1)
37
+ wisper (2.0.1)
38
+
39
+ PLATFORMS
40
+ arm64-darwin-20
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ carioca!
45
+ rake (~> 13.0)
46
+ rspec (~> 3.0)
47
+
48
+ BUNDLED WITH
49
+ 2.2.3
data/README.md CHANGED
@@ -1,239 +1,31 @@
1
1
  # Carioca
2
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
- [![Build Status](https://travis-ci.org/lecid/carioca.png?branch=master)](https://travis-ci.org/lecid/carioca)
18
-
19
-
20
3
  ## Installation
21
4
 
22
- In a valid Ruby environment :
23
-
24
- ```
25
- $ sudo zsh
26
- # gem ins carioca
27
- ```
28
- ## Implementation
29
-
30
- * [Carioca]
31
- * [Carioca::Services]
32
- * [Carioca:Services::Registry]
33
-
34
- ## Utilisation
35
-
36
- Carioca may be used to create Ruby applications, based on a service registry
37
- Carioca come with somes builtin services :
38
- * logger : an Internal logger based on the logger gem.
39
- * Configuration : a Configuration Service, with Yaml percistance, and pretty accessors.
40
- * Debug : a Class Debugger, based on Proxy Design pattern and meta-programation like method_missing
41
-
42
- ### Getting start
43
-
44
- #### Preparing Gem
45
-
46
- Just after Installation, Carioca :
47
-
48
- ```
49
- $ gem ins bundler # if needed
50
- $ bunlde gem myapp
51
- $ cd myapp
52
- ```
53
-
54
- Edit your myapp.gemspec, add this line in Gem::Specification bloc :
55
-
56
- ```ruby
57
- gem.add_dependency 'carioca'
58
- gem.add_development_dependency 'rake'
59
- gem.add_development_dependency 'carioca'
60
- ```
61
-
62
- Description and summary need to be changed to be correctly displayed on Rubygems.
63
-
64
- so, execute bundle :
65
-
66
- ```
67
- $ bundle
68
- ```
69
-
70
- Your environment, is ready to create your app
71
-
72
- #### Prepare Carioca
73
-
74
- ```
75
- $ mkdir config
76
- $ mkdir bin
77
- ```
78
-
79
- edit bin/myapp :
80
-
81
- ```ruby
82
- require 'rubygems'
83
- require 'carioca'
84
-
85
- registry = Carioca::Services::Registry.init :file => 'config/myservices.registry'
86
- ```
87
-
88
-
89
- After, you could Run Carioca and discover Builtins Services, you need the write access to config path
90
-
91
-
92
- ```
93
- $ ruby -e 'require "rubygems"; require "carioca"; reg = Carioca::Services::Registry.init :file => "config/myservices.registry"; reg.discover_builtins; reg.save!'
94
- ```
95
-
96
-
97
- this create you, a New Registry config, with all builtins registered.
98
- Default path :
99
- * config file : ./.config
100
- * log file : /tmp/log.file
101
- Carioca Registry is a Singleton, and services also be unique instance.
102
-
103
- Now you could continue coding your bin/myapp
104
-
105
- #### Using Configuration Service
106
-
107
- ```ruby
108
- require 'rubygems'
109
- require 'carioca'
110
-
111
- registry = Carioca::Services::Registry.init :file => 'config/myservices.registry'
112
- config = registry.start_service :name => 'configuration'
113
- config.setings.db = { :name => 'mydb' }
114
- config.settings.db.host = "myhost"
115
- config.settings.db.port = "4545"
116
- config.settings.email = "my@email.com"
117
- config.save!
118
- ```
119
-
120
- #### Using Logger Service
121
-
122
- logger is automatically loaded with Carioca, loading registry with :debug => true, let you see the Carioca traces.
123
-
124
- ```ruby
125
- require 'rubygems'
126
- require 'carioca'
127
-
128
- registry = Carioca::Services::Registry.init :file => 'config/myservices.registry' :debug => true
129
- log = registry.get_service :name => 'logger'
130
- log.info('myapp') {'my message' }
131
- ```
132
-
133
- #### Creating and using your own service
134
-
135
- before create your own service :
136
-
137
- ```
138
- $ mkdir services
139
- ```
140
-
141
- Services, must be a class, if not do a wrapper
142
- edit services/myservice.rb
143
-
144
- ```ruby
145
- class MyService
146
- def initialize
147
- end
148
-
149
- def test(arg = nil)
150
- return 'OK'
151
- end
152
- end
153
- end
154
- ```
155
-
156
- You could use the #service_register API (See spec for all details)
157
- but, you could write it directly in YAML in your config/myservices.registry :
158
- add the following lines :
159
-
160
- ```yaml
161
- ...
162
- myservice:
163
- :type: :file
164
- :resource: services/myservice.rb
165
- :description: a test service
166
- :service: MyServices
167
- ...
168
-
169
- So in your app :
170
-
171
- ```ruby
172
- require 'rubygems'
173
- require 'carioca'
174
-
175
- registry = Carioca::Services::Registry.init :file => 'config/myservices.registry'
176
- service = registry.start_service :name => 'myservice'
177
- service.test('titi')
178
- ```
179
-
180
- #### Using Debug in multiple service instance
181
-
182
-
183
- in your app, for debug you could use the Proxy Debug (you need to run Carioca Registry in debug mode ) :
184
- (Using "debug_", you create an instance of service debug, so with this syntaxe you could create multiple services instances, with different parameters calling.)
5
+ Add this line to your application's Gemfile:
185
6
 
186
7
  ```ruby
187
- require 'rubygems'
188
- require 'carioca'
189
-
190
- registry = Carioca::Services::Registry.init :file => 'config/myservices.registry' :debug => true
191
- proxy1 = registry.get_service :name => 'debug_myservice', :params => {:service => 'myservice'}
192
- proxy1.test('titi')
8
+ gem 'carioca'
193
9
  ```
194
10
 
11
+ And then execute:
195
12
 
196
- see the log /tmp/log.file :
13
+ $ bundle install
197
14
 
198
- ```
199
- D, [2013-03-23T18:20:39.839826 #76641] DEBUG -- ProxyDebug: BEGIN CALL for mapped service myservice
200
- D, [2013-03-23T18:20:39.839875 #76641] DEBUG -- ProxyDebug: called: test
201
- D, [2013-03-23T18:20:39.839920 #76641] DEBUG -- ProxyDebug: args : titi
202
- D, [2013-03-23T18:20:39.839970 #76641] DEBUG -- ProxyDebug: => returned: OK
203
- D, [2013-03-23T18:20:39.840014 #76641] DEBUG -- ProxyDebug: END CALL
204
- ```
15
+ Or install it yourself as:
205
16
 
206
- #### Using Gem for a service
17
+ $ gem install carioca
207
18
 
19
+ ## Usage
208
20
 
209
- For exemple install uuid gem :
210
21
 
211
- ```
212
- $ gem ins uuid
213
- ```
214
22
 
215
- add to your YAML config config/myservices.registry :
23
+ ## Development
216
24
 
217
- ```yaml
218
- uuid:
219
- :type: :gem
220
- :resource: uuid
221
- :description: a Rubygems called uuid to build UUID ids.
222
- :service: UUID
223
- ```
224
-
225
- in your app :
226
-
227
- ```ruby
228
- require 'rubygems'
229
- require 'carioca'
230
-
231
- registry = Carioca::Services::Registry.init :file => 'config/myservices.registry' :debug => true
232
- uuid = registry.get_service :name => 'uuid'
233
- uuid.generate
234
- ```
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
235
26
 
236
- == Copyright
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
237
28
 
238
- <pre>carioca (c) 2012-2013 Romain GEORGES <romain@ultragreen.net> for Ultragreen Software </pre>
29
+ ## Contributing
239
30
 
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Ultragreen/carioca.
data/Rakefile CHANGED
@@ -1,69 +1,8 @@
1
- require 'rubygems'
2
- require "bundler/gem_tasks"
3
- require 'rspec'
4
- require 'rake'
5
- require "rake/clean"
6
- require "rubygems/package_task"
7
- require "rdoc/task"
8
- require 'rspec/core/rake_task'
9
- require 'yard'
10
- require 'yard/rake/yardoc_task.rb'
11
- require "rake/tasklib"
12
- require "roodi"
13
- require "roodi_task"
14
- require 'code_statistics'
15
-
16
-
17
- RoodiTask.new() do | t |
18
- t.patterns = %w(lib/**/*.rb)
19
- t.config = "ultragreen_roodi_coding_convention.yml"
20
- end
21
-
22
-
23
- CLEAN.include('*.tmp','*.old')
24
- CLOBBER.include('*.tmp', 'build/*','#*#')
25
-
26
-
27
- content = File::readlines(File.join(File.dirname(__FILE__), 'carioca.gemspec')).join
28
- spec = eval(content)
29
-
30
- RSpec::Core::RakeTask.new('spec')
1
+ # frozen_string_literal: true
31
2
 
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
32
5
 
6
+ RSpec::Core::RakeTask.new(:spec)
33
7
 
34
- YARD::Rake::YardocTask.new do |t|
35
- t.files = [ 'lib/**/*.rb', '-', 'doc/**/*','spec/**/*_spec.rb']
36
- t.options += ['--title', "Gem Documentation"]
37
- t.options += ['-o', "yardoc"]
38
- t.options += ['-r', "doc/manual.rdoc"]
39
- end
40
- YARD::Config.load_plugin('yard-rspec')
41
-
42
- namespace :yardoc do
43
- task :clobber do
44
- rm_r "yardoc" rescue nil
45
- rm_r ".yardoc" rescue nil
46
- end
47
- end
48
- task :clobber => "yardoc:clobber"
49
-
50
-
51
- Gem::PackageTask.new(spec) do |pkg|
52
- pkg.need_tar = true
53
- pkg.need_zip = true
54
- end
55
-
56
- Rake::RDocTask.new('rdoc') do |d|
57
- d.rdoc_files.include('doc/**/*','bin/*')
58
- d.main = 'doc/manual.rdoc'
59
- d.title = 'Uglibs : Ultragreen libraries'
60
- d.options << '--line-numbers' << '--diagram' << '-SHN'
61
- end
62
-
63
- task :default => [:gem]
64
-
65
- task :stage do
66
- Rake::Task["clean"].invoke
67
- Rake::Task["clobber"].invoke
68
- Rake::Task["install"].invoke
69
- end
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "carioca"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/carioca.gemspec CHANGED
@@ -1,32 +1,41 @@
1
- Gem::Specification.new do |s|
2
- s.name = %q{carioca}
3
- s.author = "Romain GEORGES"
4
- s.version = "1.4"
5
- s.license = "BSD-2-Clause"
6
- s.summary = %q{Carioca : Configuration Agent and Registry with Inversion Of Control for your Applications}
7
- s.email = %q{romain@ultragreen.net}
8
- s.homepage = %q{https://github.com/Ultragreen/carioca}
9
- s.description = %q{Carioca : provide a full IoC light Container for designing your applications}
10
- s.files = `git ls-files`.split($/)
1
+ # frozen_string_literal: true
11
2
 
3
+ require_relative "lib/carioca/constants"
12
4
 
13
- s.add_development_dependency "rake", "~> 13.0.1"
14
- s.add_development_dependency 'rspec', '~> 3.9.0'
15
- s.add_development_dependency 'yard', '~> 0.9.24'
16
- s.add_development_dependency 'rdoc', '~> 6.2.1'
17
- s.add_development_dependency 'roodi', '~> 5.0.0'
18
- s.add_development_dependency 'code_statistics', '~> 0.2.13'
19
- s.add_development_dependency 'yard-rspec', '~> 0.1'
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "carioca"
7
+ spec.version = Carioca::Constants::VERSION
8
+ spec.authors = ["Romain GEORGES"]
9
+ spec.email = ["romain@ultragreen.net"]
20
10
 
21
11
 
22
- s.add_development_dependency 'uuid', '~> 2.3.9'
23
12
 
24
13
 
14
+ spec.license = "BSD-3-Clause"
15
+
16
+ spec.summary = %q{Carioca : Configuration Agent and Registry with Inversion Of Control for your Applications}
17
+ spec.homepage = %q{https://github.com/Ultragreen/carioca}
18
+ spec.description = %q{Carioca : provide a full IoC light Container for designing your applications}
19
+
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
21
+
22
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
23
+
24
+ spec.metadata["homepage_uri"] = spec.homepage
25
+ spec.metadata["source_code_uri"] = spec.homepage
26
+ spec.metadata["changelog_uri"] = spec.homepage
27
+
28
+
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ # Uncomment to register a new dependency of your gem
37
+ spec.add_dependency "tty-prompt", "~>0.23.1"
38
+ spec.add_dependency "pastel", "~>0.8.0"
25
39
 
26
- s.add_dependency 'dorsal', "~> 1.0"
27
- s.add_dependency 'methodic', "~> 1.3", '>= 1.3'
28
- s.add_dependency 'xml-simple', "~> 1.1", '>= 1.1.5'
29
- s.add_dependency 'activesupport', "~> 6.0.2.2"
30
- s.required_ruby_version = '>= 1.8.1'
31
40
 
32
41
  end
@@ -0,0 +1,15 @@
1
+ en:
2
+ service:
3
+ adding: "Adding service %{name}"
4
+ starting: "Starting service %{name}"
5
+ getting: "Getting service %{name}"
6
+ depends: "Dependencie service %{name}"
7
+ notify:
8
+ locale: "Preloaded service :i18n on locale : %{loc}"
9
+ logger: "Preloaded service :logger ready on %{target}"
10
+ init:
11
+ carioca: "Initializing Carioca registry"
12
+ builtins: "Preparing builtins services"
13
+ registry:
14
+ processing: "Initializing registry from file : %{filename}"
15
+ success: "Registry initialized successfully"
@@ -0,0 +1,19 @@
1
+ fr:
2
+ service:
3
+ adding: "Service %{name} Ajouté"
4
+ starting: "Démarrage du service %{name}"
5
+ getting: "Appel du service %{name}"
6
+ depends: "Dépendence du service %{name}"
7
+ notify:
8
+ locale: "Service pré-chargé :i18n sur la locale : %{loc}"
9
+ logger: "Service pré-chargé :logger sur la cible : %{target}"
10
+ useless_entry: "Entrée inutile dans le registre (service pré-defini) %{altered} dans %{filename}"
11
+ init:
12
+ carioca: "Initialisation du registre Carioca"
13
+ builtins: "Préparation des services pré-définis"
14
+ registry:
15
+ processing: "Initialisation du registre depuis le fichier : %{filename}"
16
+ success: "Registre initialisé avec succès"
17
+ config:
18
+ load:
19
+ error: "Fichier de configuration ignoré, erreur : %{message}"
@@ -0,0 +1,47 @@
1
+ module Carioca
2
+ class Configuration
3
+ include Carioca::Constants
4
+ include Carioca::Helpers
5
+ attr_accessor :filename, :name, :builtins, :log_target, :default_locale, :locales_load_path
6
+ attr_accessor :config_file, :config_root, :environment, :supported_environment
7
+ attr_writer :debug, :init_from_file
8
+ attr_reader :log_file, :locales_availables
9
+ def initialize
10
+ @init_from_file = true
11
+ @filename = DEFAULT_REGISTRY_FILE.dup
12
+ @debug = false
13
+ @name = 'Carioca'
14
+ @builtins = BUILTINS
15
+ @log_file = ''
16
+ @config_file = DEFAULT_CONFIG_FILE.dup
17
+ @environment = DEFAULT_ENVIRONMENT.dup
18
+ @config_root = DEFAULT_CONFIG_ROOT.dup
19
+ @log_target = '::Logger::new(STDOUT)'
20
+ @supported_environment = DEFAULT_ENVIRONMENTS_LIST.dup
21
+ @default_locale = DEFAULT_LOCALE
22
+ @locales_availables = []
23
+ path = search_file_in_gem('carioca',"config/locales")
24
+ @locales_load_path = Dir[File.expand_path(path) + "/*.yml"]
25
+ Dir[path + '/*.yml'].sort.each do |file|
26
+ @locales_availables.push File::basename(file,'.yml').to_sym
27
+ end
28
+ end
29
+
30
+ def debug?
31
+ return @debug
32
+ end
33
+
34
+ def init_from_file?
35
+ return @init_from_file
36
+ end
37
+
38
+ def log_file?
39
+ return !@log_file.empty?
40
+ end
41
+
42
+ def log_file=(name)
43
+ @log_file = name
44
+ @log_target = "::Logger::new('#{name}')"
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,45 @@
1
+ module Carioca
2
+ module Constants
3
+
4
+ VERSION = '2.0.1'
5
+ DEFAULT_REGISTRY_FILE = './config/carioca.registry'
6
+ DEFAULT_CONFIG_FILE = './config/settings.yml'
7
+ DEFAULT_ENVIRONMENT = :development
8
+ DEFAULT_CONFIG_ROOT = :carioca
9
+ DEFAULT_LOCALE = :en
10
+
11
+
12
+ # service definitions specs
13
+ SERVICES_MANDATORY_SPECS = {type: Symbol, service: String}
14
+ SERVICES_FULL_LIST_SPECS = SERVICES_MANDATORY_SPECS.merge({depends: Array, description: String, resource: String })
15
+ SERVICES_SPECS_DETAIL = {type: [:gem, :stdlib, :file, :internal]}
16
+
17
+ DEFAULT_ENVIRONMENTS_LIST = [:production, :staging, :test, :development]
18
+
19
+ BUILTINS = {
20
+ configuration: {
21
+ type: :internal,
22
+ depends: [:logger],
23
+ description: "The configuration service of Carioca",
24
+ service: "Carioca::Services::Config::Factory::new(
25
+ config_filename: Carioca::Registry.config.config_file,
26
+ stage: Carioca::Registry.config.environment,
27
+ root: Carioca::Registry.config.config_root)" },
28
+ logger: {
29
+ type: :stdlib,
30
+ resource: "logger",
31
+ description: "The Logger service of Carioca",
32
+ depends: [:i18n]
33
+ },
34
+ i18n:{
35
+ type: :internal,
36
+ description: "The Internalisation service of Carocia",
37
+ service: "Carioca::Services::I18n.get(
38
+ default_locale: Carioca::Registry.config.default_locale,
39
+ load_path: Carioca::Registry.config.locales_load_path,
40
+ locales_availables: Carioca::Registry.config.locales_availables)"
41
+ }
42
+ }
43
+
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+
2
+ module Carioca
3
+ class Container
4
+
5
+ extend Carioca::Injector
6
+
7
+ inject service: :logger
8
+ inject service: :configuration
9
+
10
+ def initialize(name: 'Carioca')
11
+ @name = name
12
+ end
13
+
14
+ end
15
+
16
+ end