eac_ruby_utils 0.132.0 → 0.134.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d495eb9aed9b90a87d50739a32a653e9be6712d5781dbeb846602b73f2f12bf2
4
- data.tar.gz: 2f63060816193846affe116f06681a755ab581542efbb8df54a83b3c6520fd83
3
+ metadata.gz: 67b9797b5e613c584015d1101bcf9027e34e5fa8442bd0087d967db89ff41e44
4
+ data.tar.gz: df3aab0d94a57473449bfeea90ef8959c687dfb84243182e7897cd7a3a2f7632
5
5
  SHA512:
6
- metadata.gz: a54a6340e48024bed79820a9ecaed074d43cdfb585895953bf9e2f4d8591570de76f9d24011fdc8871b6e9802726d059971e9729d8a42d1e77e6130e01baa60e
7
- data.tar.gz: f110cd9ad44c30732e742c074b098d053af0b38ab9c41df126922e63f8dd6f299efb942b8670377274fd819188805bf599d5b1247761919d9ace40c910506ce7
6
+ metadata.gz: aa28edfdfec3de51d4a00c8cb39f6d259d4f352db7ce8f78e7b1fa11da7f36fe1520e4f5b422486fae990e1024f6a49808390b37b4c62618dc2a46fbaf35e690
7
+ data.tar.gz: 1ebcf27e69838827acce00cd02cad19574d6fe8fba15996b60a774bf74eb555c9ffc5dda51bf3f622195ad384b2d0f099484ae318ed828dbc6a75d9a22c94840
@@ -2,12 +2,19 @@
2
2
 
3
3
  require 'active_support/core_ext/module/introspection'
4
4
  require 'eac_ruby_utils/patches/class/common_constructor'
5
+ require 'eac_ruby_utils/patches/module/listable'
5
6
  require 'eac_ruby_utils/patches/module/module_parent'
6
7
  require 'eac_ruby_utils/patches/string/inflector'
7
8
 
8
9
  module EacRubyUtils
9
10
  class ActsAsInstanceMethod
10
- common_constructor :method_class
11
+ enable_listable
12
+ lists.add_symbol :option, :name_mark
13
+ lists.add_symbol :name_mark, '': :none, '!': :exclamation, '?': :interrogation
14
+
15
+ common_constructor :method_class, :options, default: [{}] do
16
+ self.options = ::EacRubyUtils::ActsAsInstanceMethod.lists.option.hash_keys_validate!(options)
17
+ end
11
18
 
12
19
  # @param sender_module [Module, nil]
13
20
  # @return [self]
@@ -23,7 +30,12 @@ module EacRubyUtils
23
30
 
24
31
  # @return [String]
25
32
  def method_name
26
- method_class.name.demodulize.underscore.variableize
33
+ "#{method_class.name.demodulize.underscore.variableize}#{method_name_mark}"
34
+ end
35
+
36
+ # @return [Symbol]
37
+ def method_name_mark
38
+ options[OPTION_NAME_MARK] || NAME_MARK_NONE
27
39
  end
28
40
 
29
41
  # @return [Module]
@@ -10,6 +10,12 @@ module EacRubyUtils
10
10
  module Envs
11
11
  module BaseCommand
12
12
  module Execution
13
+ common_concern do
14
+ include ActiveSupport::Callbacks
15
+
16
+ define_callbacks :any_execution, :execute, :spawn, :system
17
+ end
18
+
13
19
  def execute!(options = {})
14
20
  options[:exit_outputs] = status_results.merge(options[:exit_outputs].presence || {})
15
21
  er = ::EacRubyUtils::Envs::ExecutionResult.new(execute(options), options)
@@ -23,7 +29,9 @@ module EacRubyUtils
23
29
  c = command(options)
24
30
  debug_print("BEFORE: #{c}")
25
31
  t1 = Time.now
26
- r = ::EacRubyUtils::Envs::Process.new(c).to_h
32
+ r = run_callbacks :any_execution, :execute do
33
+ ::EacRubyUtils::Envs::Process.new(c).to_h
34
+ end
27
35
  i = Time.now - t1
28
36
  debug_print("AFTER [#{i}]: #{c}")
29
37
  r
@@ -32,7 +40,9 @@ module EacRubyUtils
32
40
  def spawn(options = {})
33
41
  c = command(options)
34
42
  debug_print("SPAWN: #{c}")
35
- ::EacRubyUtils::Envs::Spawn.new(c)
43
+ run_callbacks :any_execution, :spawn do
44
+ ::EacRubyUtils::Envs::Spawn.new(c)
45
+ end
36
46
  end
37
47
 
38
48
  def system!(options = {})
@@ -44,7 +54,7 @@ module EacRubyUtils
44
54
  def system(options = {})
45
55
  c = command(options)
46
56
  debug_print(c)
47
- Kernel.system(c)
57
+ run_callbacks(:any_execution, :system) { Kernel.system(c) }
48
58
  end
49
59
  end
50
60
  end
@@ -11,8 +11,10 @@ module EacRubyUtils
11
11
  end
12
12
 
13
13
  class Setup < ::EacRubyUtils::ActsAsInstanceMethod
14
- common_constructor :method_class, :static_method, default: [false],
15
- super_args: -> { [method_class] } do
14
+ common_constructor :method_class, :static_method, :options, default: [false, {}],
15
+ super_args: lambda {
16
+ [method_class, options]
17
+ } do
16
18
  perform
17
19
  end
18
20
 
@@ -3,15 +3,15 @@
3
3
  require 'eac_ruby_utils/patches/module/common_concern'
4
4
 
5
5
  module EacRubyUtils
6
- module PatchModule
7
- common_concern
8
-
9
- class_methods do
10
- delegate :patch_module, to: :'::EacRubyUtils::PatchModule'
6
+ class << self
7
+ def patch_module(*)
8
+ ::EacRubyUtils::PatchModule.perform(*)
11
9
  end
10
+ end
12
11
 
12
+ module PatchModule
13
13
  class << self
14
- def patch_module(target, patch)
14
+ def perform(target, patch)
15
15
  return if target.include?(patch)
16
16
 
17
17
  target.send(:include, patch)
@@ -3,8 +3,9 @@
3
3
  require 'eac_ruby_utils/acts_as_instance_method'
4
4
 
5
5
  class Module
6
+ # @param options [Hash]
6
7
  # @return [EacRubyUtils::ActsAsInstanceMethod]
7
- def acts_as_instance_method
8
- ::EacRubyUtils::ActsAsInstanceMethod.new(self).setup
8
+ def acts_as_instance_method(**options)
9
+ ::EacRubyUtils::ActsAsInstanceMethod.new(self, options).setup
9
10
  end
10
11
  end
@@ -4,6 +4,6 @@ require 'eac_ruby_utils/patch_module'
4
4
 
5
5
  class Module
6
6
  def patch_self(patch_module)
7
- ::EacRubyUtils::PatchModule.patch_module(self, patch_module)
7
+ ::EacRubyUtils::PatchModule.perform(self, patch_module)
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.132.0'
4
+ VERSION = '0.134.0'
5
5
  end
@@ -9,7 +9,6 @@ EacRubyUtils::RootModuleSetup.perform __FILE__ do
9
9
  end
10
10
 
11
11
  module EacRubyUtils
12
- include ::EacRubyUtils::PatchModule
13
12
  end
14
13
 
15
14
  require 'eac_ruby_utils/core_ext'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.132.0
4
+ version: 0.134.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company