eac_ruby_utils 0.75.0 → 0.78.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68abbc7acfbe86b2e24bb721047ef23e0d99c7444c9d97e107db9adbb92adca8
4
- data.tar.gz: af3d13481855122ae753eaaf0ed1dec94ec620524d03cf358592573405017399
3
+ metadata.gz: 04265a77c385833952f4e144e1384702799030c28add480973ac925d1042bde7
4
+ data.tar.gz: bdb7856467fd1d77f75a468c2a2c3c292231a3387c40281da5325d098eda76cd
5
5
  SHA512:
6
- metadata.gz: '0041989ecacd0b99a2a699fd2fbbceebf22f002360c8f4ef1b622bce4975d230e42b8912b4236d3d653b55a9864c00873be0222ac33ecf8b1efc588880c4bb23'
7
- data.tar.gz: 0a030761ca0ae9030bd68421b8c6e1cbd883ffcae51e947241821deef8c887fcf99819ef2fc7c3f2912c962b81c7c35271950934c87553839923a492af698e8b
6
+ metadata.gz: 70556b9064c0cf84e202e3f65c2f172c60e79304263abe596a1d7ec7a46753f4f58f81565ebeeaa644035f5fbb45f12cb2a5158a3084cd3fac634a0448c1953d
7
+ data.tar.gz: 9c664e92bcefc75aac89e85016c8b8007bd14a061e46409b5c4b20cb36b8a80707046cb16302a8b1b26bd154cbb28c09027599e7494839abc707b6fe531a65f3
@@ -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|
@@ -3,3 +3,4 @@
3
3
  require 'eac_ruby_utils/patches'
4
4
  require 'active_support/dependencies/autoload'
5
5
  require 'active_support/core_ext'
6
+ require 'active_support/json'
@@ -57,6 +57,10 @@ module EacRubyUtils
57
57
  gemspec.name.gsub('-', '/') + '/' + registry.module_suffix.underscore
58
58
  end
59
59
 
60
+ def to_s
61
+ "#{self.class.name}[#{gemspec.name}]"
62
+ end
63
+
60
64
  private
61
65
 
62
66
  def dependencies_uncached
@@ -21,7 +21,7 @@ module EacRubyUtils
21
21
 
22
22
  # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
23
23
  def registered
24
- @registered ||= all_gems.select(&:found?)
24
+ @registered ||= all_gems.select(&:found?).sort
25
25
  end
26
26
 
27
27
  private
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/abstract_methods'
4
+
5
+ class Class
6
+ def abstract?
7
+ ::EacRubyUtils::AbstractMethods.abstract?(self)
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Class
4
+ def self_included_modules
5
+ ancestors.take_while { |a| a != superclass }.select { |ancestor| ancestor.instance_of?(Module) }
6
+ end
7
+ end
@@ -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,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/compact'
4
+
5
+ class Object
6
+ # If +self+ is a Proc, return the value of +.call+. If not, return +self+.
7
+ # @return [Object]
8
+ def call_if_proc
9
+ is_a?(::Proc) ? call : self
10
+ end
11
+ 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(__FILE__)
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(__FILE__)
21
+ raise_abstract_method(__method__)
22
22
  end
23
23
 
24
24
  def info(_string)
25
- raise_abstract_method(__FILE__)
25
+ raise_abstract_method(__method__)
26
26
  end
27
27
 
28
28
  def infom(_string)
29
- raise_abstract_method(__FILE__)
29
+ raise_abstract_method(__method__)
30
30
  end
31
31
 
32
32
  def infov(*_args)
33
- raise_abstract_method(__FILE__)
33
+ raise_abstract_method(__method__)
34
34
  end
35
35
 
36
36
  def out(_string = '')
37
- raise_abstract_method(__FILE__)
37
+ raise_abstract_method(__method__)
38
38
  end
39
39
 
40
40
  def puts(_string = '')
41
- raise_abstract_method(__FILE__)
41
+ raise_abstract_method(__method__)
42
42
  end
43
43
 
44
44
  def success(_string)
45
- raise_abstract_method(__FILE__)
45
+ raise_abstract_method(__method__)
46
46
  end
47
47
 
48
48
  def title(_string)
49
- raise_abstract_method(__FILE__)
49
+ raise_abstract_method(__method__)
50
50
  end
51
51
 
52
52
  def warn(_string)
53
- raise_abstract_method(__FILE__)
53
+ raise_abstract_method(__method__)
54
54
  end
55
55
  end
56
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.75.0'
4
+ VERSION = '0.78.0'
5
5
  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.75.0
4
+ version: 0.78.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-09-21 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -127,7 +127,6 @@ files:
127
127
  - lib/eac_ruby_utils/envs/ssh_env/identity_file.rb
128
128
  - lib/eac_ruby_utils/envs/ssh_env/quiet.rb
129
129
  - lib/eac_ruby_utils/envs/ssh_env/terminal.rb
