eac_ruby_utils 0.55.0 → 0.56.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9bc19b521f818ba1b2e93fc75d8000f375fd4c2fcd2b9cb994f235d577e4394
4
- data.tar.gz: d27abb2be7b2132da7e6c9b3699877a30970f428395bc2c80a7a1852f79687c8
3
+ metadata.gz: 9359fc40aed41fdc0eb2b7570bff084403a0a1aec9803d3581e2cc1b27f5318c
4
+ data.tar.gz: '0749a1a5ec6ec7e31701f8cf18af86a8fd0a8cf6f3e7d62df1d41a568e91394c'
5
5
  SHA512:
6
- metadata.gz: fd409878560e621551651fe0d8f299d48dc9c14a85da4ef983b65e60075569dd7af2ba3c2be11b44e873793771a3b9315803e3b5e507a93d6fa40d921cc44ee9
7
- data.tar.gz: f213403725b956955274f7da31f612f1a39b365d0e39ad3ae86b1879252b7f604d3e80f5a84bd2ae8c0244da3cb9a90cc68f3cc7879b6b9a990dd9a3e4349d82
6
+ metadata.gz: c87bcbfdbc771869f7654eb28e2cf77e48e0ef70e2981be895c228332608c2aa05f90fd4cadcee926749870da742fa6f9061ad4c1424bdeba3cc5eb06fbabaf0
7
+ data.tar.gz: df6e1db72f930687085bde679b38d141edc7cea9de95d9126cb2d87d155d402ccce0581dad5e8abf1bbd5831633dec6c896b2c143cb354ab5c8c44b05401d7cb
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/concern'
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
- Setup.new(self, a_module).run
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,31 @@
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
+ setup = self
21
+ a_module.extend(::ActiveSupport::Concern)
22
+ a_module.included do
23
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :include).run
24
+ end
25
+ a_module.prepended do
26
+ ::EacRubyUtils::CommonConcern::ClassSetup.new(setup, self, :prepend).run
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -3,7 +3,7 @@
3
3
  require 'pathname'
4
4
 
5
5
  class Pathname
6
- def basename_sub
7
- parent.join(yield(basename))
6
+ def basename_sub(suffix = '')
7
+ parent.join(yield(basename(suffix)))
8
8
  end
9
9
  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 = ::ActiveSupport::HashWithIndifferentAccess.new(initial_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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.55.0'
4
+ VERSION = '0.56.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.55.0
4
+ version: 0.56.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: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2020-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,6 +114,8 @@ 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
118
120
  - lib/eac_ruby_utils/configs.rb
119
121
  - lib/eac_ruby_utils/configs/base.rb