eac_ruby_utils 0.124.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/contextualizable.rb +1 -3
- data/lib/eac_ruby_utils/custom_format.rb +1 -3
- data/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +1 -3
- 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 +41 -0
- 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/object/i18n_translate.rb +1 -3
- data/lib/eac_ruby_utils/patches/pathname/basename_noext.rb +0 -1
- data/lib/eac_ruby_utils/require_sub/base.rb +1 -0
- data/lib/eac_ruby_utils/root_module_setup.rb +72 -0
- 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 +11 -2
- metadata +36 -6
- 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
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/regexp_parser'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class ObjectsTable
|
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)
|
11
|
+
|
12
|
+
common_constructor :objects, default: [[]]
|
13
|
+
|
14
|
+
# @param name [String, Symbol]
|
15
|
+
# @param value [Object]
|
16
|
+
# @return [Object, nil]
|
17
|
+
def by_attribute(name, value)
|
18
|
+
objects.find { |e| e.send(name) == value }
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param name [String, Symbol]
|
22
|
+
# @param value [Object]
|
23
|
+
# @return [Object]
|
24
|
+
def by_attribute!(name, value)
|
25
|
+
by_attribute(name, value) ||
|
26
|
+
raise(::ArgumentError, "No item found with attribute #{name}=#{value}")
|
27
|
+
end
|
28
|
+
|
29
|
+
def respond_to_missing?(method_name, include_private = false)
|
30
|
+
super || BY_PARSER.parse?(method_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(method_name, *arguments, &block)
|
34
|
+
if (parsed = BY_PARSER.parse(method_name))
|
35
|
+
return send(parsed.method_name, parsed.attribute, *arguments, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -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
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/pathname'
|
4
|
+
require 'eac_ruby_utils/patches/object/to_pathname'
|
5
|
+
require 'zeitwerk'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
class RootModuleSetup
|
9
|
+
class << self
|
10
|
+
# @param root_module_file [String]
|
11
|
+
def perform(root_module_file, &block)
|
12
|
+
new(root_module_file, &block).perform
|
13
|
+
end
|
14
|
+
end
|
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]
|
39
|
+
def perform
|
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
|
60
|
+
loader.setup
|
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
|
71
|
+
end
|
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,6 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/root_module_setup'
|
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
|
10
|
+
|
3
11
|
module EacRubyUtils
|
4
|
-
|
5
|
-
::EacRubyUtils.require_sub __FILE__
|
12
|
+
include ::EacRubyUtils::PatchModule
|
6
13
|
end
|
14
|
+
|
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:
|
11
|
+
date: 2025-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -92,6 +92,26 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '4.2'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: zeitwerk
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.6'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.6.18
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.6'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 2.6.18
|
95
115
|
- !ruby/object:Gem::Dependency
|
96
116
|
name: avm-eac_ubuntu_base0
|
97
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,14 +138,20 @@ dependencies:
|
|
118
138
|
requirements:
|
119
139
|
- - "~>"
|
120
140
|
- !ruby/object:Gem::Version
|
121
|
-
version: '0.
|
141
|
+
version: '0.11'
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.11.1
|
122
145
|
type: :development
|
123
146
|
prerelease: false
|
124
147
|
version_requirements: !ruby/object:Gem::Requirement
|
125
148
|
requirements:
|
126
149
|
- - "~>"
|
127
150
|
- !ruby/object:Gem::Version
|
128
|
-
version: '0.
|
151
|
+
version: '0.11'
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.11.1
|
129
155
|
description:
|
130
156
|
email:
|
131
157
|
executables: []
|
@@ -222,8 +248,9 @@ files:
|
|
222
248
|
- lib/eac_ruby_utils/module_ancestors_variable/base.rb
|
223
249
|
- lib/eac_ruby_utils/module_ancestors_variable/hash.rb
|
224
250
|
- lib/eac_ruby_utils/module_ancestors_variable/set.rb
|
251
|
+
- lib/eac_ruby_utils/objects_table.rb
|
225
252
|
- lib/eac_ruby_utils/options_consumer.rb
|
226
|
-
- lib/eac_ruby_utils/
|
253
|
+
- lib/eac_ruby_utils/patch_module.rb
|
227
254
|
- lib/eac_ruby_utils/patches.rb
|
228
255
|
- lib/eac_ruby_utils/patches/addressable.rb
|
229
256
|
- lib/eac_ruby_utils/patches/addressable/uri.rb
|
@@ -245,6 +272,8 @@ files:
|
|
245
272
|
- lib/eac_ruby_utils/patches/hash/options_consumer.rb
|
246
273
|
- lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
|
247
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
|
248
277
|
- lib/eac_ruby_utils/patches/kernel.rb
|
249
278
|
- lib/eac_ruby_utils/patches/kernel/ibr.rb
|
250
279
|
- lib/eac_ruby_utils/patches/kernel/nyi.rb
|
@@ -260,7 +289,7 @@ files:
|
|
260
289
|
- lib/eac_ruby_utils/patches/module/immutable.rb
|
261
290
|
- lib/eac_ruby_utils/patches/module/listable.rb
|
262
291
|
- lib/eac_ruby_utils/patches/module/module_parent.rb
|
263
|
-
- lib/eac_ruby_utils/patches/module/
|
292
|
+
- lib/eac_ruby_utils/patches/module/patch_self.rb
|
264
293
|
- lib/eac_ruby_utils/patches/module/require_sub.rb
|
265
294
|
- lib/eac_ruby_utils/patches/module/simple_cache.rb
|
266
295
|
- lib/eac_ruby_utils/patches/module/speaker.rb
|
@@ -301,6 +330,7 @@ files:
|
|
301
330
|
- lib/eac_ruby_utils/require_sub.rb
|
302
331
|
- lib/eac_ruby_utils/require_sub/base.rb
|
303
332
|
- lib/eac_ruby_utils/require_sub/sub_file.rb
|
333
|
+
- lib/eac_ruby_utils/root_module_setup.rb
|
304
334
|
- lib/eac_ruby_utils/rspec.rb
|
305
335
|
- lib/eac_ruby_utils/rspec/default_setup.rb
|
306
336
|
- lib/eac_ruby_utils/rspec/setup.rb
|
data/lib/eac_ruby_utils/patch.rb
DELETED