eac_ruby_utils 0.125.0 → 0.126.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/fs/extname.rb +22 -17
- data/lib/eac_ruby_utils/fs.rb +2 -0
- data/lib/eac_ruby_utils/objects_table.rb +6 -3
- data/lib/eac_ruby_utils/patch_module.rb +17 -0
- data/lib/eac_ruby_utils/patches/class/method_class.rb +1 -1
- data/lib/eac_ruby_utils/patches/class/settings_provider.rb +2 -2
- data/lib/eac_ruby_utils/patches/class/static_method_class.rb +1 -1
- data/lib/eac_ruby_utils/patches/integer/rjust_zero.rb +13 -0
- data/lib/eac_ruby_utils/patches/integer.rb +4 -0
- data/lib/eac_ruby_utils/patches/module/acts_as_immutable.rb +2 -2
- data/lib/eac_ruby_utils/patches/module/context.rb +2 -2
- data/lib/eac_ruby_utils/patches/module/immutable.rb +2 -2
- data/lib/eac_ruby_utils/patches/module/listable.rb +2 -2
- data/lib/eac_ruby_utils/patches/module/patch_self.rb +9 -0
- data/lib/eac_ruby_utils/patches/module/simple_cache.rb +2 -2
- data/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +0 -1
- data/lib/eac_ruby_utils/root_module_setup.rb +58 -2
- data/lib/eac_ruby_utils/rspec/default_setup.rb +12 -9
- data/lib/eac_ruby_utils/rspec.rb +2 -2
- data/lib/eac_ruby_utils/version.rb +1 -1
- data/lib/eac_ruby_utils.rb +7 -1
- metadata +12 -4
- data/lib/eac_ruby_utils/patch.rb +0 -11
- data/lib/eac_ruby_utils/patches/module/patch.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6fa9ca21dfcc4833795698cd71fe64c049739f6621bc4cc9e92f9617c820b56
|
4
|
+
data.tar.gz: 5f952359cdc1e9a8dc648ecc5b4f1d9401868ad9a08657eeec8d510850ed89dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f92a99f7e5f4746d3f7bc761e6d1977dd50920924e09676ac3d10298a3197cce9f7e1fc923e311058b8efee8468681bf6643d65cf8b70078a55d5308e3ef3627
|
7
|
+
data.tar.gz: e2304ee62e742a30c48bff94f9db979d6c2ae609e1db33cfc1843b66891e2406a0ee41e24ab4ecb19ae2a211268c168262c5cb7bd713e1eef2756b9b445d52e6
|
@@ -1,28 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/patches/module/common_concern'
|
4
|
+
|
3
5
|
module EacRubyUtils
|
4
6
|
module Fs
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
module Extname
|
8
|
+
common_concern
|
9
|
+
class_methods do
|
10
|
+
# A [File.extname] which find multiple extensions (Ex.: .tar.gz).
|
11
|
+
def extname(path, limit = -1)
|
12
|
+
recursive_extension(::File.basename(path), limit)
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
# Shortcut to +extname(2)+.
|
16
|
+
def extname2(path)
|
17
|
+
extname(path, 2)
|
18
|
+
end
|
15
19
|
|
16
|
-
|
20
|
+
private
|
17
21
|
|
18
|
-
|
19
|
-
|
22
|
+
def recursive_extension(basename, limit)
|
23
|
+
return '' if limit.zero?
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
m = /\A(.+)(\.[a-z][a-z0-9]*)\z/i.match(basename)
|
26
|
+
if m
|
27
|
+
"#{recursive_extension(m[1], limit - 1)}#{m[2]}"
|
28
|
+
else
|
29
|
+
''
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end
|
data/lib/eac_ruby_utils/fs.rb
CHANGED
@@ -4,7 +4,10 @@ require 'eac_ruby_utils/regexp_parser'
|
|
4
4
|
|
5
5
|
module EacRubyUtils
|
6
6
|
class ObjectsTable
|
7
|
-
BY_PARSER = ::EacRubyUtils::RegexpParser.new(/\Aby_(
|
7
|
+
BY_PARSER = ::EacRubyUtils::RegexpParser.new(/\Aby_([^!\?]+)(!)?\z/) do |m|
|
8
|
+
BY_PARSER_PARSED_STRUCT.new(m[1], "by_attribute#{m[2].present? ? '!' : ''}")
|
9
|
+
end
|
10
|
+
BY_PARSER_PARSED_STRUCT = ::Struct.new(:attribute, :method_name)
|
8
11
|
|
9
12
|
common_constructor :objects, default: [[]]
|
10
13
|
|
@@ -28,8 +31,8 @@ module EacRubyUtils
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def method_missing(method_name, *arguments, &block)
|
31
|
-
if (
|
32
|
-
return
|
34
|
+
if (parsed = BY_PARSER.parse(method_name))
|
35
|
+
return send(parsed.method_name, parsed.attribute, *arguments, &block)
|
33
36
|
end
|
34
37
|
|
35
38
|
super
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/common_concern'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module PatchModule
|
7
|
+
common_concern
|
8
|
+
|
9
|
+
class_methods do
|
10
|
+
def patch_module(target, patch)
|
11
|
+
return if target.included_modules.include?(patch)
|
12
|
+
|
13
|
+
target.send(:include, patch)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patch_module'
|
4
4
|
require 'eac_ruby_utils/settings_provider'
|
5
5
|
|
6
6
|
class Class
|
7
7
|
def enable_settings_provider
|
8
|
-
::EacRubyUtils.
|
8
|
+
::EacRubyUtils.patch_module(self, ::EacRubyUtils::SettingsProvider)
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patch_module'
|
4
4
|
require 'eac_ruby_utils/acts_as_immutable'
|
5
5
|
|
6
6
|
class Module
|
7
7
|
def acts_as_immutable
|
8
|
-
::EacRubyUtils.
|
8
|
+
::EacRubyUtils.patch_module(self, ::EacRubyUtils::ActsAsImmutable)
|
9
9
|
end
|
10
10
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patch_module'
|
4
4
|
require 'eac_ruby_utils/contextualizable'
|
5
5
|
|
6
6
|
class Module
|
7
7
|
# Patches module with [EacRubyUtils::Contextualizable].
|
8
8
|
def enable_context
|
9
|
-
::EacRubyUtils.
|
9
|
+
::EacRubyUtils.patch_module(self, ::EacRubyUtils::Contextualizable)
|
10
10
|
end
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patch_module'
|
4
4
|
require 'eac_ruby_utils/acts_as_immutable'
|
5
5
|
|
6
6
|
class Module
|
7
7
|
# @deprecated Use {#acts_as_immutable} instead.
|
8
8
|
def enable_immutable
|
9
|
-
::EacRubyUtils.
|
9
|
+
::EacRubyUtils.patch_module(self, ::EacRubyUtils::ActsAsImmutable)
|
10
10
|
end
|
11
11
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patch_module'
|
4
4
|
require 'eac_ruby_utils/listable'
|
5
5
|
|
6
6
|
class Module
|
7
7
|
def enable_listable
|
8
|
-
::EacRubyUtils.
|
8
|
+
::EacRubyUtils.patch_module(self, ::EacRubyUtils::Listable)
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
3
|
+
require 'eac_ruby_utils/patch_module'
|
4
4
|
require 'eac_ruby_utils/simple_cache'
|
5
5
|
|
6
6
|
class Module
|
7
7
|
def enable_simple_cache
|
8
|
-
::EacRubyUtils.
|
8
|
+
::EacRubyUtils.patch_module(self, ::EacRubyUtils::SimpleCache)
|
9
9
|
end
|
10
10
|
end
|
@@ -1,16 +1,72 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/patches/pathname'
|
4
|
+
require 'eac_ruby_utils/patches/object/to_pathname'
|
3
5
|
require 'zeitwerk'
|
4
6
|
|
5
7
|
module EacRubyUtils
|
6
8
|
class RootModuleSetup
|
7
9
|
class << self
|
8
|
-
|
10
|
+
# @param root_module_file [String]
|
11
|
+
def perform(root_module_file, &block)
|
12
|
+
new(root_module_file, &block).perform
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
16
|
+
attr_reader :block, :root_module_file
|
17
|
+
|
18
|
+
# @param root_module_file [String]
|
19
|
+
def initialize(root_module_file, &block)
|
20
|
+
self.root_module_file = root_module_file
|
21
|
+
self.block = block
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param path [String] Relative path to root module's directory.
|
25
|
+
def ignore(path)
|
26
|
+
count_before = loader.send(:ignored_paths).count
|
27
|
+
target_path = path.to_pathname.basename_sub { |b| "#{b.basename('.*')}.rb" }
|
28
|
+
.expand_path(root_module_directory)
|
29
|
+
result = loader.ignore target_path
|
30
|
+
return result if result.count > count_before
|
31
|
+
|
32
|
+
raise ::ArgumentError, [
|
33
|
+
"Trying to ignore path \"#{path}\" did not increase the ignored paths.",
|
34
|
+
"Argument path: \"#{path}\"", "Target path: \"#{target_path}\"", "Ignored paths: #{result}"
|
35
|
+
].join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [void]
|
11
39
|
def perform
|
12
|
-
|
40
|
+
perform_block
|
41
|
+
perform_zeitwerk
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [String]
|
45
|
+
def root_module_directory
|
46
|
+
::File.expand_path(::File.basename(root_module_file, '.*'),
|
47
|
+
::File.dirname(root_module_file))
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
attr_writer :block, :root_module_file
|
53
|
+
|
54
|
+
def perform_block
|
55
|
+
instance_eval(&block) if block
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [void]
|
59
|
+
def perform_zeitwerk
|
13
60
|
loader.setup
|
14
61
|
end
|
62
|
+
|
63
|
+
# @return [Zeitwerk::GemLoader]
|
64
|
+
def loader
|
65
|
+
@loader ||= ::Zeitwerk::Registry.loader_for_gem(
|
66
|
+
root_module_file,
|
67
|
+
namespace: Object,
|
68
|
+
warn_on_extra_files: true
|
69
|
+
)
|
70
|
+
end
|
15
71
|
end
|
16
72
|
end
|
@@ -4,16 +4,19 @@ require 'eac_ruby_utils/rspec/setup_manager'
|
|
4
4
|
|
5
5
|
module EacRubyUtils
|
6
6
|
module Rspec
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
|
12
|
-
|
7
|
+
module DefaultSetup
|
8
|
+
common_concern
|
9
|
+
class_methods do
|
10
|
+
# @return [EacRubyUtils::Rspec::SetupManager]
|
11
|
+
def default_setup
|
12
|
+
@default_setup ||
|
13
|
+
raise("Default instance was not set. Use #{self.class.name}.default_setup_create")
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
# @return [EacRubyUtils::Rspec::SetupManager]
|
17
|
+
def default_setup_create(app_root_path, rspec_config = nil)
|
18
|
+
@default_setup = ::EacRubyUtils::Rspec::SetupManager.create(app_root_path, rspec_config)
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
data/lib/eac_ruby_utils/rspec.rb
CHANGED
data/lib/eac_ruby_utils.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/root_module_setup'
|
4
|
-
EacRubyUtils::RootModuleSetup.perform
|
4
|
+
EacRubyUtils::RootModuleSetup.perform __FILE__ do
|
5
|
+
ignore 'core_ext'
|
6
|
+
ignore 'locales/from_all_gems'
|
7
|
+
ignore 'patches'
|
8
|
+
ignore 'ruby/on_clean_environment'
|
9
|
+
end
|
5
10
|
|
6
11
|
module EacRubyUtils
|
12
|
+
include ::EacRubyUtils::PatchModule
|
7
13
|
end
|
8
14
|
|
9
15
|
require 'eac_ruby_utils/core_ext'
|
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.126.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-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -139,6 +139,9 @@ dependencies:
|
|
139
139
|
- - "~>"
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0.11'
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.11.1
|
142
145
|
type: :development
|
143
146
|
prerelease: false
|
144
147
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -146,6 +149,9 @@ dependencies:
|
|
146
149
|
- - "~>"
|
147
150
|
- !ruby/object:Gem::Version
|
148
151
|
version: '0.11'
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.11.1
|
149
155
|
description:
|
150
156
|
email:
|
151
157
|
executables: []
|
@@ -244,7 +250,7 @@ files:
|
|
244
250
|
- lib/eac_ruby_utils/module_ancestors_variable/set.rb
|
245
251
|
- lib/eac_ruby_utils/objects_table.rb
|
246
252
|
- lib/eac_ruby_utils/options_consumer.rb
|
247
|
-
- lib/eac_ruby_utils/
|
253
|
+
- lib/eac_ruby_utils/patch_module.rb
|
248
254
|
- lib/eac_ruby_utils/patches.rb
|
249
255
|
- lib/eac_ruby_utils/patches/addressable.rb
|
250
256
|
- lib/eac_ruby_utils/patches/addressable/uri.rb
|
@@ -266,6 +272,8 @@ files:
|
|
266
272
|
- lib/eac_ruby_utils/patches/hash/options_consumer.rb
|
267
273
|
- lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
|
268
274
|
- lib/eac_ruby_utils/patches/hash/to_struct.rb
|
275
|
+
- lib/eac_ruby_utils/patches/integer.rb
|
276
|
+
- lib/eac_ruby_utils/patches/integer/rjust_zero.rb
|
269
277
|
- lib/eac_ruby_utils/patches/kernel.rb
|
270
278
|
- lib/eac_ruby_utils/patches/kernel/ibr.rb
|
271
279
|
- lib/eac_ruby_utils/patches/kernel/nyi.rb
|
@@ -281,7 +289,7 @@ files:
|
|
281
289
|
- lib/eac_ruby_utils/patches/module/immutable.rb
|
282
290
|
- lib/eac_ruby_utils/patches/module/listable.rb
|
283
291
|
- lib/eac_ruby_utils/patches/module/module_parent.rb
|
284
|
-
- lib/eac_ruby_utils/patches/module/
|
292
|
+
- lib/eac_ruby_utils/patches/module/patch_self.rb
|
285
293
|
- lib/eac_ruby_utils/patches/module/require_sub.rb
|
286
294
|
- lib/eac_ruby_utils/patches/module/simple_cache.rb
|
287
295
|
- lib/eac_ruby_utils/patches/module/speaker.rb
|
data/lib/eac_ruby_utils/patch.rb
DELETED