eac_ruby_utils 0.63.0 → 0.68.0

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/eac_ruby_utils/context.rb +31 -0
  3. data/lib/eac_ruby_utils/contextualizable.rb +12 -7
  4. data/lib/eac_ruby_utils/envs/command.rb +10 -5
  5. data/lib/eac_ruby_utils/patches/module/common_concern.rb +0 -1
  6. data/lib/eac_ruby_utils/patches/module/context.rb +11 -0
  7. data/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
  8. data/lib/eac_ruby_utils/rspec/conditional.rb +1 -4
  9. data/lib/eac_ruby_utils/simple_cache.rb +10 -2
  10. data/lib/eac_ruby_utils/speaker.rb +16 -0
  11. data/lib/eac_ruby_utils/speaker/receiver.rb +57 -0
  12. data/lib/eac_ruby_utils/speaker/sender.rb +32 -0
  13. data/lib/eac_ruby_utils/version.rb +1 -1
  14. metadata +8 -66
  15. data/lib/eac_ruby_utils/configs.rb +0 -74
  16. data/lib/eac_ruby_utils/configs/base.rb +0 -43
  17. data/lib/eac_ruby_utils/configs/file.rb +0 -47
  18. data/lib/eac_ruby_utils/console.rb +0 -5
  19. data/lib/eac_ruby_utils/console/configs.rb +0 -38
  20. data/lib/eac_ruby_utils/console/configs/entry_reader.rb +0 -81
  21. data/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +0 -18
  22. data/lib/eac_ruby_utils/console/configs/read_entry_options.rb +0 -46
  23. data/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +0 -27
  24. data/lib/eac_ruby_utils/console/docopt_runner.rb +0 -45
  25. data/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +0 -18
  26. data/lib/eac_ruby_utils/console/docopt_runner/_doc.rb +0 -25
  27. data/lib/eac_ruby_utils/console/docopt_runner/_settings.rb +0 -19
  28. data/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +0 -154
  29. data/lib/eac_ruby_utils/console/speaker.rb +0 -133
  30. data/lib/eac_ruby_utils/console/speaker/_class_methods.rb +0 -39
  31. data/lib/eac_ruby_utils/console/speaker/_constants.rb +0 -14
  32. data/lib/eac_ruby_utils/console/speaker/list.rb +0 -63
  33. data/lib/eac_ruby_utils/console/speaker/node.rb +0 -26
  34. data/lib/eac_ruby_utils/patches/module/console_speaker.rb +0 -10
  35. data/lib/eac_ruby_utils/patches/module/template.rb +0 -10
  36. data/lib/eac_ruby_utils/patches/object/template.rb +0 -9
  37. data/lib/eac_ruby_utils/paths_hash.rb +0 -56
  38. data/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +0 -8
  39. data/lib/eac_ruby_utils/paths_hash/node.rb +0 -67
  40. data/lib/eac_ruby_utils/paths_hash/path_search.rb +0 -39
  41. data/lib/eac_ruby_utils/templates.rb +0 -9
  42. data/lib/eac_ruby_utils/templates/directory.rb +0 -110
  43. data/lib/eac_ruby_utils/templates/file.rb +0 -50
  44. data/lib/eac_ruby_utils/templates/searcher.rb +0 -55
  45. data/lib/eac_ruby_utils/templates/variable_not_found_error.rb +0 -7
  46. data/lib/eac_ruby_utils/templates/variable_providers.rb +0 -25
  47. data/lib/eac_ruby_utils/templates/variable_providers/base.rb +0 -23
  48. data/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +0 -25
  49. data/lib/eac_ruby_utils/templates/variable_providers/generic.rb +0 -25
  50. data/lib/eac_ruby_utils/templates/variable_providers/hash.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 988305393f16d7782424d4d46c3cfa88d805d1a06b813e87027a9f44ea2b5ce3
