carioca 2.0.1 → 2.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c349ebcb566a9571f7cd424b6cb3a95dd3b6871a99caf992ac04af996a35259a
4
- data.tar.gz: d4f4a5db811c978fe0390f41a757a352452c844f72775c21435c6ca1656213c1
3
+ metadata.gz: 23b95a753d4b358bde71f7d1e9f59ba9456b40302ef9a028a5e791a00c2c7d07
4
+ data.tar.gz: cb29906d32001f5eecf0b7f78e161cf86436b11cec67377a9efacd2ecf63a469
5
5
  SHA512:
6
- metadata.gz: d05baa11c7379fe052161140fef4a17dd075ce2998c600ad5023d947edf76769fe2020829438863bc4adf4ee4c62f50da2bfb73c2937a5837fe6a48be87de1fb
7
- data.tar.gz: 1e12daba542a3e103205f1f7f7fcd71f82a924b2e247fc48ca6a0ee0feb9e4fca85e3a22d2b6baf9c2b7c705b6ef71d0e70611cd9509928eb25584b423a8578a
6
+ metadata.gz: b105358ef95e063ffdeea22f81eff91dc0a9044b6dcc941fb0449b0d5f6a9b8106d2cdead2d6fd81223b5863d3a2e8ec902d0ce339c24b6c350f84dbcbd4fb4c
7
+ data.tar.gz: ccd2744676d47b0dd3e6e25acf29194441c2217018d7b1ca1266b55ad598a942b23ae219c26277b6b2986c67c1dcce1b1dc74ee041e4b32f1fab1ec4ed21c567
data/Gemfile CHANGED
@@ -2,8 +2,5 @@ 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"
5
+
6
+
data/Gemfile.lock CHANGED
@@ -1,13 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- carioca (2.0.0)
4
+ carioca (2.0.2)
5
+ deep_merge (~> 1.2)
6
+ i18n (~> 1.10)
7
+ locale (~> 2.1)
8
+ pastel (~> 0.8.0)
5
9
  tty-prompt (~> 0.23.1)
6
10
 
7
11
  GEM
8
12
  remote: https://rubygems.org/
9
13
  specs:
14
+ concurrent-ruby (1.1.9)
15
+ deep_merge (1.2.2)
10
16
  diff-lcs (1.5.0)
17
+ i18n (1.10.0)
18
+ concurrent-ruby (~> 1.0)
19
+ locale (2.1.3)
11
20
  pastel (0.8.0)
12
21
  tty-color (~> 0.5)
13
22
  rake (13.0.6)
data/README.md CHANGED
@@ -2,22 +2,163 @@
2
2
 
3
3
  ## Installation
4
4
 
5
- Add this line to your application's Gemfile:
5
+ Install it yourself as:
6
+
7
+ $ gem install carioca
8
+
9
+ ## Usage
10
+
11
+
12
+ ### Basic usage
13
+
14
+ Create you own gem :
15
+
16
+ $ bundle gem yourgem
17
+ $ cd yourgem
18
+ $ vi yourgem.gemspec
19
+
20
+ check all the TODO in your gemspec, specify concretly you Gem specification, add the following line :
21
+
22
+ ```ruby
23
+ spec.add_dependency "carioca", "~> 2.0"
24
+ ```
25
+ and after :
26
+
27
+ $ bundle add carioca
28
+ $ mkdir -p config/locales
29
+
30
+ Edit the Rakefil, and add the following line :
6
31
 
7
32
  ```ruby
8
- gem 'carioca'
33
+ require "carioca/rake/manage"
9
34
  ```
35
+ Verify, all is right with :
10
36
 
11
- And then execute:
37
+ $ rake -T
38
+ rake build # Build yourgem-0.1.0.gem into the pkg directory
39
+ rake carioca:registry:add_service # Adding service to Carioca Registry file
40
+ rake clean # Remove any temporary products
41
+ rake clobber # Remove any generated files
42
+ rake install # Build and install yourgem-0.1.0.gem into system gems
43
+ rake install:local # Build and install yourgem-0.1.0.gem into system gems without network access
44
+ rake release[remote] # Create tag v0.1.0 and build and push yourgem-0.1.0.gem to Set to 'http://mygemserver.com'
45
+ rake spec # Run RSpec code examples
12
46
 
