eac_ruby_utils 0.127.0 → 0.128.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 +4 -4
- data/lib/eac_ruby_utils/common_constructor.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/recursive_builder.rb +1 -1
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7471bdc60fb8e985c2ca4d3d43985ee1a2dfbbf73324a2843bc2bea5254b020
|
4
|
+
data.tar.gz: 302008ed227fee3b0c9835cdd95bb6d10b3b2bbf3d80da149429ce6bddec5c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a73f93f2a91d8a268d0f17e67480daaef1a57e101bc01f8769cb3312c0547f8f0bdb837504ec5b5ef340c9413562cda38d001098768fbc6926e7e3fdedca6ea
|
7
|
+
data.tar.gz: e53d8f802385d3545fdfc72842a728ff9e3834f6cde2b30112f5ddc300e92c6eff6717a869057fa4145cd39f77e99d914806932119fa49d858df2959916f53a4
|
@@ -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)
|
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
|
|
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.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-06-
|
11
|
+
date: 2025-06-15 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
|