4
- data.tar.gz: c8c55c9c290a618bcf090a9c7d59bd5a51055d91284ca2e8c411fdb6898f3ee0
3
+ metadata.gz: e3efdb1a6b5314499bf9a4ea397ffbb6f60234d4300170f84f47f113cc530604
4
+ data.tar.gz: 76d6c0005193c3c52c05bcf1c9d037908c909728fb5d51cae0a840de0fb06d6c
5
5
  SHA512:
6
- metadata.gz: c7c3cdfdef8b47a669ef14010c8a76399e4bd3febe7c860123a36a3b54dabce947ccbb5231031a11ea11540977930f10a6ca03079e8de86a47f7b4f048b4d0dc
7
- data.tar.gz: b1ff9b89451e86ce8a76a05dff08b19b21a77c2c129f5390a2a9400b49bc5a9812eb44ec9591a323c5fb8f419d83da8321d4251cbd5ca0d07409277dabf8e82b
6
+ metadata.gz: dfe79da4c2ac368cc8db6e06f7ae2fafdc18987ab66ebd5a020cac638022bebb11fa1752e6e42bb15f01a2d93b612cf6e653bbf2569b377abacd82761fa761a1
7
+ data.tar.gz: 6bbb5c7b6757fca0b4b0f66451cb318b4e73608c2c9ce16e6d02a65d85d8a12fe5d021790bf674a7d722517294f65e9667d7c66fdb624f085e1f3d96c1b1cc0b
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Context
5
+ def current
6
+ optional_current || raise('No elements in context')
7
+ end
8
+
9
+ def optional_current
10
+ stack.last
11
+ end
12
+
13
+ delegate :pop, to: :stack
14
+ delegate :push, to: :stack
15
+
16
+ def on(obj)
17
+ push(obj)
18
+ begin
19
+ yield
20
+ ensure
21
+ pop
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def stack
28
+ @stack ||= []
29
+ end
30
+ end
31
+ end
@@ -1,16 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/context'
4
+
3
5
  module EacRubyUtils
4
- # Provides the method context which search and call a method in self and ancestor objects.
5
6
  module Contextualizable
6
- def context(method)
7
- current = self
8
- while current
9
- return current.send(method) if current.respond_to?(method)
7
+ common_concern
8
+
9
+ module ClassMethods
10
+ def context
11
+ @context ||= ::EacRubyUtils::Context.new
12
+ end
13
+ end
10
14
 
11
- current = current.respond_to?(:parent) ? current.parent : nil
15
+ module InstanceMethods
16
+ def context
17
+ self.class.context
12
18
  end
13
- raise "Context method \"#{method}\" not found for #{self.class}"
14
19
  end
15
20
  end
16
21
  end
@@ -10,7 +10,6 @@ module EacRubyUtils
10
10
  module Envs
11
11
  class Command
12
12
  require_sub __FILE__, include_modules: true
13
- enable_console_speaker
14
13
 
15
14
  def initialize(env, command, extra_options = {})
16
15
  @env = env
@@ -61,17 +60,17 @@ module EacRubyUtils
61
60
 
62
61
  def execute(options = {})
63
62
  c = command(options)
64
- puts "BEFORE: #{c}".light_red if debug?
63
+ debug_print("BEFORE: #{c}")
65
64
  t1 = Time.now
66
65
  r = ::EacRubyUtils::Envs::Process.new(c).to_h
67
66
  i = Time.now - t1
68
- puts "AFTER [#{i}]: #{c}".light_red if debug?
67
+ debug_print("AFTER [#{i}]: #{c}")
69
68
  r
70
69
  end
71
70
 
72
71
  def spawn(options = {})
73
72
  c = command(options)
74
- puts "SPAWN: #{c}".light_red if debug?
73
+ debug_print("SPAWN: #{c}")
75
74
  ::EacRubyUtils::Envs::Spawn.new(c)
76
75
  end
77
76
 
@@ -83,7 +82,7 @@ module EacRubyUtils
83
82
 
84
83
  def system(options = {})
85
84
  c = command(options)
