eac_ruby_utils 0.114.0 → 0.116.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_utils/acts_as_abstract.rb +26 -5
- data/lib/eac_ruby_utils/envs/executable.rb +14 -2
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fed0a4f4e98925140bbe7b73fcc12c3d6bc0f8da44b67e08a8fd6a59e52c664
|
4
|
+
data.tar.gz: c9e002c790e093344a13de00f237054324f834dd17f49c1537f1e3f89fa77611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f03296a5e5d918abf8ea4e53e89361eb1d4e63ee14c4fd3cd846bd3898d5d3a261c704853f27881779d231f68329a2df3ed79225de61527b2d71ed17b317c838
|
7
|
+
data.tar.gz: 670aa54e208f995b0c11188b8fb8db3940de50c6b1bc1e4ff010e28de2d2db43ac50e875872aec17fef74e126aeed93898ee0a93daa4d0e27a02a352276868f1
|
@@ -35,13 +35,34 @@ module EacRubyUtils
|
|
35
35
|
end
|
36
36
|
|
37
37
|
module ClassMethods
|
38
|
+
# @param name [Symbol]
|
39
|
+
# @param arguments [Enumerable<Symbol>]
|
40
|
+
# @return [void]
|
41
|
+
def abstract_method(name, *arguments)
|
42
|
+
define_method name.to_sym do |*_the_args|
|
43
|
+
raise_abstract_method(name.to_sym, arguments)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param methods_names [Enumerable<Object>] Each item can be a symbolizable or a hash.
|
48
|
+
# @return [void]
|
38
49
|
def abstract_methods(*methods_names)
|
39
50
|
methods_names.each do |method_name|
|
40
|
-
|
41
|
-
|
51
|
+
if method_name.is_a?(::Hash)
|
52
|
+
abstract_methods_from_hash(method_name)
|
53
|
+
else
|
54
|
+
abstract_method(method_name)
|
42
55
|
end
|
43
56
|
end
|
44
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# @param hash [Hash]
|
62
|
+
# @return [void]
|
63
|
+
def abstract_methods_from_hash(hash)
|
64
|
+
hash.each { |name, arguments| abstract_method(name, *arguments) }
|
65
|
+
end
|
45
66
|
end
|
46
67
|
|
47
68
|
module InstanceMethods
|
@@ -59,9 +80,9 @@ module EacRubyUtils
|
|
59
80
|
self.class.abstract_methods.include?(method_name.to_sym)
|
60
81
|
end
|
61
82
|
|
62
|
-
def raise_abstract_method(method_name)
|
63
|
-
raise ::NoMethodError, "Abstract method
|
64
|
-
" (Class: #{self.class})"
|
83
|
+
def raise_abstract_method(method_name, arguments = [])
|
84
|
+
raise ::NoMethodError, "Abstract method #{method_name}(#{arguments.join(', ')}) hit in " \
|
85
|
+
"#{self}\" (Class: #{self.class})"
|
65
86
|
end
|
66
87
|
end
|
67
88
|
end
|
@@ -9,7 +9,7 @@ module EacRubyUtils
|
|
9
9
|
include ::EacRubyUtils::Listable
|
10
10
|
include ::EacRubyUtils::SimpleCache
|
11
11
|
|
12
|
-
lists.add_symbol :option, :check_args, :auto_validate
|
12
|
+
lists.add_symbol :option, :check_args, :exec_args, :auto_validate
|
13
13
|
|
14
14
|
DEFAULT_AUTO_VALIDATE = true
|
15
15
|
|
@@ -53,7 +53,7 @@ module EacRubyUtils
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def executable_args
|
56
|
-
executable_args_from_envvar ||
|
56
|
+
executable_args_from_envvar || executable_args_from_options || executable_args_from_name
|
57
57
|
end
|
58
58
|
|
59
59
|
def executable_args_envvar
|
@@ -64,6 +64,18 @@ module EacRubyUtils
|
|
64
64
|
ENV[executable_args_envvar].if_present { |v| ::Shellwords.split(v) }
|
65
65
|
end
|
66
66
|
|
67
|
+
# @return [Enumerable<String>]
|
68
|
+
def executable_args_from_name
|
69
|
+
::Shellwords.split(name)
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [Enumerable<String>]
|
73
|
+
def executable_args_from_options
|
74
|
+
options[OPTION_EXEC_ARGS].if_present do |v|
|
75
|
+
v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
67
79
|
private
|
68
80
|
|
69
81
|
attr_writer :options
|
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.
|
4
|
+
version: 0.116.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: 2023-05-
|
11
|
+
date: 2023-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|