carioca 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df2fae455d522ba26500abac0d203b29e1b173391b2e9eb9c27f9de83f282a55
4
- data.tar.gz: 5e34e6d5b0eef09348906b45f6bb5c2db3d1874c6d4f3f05c5a017baca5f5da1
3
+ metadata.gz: 8c9296f0a424070e2bd252fe15432b820cfb6a3e9bd52f45e9fd2a0430d06174
4
+ data.tar.gz: 5815c387bafb81c50cb19e659d5440ab8db1654e873be742eaac9857433ad7fd
5
5
  SHA512:
6
- metadata.gz: fad3b4fcbf8beb5811458891ad529a405fe85f19af613eb986369e51573eb87524d5849a566e7009a1a6c8d6f142e5a6f60a5e3ce82f9b60e82cabcfc814d02b
7
- data.tar.gz: 1049e060ed5326a3f67acea98258fca5c2880f46ae1edc3b1d08070e7012d374d975c062e076adfb2a127e0f3027ba0117b57ba97bc06f43d1ab3f904f63a0a4
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
@@ -1,6 +1,5 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
1
+ # frozen_string_literal: true
5
2
 
3
+ source 'https://rubygems.org'
6
4
 
5
+ gemspec
data/Gemfile.lock CHANGED
@@ -7,19 +7,29 @@ PATH
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
- concurrent-ruby (1.1.9)
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.10.0)
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/Rakefile CHANGED
@@ -1,8 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
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 "bundler/setup"
5
- require "carioca"
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 "irb"
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 "lib/carioca/constants"
3
+ require_relative 'lib/carioca/constants'
4
4
 
5
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"]
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.license = "BSD-3-Clause"
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 = "exe"
28
+ spec.bindir = 'exe'
33
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
- spec.require_paths = ["lib"]
30
+ spec.require_paths = ['lib']
35
31
 
36
32
  # 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
- spec.add_dependency 'i18n', "~> 1.10"
40
- spec.add_dependency 'locale', "~> 2.1"
41
- spec.add_dependency "deep_merge", "~> 1.2"
42
- spec.add_development_dependency "rake", "~> 13.0"
43
- spec.add_development_dependency "rspec", "~> 3.0"
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
@@ -1,66 +1,69 @@
1
+ # frozen_string_literal: true
2
+
1
3
  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, :debugger_tracer
6
- attr_accessor :config_file, :config_root, :environment, :supported_environment, :output_mode, :log_level
7
- attr_writer :init_from_file, :output_colors, :output_emoji
8
- attr_reader :log_file, :locales_availables, :debug
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
- @log_level = DEFAULT_LOG_LEVEL.dup
17
- @config_file = DEFAULT_CONFIG_FILE.dup
18
- @environment = DEFAULT_ENVIRONMENT.dup
19
- @config_root = DEFAULT_CONFIG_ROOT.dup
20
- @log_target = '::Logger::new(STDOUT)'
21
- @supported_environment = DEFAULT_ENVIRONMENTS_LIST.dup
22
- @default_locale = DEFAULT_LOCALE
23
- @locales_availables = []
24
- @output_mode = DEFAULT_OUTPUT_MODE.dup
25
- @output_colors = DEFAULT_COLORS_STATUS.dup
26
- @output_emoji = DEFAULT_EMOJI_STATUS.dup
27
- path = search_file_in_gem('carioca',"config/locales")
28
- @locales_load_path = Dir[File.expand_path(path) + "/*.yml"]
29
- Dir[path + '/*.yml'].sort.each do |file|
30
- @locales_availables.push File::basename(file,'.yml').to_sym
31
- end
32
- @debugger_tracer = DEFAULT_DEBUGGER_TRACER.dup
33
- 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
34
11
 
35
- def debug=(state)
36
- @debug = state
37
- @log_level = :info if @debug == false and @log_level == :debug
38
- @log_level = :debug if @debug == true
39
- end
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
40
37
 
41
- def debug?
42
- return @debug
43
- end
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
44
43
 
45
- def output_colors?
46
- return @output_colors
47
- end
44
+ def debug?
45
+ @debug
46
+ end
48
47
 
49
- def output_emoji?
50
- return @output_emoji
51
- end
48
+ def output_colors?
49
+ @output_colors
50
+ end
52
51
 