86
- puts c.light_red if debug?
85
+ debug_print(c)
87
86
  Kernel.system(c)
88
87
  end
89
88
 
@@ -109,6 +108,12 @@ module EacRubyUtils
109
108
  ENV['DEBUG'].to_s.strip != ''
110
109
  end
111
110
 
111
+ # Print a message if debugging is enabled.
112
+ def debug_print(message)
113
+ message = message.to_s
114
+ puts message.if_respond(:light_red, message) if debug?
115
+ end
116
+
112
117
  def append_command_options(command, options)
113
118
  command = options[:input].command + ' | ' + command if options[:input]
114
119
  if options[:input_file]
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/common_concern'
4
- require 'eac_ruby_utils/console/speaker'
5
4
 
6
5
  class Module
7
6
  def common_concern(&after_callback)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+ require 'eac_ruby_utils/contextualizable'
5
+
6
+ class Module
7
+ # Patches module with [EacRubyUtils::Contextualizable].
8
+ def enable_context
9
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::Contextualizable)
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/speaker/sender'
4
+
5
+ class Module
6
+ def enable_speaker
7
+ include ::EacRubyUtils::Speaker::Sender
8
+ end
9
+ end
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/core_ext/object/blank'
4
- require 'eac_ruby_utils/console/speaker'
5
4
 
6
5
  module EacRubyUtils
7
6
  module Rspec
8
7
  class Conditional
9
- include ::EacRubyUtils::Console::Speaker
10
-
11
8
  def self.default
12
9
  @default ||= new
13
10
  end
@@ -24,7 +21,7 @@ module EacRubyUtils
24
21
  tags.each do |tag, condition|
25
22
  message = condition.call
26
23
  if message.present?
27
- warn("Excluded tag: #{tag}: #{message}")
24
+ puts("[WARN] Excluded tag: #{tag}: #{message}")
28
25
  rspec_config.filter_run_excluding tag
29
26
  end
30
27
  end
@@ -3,11 +3,19 @@
3
3
  module EacRubyUtils
4
4
  module SimpleCache
5
5
  UNCACHED_METHOD_NAME_SUFFIX = '_uncached'
6
- UNCACHED_METHOD_PATTERN = /\A(\s+)_#{::Regexp.quote(UNCACHED_METHOD_NAME_SUFFIX)}\z/.freeze
6
+ UNCACHED_METHOD_PATTERN = /
7
+ \A(\s+)_#{::Regexp.quote(UNCACHED_METHOD_NAME_SUFFIX)}([\!\?]?)\z
8
+ /x.freeze
7
9
 
8
10
  class << self
9
11
  def uncached_method_name(method_name)
10
- "#{method_name}#{UNCACHED_METHOD_NAME_SUFFIX}"
12
+ method_name = method_name.to_s
13
+ end_mark = nil
14
+ if %w[! ?].any? { |mark| method_name.end_with?(mark) }
15
+ end_mark = method_name[-1]
16
+ method_name = method_name[0..-2]
17
+ end
18
+ "#{method_name}#{UNCACHED_METHOD_NAME_SUFFIX}#{end_mark}"
11
19
  end
12
20
  end
