eac_ruby_utils 0.76.0 → 0.79.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/abstract_methods.rb +7 -0
- data/lib/eac_ruby_utils/core_ext.rb +1 -0
- data/lib/eac_ruby_utils/gems_registry/gem.rb +4 -0
- data/lib/eac_ruby_utils/gems_registry.rb +1 -1
- data/lib/eac_ruby_utils/patches/class/abstract.rb +9 -0
- data/lib/eac_ruby_utils/patches/class/self_included_modules.rb +7 -0
- data/lib/eac_ruby_utils/patches/module/i18n_translate.rb +32 -0
- data/lib/eac_ruby_utils/patches/object/call_if_proc.rb +11 -0
- data/lib/eac_ruby_utils/patches/object/i18n_translate.rb +13 -0
- data/lib/eac_ruby_utils/speaker/receiver.rb +10 -10
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +7 -5
- data/lib/eac_ruby_utils/fs/traversable.rb +0 -47
- data/lib/eac_ruby_utils/fs/traverser.rb +0 -72
- data/lib/eac_ruby_utils/on_clean_ruby_environment.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e172525643a9ed06ab4af7d0e35f66eecb49c363d368abeabde1b9ecbff8a686
|
4
|
+
data.tar.gz: ecdf6f1fd26f286a0a71b74f2ba345cbeeb385017ea41b6475a09d2c42aeb54e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cb0d8299f65375a594790f37c06b126bd57e37f48ea30575c200fed283edad2f7e7ed4e6cb7a3de43a47fbb76cc775fd5955289f1287cc4a213cff1b3ade9db
|
7
|
+
data.tar.gz: 1aeea157e9b2c593421b498f6aca325a26d45e93e61c3f46bb344a6edc0805915e3b89bf8e9aaa3daeec7d148fb387d9e1b0e44f670d0add7bc8aad4263b6090
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/patches/class/self_included_modules'
|
3
4
|
require 'eac_ruby_utils/patches/module/common_concern'
|
4
5
|
|
5
6
|
module EacRubyUtils
|
@@ -27,6 +28,12 @@ module EacRubyUtils
|
|
27
28
|
module AbstractMethods
|
28
29
|
common_concern
|
29
30
|
|
31
|
+
class << self
|
32
|
+
def abstract?(a_class)
|
33
|
+
a_class.self_included_modules.include?(::EacRubyUtils::AbstractMethods)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
30
37
|
module ClassMethods
|
31
38
|
def abstract_methods(*methods_names)
|
32
39
|
methods_names.each do |method_name|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
require 'i18n'
|
5
|
+
|
6
|
+
class Module
|
7
|
+
TRANSLATE_LOCALE_KEY = :__locale
|
8
|
+
|
9
|
+
def i18n_translate(entry_suffix, values = {})
|
10
|
+
on_i18n_locale(values.delete(TRANSLATE_LOCALE_KEY)) do
|
11
|
+
::I18n.translate(i18n_translate_entry_full(entry_suffix), values)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def i18n_translate_entry_full(entry_suffix)
|
16
|
+
"#{i18n_translate_entry_self_prefix}.#{entry_suffix}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def i18n_translate_entry_self_prefix
|
20
|
+
name.underscore.gsub('/', '.')
|
21
|
+
end
|
22
|
+
|
23
|
+
def on_i18n_locale(locale)
|
24
|
+
old_locale = ::I18n.locale
|
25
|
+
begin
|
26
|
+
::I18n.locale = locale
|
27
|
+
yield
|
28
|
+
ensure
|
29
|
+
::I18n.locale = old_locale
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/i18n_translate'
|
4
|
+
|
5
|
+
class Object
|
6
|
+
def i18n_translate(entry_suffix, values = {})
|
7
|
+
self.class.i18n_translate(entry_suffix, values)
|
8
|
+
end
|
9
|
+
|
10
|
+
def on_i18n_locale(locale)
|
11
|
+
self.class.on_i18n_locale(locale)
|
12
|
+
end
|
13
|
+
end
|
@@ -8,7 +8,7 @@ module EacRubyUtils
|
|
8
8
|
extend ::EacRubyUtils::AbstractMethods
|
9
9
|
|
10
10
|
def error(_string)
|
11
|
-
raise_abstract_method(
|
11
|
+
raise_abstract_method(__method__)
|
12
12
|
end
|
13
13
|
|
14
14
|
def fatal_error(string)
|
@@ -18,39 +18,39 @@ module EacRubyUtils
|
|
18
18
|
|
19
19
|
# @see EacRubyUtils::Speaker::Sender.input
|
20
20
|
def input(_question, _options = {})
|
21
|
-
raise_abstract_method(
|
21
|
+
raise_abstract_method(__method__)
|
22
22
|
end
|
23
23
|
|
24
24
|
def info(_string)
|
25
|
-
raise_abstract_method(
|
25
|
+
raise_abstract_method(__method__)
|
26
26
|
end
|
27
27
|
|
28
28
|
def infom(_string)
|
29
|
-
raise_abstract_method(
|
29
|
+
raise_abstract_method(__method__)
|
30
30
|
end
|
31
31
|
|
32
32
|
def infov(*_args)
|
33
|
-
raise_abstract_method(
|
33
|
+
raise_abstract_method(__method__)
|
34
34
|
end
|
35
35
|
|
36
36
|
def out(_string = '')
|
37
|
-
raise_abstract_method(
|
37
|
+
raise_abstract_method(__method__)
|
38
38
|
end
|
39
39
|
|
40
40
|
def puts(_string = '')
|
41
|
-
raise_abstract_method(
|
41
|
+
raise_abstract_method(__method__)
|
42
42
|
end
|
43
43
|
|
44
44
|
def success(_string)
|
45
|
-
raise_abstract_method(
|
45
|
+
raise_abstract_method(__method__)
|
46
46
|
end
|
47
47
|
|
48
48
|
def title(_string)
|
49
|
-
raise_abstract_method(
|
49
|
+
raise_abstract_method(__method__)
|
50
50
|
end
|
51
51
|
|
52
52
|
def warn(_string)
|
53
|
-
raise_abstract_method(
|
53
|
+
raise_abstract_method(__method__)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
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.79.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: 2021-
|
11
|
+
date: 2021-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -134,8 +134,6 @@ files:
|
|
134
134
|
- lib/eac_ruby_utils/fs/temp.rb
|
135
135
|
- lib/eac_ruby_utils/fs/temp/directory.rb
|
136
136
|
- lib/eac_ruby_utils/fs/temp/file.rb
|
137
|
-
- lib/eac_ruby_utils/fs/traversable.rb
|
138
|
-
- lib/eac_ruby_utils/fs/traverser.rb
|
139
137
|
- lib/eac_ruby_utils/gems_registry.rb
|
140
138
|
- lib/eac_ruby_utils/gems_registry/gem.rb
|
141
139
|
- lib/eac_ruby_utils/immutable.rb
|
@@ -157,12 +155,13 @@ files:
|
|
157
155
|
- lib/eac_ruby_utils/listable/symbol_list.rb
|
158
156
|
- lib/eac_ruby_utils/listable/value.rb
|
159
157
|
- lib/eac_ruby_utils/local_time_zone.rb
|
160
|
-
- lib/eac_ruby_utils/on_clean_ruby_environment.rb
|
161
158
|
- lib/eac_ruby_utils/options_consumer.rb
|
162
159
|
- lib/eac_ruby_utils/patch.rb
|
163
160
|
- lib/eac_ruby_utils/patches.rb
|
164
161
|
- lib/eac_ruby_utils/patches/class.rb
|
162
|
+
- lib/eac_ruby_utils/patches/class/abstract.rb
|
165
163
|
- lib/eac_ruby_utils/patches/class/common_constructor.rb
|
164
|
+
- lib/eac_ruby_utils/patches/class/self_included_modules.rb
|
166
165
|
- lib/eac_ruby_utils/patches/class/settings_provider.rb
|
167
166
|
- lib/eac_ruby_utils/patches/enumerable.rb
|
168
167
|
- lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
|
@@ -178,6 +177,7 @@ files:
|
|
178
177
|
- lib/eac_ruby_utils/patches/module/abstract_methods.rb
|
179
178
|
- lib/eac_ruby_utils/patches/module/common_concern.rb
|
180
179
|
- lib/eac_ruby_utils/patches/module/context.rb
|
180
|
+
- lib/eac_ruby_utils/patches/module/i18n_translate.rb
|
181
181
|
- lib/eac_ruby_utils/patches/module/immutable.rb
|
182
182
|
- lib/eac_ruby_utils/patches/module/listable.rb
|
183
183
|
- lib/eac_ruby_utils/patches/module/patch.rb
|
@@ -186,8 +186,10 @@ files:
|
|
186
186
|
- lib/eac_ruby_utils/patches/module/speaker.rb
|
187
187
|
- lib/eac_ruby_utils/patches/object.rb
|
188
188
|
- lib/eac_ruby_utils/patches/object/asserts.rb
|
189
|
+
- lib/eac_ruby_utils/patches/object/call_if_proc.rb
|
189
190
|
- lib/eac_ruby_utils/patches/object/compact.rb
|
190
191
|
- lib/eac_ruby_utils/patches/object/debug.rb
|
192
|
+
- lib/eac_ruby_utils/patches/object/i18n_translate.rb
|
191
193
|
- lib/eac_ruby_utils/patches/object/if_nil.rb
|
192
194
|
- lib/eac_ruby_utils/patches/object/if_present.rb
|
193
195
|
- lib/eac_ruby_utils/patches/object/if_respond.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/fs/traverser'
|
4
|
-
|
5
|
-
module EacRubyUtils
|
6
|
-
module Fs
|
7
|
-
module Traversable
|
8
|
-
PROP_METHOD_PREFIX = 'traverser_'
|
9
|
-
BOOLEAN_PROPS = %i[hidden_directories recursive sort].freeze
|
10
|
-
PATH_PROPS = %i[check_directory check_file].freeze
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def prop_method_name(prop)
|
14
|
-
"#{PROP_METHOD_PREFIX}#{prop}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
PATH_PROPS.each do |method|
|
19
|
-
define_method(::EacRubyUtils::Fs::Traversable.prop_method_name(method)) do |_path|
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
BOOLEAN_PROPS.each do |method|
|
25
|
-
define_method(::EacRubyUtils::Fs::Traversable.prop_method_name(method)) do
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
define_method("#{::EacRubyUtils::Fs::Traversable.prop_method_name(method)}?") do
|
30
|
-
send(method_name)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def traverser_check_path(path)
|
35
|
-
traverser_new.check_path(path)
|
36
|
-
end
|
37
|
-
|
38
|
-
def traverser_new
|
39
|
-
r = ::EacRubyUtils::Fs::Traverser.new
|
40
|
-
(BOOLEAN_PROPS + PATH_PROPS).each do |prop|
|
41
|
-
r.send("#{prop}=", method(::EacRubyUtils::Fs::Traversable.prop_method_name(prop)))
|
42
|
-
end
|
43
|
-
r
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module EacRubyUtils
|
4
|
-
module Fs
|
5
|
-
class Traverser
|
6
|
-
attr_accessor :check_directory, :check_file, :recursive, :hidden_directories, :sort
|
7
|
-
|
8
|
-
def check_path(path)
|
9
|
-
path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
|
10
|
-
internal_check_path(path, 0)
|
11
|
-
end
|
12
|
-
|
13
|
-
def hidden_directories?
|
14
|
-
boolean_value(hidden_directories)
|
15
|
-
end
|
16
|
-
|
17
|
-
def recursive?
|
18
|
-
boolean_value(recursive)
|
19
|
-
end
|
20
|
-
|
21
|
-
def sort?
|
22
|
-
boolean_value(sort)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def boolean_value(source_value)
|
28
|
-
source_value = source_value.call if source_value.respond_to?(:call)
|
29
|
-
source_value ? true : false
|
30
|
-
end
|
31
|
-
|
32
|
-
def each_child(dir, &block)
|
33
|
-
if sort?
|
34
|
-
dir.each_child.sort_by { |p| [p.to_s] }.each(&block)
|
35
|
-
else
|
36
|
-
dir.each_child(&block)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def process_directory?(level)
|
41
|
-
level.zero? || recursive?
|
42
|
-
end
|
43
|
-
|
44
|
-
def inner_check_directory(dir, level)
|
45
|
-
return unless process_directory?(level)
|
46
|
-
|
47
|
-
user_check_directory(dir)
|
48
|
-
each_child(dir) do |e|
|
49
|
-
next unless !e.basename.to_s.start_with?('.') || hidden_directories?
|
50
|
-
|
51
|
-
internal_check_path(e, level + 1)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def internal_check_path(path, level)
|
56
|
-
if path.file?
|
57
|
-
user_check_file(path)
|
58
|
-
elsif path.directory?
|
59
|
-
inner_check_directory(path, level)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def user_check_file(path)
|
64
|
-
check_file&.call(path)
|
65
|
-
end
|
66
|
-
|
67
|
-
def user_check_directory(path)
|
68
|
-
check_directory&.call(path)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/ruby/on_clean_environment'
|
4
|
-
|
5
|
-
module EacRubyUtils
|
6
|
-
class << self
|
7
|
-
# <b>DEPRECATED:</b> Please use <tt>EacRubyUtils::Ruby.on_clean_environment</tt> instead.
|
8
|
-
def on_clean_ruby_environment(*args, &block)
|
9
|
-
::EacRubyUtils::Ruby.on_clean_environment(*args, &block)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|