13
- $ bundle install
47
+ You could now initialize the Carioca registry following the wizard, with (sample with a simple UUID generator gem):
14
48
 
15
- Or install it yourself as:
49
+ $ rake carioca:registry:add_service
50
+ Carioca : registering service :
51
+ Registry File path ? ./config/carioca.registry
52
+ Service name ? uuid
53
+ Choose the service type ? gem
54
+ Description ? The uuid service
55
+ Service [uuid] inline Proc Ruby code ? UUID
56
+ Give the Rubygem name ? uuid
57
+ Did this service have dependencies ? no
16
58
 
17
- $ gem install carioca
59
+ => Service : uuid
60
+ Definition
61
+ * type: gem
62
+ * description: The uuid service
63
+ * service: UUID
64
+ * resource: uuid
65
+ Is it correct ? Yes
66
+ Carioca : Registry saved
18
67
 
19
- ## Usage
68
+ 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
+
70
+ $ cat config/carioca.registry
71
+ ---
72
+ :uuid:
73
+ :type: :gem
74
+ :description: The uuid service
75
+ :service: UUID
76
+ :resource: uuid
77
+
78
+ Now your are ready to use Carioca :
79
+
80
+ In this sample, we are going th create a demo command.
81
+ Firstly, we have to configure a basic usage of Carioca, this could be made in the lib path, in the root gem library.
82
+
83
+ $ emacs lib/yourgem.rb
84
+
85
+ content of the destination file
86
+
87
+ ```ruby
88
+
89
+ # frozen_string_literal: true
90
+
91
+ require_relative "yourgem/version"
92
+ require 'carioca'
93
+
94
+
95
+ Carioca::Registry.configure do |spec|
96
+ spec.debug = true
97
+ end
98
+
99
+ module Yourgem
100
+ class Error < StandardError; end
101
+
102
+ class YourgemCMD < Carioca::Container
103
+ def test
104
+ logger.info(self.to_s) { "Log me as an instance method" }
105
+ logger.warn(self.class.to_s) {"Give me an UUID : " + uuid.generate}
106
+ end
107
+
108
+ inject service: :uuid
109
+
110
+ logger.info(self.to_s) { "Log me as class method" }
111
+
112
+ end
113
+
114
+ end
115
+
116
+ ```
117
+
118
+ $ emacs exe/yourgem_cmd
119
+
120
+ content of the file
121
+
122
+ ```ruby
123
+ require 'yourgem'
124
+
125
+ yourgem_cmd = Yourgem::YourgemCMD::new
126
+ yourgem_cmd.test
127
+ ```
128
+
129
+ After this, don't forget to stage new files, and you could build & install the gem before running your new command for the first time :
130
+
131
+ $ git add config/ exe/
132
+ $ rake install && yourgem_cmd
133
+ yourgem 0.1.0 built to pkg/yourgem-0.1.0.gem.
134
+ yourgem (0.1.0) installed.
135
+ D, [2022-03-04T23:11:52.663459 #88808] DEBUG -- Carioca: Preloaded service :i18n on locale : en
136
+ D, [2022-03-04T23:11:52.663519 #88808] DEBUG -- Carioca: Preloaded service :logger ready on STDOUT
137
+ D, [2022-03-04T23:11:52.663537 #88808] DEBUG -- Carioca: Initializing Carioca registry
138
+ D, [2022-03-04T23:11:52.663550 #88808] DEBUG -- Carioca: Preparing builtins services
139
+ D, [2022-03-04T23:11:52.663580 #88808] DEBUG -- Carioca: Adding service configuration
140
+ D, [2022-03-04T23:11:52.663609 #88808] DEBUG -- Carioca: Adding service i18n
141
+ D, [2022-03-04T23:11:52.663649 #88808] DEBUG -- Carioca: Initializing registry from file : ./config/carioca.registry
142
+ D, [2022-03-04T23:11:52.663773 #88808] DEBUG -- Carioca: Adding service uuid
143
+ D, [2022-03-04T23:11:52.663794 #88808] DEBUG -- Carioca: Registry initialized successfully
144
+ I, [2022-03-04T23:11:52.663802 #88808] INFO -- Sample::YourGemCMD: Log me as class method
145
+ I, [2022-03-04T23:11:52.663813 #88808] INFO -- #<Sample::YourGemCMD:0x00000001312c0bf0>: Log me as an instance method
146
+ D, [2022-03-04T23:11:52.663844 #88808] DEBUG -- Carioca: Starting service uuid
147
+ W, [2022-03-04T23:11:52.682812 #88808] WARN -- Sample::YourGemCMD: Give me an UUID : 0505f3f0-7e36-013a-22c7-1e00870a7189
148
+
149
+ You could see, somme interesting things :
150
+ * Carioca have an internationalisation service (this service will be explain in detail after):
151
+ * default configured on :en locale
152
+ * must be in French (:fr) or English (:en), other traductions are welcome
153
+ * Carioca have a builtin logger service using regular Logger from Stdlib (also explain in detail in this document)
154
+ * default logging on STDOUT, but could be redirect in the configure bloc
155
+ * Carioca give us some usefull traces in debug
156
+ * Carioca come with a Container Class Template
157
+ * the Container automatically inject :logger, :i18n and a :configuration service (explain in detail after)
158
+ * the Container provide a class method macro :inject
159
+ * this macro give a way to use other services defined in the registry file (service could be register inline, presented after)
20
160
 
161
+ ## A step further
21
162
 
22
163
 
23
164
  ## Development
data/carioca.gemspec CHANGED
@@ -13,9 +13,9 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.license = "BSD-3-Clause"
15
15
 
16
- spec.summary = %q{Carioca : Configuration Agent and Registry with Inversion Of Control for your Applications}
16
+ spec.summary = %q{Carioca : Container And Registry with Inversion Of Control for your Applications}
17
17
  spec.homepage = %q{https://github.com/Ultragreen/carioca}
18
- spec.description = %q{Carioca : provide a full IoC light Container for designing your applications}
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
19
 
20
20
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
21
21
 
@@ -36,6 +36,11 @@ Gem::Specification.new do |spec|
36
36
  # Uncomment to register a new dependency of your gem
37
37
  spec.add_dependency "tty-prompt", "~>0.23.1"
38
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"
39
44
 
40
45
 
41
46
  end
@@ -7,9 +7,13 @@ en:
7
7
  notify:
8
8
  locale: "Preloaded service :i18n on locale : %{loc}"
9
9
  logger: "Preloaded service :logger ready on %{target}"
10
+ useless_entry: "Useless entry in registry (builtin service) %{altered} in %{filename}"
10
11
  init:
11
12
  carioca: "Initializing Carioca registry"
12
13
  builtins: "Preparing builtins services"
13
14
  registry:
14
- processing: "Initializing registry from file : %{filename}"
15
- success: "Registry initialized successfully"
15
+ processing: "Initializing registry from file : %{filename}"
16
+ success: "Registry initialized successfully"
17
+ config:
18
+ load:
19
+ error: "Config file ignored, error : %{message}"
@@ -3,8 +3,8 @@ module Carioca
3
3
  include Carioca::Constants
4
4
  include Carioca::Helpers
5
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
6
+ attr_accessor :config_file, :config_root, :environment, :supported_environment, :output_mode, :log_level
7
+ attr_writer :debug, :init_from_file, :output_colors, :output_emoji
8
8
  attr_reader :log_file, :locales_availables
9
9
  def initialize
10
10
  @init_from_file = true
@@ -13,6 +13,8 @@ module Carioca
13
13
  @name = 'Carioca'
14
14
  @builtins = BUILTINS
15
15
  @log_file = ''
16
+ @log_level = DEFAULT_LOG_LEVEL.dup
17
+ @log_level = :info if @debug == false and @log_level == :debug
16
18
  @config_file = DEFAULT_CONFIG_FILE.dup
17
19
  @environment = DEFAULT_ENVIRONMENT.dup
18
20
  @config_root = DEFAULT_CONFIG_ROOT.dup
@@ -20,6 +22,9 @@ module Carioca
20
22
  @supported_environment = DEFAULT_ENVIRONMENTS_LIST.dup
21
23
  @default_locale = DEFAULT_LOCALE
22
24
  @locales_availables = []
25
+ @output_mode = DEFAULT_OUTPUT_MODE.dup
26
+ @output_colors = DEFAULT_COLORS_STATUS.dup
27
+ @output_emoji = DEFAULT_EMOJI_STATUS.dup
23
28
  path = search_file_in_gem('carioca',"config/locales")
24
29
  @locales_load_path = Dir[File.expand_path(path) + "/*.yml"]
25
30
  Dir[path + '/*.yml'].sort.each do |file|
@@ -31,6 +36,14 @@ module Carioca
31
36
  return @debug
32
37
  end
33
38
 
39
+ def output_colors?
40
+ return @output_colors
41
+ end
42
+
43
+ def output_emoji?
44
+ return @output_emoji
45
+ end
46
+
34
47
  def init_from_file?
35
48
  return @init_from_file
36
49
  end
@@ -1,7 +1,7 @@
1
1
  module Carioca
2
2
  module Constants
3
3
 
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  DEFAULT_REGISTRY_FILE = './config/carioca.registry'
6
6
  DEFAULT_CONFIG_FILE = './config/settings.yml'
7
7
  DEFAULT_ENVIRONMENT = :development
@@ -9,6 +9,11 @@ module Carioca
9
9
  DEFAULT_LOCALE = :en
10
10
 
11
11
 
12
+ DEFAULT_OUTPUT_MODE = :mono
13
+ DEFAULT_EMOJI_STATUS = true
14
+ DEFAULT_COLORS_STATUS = true
15
+ DEFAULT_LOG_LEVEL = :info
16
+
12
17
  # service definitions specs
13
18
  SERVICES_MANDATORY_SPECS = {type: Symbol, service: String}
14
19
  SERVICES_FULL_LIST_SPECS = SERVICES_MANDATORY_SPECS.merge({depends: Array, description: String, resource: String })
@@ -38,6 +43,16 @@ module Carioca
38
43
  default_locale: Carioca::Registry.config.default_locale,
39
44
  load_path: Carioca::Registry.config.locales_load_path,
40
45
  locales_availables: Carioca::Registry.config.locales_availables)"
46
+ },
47
+ output:{
48
+ type: :internal,
49
+ description: "The Output serice of Carioca",
50
+ service: "Carioca::Services::Output::Provider::new(
51
+ mode: Carioca::Registry.config.output_mode,
52
+ emoji: Carioca::Registry.config.output_emoji?,
53
+ colors: Carioca::Registry.config.output_colors?,
54
+ level: Carioca::Registry.config.log_level
55
+ )"
41
56
  }
42
57
  }
43
58
 
@@ -6,6 +6,7 @@ require 'rubygems'
6
6
  require 'i18n'
7
7
  require 'locale'
8
8
  require 'deep_merge'
9
+ require 'pastel'
9
10
 
10
11
  require_relative 'constants'
11
12
  require_relative 'validator'
@@ -59,7 +59,8 @@ module Carioca
59
59
  conf_logger = @@config.builtins[:logger]
60
60
  conf_logger[:service] = @@config.log_target
61
61
  add service: :logger, definition: @@config.builtins[:logger], skip_validation: true
62
- get_service name: :logger
62
+ log = get_service name: :logger
63
+ log.level = @@config.log_level
63
64
  end
64
65
 
65
66
  def initialize
@@ -81,11 +82,11 @@ module Carioca
81
82
  def open_registry_file
82
83
  debug message: i18n.t('init.registry.processing', filename: @@config.filename) if @@config.debug?
83
84
  registry_file = Carioca::RegistryFile::new filename: @@config.filename
84
- debug message: i18n.t('notify.useless_entry', altered: registry_file.altered.to_s, filename: @@config.filename ) if registry_file.altered? and @@config.debug?
85
+ debug message: i18n.t('notify.useless_entry', altered: registry_file.altered.to_s, file_name: @@config.filename ) if registry_file.altered? and @@config.debug?
85
86
  registry_file.validated.each do |service,spec|
86
87
  add service: service, definition: spec
87
88
  end
88
- debug message: i18n.t('init.registry.processing') if @@config.debug?
89
+ debug message: i18n.t('init.registry.success') if @@config.debug?
89
90
  end
90
91
 
91
92
 
@@ -0,0 +1,175 @@
1
+ module Carioca
2
+ module Services
3
+ module Output
4
+
5
+ module FormatsMapping
6
+ COLORS = {
7
+ :unknown => :red,
8
+ :fatal => :red,
9
+ :error => :red,
10
+ :ko => :yellow,
11
+ :warn => :yellow,
12
+ :item => :white,
13
+ :arrow => :white,
14
+ :sending => :white,
15
+ :calling => :white,
16
+ :scheduling => :white,
17
+ :trigger => :white,
18
+ :receive => :white,
19
+ :info => :cyan,
20
+ :ok => :green,
21
+ :success => :green,
22
+ :debug => :magenta,
23
+ :flat => :white
24
+ }
25
+
26
+ EMOJI = {
27
+ :unknown => {:value => "\u{1F4A5}", :alt => '[!!]', :text => "(UNKNOWN)"},
28
+ :fatal => {:value => "\u{26D4}", :alt => '[!!]', :text => "(FATAL)"},
29
+ :error => {:value => "\u{1F6AB}", :alt => '[!]', :text => "(ERROR)"},
30
+ :ko => {:value => "\u{1F44E}", :alt => '[-]', :text => "(KO)"},
31
+ :warn => {:value => "\u{26A0}", :alt => '[/!\]', :text => "(WARNING)"},
32
+ :info => {:value => "\u{2139}", :alt => '[i]', :text => "(INFO)"},
33
+ :item => {:value => " \u{1F539}", :alt => '', :text => " *"},
34
+ :arrow => {:value => " \u{27A1}", :alt => '', :text => " =>"},
35
+ :calling => {:value => "\u{1F4DE}" , :alt => '[C]', :text => "(CALLING)"},
36
+ :scheduling => {:value => "\u{23F2}" , :alt => '[S]', :text => "{SCHEDULING})"},
37
+ :trigger => {:value => "\u{23F0}", :alt => '[T]', :text => "(TRIGGER)"},
38
+ :sending => {:value => "\u{1F4E4}", :alt => '[>]', :text => "(SENDING)"},
39
+ :receive => {:value => "\u{1F4E5}" , :alt => '[<]', :text => "(RECEIVE)"},
40
+ :ok => {:value => "\u{1F44D}" , :alt => '[+]', :text => "(OK)"},
41
+ :success => {:value => "\u{1F4AA}" , :alt => '[+]', :text => "(SUCCESS)"},
42
+ :debug => {:value => "\u{1F41B}" , :alt => '[D]', :text => "(DEBUG)"},
43
+ :flat => {:value => "", :alt => ""}
44
+ }
45
+ LEVELS = [:debug, :info, :warn, :error, :fatal, :unknown ]
46
+ ALIAS = {
47
+ :flat => :info,
48
+ :item => :info,
49
+ :ok => :info,
50
+ :ko => :error,
51
+ :trigger => :info,
52
+ :scheduling => :info,
53
+ :arrow => :info,
54
+ :sending => :info,
55
+ :calling => :info,
56
+ :receive => :info,
57
+ :success => :info
58
+
59
+ }
60
+ end
61
+ class Provider
62
+ include FormatsMapping
63
+
64
+ attr_accessor :mode, :emoji, :color
65
+
66
+ @@alias = ALIAS.dup
67
+ @@colors = COLORS.dup
68
+ @@emoji = EMOJI.dup
69
+
70
+ MODE = [:mono, :dual]
71
+
72
+ LEVELS.each do |method|
73
+ define_method(method) do |message, session = ''|
74
+ self.display(level: method, message: message, session: session)
75
+ end
76
+ end
77
+ @@alias.keys.each do |method|
78
+ define_method(method) do |message, session = ''|
79
+ self.display( level: method, message: message, session: session)
80
+ end
81
+ end
82
+
83
+ def map_color(color: , analias: )
84
+ raise "Color must be a Symbol" unless color.class == Symbol
85
+ raise "Missing alias : #{analias}" unless LEVELS.include? analias
86
+ @@alias[analias] = color
87
+ end
88
+
89
+ def map_emoji(emoji: , analias: )
90
+ raise "Emoji must be a String" unless color.class == String
91
+ raise "Missing alias : #{analias}" unless LEVELS.include? analias
92
+ @@alias[analias] = emoji
93
+ end
94
+
95
+
96
+ def add_alias(newalias:, level:)
97
+ raise "Alias must be a Symbol" unless newalias.class == Symbol
98
+ raise "Bad Level : #{level}" unless LEVELS.include? level
99
+ self.class.define_method(newalias) do |message, session = ''|
100
+ self.display({ level: newalias, message: message, session: session})
101
+ end
102
+ end
103
+
104
+
105
+ # constructor
106
+ def initialize(level: :debug, mode: :mono , emoji: true, colors: true)
107
+ self.level = level
108
+ @mode = mode
109
+ @emoji = emoji
110
+ @color = colors
111
+ if @mode == :dual then
112
+ registry = Carioca::Registry.get
113
+ @logger = registry.get_service name: :logger
114
+ end
115
+ raise "Unknown output mode : #{@mode}" unless MODE.include? @mode
116
+ end
117
+
118
+ # build a session number
119
+ # @return [String] Session number
120
+ def get_session
121
+ return "#{Time.now.to_i.to_s}#{rand(999)}"
122
+ end
123
+
124
+ # getter for the current level
125
+ # @return [Symbol] level
126
+ def level
127
+ return @active_levels.first
128
+ end
129
+
130
+ # virtual setter for level, set the current level
131
+ # @raise a badLevel in case of bad level
132
+ # @param [Symbol] level
133
+ def level=(level)
134
+ raise "Bad Level : #{level}" unless LEVELS.include? level
135
+ @active_levels = LEVELS.dup
136
+ @active_levels.shift(LEVELS.index(level))
137
+ end
138
+
139
+
140
+ # abstract method for log wrapper
141
+ # @param [Hash] params
142
+ # @option params [Symbol] :level, a valid level in LEVELS or ALIAS
143
+ # @option params [String] :message text
144
+ def display(level: , message: , session:)
145
+ save = message.dup
146
+ target_level = (@@alias.keys.include? level)? @@alias[level] : level
147
+ if @active_levels.include? target_level then
148
+ if @color then
149
+ pastel = ::Pastel.new
150
+ message = pastel.send @@colors[level], message
151
+ end
152
+ if @@emoji.include? level
153
+ pattern = (@emoji)? @@emoji[level][:value] : @@emoji[level][:alt]
154
+ pattern = "#{pattern} #{@@emoji[level][:text]}" if @@emoji[level].include? :text and !@emoji
155
+ message = pattern + " " + message unless pattern.empty?
156
+ end
157
+ if @mode == :dual
158
+
159
+ pattern = @@emoji[level][:alt]
160
+ unless LEVELS.include? level
161
+ save = "#{@@emoji[level][:text]} #{save}" if @@emoji[level].include? :text
162
+ end
163
+ @logger.send target_level, save
164
+ end
165
+ puts message
166
+ end
167
+ end
168
+
169
+ end
170
+
171
+
172
+ end
173
+ end
174
+ end
175
+
data/samples/test.rb CHANGED
@@ -4,13 +4,16 @@ require 'carioca'
4
4
 
5
5
  Carioca::Registry.configure do |spec|
6
6
  spec.filename = './config/carioca.registry'
7
- spec.debug = true
7
+ spec.debug = false
8
8
  spec.init_from_file = true
9
9
  # spec.log_file = '/tmp/test.rge'
10
10
  spec.config_file = './config/settings.yml'
11
11
  spec.config_root = :monappli
12
12
  spec.environment = :development
13
13
  spec.default_locale = :fr
14
+ spec.log_level = :debug
15
+ spec.output_mode = :mono
16
+
14
17
  spec.locales_load_path << Dir[File.expand_path('./config/locales') + "/*.yml"]
15
18
  end
16
19
 
@@ -58,13 +61,37 @@ class MonAppli < Carioca::Container
58
61
  inject service: :myservice
59
62
  logger.info(self.to_s) { uuid.generate }
60
63
 
64
+ inject service: :output
65
+
66
+ def test2
67
+ cycle = [:unknown,:fatal,:error,:ko,:warn,:info,:item,:arrow,:scheduling,:trigger,:sending, :calling,:receive,:ok,:success,:debug,:flat]
68
+ cycle.each do |verb|
69
+ output.send verb, verb.to_s
70
+ end
71
+ output.color = false
72
+ cycle.each do |verb|
73
+ output.send verb, verb.to_s
74
+ end
75
+ output.emoji = false
76
+ cycle.each do |verb|
77
+ output.send verb, verb.to_s
78
+ end
79
+ output.color = true
80
+ cycle.each do |verb|
81
+ output.send verb, verb.to_s
82
+ end
83
+
84
+ end
85
+
61
86
  end
62
87
 
63
88
 
64
89
 
65
90
 
91
+
66
92
  appli = MonAppli::new
67
93
  appli.test
94
+ appli.test2
68
95
 
69
96
 
70
97
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carioca
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain GEORGES
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-04 00:00:00.000000000 Z
11
+ date: 2022-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -38,7 +38,79 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.8.0
41
- description: 'Carioca : provide a full IoC light Container for designing your applications'
41
+ - !ruby/object:Gem::Dependency
42
+ name: i18n
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: locale
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: deep_merge
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: 'Carioca 2: is a complete rewrite who provide a full IoC/DI light Container
112
+ and a services registry, build with logs, config and Internationalization facilities
113
+ for designing your applications'
42
114
  email:
43
115
  - romain@ultragreen.net
44
116
  executables: []
@@ -71,6 +143,7 @@ files:
71
143
  - lib/carioca/services/config.rb
72
144
  - lib/carioca/services/i18n.rb
73
145
  - lib/carioca/services/init.rb
146
+ - lib/carioca/services/output.rb
74
147
  - lib/carioca/validator.rb
75
148
  - samples/Rakefile
76
149
  - samples/config/carioca.registry
@@ -87,7 +160,7 @@ metadata:
87
160
  homepage_uri: https://github.com/Ultragreen/carioca
88
161
  source_code_uri: https://github.com/Ultragreen/carioca
89
162
  changelog_uri: https://github.com/Ultragreen/carioca
90
- post_install_message:
163
+ post_install_message:
91
164
  rdoc_options: []
92
165
  require_paths:
93
166
  - lib
@@ -102,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
175
  - !ruby/object:Gem::Version
103
176
  version: '0'
104
177
  requirements: []
105
- rubygems_version: 3.1.2
106
- signing_key:
178
+ rubygems_version: 3.2.3
179
+ signing_key:
107
180
  specification_version: 4
108
- summary: 'Carioca : Configuration Agent and Registry with Inversion Of Control for
109
- your Applications'
181
+ summary: 'Carioca : Container And Registry with Inversion Of Control for your Applications'
110
182
  test_files: []