13
21
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/contextualizable'
4
+
5
+ module EacRubyUtils
6
+ module Speaker
7
+ include ::EacRubyUtils::Contextualizable
8
+
9
+ class << self
10
+ # @return [EacRubyUtils::Speaker::Receiver]
11
+ def current_receiver
12
+ context.current
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/abstract_methods'
4
+
5
+ module EacRubyUtils
6
+ module Speaker
7
+ module Receiver
8
+ extend ::EacRubyUtils::AbstractMethods
9
+
10
+ def error(_string)
11
+ raise_abstract_method(__FILE__)
12
+ end
13
+
14
+ def fatal_error(string)
15
+ error(string)
16
+ ::Kernel.exit 1 # rubocop:disable Rails/Exit
17
+ end
18
+
19
+ # @see EacRubyUtils::Speaker::Sender.input
20
+ def input(_question, _options = {})
21
+ raise_abstract_method(__FILE__)
22
+ end
23
+
24
+ def info(_string)
25
+ raise_abstract_method(__FILE__)
26
+ end
27
+
28
+ def infom(_string)
29
+ raise_abstract_method(__FILE__)
30
+ end
31
+
32
+ def infov(*_args)
33
+ raise_abstract_method(__FILE__)
34
+ end
35
+
36
+ def out(_string = '')
37
+ raise_abstract_method(__FILE__)
38
+ end
39
+
40
+ def puts(_string = '')
41
+ raise_abstract_method(__FILE__)
42
+ end
43
+
44
+ def success(_string)
45
+ raise_abstract_method(__FILE__)
46
+ end
47
+
48
+ def title(_string)
49
+ raise_abstract_method(__FILE__)
50
+ end
51
+
52
+ def warn(_string)
53
+ raise_abstract_method(__FILE__)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Speaker
5
+ module Sender
6
+ delegate :error, :fatal_error, :info, :infom, :title, :success, :warn, to: :speaker_receiver
7
+
8
+ def infov(*args)
9
+ speaker_receiver.infov(*args)
10
+ end
11
+
12
+ delegate :out, to: :speaker_receiver
13
+
14
+ delegate :puts, to: :speaker_receiver
15
+
16
+ # Shortcut to [EacRubyUtils::Speaker.current_receiver].
17
+ #
18
+ # @return [EacRubyUtils::Speaker::Receiver]
19
+ def speaker_receiver
20
+ ::EacRubyUtils::Speaker.current_receiver
21
+ end
22
+
23
+ # Options:
24
+ # +bool+ ([Boolean], default: +false+): requires a answer "yes" or "no".
25
+ # +list+ ([Hash] or [Array], default: +nil+): requires a answer from a list.
26
+ # +noecho+ ([Boolean], default: +false+): does not output answer.
27
+ def input(question, options = {})
28
+ speaker_receiver.input(question, options)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.63.0'
4
+ VERSION = '0.68.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.0
4
+ version: 0.68.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-06 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.6'
41
- - !ruby/object:Gem::Dependency
42
- name: colorize
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.8.1
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.8.1
55
- - !ruby/object:Gem::Dependency
56
- name: docopt
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.6.1
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.6.1
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: filesize
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,25 +100,7 @@ files:
128
100
  - lib/eac_ruby_utils/common_constructor/class_initialize.rb
129
101
  - lib/eac_ruby_utils/common_constructor/instance_initialize.rb
130
102
  - lib/eac_ruby_utils/common_constructor/super_args.rb
131
- - lib/eac_ruby_utils/configs.rb
132
- - lib/eac_ruby_utils/configs/base.rb
133
- - lib/eac_ruby_utils/configs/file.rb
134
- - lib/eac_ruby_utils/console.rb
135
- - lib/eac_ruby_utils/console/configs.rb
136
- - lib/eac_ruby_utils/console/configs/entry_reader.rb
137
- - lib/eac_ruby_utils/console/configs/password_entry_reader.rb
138
- - lib/eac_ruby_utils/console/configs/read_entry_options.rb
139
- - lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb
140
- - lib/eac_ruby_utils/console/docopt_runner.rb
141
- - lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb
142
- - lib/eac_ruby_utils/console/docopt_runner/_doc.rb
143
- - lib/eac_ruby_utils/console/docopt_runner/_settings.rb
144
- - lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb
145
- - lib/eac_ruby_utils/console/speaker.rb
146
- - lib/eac_ruby_utils/console/speaker/_class_methods.rb
147
- - lib/eac_ruby_utils/console/speaker/_constants.rb
148
- - lib/eac_ruby_utils/console/speaker/list.rb
149
- - lib/eac_ruby_utils/console/speaker/node.rb
103
+ - lib/eac_ruby_utils/context.rb
150
104
  - lib/eac_ruby_utils/contextualizable.rb