53
- def init_from_file?
54
- return @init_from_file
55
- end
52
+ def output_emoji?
53
+ @output_emoji
54
+ end
55
+
56
+ def init_from_file?
57
+ @init_from_file
58
+ end
56
59
 
57
- def log_file?
58
- return !@log_file.empty?
59
- end
60
+ def log_file?
61
+ !@log_file.empty?
62
+ end
60
63
 
61
- def log_file=(name)
62
- @log_file = name
63
- @log_target = "::Logger::new('#{name}')"
64
- end
64
+ def log_file=(name)
65
+ @log_file = name
66
+ @log_target = "::Logger::new('#{name}')"
65
67
  end
66
- end
68
+ end
69
+ end
@@ -1,68 +1,67 @@
1
- module Carioca
2
- module Constants
3
-
4
- VERSION = '2.0.4'
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
-
1
+ # frozen_string_literal: true
11
2
 
12
- DEFAULT_OUTPUT_MODE = :mono
13
- DEFAULT_EMOJI_STATUS = true
14
- DEFAULT_COLORS_STATUS = true
15
- DEFAULT_LOG_LEVEL = :info
3
+ module Carioca
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
16
10
 
11
+ DEFAULT_OUTPUT_MODE = :mono
12
+ DEFAULT_EMOJI_STATUS = true
13
+ DEFAULT_COLORS_STATUS = true
14
+ DEFAULT_LOG_LEVEL = :info
17
15
 
18
- DEFAULT_DEBUGGER_TRACER = :output
16
+ DEFAULT_DEBUGGER_TRACER = :output
19
17
 
20
- # service definitions specs
21
- SERVICES_MANDATORY_SPECS = {type: Symbol, service: String}
22
- SERVICES_FULL_LIST_SPECS = SERVICES_MANDATORY_SPECS.merge({depends: Array, description: String, resource: String })
23
- SERVICES_SPECS_DETAIL = {type: [:gem, :stdlib, :file, :internal]}
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
24
23
 
25
- DEFAULT_ENVIRONMENTS_LIST = [:production, :staging, :test, :development]
24
+ DEFAULT_ENVIRONMENTS_LIST = %i[production staging test development].freeze
26
25
 
27
- BUILTINS = {
28
- configuration: {
29
- type: :internal,
30
- depends: [:logger],
31
- description: "The configuration service of Carioca",
32
- service: "Carioca::Services::Config::Factory::new(
33
- config_filename: Carioca::Registry.config.config_file,
34
- stage: Carioca::Registry.config.environment,
35
- root: Carioca::Registry.config.config_root)" },
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(
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(
46
46
  default_locale: Carioca::Registry.config.default_locale,
47
47
  load_path: Carioca::Registry.config.locales_load_path,
48
48
  locales_availables: Carioca::Registry.config.locales_availables)"
49
- },
50
- output:{
51
- type: :internal,
52
- description: "The Output serice of Carioca",
53
- service: "Carioca::Services::Output::Provider::new(
49
+ },
50
+ output: {
51
+ type: :internal,
52
+ description: 'The Output serice of Carioca',
53
+ service: "Carioca::Services::Output::Provider::new(
54
54
  mode: Carioca::Registry.config.output_mode,
55
55
  emoji: Carioca::Registry.config.output_emoji?,
56
56
  colors: Carioca::Registry.config.output_colors?,
57
57
  level: Carioca::Registry.config.log_level
58
58
  )"
59
- },
60
- debugger:{
61
- type: :internal,
62
- description: "The Debugger Service of Carioca",
63
- service: "Carioca::Services::Debugger"
64
- }
65
- }
66
-
67
- end
59
+ },
60
+ debugger: {
61
+ type: :internal,
62
+ description: 'The Debugger Service of Carioca',
63
+ service: 'Carioca::Services::Debugger'
64
+ }
65
+ }.freeze
66
+ end
68
67
  end
@@ -1,16 +1,14 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Carioca
3
- class Container
4
+ class Container
5
+ extend Carioca::Injector
4
6
 
5
- extend Carioca::Injector
6
-
7
- inject service: :logger
8
- inject service: :configuration
9
-
10
- def initialize(name: 'Carioca')
11
- @name = name
12
- end
7
+ inject service: :logger
8
+ inject service: :configuration
13
9
 
10
+ def initialize(name: 'Carioca')
11
+ @name = name
14
12
  end
15
-
13
+ end
16
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'forwardable'
3
5
  require 'singleton'