130
- - lib/eac_ruby_utils/filesystem_cache.rb
131
130
  - lib/eac_ruby_utils/fs.rb
132
131
  - lib/eac_ruby_utils/fs/clearable_directory.rb
133
132
  - lib/eac_ruby_utils/fs/extname.rb
@@ -137,7 +136,6 @@ files:
137
136
  - lib/eac_ruby_utils/fs/temp/file.rb
138
137
  - lib/eac_ruby_utils/fs/traversable.rb
139
138
  - lib/eac_ruby_utils/fs/traverser.rb
140
- - lib/eac_ruby_utils/fs_cache.rb
141
139
  - lib/eac_ruby_utils/gems_registry.rb
142
140
  - lib/eac_ruby_utils/gems_registry/gem.rb
143
141
  - lib/eac_ruby_utils/immutable.rb
@@ -159,12 +157,13 @@ files:
159
157
  - lib/eac_ruby_utils/listable/symbol_list.rb
160
158
  - lib/eac_ruby_utils/listable/value.rb
161
159
  - lib/eac_ruby_utils/local_time_zone.rb
162
- - lib/eac_ruby_utils/on_clean_ruby_environment.rb
163
160
  - lib/eac_ruby_utils/options_consumer.rb
164
161
  - lib/eac_ruby_utils/patch.rb
165
162
  - lib/eac_ruby_utils/patches.rb
166
163
  - lib/eac_ruby_utils/patches/class.rb
164
+ - lib/eac_ruby_utils/patches/class/abstract.rb
167
165
  - lib/eac_ruby_utils/patches/class/common_constructor.rb
166
+ - lib/eac_ruby_utils/patches/class/self_included_modules.rb
168
167
  - lib/eac_ruby_utils/patches/class/settings_provider.rb
169
168
  - lib/eac_ruby_utils/patches/enumerable.rb
170
169
  - lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
@@ -180,6 +179,7 @@ files:
180
179
  - lib/eac_ruby_utils/patches/module/abstract_methods.rb
181
180
  - lib/eac_ruby_utils/patches/module/common_concern.rb
182
181
  - lib/eac_ruby_utils/patches/module/context.rb
182
+ - lib/eac_ruby_utils/patches/module/i18n_translate.rb
183
183
  - lib/eac_ruby_utils/patches/module/immutable.rb
184
184
  - lib/eac_ruby_utils/patches/module/listable.rb
185
185
  - lib/eac_ruby_utils/patches/module/patch.rb
@@ -188,8 +188,10 @@ files:
188
188
  - lib/eac_ruby_utils/patches/module/speaker.rb
189
189
  - lib/eac_ruby_utils/patches/object.rb
190
190
  - lib/eac_ruby_utils/patches/object/asserts.rb
191
+ - lib/eac_ruby_utils/patches/object/call_if_proc.rb
191
192
  - lib/eac_ruby_utils/patches/object/compact.rb
192
193
  - lib/eac_ruby_utils/patches/object/debug.rb
194
+ - lib/eac_ruby_utils/patches/object/i18n_translate.rb
193
195
  - lib/eac_ruby_utils/patches/object/if_nil.rb
194
196
  - lib/eac_ruby_utils/patches/object/if_present.rb
195
197
  - lib/eac_ruby_utils/patches/object/if_respond.rb
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacRubyUtils
4
- class FilesystemCache
5
- CONTENT_FILE_NAME = '__content__'
6
-
7
- attr_reader :path
8
-
9
- def initialize(*path_parts)
10
- raise ArgumentError, "\"#{path_parts}\" is empty" if path_parts.empty?
11
-
12
- @path = ::File.expand_path(::File.join(*path_parts.map(&:to_s)))
13
- end
14
-
15
- def clear
16
- return unless cached?
17
-
18
- ::File.unlink(content_path)
19
- end
20
-
21
- def read
22
- return nil unless cached?
23
-
24
- ::File.read(content_path)
25
- end
26
-
27
- def read_or_cache
28
- write(yield) unless cached?
29
-
30
- read
31
- end
32
-
33
- def write(value)
34
- assert_directory_on_path
35
- ::File.write(content_path, value)
36
- value
37
- end
38
-
39
- def child(*child_path_parts)
40
- self.class.new(path, *child_path_parts)
41
- end
42
-
43
- def cached?
44
- ::File.exist?(content_path)
45
- end
46
-
47
- def content_path
48
- ::File.join(path, CONTENT_FILE_NAME)
49
- end
50
-
51
- private
52
-
53
- def assert_directory_on_path
54
- raise "#{path} is a file" if ::File.file?(path)
55
-
56
- ::FileUtils.mkdir_p(path)
57
- end
58
- end
59
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/filesystem_cache'
4
- require 'tmpdir'
5
-
6
- module EacRubyUtils
7
- class << self
8
- def fs_cache
9
- @fs_cache ||= ::EacRubyUtils::FilesystemCache.new(::Dir.tmpdir, 'eac_ruby_utils_fs_cache')
10
- end
11
- end
12
- 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