eac_ruby_utils 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36ad6529aeb2cd18a50fdd7ee4af8be6e3cd7157d41ff48352e5bc82b32fefc9
4
- data.tar.gz: 32503898f9f75eebcd106a990ac11560b32ef0a6f6b2511e9a62e05bc0ce42e9
3
+ metadata.gz: b885c805971bcee518de5de56939c08616539d6855742c69e20f70dfd787c552
4
+ data.tar.gz: 6abd9b7bce1bd9eac4efee4966ffc4b177dea1ddc88e82e613125b79587a68c4
5
5
  SHA512:
6
- metadata.gz: b6e09038246c4300dc4c087cfbd8501f18e528bc988be179fd11ec7675a5dfa8ec0f04fb9e588265d46fa96fb76f5639b74eec4bb5e49f1f1b133213dfdd6841
7
- data.tar.gz: cde052825e985ffb6be03b9aadae9344edf612536a248cb1cb5a57df8dc1226fee5df2c20e497d3913ed3ad33e39ff907155799a0b7303b5edc4e6cec500117e
6
+ metadata.gz: b4600e778c91f1a038fe457e1afb61ac8a7aba5b23e8c77c166afe8b922c872cecffaa8850f6863eb5e11497fd45c84fcc287df4977e9dd0ddfe3e5dffb6a578
7
+ data.tar.gz: 1288c11637181bc9fd90cab0be1f9fcefcb9a16562d710676bdb022534835af5e200543df5af7d56f17e636b83f05758cd40d237eb5bf80b8e4f5833d652caec
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patches'
4
+ require 'active_support/dependencies/autoload'
5
+ require 'active_support/core_ext'
@@ -39,6 +39,19 @@ module EacRubyUtils
39
39
  raise "List value unkown: #{v} (Source: #{@lists.source}, Item: #{item})"
40
40
  end
41
41
 
42
+ def value_valid?(value)
43
+ values.include?(value)
44
+ end
45
+
46
+ def value_validate!(value, error_class = ::StandardError)
47
+ value_valid?(value) ||
48
+ raise(error_class, "Invalid value: \"#{value}\" (Valid: #{values_to_s})")
49
+ end
50
+
51
+ def values_to_s
52
+ values.map { |v| "\"#{v}\"" }.join(', ')
53
+ end
54
+
42
55
  private
43
56
 
44
57
  def class_i18n_key
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+ require 'eac_ruby_utils/console/speaker'
5
+
6
+ class Module
7
+ def enable_console_speaker
8
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::Console::Speaker)
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+ require 'eac_ruby_utils/listable'
5
+
6
+ class Module
7
+ def enable_listable
8
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::Listable)
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+
5
+ class Module
6
+ def patch(patch_module)
7
+ ::Eac::Ruby::Utils.patch(self, patch_module)
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+ require 'eac_ruby_utils/simple_cache'
5
+
6
+ class Module
7
+ def enable_simple_cache
8
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::SimpleCache)
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+
5
+ class Object
6
+ # @return +block.call(self)+ if +self+ is present, +default_value+ otherwise.
7
+ def if_present(default_value = nil)
8
+ return default_value unless present?
9
+ block_given? ? yield(self) : self
10
+ end
11
+ end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].each do |path|
4
- require path
5
- end
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -5,6 +5,7 @@ module EacRubyUtils
5
5
  require 'eac_ruby_utils/configs'
6
6
  require 'eac_ruby_utils/console'
7
7
  require 'eac_ruby_utils/contextualizable'
8
+ require 'eac_ruby_utils/core_ext'
8
9
  require 'eac_ruby_utils/envs'
9
10
  require 'eac_ruby_utils/listable'
10
11
  require 'eac_ruby_utils/options_consumer'
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.11.0
4
+ version: 0.12.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: 2019-08-26 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,6 +114,7 @@ files:
114
114
  - lib/eac_ruby_utils/console/speaker.rb
115
115
  - lib/eac_ruby_utils/console/speaker/list.rb
116
116
  - lib/eac_ruby_utils/contextualizable.rb
117
+ - lib/eac_ruby_utils/core_ext.rb
117
118
  - lib/eac_ruby_utils/envs.rb
118
119
  - lib/eac_ruby_utils/envs/base_env.rb
119
120
  - lib/eac_ruby_utils/envs/command.rb
@@ -135,8 +136,14 @@ files:
135
136
  - lib/eac_ruby_utils/patches/hash.rb
136
137
  - lib/eac_ruby_utils/patches/hash/options_consumer.rb
137
138
  - lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
139
+ - lib/eac_ruby_utils/patches/module.rb
140
+ - lib/eac_ruby_utils/patches/module/console_speaker.rb
141
+ - lib/eac_ruby_utils/patches/module/listable.rb
142
+ - lib/eac_ruby_utils/patches/module/patch.rb
143
+ - lib/eac_ruby_utils/patches/module/simple_cache.rb
138
144
  - lib/eac_ruby_utils/patches/object.rb
139
145
  - lib/eac_ruby_utils/patches/object/asserts.rb
146
+ - lib/eac_ruby_utils/patches/object/if_present.rb
140
147
  - lib/eac_ruby_utils/paths_hash.rb
141
148
  - lib/eac_ruby_utils/require_sub.rb
142
149
  - lib/eac_ruby_utils/simple_cache.rb