eac_ruby_utils 0.127.0 → 0.128.1
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/boolean.rb +2 -2
- data/lib/eac_ruby_utils/common_constructor.rb +1 -1
- data/lib/eac_ruby_utils/enum.rb +1 -1
- data/lib/eac_ruby_utils/envs/command.rb +1 -1
- data/lib/eac_ruby_utils/gems_registry/gem/dependencies.rb +34 -0
- data/lib/eac_ruby_utils/gems_registry/gem/paths_to_require.rb +55 -0
- data/lib/eac_ruby_utils/gems_registry/gem.rb +7 -38
- data/lib/eac_ruby_utils/objects_table.rb +1 -1
- data/lib/eac_ruby_utils/patch_module.rb +4 -0
- data/lib/eac_ruby_utils/patches/addressable/uri/query_value.rb +1 -1
- data/lib/eac_ruby_utils/patches/module/patch_self.rb +1 -1
- data/lib/eac_ruby_utils/patches/module/simple_cache.rb +2 -2
- data/lib/eac_ruby_utils/recursive_builder.rb +1 -1
- data/lib/eac_ruby_utils/root_module_setup/ignore.rb +56 -0
- data/lib/eac_ruby_utils/root_module_setup.rb +10 -23
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b94935e750593c0ab19c4a7dd5a7c9706b59a92c42c0be89daee54f88f236a0
|
4
|
+
data.tar.gz: 9f71b5d9ed0c45d0c8338288a19487693de100a1fa1b23787ee03fff63d5aa94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40951b5b3c354a75e30cfbe82c614289da2c7b4564b3f65d61c8f327949f5443954bfd11561d790faf6bd1596a85ba9722f86a33aeddec330fc136f9fcf8a4a4
|
7
|
+
data.tar.gz: bd9eb72941c5eb09ce73a3b4e337f324d254a6d33c845eb67dca62abd67a046674dbaae4fb0cbf9b5c9b2ed52fadc1d88311d0e4b35a459997c925d297e93a00
|
@@ -13,11 +13,11 @@ module EacRubyUtils
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def parse_string(value)
|
16
|
+
def parse_string(value) # rubocop:disable Naming/PredicateMethod
|
17
17
|
['', 'n', 'no', 'f', 'false'].exclude?(value.strip.downcase)
|
18
18
|
end
|
19
19
|
|
20
|
-
def parse_number(value)
|
20
|
+
def parse_number(value) # rubocop:disable Naming/PredicateMethod
|
21
21
|
value.zero?
|
22
22
|
end
|
23
23
|
end
|
data/lib/eac_ruby_utils/enum.rb
CHANGED
@@ -13,7 +13,7 @@ module EacRubyUtils
|
|
13
13
|
# @param command [Array]
|
14
14
|
# @return [Array]
|
15
15
|
def sanitize_initialize_arguments(arguments)
|
16
|
-
if arguments.
|
16
|
+
if arguments.one? && arguments.first.is_a?(Array)
|
17
17
|
arguments.first
|
18
18
|
elsif arguments.is_a?(Array)
|
19
19
|
arguments
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/recursive_builder'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class GemsRegistry
|
7
|
+
class Gem
|
8
|
+
module Dependencies
|
9
|
+
def depend_on(gem) # rubocop:disable Naming/PredicateMethod
|
10
|
+
dependencies.lazy.map(&:name).include?(gem.gemspec.name)
|
11
|
+
end
|
12
|
+
|
13
|
+
def dependencies
|
14
|
+
@dependencies ||= dependencies_uncached # dependencies_uncached
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def dependencies_uncached
|
20
|
+
::EacRubyUtils::RecursiveBuilder
|
21
|
+
.new(gemspec) { |item| gem_item_dependencies(item) }
|
22
|
+
.result
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Array<Gem::Dependency>]
|
26
|
+
def gem_item_dependencies(item)
|
27
|
+
::Gem::Specification.find_by_name(item.name).dependencies.select(&:runtime?)
|
28
|
+
rescue ::Gem::MissingSpecError
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
require 'eac_ruby_utils/recursive_builder'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
class GemsRegistry
|
9
|
+
class Gem
|
10
|
+
module PathsToRequire
|
11
|
+
ROOT_MODULE_REQUIRE_PATTERNS = %w[EacRubyUtils::RootModuleSetup Zeitwerk].freeze
|
12
|
+
|
13
|
+
# @return [Enumerable<Pathname>]
|
14
|
+
def absolute_require_paths(lib_relative_path)
|
15
|
+
gemspec.require_paths.lazy.map do |e|
|
16
|
+
::Pathname.new(e).expand_path(gemspec.gem_dir)
|
17
|
+
.join("#{lib_relative_path}.rb")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def path_to_require
|
23
|
+
require_root_module? ? root_module_path_to_require : direct_path_to_require
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def to_s
|
28
|
+
"#{self.class.name}[#{gemspec.name}]"
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def direct_path_to_require
|
35
|
+
"#{root_module_path_to_require}/#{registry.module_suffix.underscore}"
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [Boolean]
|
39
|
+
def require_root_module?
|
40
|
+
absolute_require_paths(root_module_path_to_require).find do |e|
|
41
|
+
next false unless e.file?
|
42
|
+
|
43
|
+
content = e.read
|
44
|
+
ROOT_MODULE_REQUIRE_PATTERNS.any? { |e| content.include?(e) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String]
|
49
|
+
def root_module_path_to_require
|
50
|
+
gemspec.name.gsub('-', '/')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/core_ext/string/inflections'
|
4
|
-
require 'eac_ruby_utils/
|
4
|
+
require 'eac_ruby_utils/gems_registry/gem/dependencies'
|
5
|
+
require 'eac_ruby_utils/gems_registry/gem/paths_to_require'
|
5
6
|
require 'eac_ruby_utils/simple_cache'
|
6
7
|
|
7
8
|
module EacRubyUtils
|
8
9
|
class GemsRegistry
|
9
10
|
class Gem
|
10
11
|
include ::Comparable
|
12
|
+
include ::EacRubyUtils::GemsRegistry::Gem::Dependencies
|
13
|
+
include ::EacRubyUtils::GemsRegistry::Gem::PathsToRequire
|
11
14
|
include ::EacRubyUtils::SimpleCache
|
12
15
|
|
13
16
|
attr_reader :registry, :gemspec
|
@@ -17,14 +20,6 @@ module EacRubyUtils
|
|
17
20
|
@gemspec = gemspec
|
18
21
|
end
|
19
22
|
|
20
|
-
def depend_on(gem)
|
21
|
-
dependencies.lazy.map(&:name).include?(gem.gemspec.name)
|
22
|
-
end
|
23
|
-
|
24
|
-
def dependencies
|
25
|
-
@dependencies ||= dependencies_uncached # dependencies_uncached
|
26
|
-
end
|
27
|
-
|
28
23
|
def <=>(other)
|
29
24
|
sd = depend_on(other)
|
30
25
|
od = other.depend_on(self)
|
@@ -38,42 +33,16 @@ module EacRubyUtils
|
|
38
33
|
lib_file_found? && registered_module.is_a?(::Module)
|
39
34
|
end
|
40
35
|
|
36
|
+
# @return [Boolean]
|
41
37
|
def lib_file_found?
|
42
|
-
|
43
|
-
::Pathname.new(require_path).expand_path(gemspec.gem_dir).join("#{path_to_require}.rb")
|
44
|
-
.file?
|
45
|
-
end
|
38
|
+
absolute_require_paths(direct_path_to_require).any?(&:file?)
|
46
39
|
end
|
47
40
|
|
48
41
|
def registered_module
|
49
42
|
return nil unless lib_file_found?
|
50
43
|
|
51
44
|
require path_to_require
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [String]
|
56
|
-
def path_to_require
|
57
|
-
"#{gemspec.name.gsub('-', '/')}/#{registry.module_suffix.underscore}"
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_s
|
61
|
-
"#{self.class.name}[#{gemspec.name}]"
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def dependencies_uncached
|
67
|
-
::EacRubyUtils::RecursiveBuilder
|
68
|
-
.new(gemspec) { |item| gem_item_dependencies(item) }
|
69
|
-
.result
|
70
|
-
end
|
71
|
-
|
72
|
-
# @return [Array<Gem::Dependency>]
|
73
|
-
def gem_item_dependencies(item)
|
74
|
-
::Gem::Specification.find_by_name(item.name).dependencies.select(&:runtime?)
|
75
|
-
rescue ::Gem::MissingSpecError
|
76
|
-
[]
|
45
|
+
direct_path_to_require.camelize.constantize
|
77
46
|
end
|
78
47
|
end
|
79
48
|
end
|
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/regexp_parser'
|
|
5
5
|
module EacRubyUtils
|
6
6
|
class ObjectsTable
|
7
7
|
BY_PARSER = ::EacRubyUtils::RegexpParser.new(/\Aby_([^!\?]+)(!)?\z/) do |m|
|
8
|
-
BY_PARSER_PARSED_STRUCT.new(m[1], "by_attribute#{m[2].present?
|
8
|
+
BY_PARSER_PARSED_STRUCT.new(m[1], "by_attribute#{'!' if m[2].present?}")
|
9
9
|
end
|
10
10
|
BY_PARSER_PARSED_STRUCT = ::Struct.new(:attribute, :method_name)
|
11
11
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patches/module/patch_self'
|
4
4
|
require 'eac_ruby_utils/simple_cache'
|
5
5
|
|
6
6
|
class Module
|
7
7
|
def enable_simple_cache
|
8
|
-
|
8
|
+
patch_self(::EacRubyUtils::SimpleCache)
|
9
9
|
end
|
10
10
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/acts_as_instance_method'
|
4
|
+
require 'eac_ruby_utils/patches/object/to_pathname'
|
5
|
+
require 'eac_ruby_utils/patches/module/simple_cache'
|
6
|
+
require 'eac_ruby_utils/patches/pathname/basename_sub'
|
7
|
+
|
8
|
+
module EacRubyUtils
|
9
|
+
class RootModuleSetup
|
10
|
+
class Ignore
|
11
|
+
acts_as_instance_method
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :setup, :path do
|
14
|
+
self.path = path.to_pathname
|
15
|
+
end
|
16
|
+
delegate :loader, :root_module_directory, to: :setup
|
17
|
+
|
18
|
+
# @return [Set]
|
19
|
+
def result
|
20
|
+
target_paths.each do |target_path|
|
21
|
+
expect_count_increment { loader.ignore target_path }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
# @return [Pathname]
|
28
|
+
def absolute_path_uncached
|
29
|
+
path.expand_path(root_module_directory)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Set]
|
33
|
+
def expect_count_increment
|
34
|
+
count_before = loader.send(:ignored_paths).count
|
35
|
+
result = yield
|
36
|
+
return result if result.count > count_before
|
37
|
+
|
38
|
+
raise ::ArgumentError, [
|
39
|
+
"Trying to ignore path \"#{path}\" did not increase the ignored paths.",
|
40
|
+
"Argument path: \"#{path}\"", "Target path: \"#{target_path}\"",
|
41
|
+
"Ignored paths: #{result}"
|
42
|
+
].join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Pathname]
|
46
|
+
def target_paths_uncached
|
47
|
+
return [absolute_path] if %w[* ?].any? { |e| absolute_path.to_path.include?(e) }
|
48
|
+
|
49
|
+
r = []
|
50
|
+
r << absolute_path if absolute_path.directory?
|
51
|
+
r << [absolute_path.basename_sub { |b| "#{b.basename('.*')}.rb" }]
|
52
|
+
r
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/inflector'
|
4
|
-
require 'eac_ruby_utils/patches/
|
5
|
-
require 'eac_ruby_utils/patches/object/to_pathname'
|
4
|
+
require 'eac_ruby_utils/patches/module/require_sub'
|
6
5
|
require 'zeitwerk'
|
7
6
|
|
8
7
|
module EacRubyUtils
|
9
8
|
class RootModuleSetup
|
9
|
+
require_sub __FILE__, require_mode: :kernel
|
10
|
+
|
10
11
|
DEFAULT_NAMESPACE = ::Object
|
11
12
|
LIB_DIRECTORY_BASENAME = 'lib'
|
12
13
|
|
@@ -34,18 +35,13 @@ module EacRubyUtils
|
|
34
35
|
::ActiveSupport::Inflector.constantize(dirname.classify)
|
35
36
|
end
|
36
37
|
|
37
|
-
# @
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
raise ::ArgumentError, [
|
46
|
-
"Trying to ignore path \"#{path}\" did not increase the ignored paths.",
|
47
|
-
"Argument path: \"#{path}\"", "Target path: \"#{target_path}\"", "Ignored paths: #{result}"
|
48
|
-
].join("\n")
|
38
|
+
# @return [Zeitwerk::GemLoader]
|
39
|
+
def loader
|
40
|
+
@loader ||= ::Zeitwerk::Registry.loader_for_gem(
|
41
|
+
root_module_file,
|
42
|
+
namespace: namespace,
|
43
|
+
warn_on_extra_files: true
|
44
|
+
)
|
49
45
|
end
|
50
46
|
|
51
47
|
# @return [Module]
|
@@ -94,14 +90,5 @@ module EacRubyUtils
|
|
94
90
|
def perform_zeitwerk
|
95
91
|
loader.setup
|
96
92
|
end
|
97
|
-
|
98
|
-
# @return [Zeitwerk::GemLoader]
|
99
|
-
def loader
|
100
|
-
@loader ||= ::Zeitwerk::Registry.loader_for_gem(
|
101
|
-
root_module_file,
|
102
|
-
namespace: namespace,
|
103
|
-
warn_on_extra_files: true
|
104
|
-
)
|
105
|
-
end
|
106
93
|
end
|
107
94
|
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.128.1
|
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-06-
|
11
|
+
date: 2025-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -228,6 +228,8 @@ files:
|
|
228
228
|
- lib/eac_ruby_utils/fs/temp/file.rb
|
229
229
|
- lib/eac_ruby_utils/gems_registry.rb
|
230
230
|
- lib/eac_ruby_utils/gems_registry/gem.rb
|
231
|
+
- lib/eac_ruby_utils/gems_registry/gem/dependencies.rb
|
232
|
+
- lib/eac_ruby_utils/gems_registry/gem/paths_to_require.rb
|
231
233
|
- lib/eac_ruby_utils/inflector.rb
|
232
234
|
- lib/eac_ruby_utils/listable.rb
|
233
235
|
- lib/eac_ruby_utils/listable/class_methods.rb
|
@@ -331,6 +333,7 @@ files:
|
|
331
333
|
- lib/eac_ruby_utils/require_sub/base.rb
|
332
334
|
- lib/eac_ruby_utils/require_sub/sub_file.rb
|
333
335
|
- lib/eac_ruby_utils/root_module_setup.rb
|
336
|
+
- lib/eac_ruby_utils/root_module_setup/ignore.rb
|
334
337
|
- lib/eac_ruby_utils/rspec.rb
|
335
338
|
- lib/eac_ruby_utils/rspec/default_setup.rb
|
336
339
|
- lib/eac_ruby_utils/rspec/setup.rb
|