carioca 1.1 → 2.0.1
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 +6 -1
- data/Gemfile.lock +42 -34
- data/README.md +12 -220
- data/Rakefile +5 -59
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/carioca.gemspec +41 -25
- data/config/locales/en.yml +15 -0
- data/config/locales/fr.yml +19 -0
- data/lib/carioca/configuration.rb +47 -0
- data/lib/carioca/constants.rb +45 -0
- data/lib/carioca/container.rb +16 -0
- data/lib/carioca/dependencies.rb +19 -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 +93 -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/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 +71 -0
- metadata +59 -152
- 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 -187
- 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 -459
- 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 -11
- data/test.rb +0 -12
- data/ultragreen_roodi_coding_convention.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c349ebcb566a9571f7cd424b6cb3a95dd3b6871a99caf992ac04af996a35259a
|
4
|
+
data.tar.gz: d4f4a5db811c978fe0390f41a757a352452c844f72775c21435c6ca1656213c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/.rspec
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,41 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
carioca (2.0.0)
|
5
|
+
tty-prompt (~> 0.23.1)
|
6
|
+
|
1
7
|
GEM
|
2
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
diff-lcs (1.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
rspec (
|
13
|
-
rspec-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rspec-
|
18
|
-
diff-lcs (>= 1.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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)
|
29
38
|
|
30
39
|
PLATFORMS
|
40
|
+
arm64-darwin-20
|
31
41
|
ruby
|
32
42
|
|
33
43
|
DEPENDENCIES
|
34
|
-
|
35
|
-
rake
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
yard
|
41
|
-
yard-rspec
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
23
|
+
## Development
|
216
24
|
|
217
|
-
|
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
|
-
|
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
|
-
|
29
|
+
## Contributing
|
239
30
|
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Ultragreen/carioca.
|
data/Rakefile
CHANGED
@@ -1,62 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
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
|
-
|
15
|
-
|
16
|
-
RoodiTask.new() do | t |
|
17
|
-
t.patterns = %w(lib/**/*.rb)
|
18
|
-
t.config = "ultragreen_roodi_coding_convention.yml"
|
19
|
-
end
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
20
5
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
21
7
|
|
22
|
-
|
23
|
-
CLOBBER.include('*.tmp', 'build/*','#*#')
|
24
|
-
|
25
|
-
|
26
|
-
content = File::readlines(File.join(File.dirname(__FILE__), 'carioca.gemspec')).join
|
27
|
-
spec = eval(content)
|
28
|
-
|
29
|
-
RSpec::Core::RakeTask.new('spec')
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
YARD::Rake::YardocTask.new do |t|
|
34
|
-
t.files = [ 'lib/**/*.rb', '-', 'doc/**/*','spec/**/*_spec.rb']
|
35
|
-
t.options += ['--title', "Gem Documentation"]
|
36
|
-
t.options += ['-o', "yardoc"]
|
37
|
-
t.options += ['-r', "doc/manual.rdoc"]
|
38
|
-
end
|
39
|
-
YARD::Config.load_plugin('yard-rspec')
|
40
|
-
|
41
|
-
namespace :yardoc do
|
42
|
-
task :clobber do
|
43
|
-
rm_r "yardoc" rescue nil
|
44
|
-
rm_r ".yardoc" rescue nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
task :clobber => "yardoc:clobber"
|
48
|
-
|
49
|
-
|
50
|
-
Gem::PackageTask.new(spec) do |pkg|
|
51
|
-
pkg.need_tar = true
|
52
|
-
pkg.need_zip = true
|
53
|
-
end
|
54
|
-
|
55
|
-
Rake::RDocTask.new('rdoc') do |d|
|
56
|
-
d.rdoc_files.include('doc/**/*','bin/*')
|
57
|
-
d.main = 'doc/manual.rdoc'
|
58
|
-
d.title = 'Uglibs : Ultragreen libraries'
|
59
|
-
d.options << '--line-numbers' << '--diagram' << '-SHN'
|
60
|
-
end
|
61
|
-
|
62
|
-
task :default => [:gem]
|
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
data/carioca.gemspec
CHANGED
@@ -1,25 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/carioca/constants"
|
4
|
+
|
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"]
|
10
|
+
|
11
|
+
|
12
|
+
|
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"
|
39
|
+
|
40
|
+
|
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
|