eac_ruby_utils 0.76.0 → 0.77.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/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 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e06edffaad46bc2ba5ca801c9ed8004c7d6073c8ef64caa3fd0327d8cc2076c
|
4
|
+
data.tar.gz: f40d57df68294853df723ca77f44e2751a9d20b05cabba21e6c58cc80238bbce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0fc702764d86de58bfd0f4e0df5ed11ebf9e91eed6261ba618a29b91a16129ab6637988338a27aa562ac46f18d41558ac8c6778db379a253efcca50bcf3cbf9
|
7
|
+
data.tar.gz: f58367bb2cc218de71ed3d166e466f52d5f285d59880bb55077cc84ba06515a916855582d284519c736ebd70a29522c4602d6411c78e7f83670390e64e18fe8f
|
@@ -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.77.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-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -162,7 +162,9 @@ files:
|
|
162
162
|
- lib/eac_ruby_utils/patch.rb
|
163
163
|
- lib/eac_ruby_utils/patches.rb
|
164
164
|
- lib/eac_ruby_utils/patches/class.rb
|
165
|
+
- lib/eac_ruby_utils/patches/class/abstract.rb
|
165
166
|
- lib/eac_ruby_utils/patches/class/common_constructor.rb
|
167
|
+
- lib/eac_ruby_utils/patches/class/self_included_modules.rb
|
166
168
|
- lib/eac_ruby_utils/patches/class/settings_provider.rb
|
167
169
|
- lib/eac_ruby_utils/patches/enumerable.rb
|
168
170
|
- lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
|
@@ -178,6 +180,7 @@ files:
|
|
178
180
|
- lib/eac_ruby_utils/patches/module/abstract_methods.rb
|
179
181
|
- lib/eac_ruby_utils/patches/module/common_concern.rb
|
180
182
|
- lib/eac_ruby_utils/patches/module/context.rb
|
183
|
+
- lib/eac_ruby_utils/patches/module/i18n_translate.rb
|
181
184
|
- lib/eac_ruby_utils/patches/module/immutable.rb
|
182
185
|
- lib/eac_ruby_utils/patches/module/listable.rb
|
183
186
|
- lib/eac_ruby_utils/patches/module/patch.rb
|
@@ -186,8 +189,10 @@ files:
|
|
186
189
|
- lib/eac_ruby_utils/patches/module/speaker.rb
|
187
190
|
- lib/eac_ruby_utils/patches/object.rb
|
188
191
|
- lib/eac_ruby_utils/patches/object/asserts.rb
|
192
|
+
- lib/eac_ruby_utils/patches/object/call_if_proc.rb
|
189
193
|
- lib/eac_ruby_utils/patches/object/compact.rb
|
190
194
|
- lib/eac_ruby_utils/patches/object/debug.rb
|
195
|
+
- lib/eac_ruby_utils/patches/object/i18n_translate.rb
|
191
196
|
- lib/eac_ruby_utils/patches/object/if_nil.rb
|
192
197
|
- lib/eac_ruby_utils/patches/object/if_present.rb
|
193
198
|
- lib/eac_ruby_utils/patches/object/if_respond.rb
|