eac_ruby_utils 0.53.0 → 0.56.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 +4 -4
- data/lib/eac_ruby_utils/common_concern.rb +2 -50
- data/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
- data/lib/eac_ruby_utils/common_concern/module_setup.rb +41 -0
- data/lib/eac_ruby_utils/common_constructor.rb +6 -50
- data/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- data/lib/eac_ruby_utils/envs/command.rb +4 -6
- data/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
- data/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
- data/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
- data/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/lib/eac_ruby_utils/struct.rb +7 -1
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b3d020bb7af10057a1e59b06dab3c2373b2b08f41d5bfd5b04ef8447c5aae61
|
4
|
+
data.tar.gz: 8125f0827f51e15f174df22b8a55e56646a322e013749fca184025ada77233e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c084da333de3de3542c1a0d7ed961d22ecc10d21d98b5d3941f0bbbf6a867232a5384da17b8387b2095698932ce141d4614787d2f5181b4653f3b11f387e45a3
|
7
|
+
data.tar.gz: 63eb2bdfb9f522195acb9ac712d1fefb6dfdc1c84f0da6c2b4dcf3eaef10a4aa41f4d6ff426ba019552d021b2ee762cef940c1d839cd1a61a55328aa54f6e7ed
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/simple_cache'
|
5
|
-
require 'eac_ruby_utils/patches/object/if_present'
|
3
|
+
require 'eac_ruby_utils/common_concern/module_setup'
|
6
4
|
|
7
5
|
module EacRubyUtils
|
8
6
|
class CommonConcern
|
@@ -16,53 +14,7 @@ module EacRubyUtils
|
|
16
14
|
end
|
17
15
|
|
18
16
|
def setup(a_module)
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
class Setup
|
23
|
-
include ::EacRubyUtils::SimpleCache
|
24
|
-
attr_reader :a_module, :common_concern
|
25
|
-
|
26
|
-
def initialize(common_concern, a_module)
|
27
|
-
@common_concern = common_concern
|
28
|
-
@a_module = a_module
|
29
|
-
end
|
30
|
-
|
31
|
-
def run
|
32
|
-
setup = self
|
33
|
-
a_module.extend(::ActiveSupport::Concern)
|
34
|
-
a_module.included do
|
35
|
-
%w[class_methods instance_methods after_callback].each do |suffix|
|
36
|
-
setup.send("setup_#{suffix}", self)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def setup_class_methods(base)
|
42
|
-
class_methods_module.if_present { |v| base.extend v }
|
43
|
-
end
|
44
|
-
|
45
|
-
def setup_instance_methods(base)
|
46
|
-
instance_methods_module.if_present { |v| base.include v }
|
47
|
-
end
|
48
|
-
|
49
|
-
def setup_after_callback(base)
|
50
|
-
common_concern.after_callback.if_present do |v|
|
51
|
-
base.instance_eval(&v)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def class_methods_module_uncached
|
56
|
-
a_module.const_get(CLASS_METHODS_MODULE_NAME)
|
57
|
-
rescue NameError
|
58
|
-
nil
|
59
|
-
end
|
60
|
-
|
61
|
-
def instance_methods_module_uncached
|
62
|
-
a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
|
63
|
-
rescue NameError
|
64
|
-
nil
|
65
|
-
end
|
17
|
+
::EacRubyUtils::CommonConcern::ModuleSetup.new(self, a_module).run
|
66
18
|
end
|
67
19
|
end
|
68
20
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'eac_ruby_utils/simple_cache'
|
5
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
class CommonConcern
|
9
|
+
class ClassSetup
|
10
|
+
include ::EacRubyUtils::SimpleCache
|
11
|
+
attr_reader :a_class, :module_setup, :include_method
|
12
|
+
|
13
|
+
def initialize(module_setup, a_class, include_method)
|
14
|
+
@module_setup = module_setup
|
15
|
+
@a_class = a_class
|
16
|
+
@include_method = include_method
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
%w[class_methods instance_methods after_callback].each do |suffix|
|
21
|
+
send("setup_#{suffix}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_class_methods
|
26
|
+
class_methods_module.if_present { |v| a_class.extend v }
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_instance_methods
|
30
|
+
instance_methods_module.if_present { |v| a_class.send(include_method, v) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup_after_callback
|
34
|
+
module_setup.common_concern.after_callback.if_present do |v|
|
35
|
+
a_class.instance_eval(&v)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def class_methods_module_uncached
|
40
|
+
module_setup.a_module.const_get(CLASS_METHODS_MODULE_NAME)
|
41
|
+
rescue NameError
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def instance_methods_module_uncached
|
46
|
+
module_setup.a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
|
47
|
+
rescue NameError
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'eac_ruby_utils/common_concern/class_setup'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
6
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
7
|
+
|
8
|
+
module EacRubyUtils
|
9
|
+
class CommonConcern
|
10
|
+
class ModuleSetup
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
attr_reader :a_module, :common_concern
|
13
|
+
|
14
|
+
def initialize(common_concern, a_module)
|
15
|
+
@common_concern = common_concern
|
16
|
+
@a_module = a_module
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
a_module.extend(::ActiveSupport::Concern)
|
21
|
+
include_or_prepend(:included, :include)
|
22
|
+
include_or_prepend(:prepended, :prepend)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def include_or_prepend(module_method, class_setup_method)
|
28
|
+
setup = self
|
29
|
+
a_module.send(module_method, *a_module_method_args(module_method)) do
|
30
|
+
::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, class_setup_method).run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def a_module_method_args(module_method)
|
35
|
+
method_arity = a_module.method(module_method).arity
|
36
|
+
method_arity = -method_arity - 1 if method_arity.negative?
|
37
|
+
method_arity.times.map { |_n| a_module }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'active_support/callbacks'
|
4
4
|
require 'eac_ruby_utils/arguments_consumer'
|
5
|
+
require 'eac_ruby_utils/common_constructor/class_initialize'
|
5
6
|
require 'ostruct'
|
6
7
|
|
7
8
|
module EacRubyUtils
|
@@ -61,6 +62,8 @@ module EacRubyUtils
|
|
61
62
|
setup_class_attr_readers(klass)
|
62
63
|
setup_class_attr_writers(klass)
|
63
64
|
setup_class_initialize(klass)
|
65
|
+
|
66
|
+
klass
|
64
67
|
end
|
65
68
|
|
66
69
|
def setup_class_attr_readers(klass)
|
@@ -74,60 +77,13 @@ module EacRubyUtils
|
|
74
77
|
end
|
75
78
|
|
76
79
|
def setup_class_initialize(klass)
|
77
|
-
common_constructor = self
|
78
80
|
klass.include(::ActiveSupport::Callbacks)
|
79
81
|
klass.define_callbacks :initialize
|
80
|
-
|
81
|
-
Initialize.new(common_constructor, args, self).run
|
82
|
-
end
|
82
|
+
::EacRubyUtils::CommonConstructor::ClassInitialize.new(self, klass).run
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def initialize(common_constructor, args, object)
|
89
|
-
@common_constructor = common_constructor
|
90
|
-
@args = args
|
91
|
-
@object = object
|
92
|
-
end
|
93
|
-
|
94
|
-
def run
|
95
|
-
validate_args_count
|
96
|
-
object.run_callbacks :initialize do
|
97
|
-
object_attributes_set
|
98
|
-
object_after_callback
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def arg_value(arg_name)
|
105
|
-
arg_index = common_constructor.args.index(arg_name)
|
106
|
-
if arg_index < args.count
|
107
|
-
args[arg_index]
|
108
|
-
else
|
109
|
-
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def object_after_callback
|
114
|
-
return unless common_constructor.after_set_block
|
115
|
-
|
116
|
-
object.instance_eval(&common_constructor.after_set_block)
|
117
|
-
end
|
118
|
-
|
119
|
-
def object_attributes_set
|
120
|
-
common_constructor.args.each do |arg_name|
|
121
|
-
object.send("#{arg_name}=", arg_value(arg_name))
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def validate_args_count
|
126
|
-
return if common_constructor.args_count.include?(args.count)
|
127
|
-
|
128
|
-
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
129
|
-
" (given #{args.count}, expected #{common_constructor.args_count})"
|
130
|
-
end
|
85
|
+
def super_args
|
86
|
+
options[:super_args]
|
131
87
|
end
|
132
88
|
end
|
133
89
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/common_constructor/instance_initialize'
|
4
|
+
require 'eac_ruby_utils/common_constructor/super_args'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
class CommonConstructor
|
8
|
+
class ClassInitialize
|
9
|
+
attr_reader :common_constructor, :klass
|
10
|
+
|
11
|
+
def initialize(common_constructor, klass)
|
12
|
+
@common_constructor = common_constructor
|
13
|
+
@klass = klass
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
class_initialize = self
|
18
|
+
klass.send(:define_method, :initialize) do |*args|
|
19
|
+
::EacRubyUtils::CommonConstructor::InstanceInitialize.new(
|
20
|
+
class_initialize.common_constructor, args, self
|
21
|
+
).run
|
22
|
+
super(*::EacRubyUtils::CommonConstructor::SuperArgs.new(
|
23
|
+
class_initialize, args, self
|
24
|
+
).result)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class CommonConstructor
|
5
|
+
class InstanceInitialize
|
6
|
+
attr_reader :common_constructor, :args, :object
|
7
|
+
|
8
|
+
def initialize(common_constructor, args, object)
|
9
|
+
@common_constructor = common_constructor
|
10
|
+
@args = args
|
11
|
+
@object = object
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
validate_args_count
|
16
|
+
object.run_callbacks :initialize do
|
17
|
+
object_attributes_set
|
18
|
+
object_after_callback
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def arg_value(arg_name)
|
25
|
+
arg_index = common_constructor.args.index(arg_name)
|
26
|
+
if arg_index < args.count
|
27
|
+
args[arg_index]
|
28
|
+
else
|
29
|
+
common_constructor.default_values[arg_index - common_constructor.args_count_min]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def object_after_callback
|
34
|
+
return unless common_constructor.after_set_block
|
35
|
+
|
36
|
+
object.instance_eval(&common_constructor.after_set_block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def object_attributes_set
|
40
|
+
common_constructor.args.each do |arg_name|
|
41
|
+
object.send("#{arg_name}=", arg_value(arg_name))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_args_count
|
46
|
+
return if common_constructor.args_count.include?(args.count)
|
47
|
+
|
48
|
+
raise ArgumentError, "#{object.class}.initialize: wrong number of arguments" \
|
49
|
+
" (given #{args.count}, expected #{common_constructor.args_count})"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class CommonConstructor
|
7
|
+
class SuperArgs
|
8
|
+
attr_reader :class_initialize, :args, :object
|
9
|
+
delegate :common_constructor, to: :class_initialize
|
10
|
+
|
11
|
+
def initialize(class_initialize, args, object)
|
12
|
+
@class_initialize = class_initialize
|
13
|
+
@args = args
|
14
|
+
@object = object
|
15
|
+
end
|
16
|
+
|
17
|
+
def auto_result
|
18
|
+
r = []
|
19
|
+
sub_args.each do |name, value|
|
20
|
+
i = super_arg_index(name)
|
21
|
+
r[i] = value if i
|
22
|
+
end
|
23
|
+
r
|
24
|
+
end
|
25
|
+
|
26
|
+
def result
|
27
|
+
result_from_options || auto_result
|
28
|
+
end
|
29
|
+
|
30
|
+
def result_from_options
|
31
|
+
return unless common_constructor.super_args
|
32
|
+
|
33
|
+
object.instance_exec(&common_constructor.super_args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def sub_args
|
37
|
+
common_constructor.args.each_with_index.map do |name, index|
|
38
|
+
[name, args[index]]
|
39
|
+
end.to_h
|
40
|
+
end
|
41
|
+
|
42
|
+
def super_arg_index(name)
|
43
|
+
super_method.parameters.each_with_index do |arg, index|
|
44
|
+
return index if arg[1] == name
|
45
|
+
end
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def super_method
|
50
|
+
class_initialize.klass.superclass&.instance_method(:initialize)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -38,7 +38,7 @@ module EacRubyUtils
|
|
38
38
|
def run_with_subcommand
|
39
39
|
if subcommand_name
|
40
40
|
check_valid_subcommand
|
41
|
-
|
41
|
+
subcommand_run
|
42
42
|
else
|
43
43
|
run_without_subcommand
|
44
44
|
end
|
@@ -52,6 +52,15 @@ module EacRubyUtils
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
def subcommand_run
|
56
|
+
if !subcommand.is_a?(::EacRubyUtils::Console::DocoptRunner) &&
|
57
|
+
subcommand.respond_to?(:run_run)
|
58
|
+
subcommand.run_run
|
59
|
+
else
|
60
|
+
subcommand.run
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
55
64
|
def target_doc
|
56
65
|
super.gsub(SUBCOMMANDS_MACRO,
|
57
66
|
"#{target_doc_subcommand_arg} [#{SUBCOMMAND_ARGS_ARG}...]") +
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'eac_ruby_utils/console/speaker'
|
5
|
-
require 'eac_ruby_utils/envs/command/extra_options'
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
6
4
|
require 'eac_ruby_utils/envs/process'
|
7
5
|
require 'eac_ruby_utils/envs/spawn'
|
8
6
|
require 'pp'
|
@@ -11,8 +9,8 @@ require 'shellwords'
|
|
11
9
|
module EacRubyUtils
|
12
10
|
module Envs
|
13
11
|
class Command
|
14
|
-
|
15
|
-
|
12
|
+
require_sub __FILE__, include_modules: true
|
13
|
+
enable_console_speaker
|
16
14
|
|
17
15
|
def initialize(env, command, extra_options = {})
|
18
16
|
@env = env
|
@@ -47,7 +45,7 @@ module EacRubyUtils
|
|
47
45
|
c = c.map { |x| escape(x) }.join(' ') if c.is_a?(Enumerable)
|
48
46
|
append_command_options(
|
49
47
|
@env.command_line(
|
50
|
-
append_chdir(
|
48
|
+
append_chdir(append_concat(append_envvars(c)))
|
51
49
|
),
|
52
50
|
options
|
53
51
|
)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/struct'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Envs
|
7
|
+
class Command
|
8
|
+
module Concat
|
9
|
+
def concat(operator, other_command)
|
10
|
+
duplicate_by_extra_options(concat: ::EacRubyUtils::Struct.new(
|
11
|
+
operator: operator, command: other_command
|
12
|
+
))
|
13
|
+
end
|
14
|
+
|
15
|
+
def or(other_command)
|
16
|
+
concat('||', other_command)
|
17
|
+
end
|
18
|
+
|
19
|
+
def pipe(other_command)
|
20
|
+
concat('|', other_command)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def append_concat(command)
|
26
|
+
extra_options[:concat].if_present(command) do |v|
|
27
|
+
"#{command} #{v.operator} #{v.command.command}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
module Envs
|
5
|
+
class Command
|
6
|
+
module Envvars
|
7
|
+
def envvar(name, value)
|
8
|
+
duplicate_by_extra_options(envvars: envvars.merge(name => value))
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def append_envvars(command)
|
14
|
+
e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
|
15
|
+
e.present? ? "#{e} #{command}" : command
|
16
|
+
end
|
17
|
+
|
18
|
+
def envvars
|
19
|
+
extra_options[:envvars] ||= {}.with_indifferent_access
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -12,39 +12,18 @@ module EacRubyUtils
|
|
12
12
|
duplicate_by_extra_options(chdir: dir)
|
13
13
|
end
|
14
14
|
|
15
|
-
def envvar(name, value)
|
16
|
-
duplicate_by_extra_options(envvars: envvars.merge(name => value))
|
17
|
-
end
|
18
|
-
|
19
15
|
def status_result(status_code, result)
|
20
16
|
duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
|
21
17
|
end
|
22
18
|
|
23
|
-
def pipe(other_command)
|
24
|
-
duplicate_by_extra_options(pipe: other_command)
|
25
|
-
end
|
26
|
-
|
27
19
|
private
|
28
20
|
|
29
21
|
attr_reader :extra_options
|
30
22
|
|
31
|
-
def envvars
|
32
|
-
extra_options[:envvars] ||= {}.with_indifferent_access
|
33
|
-
end
|
34
|
-
|
35
23
|
def status_results
|
36
24
|
extra_options[:status_results] ||= {}.with_indifferent_access
|
37
25
|
end
|
38
26
|
|
39
|
-
def append_envvars(command)
|
40
|
-
e = envvars.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
|
41
|
-
e.present? ? "#{e} #{command}" : command
|
42
|
-
end
|
43
|
-
|
44
|
-
def append_pipe(command)
|
45
|
-
extra_options[:pipe].present? ? "#{command} | #{extra_options[:pipe].command}" : command
|
46
|
-
end
|
47
|
-
|
48
27
|
def append_chdir(command)
|
49
28
|
extra_options[:chdir].present? ? "(cd '#{extra_options[:chdir]}' ; #{command} )" : command
|
50
29
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/hash_with_indifferent_access'
|
4
|
+
require 'active_support/core_ext/module/delegation'
|
4
5
|
require 'active_support/core_ext/object/blank'
|
5
6
|
|
6
7
|
module EacRubyUtils
|
7
8
|
class Struct
|
8
9
|
def initialize(initial_data = {})
|
9
|
-
self.data =
|
10
|
+
self.data = initial_data.symbolize_keys
|
10
11
|
end
|
11
12
|
|
12
13
|
def [](key)
|
@@ -19,6 +20,11 @@ module EacRubyUtils
|
|
19
20
|
bool ? fetch(key).present? : data.fetch(key)
|
20
21
|
end
|
21
22
|
|
23
|
+
def merge(other)
|
24
|
+
other = self.class.new(other) unless other.is_a?(self.class)
|
25
|
+
self.class.new(to_h.merge(other.to_h))
|
26
|
+
end
|
27
|
+
|
22
28
|
def method_missing(method_name, *arguments, &block)
|
23
29
|
property_method?(method_name) ? fetch(method_name) : super
|
24
30
|
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.
|
4
|
+
version: 0.56.2
|
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: 2020-12-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -114,7 +114,12 @@ files:
|
|
114
114
|
- lib/eac_ruby_utils/boolean.rb
|
115
115
|
- lib/eac_ruby_utils/by_reference.rb
|
116
116
|
- lib/eac_ruby_utils/common_concern.rb
|
117
|
+
- lib/eac_ruby_utils/common_concern/class_setup.rb
|
118
|
+
- lib/eac_ruby_utils/common_concern/module_setup.rb
|
117
119
|
- lib/eac_ruby_utils/common_constructor.rb
|
120
|
+
- lib/eac_ruby_utils/common_constructor/class_initialize.rb
|
121
|
+
- lib/eac_ruby_utils/common_constructor/instance_initialize.rb
|
122
|
+
- lib/eac_ruby_utils/common_constructor/super_args.rb
|
118
123
|
- lib/eac_ruby_utils/configs.rb
|
119
124
|
- lib/eac_ruby_utils/configs/base.rb
|
120
125
|
- lib/eac_ruby_utils/configs/file.rb
|
@@ -140,6 +145,8 @@ files:
|
|
140
145
|
- lib/eac_ruby_utils/envs.rb
|
141
146
|
- lib/eac_ruby_utils/envs/base_env.rb
|
142
147
|
- lib/eac_ruby_utils/envs/command.rb
|
148
|
+
- lib/eac_ruby_utils/envs/command/concat.rb
|
149
|
+
- lib/eac_ruby_utils/envs/command/envvars.rb
|
143
150
|
- lib/eac_ruby_utils/envs/command/extra_options.rb
|
144
151
|
- lib/eac_ruby_utils/envs/executable.rb
|
145
152
|
- lib/eac_ruby_utils/envs/file.rb
|