eac_ruby_base1 0.1.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 +7 -0
- data/lib/eac_ruby_base1/root_module_setup/ignore.rb +57 -0
- data/lib/eac_ruby_base1/root_module_setup/patches.rb +19 -0
- data/lib/eac_ruby_base1/root_module_setup/paths.rb +38 -0
- data/lib/eac_ruby_base1/root_module_setup/require_patch.rb +44 -0
- data/lib/eac_ruby_base1/root_module_setup/requires.rb +25 -0
- data/lib/eac_ruby_base1/root_module_setup/zeitwerk.rb +35 -0
- data/lib/eac_ruby_base1/root_module_setup.rb +68 -0
- data/lib/eac_ruby_base1/version.rb +5 -0
- data/lib/eac_ruby_base1.rb +5 -0
- metadata +98 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 51df52b49bdf910e5d57f517a13d118a4791ea1687813e010ed3614a438b071e
|
|
4
|
+
data.tar.gz: 587127f036f4126ca5e26cce60d3bc72665855a89959f78889690520068058aa
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e3800efea9743e0009deb8de108842da5d2a868a49b160dbeb53ccbe697bee56f0b15f948737a1362ea936223eaf1dfe2a21072e6a06af45621e70be875ec1fc
|
|
7
|
+
data.tar.gz: 5379676020ecf4b1449c395e8ff8b3b4d1a8c85400054ee40e35f222ea56440958a390e269fb660f9ae8eebfafbeb4ccf084f32a4864d9f4269b9a7626845e1d
|
|
@@ -0,0 +1,57 @@
|
|
|
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/pathname/basename_sub'
|
|
6
|
+
require 'memoized'
|
|
7
|
+
|
|
8
|
+
module EacRubyBase1
|
|
9
|
+
class RootModuleSetup
|
|
10
|
+
class Ignore
|
|
11
|
+
include ::Memoized
|
|
12
|
+
|
|
13
|
+
acts_as_instance_method
|
|
14
|
+
common_constructor :setup, :path do
|
|
15
|
+
self.path = path.to_pathname
|
|
16
|
+
end
|
|
17
|
+
delegate :loader, :root_module_directory, to: :setup
|
|
18
|
+
|
|
19
|
+
# @return [Set]
|
|
20
|
+
def result
|
|
21
|
+
target_paths.each do |target_path|
|
|
22
|
+
expect_count_increment { loader.ignore target_path }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
protected
|
|
27
|
+
|
|
28
|
+
# @return [Pathname]
|
|
29
|
+
memoize def absolute_path
|
|
30
|
+
path.expand_path(root_module_directory)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [Set]
|
|
34
|
+
def expect_count_increment
|
|
35
|
+
count_before = loader.send(:ignored_paths).count
|
|
36
|
+
result = yield
|
|
37
|
+
return result if result.count > count_before
|
|
38
|
+
|
|
39
|
+
raise ::ArgumentError, [
|
|
40
|
+
"Trying to ignore path \"#{path}\" did not increase the ignored paths.",
|
|
41
|
+
"Argument path: \"#{path}\"", "Target path: \"#{target_paths}\"",
|
|
42
|
+
"Ignored paths: #{result}"
|
|
43
|
+
].join("\n")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Pathname]
|
|
47
|
+
memoize def target_paths
|
|
48
|
+
return [absolute_path] if %w[* ?].any? { |e| absolute_path.to_path.include?(e) } # rubocop:disable Style/ArrayIntersect
|
|
49
|
+
|
|
50
|
+
r = []
|
|
51
|
+
r << absolute_path if absolute_path.directory?
|
|
52
|
+
r << [absolute_path.basename_sub { |b| "#{b.basename('.*')}.rb" }]
|
|
53
|
+
r
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRubyBase1
|
|
4
|
+
class RootModuleSetup
|
|
5
|
+
module Patches
|
|
6
|
+
# @return [Enumerable<Pathname>]
|
|
7
|
+
def patches_files
|
|
8
|
+
root_module_directory.join('patches').glob('**/*.rb')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @return [void]
|
|
12
|
+
def require_patches
|
|
13
|
+
patches_files.each do |absolute_path|
|
|
14
|
+
require_patch(absolute_path)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRubyBase1
|
|
4
|
+
class RootModuleSetup
|
|
5
|
+
module Paths
|
|
6
|
+
# @!attribute [r] root_module_file
|
|
7
|
+
# @return [Pathname] Absolute path to the gem's module root file.
|
|
8
|
+
|
|
9
|
+
attr_reader :root_module_file
|
|
10
|
+
|
|
11
|
+
# @return [Pathname]
|
|
12
|
+
def relative_root_module_file
|
|
13
|
+
count = 0
|
|
14
|
+
current = root_module_file.basename('.*')
|
|
15
|
+
dirname = root_module_file.dirname
|
|
16
|
+
loop do
|
|
17
|
+
ibr if dirname.root?
|
|
18
|
+
|
|
19
|
+
break current if dirname.basename.to_path == LIB_DIRECTORY_BASENAME
|
|
20
|
+
|
|
21
|
+
current = dirname.basename.join(current)
|
|
22
|
+
dirname = dirname.dirname
|
|
23
|
+
|
|
24
|
+
count += 1
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @return [Pathname]
|
|
29
|
+
def root_module_directory
|
|
30
|
+
root_module_file.basename('.*').expand_path(root_module_file.dirname)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
protected
|
|
34
|
+
|
|
35
|
+
attr_writer :root_module_file
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
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/pathname/basename_sub'
|
|
6
|
+
require 'memoized'
|
|
7
|
+
|
|
8
|
+
module EacRubyBase1
|
|
9
|
+
class RootModuleSetup
|
|
10
|
+
class RequirePatch
|
|
11
|
+
acts_as_instance_method
|
|
12
|
+
common_constructor :setup, :absolute_path do
|
|
13
|
+
self.absolute_path = absolute_path.to_pathname
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @return [void]
|
|
17
|
+
def result
|
|
18
|
+
perform_require
|
|
19
|
+
perform_ignore
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @return [Pathname]
|
|
23
|
+
def ignore_path
|
|
24
|
+
absolute_path.relative_path_from(setup.root_module_directory)
|
|
25
|
+
.basename_sub { |b| b.basename('.*') }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @return [void]
|
|
29
|
+
def perform_require
|
|
30
|
+
::Kernel.require require_path
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [void]
|
|
34
|
+
def perform_ignore
|
|
35
|
+
setup.ignore ignore_path
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @return [Pathname]
|
|
39
|
+
def require_path
|
|
40
|
+
setup.relative_root_module_file.join(ignore_path)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRubyBase1
|
|
4
|
+
class RootModuleSetup
|
|
5
|
+
module Requires
|
|
6
|
+
# @param require [String]
|
|
7
|
+
# @return [void]
|
|
8
|
+
def require(name)
|
|
9
|
+
requires << name
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# @return [void]
|
|
13
|
+
def perform_requires
|
|
14
|
+
requires.each { |name| ::Kernel.require(name) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
protected
|
|
18
|
+
|
|
19
|
+
# @return [Array<String>]
|
|
20
|
+
def requires
|
|
21
|
+
@requires ||= []
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EacRubyBase1
|
|
4
|
+
class RootModuleSetup
|
|
5
|
+
module Zeitwerk
|
|
6
|
+
# @return [Zeitwerk::GemLoader]
|
|
7
|
+
def loader
|
|
8
|
+
@loader ||= ::Zeitwerk::Registry.loader_for_gem(
|
|
9
|
+
root_module_file,
|
|
10
|
+
namespace: namespace,
|
|
11
|
+
warn_on_extra_files: true
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @param enable [Boolean] `true` to enable, `false` (default) to disable.
|
|
16
|
+
# @return
|
|
17
|
+
def logging(enable)
|
|
18
|
+
@logging = enable
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @return [Boolean]
|
|
22
|
+
def logging?
|
|
23
|
+
@logging ? true : false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
protected
|
|
27
|
+
|
|
28
|
+
# @return [void]
|
|
29
|
+
def perform_zeitwerk
|
|
30
|
+
loader.log! if logging?
|
|
31
|
+
loader.setup
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'active_support/inflector'
|
|
4
|
+
require 'eac_ruby_utils/patches/module/require_sub'
|
|
5
|
+
require 'zeitwerk'
|
|
6
|
+
|
|
7
|
+
module EacRubyBase1
|
|
8
|
+
class RootModuleSetup
|
|
9
|
+
require_sub __FILE__, require_mode: :kernel, include_modules: true
|
|
10
|
+
|
|
11
|
+
DEFAULT_NAMESPACE = ::Object
|
|
12
|
+
LIB_DIRECTORY_BASENAME = 'lib'
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# @param root_module_file [Pathname]
|
|
16
|
+
def perform(root_module_file, &)
|
|
17
|
+
new(root_module_file, &).perform
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
attr_reader :block
|
|
22
|
+
attr_writer :logging
|
|
23
|
+
|
|
24
|
+
# @param root_module_file [Pathname]
|
|
25
|
+
def initialize(root_module_file, &block)
|
|
26
|
+
self.root_module_file = root_module_file.to_pathname
|
|
27
|
+
self.block = block
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [Module, nil]
|
|
31
|
+
def extension_for
|
|
32
|
+
dirname = ::File.dirname(relative_root_module_file)
|
|
33
|
+
return nil if ['.', '/', ''].include?(dirname)
|
|
34
|
+
|
|
35
|
+
require dirname
|
|
36
|
+
::ActiveSupport::Inflector.constantize(dirname.camelize)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @return [Module]
|
|
40
|
+
def namespace
|
|
41
|
+
extension_for || DEFAULT_NAMESPACE
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [void]
|
|
45
|
+
def perform
|
|
46
|
+
perform_block
|
|
47
|
+
perform_zeitwerk
|
|
48
|
+
root_module
|
|
49
|
+
perform_requires
|
|
50
|
+
require_patches
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [void]
|
|
54
|
+
def root_module
|
|
55
|
+
relative_root_module_file.each_filename.inject(DEFAULT_NAMESPACE) do |a, e|
|
|
56
|
+
a.const_get(e.camelize)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
protected
|
|
61
|
+
|
|
62
|
+
attr_writer :block
|
|
63
|
+
|
|
64
|
+
def perform_block
|
|
65
|
+
instance_eval(&block) if block
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: eac_ruby_base1
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Put here the authors
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-07-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: eac_ruby_utils
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.131'
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 0.131.1
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0.131'
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 0.131.1
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: avm-eac_ruby_base1
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0.42'
|
|
40
|
+
type: :development
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.42'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: eac_ruby_gem_support
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0.13'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0.13'
|
|
61
|
+
description:
|
|
62
|
+
email:
|
|
63
|
+
executables: []
|
|
64
|
+
extensions: []
|
|
65
|
+
extra_rdoc_files: []
|
|
66
|
+
files:
|
|
67
|
+
- lib/eac_ruby_base1.rb
|
|
68
|
+
- lib/eac_ruby_base1/root_module_setup.rb
|
|
69
|
+
- lib/eac_ruby_base1/root_module_setup/ignore.rb
|
|
70
|
+
- lib/eac_ruby_base1/root_module_setup/patches.rb
|
|
71
|
+
- lib/eac_ruby_base1/root_module_setup/paths.rb
|
|
72
|
+
- lib/eac_ruby_base1/root_module_setup/require_patch.rb
|
|
73
|
+
- lib/eac_ruby_base1/root_module_setup/requires.rb
|
|
74
|
+
- lib/eac_ruby_base1/root_module_setup/zeitwerk.rb
|
|
75
|
+
- lib/eac_ruby_base1/version.rb
|
|
76
|
+
homepage:
|
|
77
|
+
licenses: []
|
|
78
|
+
metadata: {}
|
|
79
|
+
post_install_message:
|
|
80
|
+
rdoc_options: []
|
|
81
|
+
require_paths:
|
|
82
|
+
- lib
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '3.2'
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
requirements: []
|
|
94
|
+
rubygems_version: 3.4.19
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: Put here de description.
|
|
98
|
+
test_files: []
|