151
105
  - lib/eac_ruby_utils/core_ext.rb
152
106
  - lib/eac_ruby_utils/custom_format.rb
@@ -216,20 +170,19 @@ files:
216
170
  - lib/eac_ruby_utils/patches/module.rb
217
171
  - lib/eac_ruby_utils/patches/module/abstract_methods.rb
218
172
  - lib/eac_ruby_utils/patches/module/common_concern.rb
219
- - lib/eac_ruby_utils/patches/module/console_speaker.rb
173
+ - lib/eac_ruby_utils/patches/module/context.rb
220
174
  - lib/eac_ruby_utils/patches/module/immutable.rb
221
175
  - lib/eac_ruby_utils/patches/module/listable.rb
222
176
  - lib/eac_ruby_utils/patches/module/patch.rb
223
177
  - lib/eac_ruby_utils/patches/module/require_sub.rb
224
178
  - lib/eac_ruby_utils/patches/module/simple_cache.rb
225
- - lib/eac_ruby_utils/patches/module/template.rb
179
+ - lib/eac_ruby_utils/patches/module/speaker.rb
226
180
  - lib/eac_ruby_utils/patches/object.rb
227
181
  - lib/eac_ruby_utils/patches/object/asserts.rb
228
182
  - lib/eac_ruby_utils/patches/object/debug.rb
229
183
  - lib/eac_ruby_utils/patches/object/if_nil.rb
230
184
  - lib/eac_ruby_utils/patches/object/if_present.rb
231
185
  - lib/eac_ruby_utils/patches/object/if_respond.rb
232
- - lib/eac_ruby_utils/patches/object/template.rb
233
186
  - lib/eac_ruby_utils/patches/object/to_pathname.rb
234
187
  - lib/eac_ruby_utils/patches/pathname.rb
235
188
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
@@ -240,10 +193,6 @@ files:
240
193
  - lib/eac_ruby_utils/patches/string/inflector.rb
241
194
  - lib/eac_ruby_utils/patches/time.rb
242
195
  - lib/eac_ruby_utils/patches/time/required_zone.rb
243
- - lib/eac_ruby_utils/paths_hash.rb
244
- - lib/eac_ruby_utils/paths_hash/entry_key_error.rb
245
- - lib/eac_ruby_utils/paths_hash/node.rb
246
- - lib/eac_ruby_utils/paths_hash/path_search.rb
247
196
  - lib/eac_ruby_utils/regexp_parser.rb
248
197
  - lib/eac_ruby_utils/require_sub.rb
249
198
  - lib/eac_ruby_utils/rspec.rb
@@ -255,17 +204,10 @@ files:
255
204
  - lib/eac_ruby_utils/settings_provider.rb
256
205
  - lib/eac_ruby_utils/settings_provider/setting_value.rb
257
206
  - lib/eac_ruby_utils/simple_cache.rb
207
+ - lib/eac_ruby_utils/speaker.rb
208
+ - lib/eac_ruby_utils/speaker/receiver.rb
209
+ - lib/eac_ruby_utils/speaker/sender.rb
258
210
  - lib/eac_ruby_utils/struct.rb
259
- - lib/eac_ruby_utils/templates.rb
260
- - lib/eac_ruby_utils/templates/directory.rb
261
- - lib/eac_ruby_utils/templates/file.rb
262
- - lib/eac_ruby_utils/templates/searcher.rb
263
- - lib/eac_ruby_utils/templates/variable_not_found_error.rb
264
- - lib/eac_ruby_utils/templates/variable_providers.rb
265
- - lib/eac_ruby_utils/templates/variable_providers/base.rb
266
- - lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb
267
- - lib/eac_ruby_utils/templates/variable_providers/generic.rb
268
- - lib/eac_ruby_utils/templates/variable_providers/hash.rb
269
211
  - lib/eac_ruby_utils/version.rb
270
212
  - lib/eac_ruby_utils/yaml.rb
271
213
  homepage: