eac_ruby_utils 0.126.0 → 0.127.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eca375f90c7ffb3c396d1ca14f300e80a371d257634d7c09c8ae0f18f435dfd
|
4
|
+
data.tar.gz: 5a52cdfc7394d729ac702b0b5df8a5721afcdb79aa75d69aee25be06a20159c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33098fe65997ad6b380543fb11a1d43be9b604748c180f1ac1bd294e98dba83892b4ebd90c5cead54fe3a21c684c1cda2464cec67ef599605758e207fba1518b
|
7
|
+
data.tar.gz: fdc66f5a7426bc825db9e472574b6500c656f9cd6aad33587b60daf438db6b45fc6f6971bdd4c3515a799d67515e85bfd76d10e6f0f75bc8f129ecd351e5ebfe
|
@@ -4,6 +4,7 @@ require 'active_support/callbacks'
|
|
4
4
|
require 'eac_ruby_utils/arguments_consumer'
|
5
5
|
require 'eac_ruby_utils/common_constructor/class_accessors'
|
6
6
|
require 'eac_ruby_utils/common_constructor/class_initialize'
|
7
|
+
require 'eac_ruby_utils/patches/object/call_if_proc'
|
7
8
|
|
8
9
|
module EacRubyUtils
|
9
10
|
class CommonConstructor
|
@@ -66,8 +67,9 @@ module EacRubyUtils
|
|
66
67
|
options[:block_arg] || false
|
67
68
|
end
|
68
69
|
|
70
|
+
# @return [Enumerable]
|
69
71
|
def default_values
|
70
|
-
options[:default] || []
|
72
|
+
options[:default].call_if_proc || []
|
71
73
|
end
|
72
74
|
|
73
75
|
def setup_class(klass)
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support/inflector'
|
3
4
|
require 'eac_ruby_utils/patches/pathname'
|
4
5
|
require 'eac_ruby_utils/patches/object/to_pathname'
|
5
6
|
require 'zeitwerk'
|
6
7
|
|
7
8
|
module EacRubyUtils
|
8
9
|
class RootModuleSetup
|
10
|
+
DEFAULT_NAMESPACE = ::Object
|
11
|
+
LIB_DIRECTORY_BASENAME = 'lib'
|
12
|
+
|
9
13
|
class << self
|
10
14
|
# @param root_module_file [String]
|
11
15
|
def perform(root_module_file, &block)
|
@@ -21,6 +25,15 @@ module EacRubyUtils
|
|
21
25
|
self.block = block
|
22
26
|
end
|
23
27
|
|
28
|
+
# @return [Module, nil]
|
29
|
+
def extension_for
|
30
|
+
dirname = ::File.dirname(relative_root_module_file)
|
31
|
+
return nil if ['.', '/', ''].include?(dirname)
|
32
|
+
|
33
|
+
require dirname
|
34
|
+
::ActiveSupport::Inflector.constantize(dirname.classify)
|
35
|
+
end
|
36
|
+
|
24
37
|
# @param path [String] Relative path to root module's directory.
|
25
38
|
def ignore(path)
|
26
39
|
count_before = loader.send(:ignored_paths).count
|
@@ -35,12 +48,34 @@ module EacRubyUtils
|
|
35
48
|
].join("\n")
|
36
49
|
end
|
37
50
|
|
51
|
+
# @return [Module]
|
52
|
+
def namespace
|
53
|
+
extension_for || DEFAULT_NAMESPACE
|
54
|
+
end
|
55
|
+
|
38
56
|
# @return [void]
|
39
57
|
def perform
|
40
58
|
perform_block
|
41
59
|
perform_zeitwerk
|
42
60
|
end
|
43
61
|
|
62
|
+
# @return [String]
|
63
|
+
def relative_root_module_file
|
64
|
+
count = 0
|
65
|
+
current = ::File.basename(root_module_file, '.*')
|
66
|
+
dirname = ::File.dirname(root_module_file)
|
67
|
+
loop do
|
68
|
+
ibr if dirname == '/'
|
69
|
+
|
70
|
+
break current if ::File.basename(dirname) == LIB_DIRECTORY_BASENAME
|
71
|
+
|
72
|
+
current = ::File.join(::File.basename(dirname), current)
|
73
|
+
dirname = ::File.dirname(dirname)
|
74
|
+
|
75
|
+
count += 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
44
79
|
# @return [String]
|
45
80
|
def root_module_directory
|
46
81
|
::File.expand_path(::File.basename(root_module_file, '.*'),
|
@@ -64,7 +99,7 @@ module EacRubyUtils
|
|
64
99
|
def loader
|
65
100
|
@loader ||= ::Zeitwerk::Registry.loader_for_gem(
|
66
101
|
root_module_file,
|
67
|
-
namespace:
|
102
|
+
namespace: namespace,
|
68
103
|
warn_on_extra_files: true
|
69
104
|
)
|
70
105
|
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.127.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: 2025-
|
11
|
+
date: 2025-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|