carioca 2.0.2 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +54 -0
- data/Gemfile +3 -4
- data/Gemfile.lock +37 -3
- data/README.md +27 -18
- data/Rakefile +40 -2
- data/VERSION +1 -0
- data/bin/console +3 -3
- data/carioca.gemspec +29 -29
- data/config/locales/en.yml +4 -0
- data/config/locales/fr.yml +5 -1
- data/lib/carioca/configuration.rb +68 -59
- data/lib/carioca/constants.rb +52 -45
- data/lib/carioca/container.rb +8 -10
- data/lib/carioca/dependencies.rb +3 -1
- data/lib/carioca/helpers.rb +39 -41
- data/lib/carioca/mixin.rb +10 -12
- data/lib/carioca/rake/manage.rb +5 -2
- 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 +17 -10
- data/lib/carioca/registry.rb +95 -86
- data/lib/carioca/registry_file.rb +54 -57
- data/lib/carioca/services/config.rb +122 -126
- data/lib/carioca/services/debug.rb +51 -0
- data/lib/carioca/services/i18n.rb +15 -16
- data/lib/carioca/services/init.rb +3 -2
- data/lib/carioca/services/output.rb +181 -169
- data/lib/carioca/validator.rb +44 -45
- data/lib/carioca/version.rb +10 -0
- data/lib/carioca.rb +2 -5
- data/samples/Rakefile +2 -0
- data/samples/test.rb +75 -68
- metadata +99 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c9296f0a424070e2bd252fe15432b820cfb6a3e9bd52f45e9fd2a0430d06174
|
4
|
+
data.tar.gz: 5815c387bafb81c50cb19e659d5440ab8db1654e873be742eaac9857433ad7fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34a33f5e613a1530930cf0e6e53f8c1179a66d8eda41a440766ffeaf6d9060c44efa945ed40af22679e6e7ac90e1c3537222cf82473caaa315561b241b47814a
|
7
|
+
data.tar.gz: ab2fa5e329b95df2e04f87501ac8ab74a8450e16dbeff5cc61aa374455b4b7bc0c5c8365e198907fb2955e0c786fe3a8011292a33253545653e14ac3be1f9e5c
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2022-07-26 15:23:44 UTC using RuboCop version 1.32.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
NewCops: enable
|
11
|
+
SuggestExtensions: false
|
12
|
+
|
13
|
+
# definitive :
|
14
|
+
Lint/Debugger:
|
15
|
+
Exclude:
|
16
|
+
- 'samples/test.rb'
|
17
|
+
Security/Eval:
|
18
|
+
Enabled: true
|
19
|
+
Exclude:
|
20
|
+
- 'lib/carioca/registry.rb'
|
21
|
+
Style/ClassVars:
|
22
|
+
Enabled: false
|
23
|
+
Style/MissingRespondToMissing:
|
24
|
+
Enabled: false
|
25
|
+
Gemspec/RequireMFA:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
|
29
|
+
# to study :
|
30
|
+
Metrics/AbcSize:
|
31
|
+
Enabled: false
|
32
|
+
Metrics/CyclomaticComplexity:
|
33
|
+
Enabled: false
|
34
|
+
Metrics/MethodLength:
|
35
|
+
Enabled: false
|
36
|
+
Metrics/PerceivedComplexity:
|
37
|
+
Enabled: false
|
38
|
+
Style/EvalWithLocation:
|
39
|
+
Enabled: false
|
40
|
+
Style/GuardClause:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
# to do :
|
46
|
+
Style/Documentation:
|
47
|
+
Enabled: false
|
48
|
+
Layout/LineLength:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
carioca (2.0.
|
4
|
+
carioca (2.0.4)
|
5
5
|
deep_merge (~> 1.2)
|
6
6
|
i18n (~> 1.10)
|
7
7
|
locale (~> 2.1)
|
8
8
|
pastel (~> 0.8.0)
|
9
9
|
tty-prompt (~> 0.23.1)
|
10
|
+
version (~> 1.1)
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
|
15
|
+
ast (2.4.2)
|
16
|
+
code_statistics (0.2.13)
|
17
|
+
concurrent-ruby (1.1.10)
|
15
18
|
deep_merge (1.2.2)
|
16
19
|
diff-lcs (1.5.0)
|
17
|
-
i18n (1.
|
20
|
+
i18n (1.12.0)
|
18
21
|
concurrent-ruby (~> 1.0)
|
22
|
+
json (2.6.2)
|
19
23
|
locale (2.1.3)
|
24
|
+
parallel (1.22.1)
|
25
|
+
parser (3.1.2.0)
|
26
|
+
ast (~> 2.4.1)
|
20
27
|
pastel (0.8.0)
|
21
28
|
tty-color (~> 0.5)
|
29
|
+
rainbow (3.1.1)
|
22
30
|
rake (13.0.6)
|
31
|
+
regexp_parser (2.5.0)
|
32
|
+
rexml (3.2.5)
|
23
33
|
rspec (3.9.0)
|
24
34
|
rspec-core (~> 3.9.0)
|
25
35
|
rspec-expectations (~> 3.9.0)
|
@@ -33,6 +43,19 @@ GEM
|
|
33
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
44
|
rspec-support (~> 3.9.0)
|
35
45
|
rspec-support (3.9.4)
|
46
|
+
rubocop (1.32.0)
|
47
|
+
json (~> 2.3)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 3.1.0.0)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
regexp_parser (>= 1.8, < 3.0)
|
52
|
+
rexml (>= 3.2.5, < 4.0)
|
53
|
+
rubocop-ast (>= 1.19.1, < 2.0)
|
54
|
+
ruby-progressbar (~> 1.7)
|
55
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
56
|
+
rubocop-ast (1.19.1)
|
57
|
+
parser (>= 3.1.1.0)
|
58
|
+
ruby-progressbar (1.11.0)
|
36
59
|
tty-color (0.6.0)
|
37
60
|
tty-cursor (0.7.1)
|
38
61
|
tty-prompt (0.23.1)
|
@@ -43,7 +66,14 @@ GEM
|
|
43
66
|
tty-screen (~> 0.8)
|
44
67
|
wisper (~> 2.0)
|
45
68
|
tty-screen (0.8.1)
|
69
|
+
unicode-display_width (2.2.0)
|
70
|
+
version (1.1.1)
|
71
|
+
webrick (1.7.0)
|
46
72
|
wisper (2.0.1)
|
73
|
+
yard (0.9.28)
|
74
|
+
webrick (~> 1.7.0)
|
75
|
+
yard-rspec (0.1)
|
76
|
+
yard
|
47
77
|
|
48
78
|
PLATFORMS
|
49
79
|
arm64-darwin-20
|
@@ -51,8 +81,12 @@ PLATFORMS
|
|
51
81
|
|
52
82
|
DEPENDENCIES
|
53
83
|
carioca!
|
84
|
+
code_statistics (~> 0.2.13)
|
54
85
|
rake (~> 13.0)
|
55
86
|
rspec (~> 3.0)
|
87
|
+
rubocop (~> 1.32)
|
88
|
+
yard (~> 0.9.27)
|
89
|
+
yard-rspec (~> 0.1)
|
56
90
|
|
57
91
|
BUNDLED WITH
|
58
92
|
2.2.3
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Carioca
|
2
2
|
|
3
|
+
Carioca : Container And Registry with Inversion Of Control for your Applications
|
4
|
+
|
5
|
+
Carioca 2: is a complete rewrite who provide a full IoC/DI light Container and a services registry, build with logs, config and Internationalization facilities for designing your applications
|
3
6
|
## Installation
|
4
7
|
|
5
8
|
Install it yourself as:
|
@@ -35,17 +38,21 @@ require "carioca/rake/manage"
|
|
35
38
|
Verify, all is right with :
|
36
39
|
|
37
40
|
$ rake -T
|
38
|
-
rake build # Build
|
41
|
+
rake build # Build sample-0.1.0.gem into the pkg directory
|
42
|
+
rake carioca:gem:init_path # prepare Gem vitals path for Carioca
|
39
43
|
rake carioca:registry:add_service # Adding service to Carioca Registry file
|
44
|
+
rake carioca:services:config:init # Initialise Service configuration file ./config/settings.yml file
|
40
45
|
rake clean # Remove any temporary products
|
41
46
|
rake clobber # Remove any generated files
|
42
|
-
rake install # Build and install
|
43
|
-
rake install:local # Build and install
|
44
|
-
rake release[remote] # Create tag v0.1.0 and build and push
|
47
|
+
rake install # Build and install sample-0.1.0.gem into system gems
|
48
|
+
rake install:local # Build and install sample-0.1.0.gem into system gems without network access
|
49
|
+
rake release[remote] # Create tag v0.1.0 and build and push sample-0.1.0.gem to Set to 'http://mygemserver.com'
|
45
50
|
rake spec # Run RSpec code examples
|
46
51
|
|
47
52
|
You could now initialize the Carioca registry following the wizard, with (sample with a simple UUID generator gem):
|
48
53
|
|
54
|
+
$ rake carioca:gem:init_path
|
55
|
+
Carioca : Initialising vitals gem path : done
|
49
56
|
$ rake carioca:registry:add_service
|
50
57
|
Carioca : registering service :
|
51
58
|
Registry File path ? ./config/carioca.registry
|
@@ -63,7 +70,7 @@ You could now initialize the Carioca registry following the wizard, with (sample
|
|
63
70
|
* service: UUID
|
64
71
|
* resource: uuid
|
65
72
|
Is it correct ? Yes
|
66
|
-
Carioca : Registry
|
73
|
+
Carioca : Registry saving : done
|
67
74
|
|
68
75
|
This will initiate a Carioca Registry (YAML file, the format will be describe after, the wizard support all type of services, managed by Carioca, all keys are Symbols):
|
69
76
|
|
@@ -132,19 +139,21 @@ After this, don't forget to stage new files, and you could build & install the g
|
|
132
139
|
$ rake install && yourgem_cmd
|
133
140
|
yourgem 0.1.0 built to pkg/yourgem-0.1.0.gem.
|
134
141
|
yourgem (0.1.0) installed.
|
135
|
-
D, [2022-03-
|
136
|
-
D, [2022-03-
|
137
|
-
D, [2022-03-
|
138
|
-
D, [2022-03-
|
139
|
-
D, [2022-03-
|
140
|
-
D, [2022-03-
|
141
|
-
D, [2022-03-
|
142
|
-
D, [2022-03-
|
143
|
-
D, [2022-03-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
142
|
+
D, [2022-03-07T01:06:20.337961 #21513] DEBUG -- Carioca: Preloaded service :i18n on locale : en
|
143
|
+
D, [2022-03-07T01:06:20.338020 #21513] DEBUG -- Carioca: Preloaded service :logger ready on STDOUT
|
144
|
+
D, [2022-03-07T01:06:20.338037 #21513] DEBUG -- Carioca: Initializing Carioca registry
|
145
|
+
D, [2022-03-07T01:06:20.338049 #21513] DEBUG -- Carioca: Preparing builtins services
|
146
|
+
D, [2022-03-07T01:06:20.338079 #21513] DEBUG -- Carioca: Adding service configuration
|
147
|
+
D, [2022-03-07T01:06:20.338107 #21513] DEBUG -- Carioca: Adding service i18n
|
148
|
+
D, [2022-03-07T01:06:20.338133 #21513] DEBUG -- Carioca: Adding service output
|
149
|
+
D, [2022-03-07T01:06:20.338156 #21513] DEBUG -- Carioca: Adding service debugger
|
150
|
+
D, [2022-03-07T01:06:20.338191 #21513] DEBUG -- Carioca: Initializing registry from file : ./config/carioca.registry
|
151
|
+
D, [2022-03-07T01:06:20.338312 #21513] DEBUG -- Carioca: Adding service uuid
|
152
|
+
D, [2022-03-07T01:06:20.338333 #21513] DEBUG -- Carioca: Registry initialized successfully
|
153
|
+
I, [2022-03-07T01:06:20.338340 #21513] INFO -- Sample::YourGemCMD: Log me as class method
|
154
|
+
I, [2022-03-07T01:06:20.338351 #21513] INFO -- #<Sample::YourGemCMD:0x0000000148270698>: Log me as an instance method
|
155
|
+
D, [2022-03-07T01:06:20.338381 #21513] DEBUG -- Carioca: Starting service uuid
|
156
|
+
W, [2022-03-07T01:06:20.353142 #21513] WARN -- Sample::YourGemCMD: Give me an UUID : 574cc860-7fd8-013a-2323-1e00870a7189
|
148
157
|
|
149
158
|
You could see, somme interesting things :
|
150
159
|
* Carioca have an internationalisation service (this service will be explain in detail after):
|
data/Rakefile
CHANGED
@@ -1,8 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop//rake_task'
|
5
6
|
|
7
|
+
require 'yard'
|
8
|
+
require 'yard/rake/yardoc_task'
|
9
|
+
|
10
|
+
require 'code_statistics'
|
11
|
+
|
12
|
+
RuboCop::RakeTask.new
|
6
13
|
RSpec::Core::RakeTask.new(:spec)
|
7
14
|
|
8
15
|
task default: :spec
|
16
|
+
|
17
|
+
require 'version'
|
18
|
+
require 'rake/version_task'
|
19
|
+
Rake::VersionTask.new
|
20
|
+
|
21
|
+
YARD::Rake::YardocTask.new do |t|
|
22
|
+
t.files = ['lib/**/*.rb', '-', 'doc/**/*', 'spec/**/*_spec.rb']
|
23
|
+
t.options += ['-o', 'yardoc']
|
24
|
+
end
|
25
|
+
YARD::Config.load_plugin('yard-rspec')
|
26
|
+
|
27
|
+
namespace :yardoc do
|
28
|
+
task :clobber do
|
29
|
+
begin
|
30
|
+
rm_r 'yardoc'
|
31
|
+
rescue StandardError
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
begin
|
35
|
+
rm_r '.yardoc'
|
36
|
+
rescue StandardError
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
begin
|
40
|
+
rm_r 'pkg'
|
41
|
+
rescue StandardError
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
task clobber: 'yardoc:clobber'
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.5
|
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'carioca'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require "carioca"
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require 'irb'
|
15
15
|
IRB.start(__FILE__)
|
data/carioca.gemspec
CHANGED
@@ -1,46 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/carioca/constants'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
7
|
-
spec.version =
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
6
|
+
spec.name = 'carioca'
|
7
|
+
spec.version = `cat VERSION`.chomp
|
8
|
+
spec.authors = ['Romain GEORGES']
|
9
|
+
spec.email = ['romain@ultragreen.net']
|
10
10
|
|
11
|
+
spec.license = 'BSD-3-Clause'
|
11
12
|
|
13
|
+
spec.summary = 'Carioca : Container And Registry with Inversion Of Control for your Applications'
|
14
|
+
spec.homepage = 'https://github.com/Ultragreen/carioca'
|
15
|
+
spec.description = 'Carioca 2: is a complete rewrite who provide a full IoC/DI light Container and a services registry, build with logs, config and Internationalization facilities for designing your applications'
|
12
16
|
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
13
18
|
|
14
|
-
spec.
|
15
|
-
|
16
|
-
spec.summary = %q{Carioca : Container And Registry with Inversion Of Control for your Applications}
|
17
|
-
spec.homepage = %q{https://github.com/Ultragreen/carioca}
|
18
|
-
spec.description = %q{Carioca 2: is a complete rewrite who provide a full IoC/DI light Container and a services registry, build with logs, config and Internationalization facilities 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
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
27
20
|
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
23
|
+
spec.metadata['changelog_uri'] = spec.homepage
|
28
24
|
|
29
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
30
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
31
27
|
end
|
32
|
-
spec.bindir =
|
28
|
+
spec.bindir = 'exe'
|
33
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
34
|
-
spec.require_paths = [
|
30
|
+
spec.require_paths = ['lib']
|
35
31
|
|
36
32
|
# Uncomment to register a new dependency of your gem
|
37
|
-
spec.add_dependency
|
38
|
-
spec.add_dependency
|
39
|
-
spec.add_dependency '
|
40
|
-
spec.add_dependency '
|
41
|
-
spec.add_dependency
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency
|
44
|
-
|
45
|
-
|
33
|
+
spec.add_dependency 'deep_merge', '~> 1.2'
|
34
|
+
spec.add_dependency 'i18n', '~> 1.10'
|
35
|
+
spec.add_dependency 'locale', '~> 2.1'
|
36
|
+
spec.add_dependency 'pastel', '~>0.8.0'
|
37
|
+
spec.add_dependency 'tty-prompt', '~>0.23.1'
|
38
|
+
spec.add_development_dependency 'code_statistics', '~> 0.2.13'
|
39
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
40
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
|
+
spec.add_development_dependency 'rubocop', '~> 1.32'
|
42
|
+
spec.add_development_dependency 'yard', '~> 0.9.27'
|
43
|
+
spec.add_development_dependency 'yard-rspec', '~> 0.1'
|
44
|
+
spec.metadata['rubygems_mfa_required'] = 'false'
|
45
|
+
spec.add_dependency 'version', '~> 1.1'
|
46
46
|
end
|
data/config/locales/en.yml
CHANGED
data/config/locales/fr.yml
CHANGED
@@ -16,4 +16,8 @@ fr:
|
|
16
16
|
success: "Registre initialisé avec succès"
|
17
17
|
config:
|
18
18
|
load:
|
19
|
-
error: "Fichier de configuration ignoré, erreur : %{message}"
|
19
|
+
error: "Fichier de configuration ignoré, erreur : %{message}"
|
20
|
+
success: "Service de configuration initialisé avec succès depuis : %{from}"
|
21
|
+
output:
|
22
|
+
load:
|
23
|
+
context: "Service output initialisé en mode : %{confset}"
|
@@ -1,60 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Carioca
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
4
|
+
class Configuration
|
5
|
+
include Carioca::Constants
|
6
|
+
include Carioca::Helpers
|
7
|
+
attr_accessor :filename, :name, :builtins, :log_target, :default_locale, :locales_load_path, :debugger_tracer,
|
8
|
+
:config_file, :config_root, :environment, :supported_environment, :output_mode, :log_level
|
9
|
+
attr_writer :init_from_file, :output_colors, :output_emoji
|
10
|
+
attr_reader :log_file, :locales_availables, :debug
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@init_from_file = true
|
14
|
+
@filename = DEFAULT_REGISTRY_FILE.dup
|
15
|
+
@debug = false
|
16
|
+
@name = 'Carioca'
|
17
|
+
@builtins = BUILTINS
|
18
|
+
@log_file = ''
|
19
|
+
@log_level = DEFAULT_LOG_LEVEL.dup
|
20
|
+
@config_file = DEFAULT_CONFIG_FILE.dup
|
21
|
+
@environment = DEFAULT_ENVIRONMENT.dup
|
22
|
+
@config_root = DEFAULT_CONFIG_ROOT.dup
|
23
|
+
@log_target = '::Logger::new(STDOUT)'
|
24
|
+
@supported_environment = DEFAULT_ENVIRONMENTS_LIST.dup
|
25
|
+
@default_locale = DEFAULT_LOCALE
|
26
|
+
@locales_availables = []
|
27
|
+
@output_mode = DEFAULT_OUTPUT_MODE.dup
|
28
|
+
@output_colors = DEFAULT_COLORS_STATUS.dup
|
29
|
+
@output_emoji = DEFAULT_EMOJI_STATUS.dup
|
30
|
+
path = search_file_in_gem('carioca', 'config/locales')
|
31
|
+
@locales_load_path = Dir["#{File.expand_path(path)}/*.yml"]
|
32
|
+
Dir["#{path}/*.yml"].sort.each do |file|
|
33
|
+
@locales_availables.push File.basename(file, '.yml').to_sym
|
34
|
+
end
|
35
|
+
@debugger_tracer = DEFAULT_DEBUGGER_TRACER.dup
|
36
|
+
end
|
37
|
+
|
38
|
+
def debug=(state)
|
39
|
+
@debug = state
|
40
|
+
@log_level = :info if (@debug == false) && (@log_level == :debug)
|
41
|
+
@log_level = :debug if @debug == true
|
42
|
+
end
|
43
|
+
|
44
|
+
def debug?
|
45
|
+
@debug
|
46
|
+
end
|
47
|
+
|
48
|
+
def output_colors?
|
49
|
+
@output_colors
|
50
|
+
end
|
51
|
+
|
52
|
+
def output_emoji?
|
53
|
+
@output_emoji
|
54
|
+
end
|
55
|
+
|
56
|
+
def init_from_file?
|
57
|
+
@init_from_file
|
58
|
+
end
|
59
|
+
|
60
|
+
def log_file?
|
61
|
+
!@log_file.empty?
|
62
|
+
end
|
63
|
+
|
64
|
+
def log_file=(name)
|
65
|
+
@log_file = name
|
66
|
+
@log_target = "::Logger::new('#{name}')"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/carioca/constants.rb
CHANGED
@@ -1,60 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Carioca
|
2
|
-
|
4
|
+
module Constants
|
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
|
3
10
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
DEFAULT_CONFIG_ROOT = :carioca
|
9
|
-
DEFAULT_LOCALE = :en
|
10
|
-
|
11
|
+
DEFAULT_OUTPUT_MODE = :mono
|
12
|
+
DEFAULT_EMOJI_STATUS = true
|
13
|
+
DEFAULT_COLORS_STATUS = true
|
14
|
+
DEFAULT_LOG_LEVEL = :info
|
11
15
|
|
12
|
-
|
13
|
-
DEFAULT_EMOJI_STATUS = true
|
14
|
-
DEFAULT_COLORS_STATUS = true
|
15
|
-
DEFAULT_LOG_LEVEL = :info
|
16
|
+
DEFAULT_DEBUGGER_TRACER = :output
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
# service definitions specs
|
19
|
+
SERVICES_MANDATORY_SPECS = { type: Symbol, service: String }.freeze
|
20
|
+
SERVICES_FULL_LIST_SPECS = SERVICES_MANDATORY_SPECS.merge({ depends: Array, description: String,
|
21
|
+
resource: String })
|
22
|
+
SERVICES_SPECS_DETAIL = { type: %i[gem stdlib file internal] }.freeze
|
21
23
|
|
22
|
-
|
24
|
+
DEFAULT_ENVIRONMENTS_LIST = %i[production staging test development].freeze
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
config_filename: Carioca::Registry.config.config_file,
|
31
|
-
stage: Carioca::Registry.config.environment,
|
32
|
-
root: Carioca::Registry.config.config_root)"
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
BUILTINS = {
|
27
|
+
configuration: {
|
28
|
+
type: :internal,
|
29
|
+
depends: [:logger],
|
30
|
+
description: 'The configuration service of Carioca',
|
31
|
+
service: "Carioca::Services::Config::Factory::new(
|
32
|
+
config_filename: Carioca::Registry.config.config_file,
|
33
|
+
stage: Carioca::Registry.config.environment,
|
34
|
+
root: Carioca::Registry.config.config_root)"
|
35
|
+
},
|
36
|
+
logger: {
|
37
|
+
type: :stdlib,
|
38
|
+
resource: 'logger',
|
39
|
+
description: 'The Logger service of Carioca',
|
40
|
+
depends: [:i18n]
|
41
|
+
},
|
42
|
+
i18n: {
|
43
|
+
type: :internal,
|
44
|
+
description: 'The Internalisation service of Carocia',
|
45
|
+
service: "Carioca::Services::I18n.get(
|
43
46
|
default_locale: Carioca::Registry.config.default_locale,
|
44
47
|
load_path: Carioca::Registry.config.locales_load_path,
|
45
48
|
locales_availables: Carioca::Registry.config.locales_availables)"
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
},
|
50
|
+
output: {
|
51
|
+
type: :internal,
|
52
|
+
description: 'The Output serice of Carioca',
|
53
|
+
service: "Carioca::Services::Output::Provider::new(
|
51
54
|
mode: Carioca::Registry.config.output_mode,
|
52
55
|
emoji: Carioca::Registry.config.output_emoji?,
|
53
56
|
colors: Carioca::Registry.config.output_colors?,
|
54
57
|
level: Carioca::Registry.config.log_level
|
55
58
|
)"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
},
|
60
|
+
debugger: {
|
61
|
+
type: :internal,
|
62
|
+
description: 'The Debugger Service of Carioca',
|
63
|
+
service: 'Carioca::Services::Debugger'
|
64
|
+
}
|
65
|
+
}.freeze
|
66
|
+
end
|
60
67
|
end
|