eac_ruby_utils 0.82.1 → 0.86.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: 6aadd4c1c181c8e7ff64e358edb5e34c37c7a203e8937897739256728fb2c1df
4
- data.tar.gz: b92a231502afe5c23930c88b74eef1b122c4dc4e1c5aa2d5fd82724ee4fdae5d
3
+ metadata.gz: cb43d75df268978d9c55132da9f3e397fff08e830f699911cd1603927b4bedb8
4
+ data.tar.gz: 2eff47acaff0d353be69220b4ee511fa39ddccf2cf2e7cab0e6d4f3bad246d68
5
5
  SHA512:
6
- metadata.gz: 82a52d0d7f8d663994497e7672f64f357a79767c4237dc5aaccc39c1e01c63dd75714f7cd9ccba8acb677ff3af8df1ee20849a30f8c3d7c8e5d000dbf0f5d782
7
- data.tar.gz: 191e846d8f896b1cd4915a34678336cf2d6fc4579545e9380341dc573f9d587a9ba0527d2fbebc7b68e295a2c8ff6ab79c2423524fac9e59475a0b8fda285aca
6
+ metadata.gz: e69e6e3dfcaea37b1c1b7723289fd36cb163c9535d60d93a2ab52c428b1fc4ebaad30bb4acd5b1891a3357467942b4721e06a180521fc373cb22ef6c183d0249
7
+ data.tar.gz: dbf10280434bf5ad40b32cd0cac112e448174b1e93bafffb6d7eeed39c9389292bac59e8c8908da04792d79104c2d2a39d2b77bad0b19f2961071b040885fe01
@@ -2,6 +2,8 @@
2
2
 
3
3
  module EacRubyUtils
4
4
  class Context
5
+ delegate :any?, to: :stack
6
+
5
7
  def current
6
8
  optional_current || raise('No elements in context')
7
9
  end
@@ -1,18 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/listable'
3
4
  require 'eac_ruby_utils/simple_cache'
4
5
 
5
6
  module EacRubyUtils
6
7
  module Envs
7
8
  class Executable
9
+ include ::EacRubyUtils::Listable
8
10
  include ::EacRubyUtils::SimpleCache
9
11
 
10
- attr_reader :env, :name, :check_args
12
+ lists.add_symbol :option, :check_args, :auto_validate
13
+
14
+ DEFAULT_AUTO_VALIDATE = true
15
+
16
+ attr_reader :env, :name, :options
11
17
 
12
18
  def initialize(env, name, *check_args)
13
19
  @env = env
14
20
  @name = name
15
- @check_args = check_args
21
+ self.options = self.class.lists.option.hash_keys_validate!(check_args.extract_options!)
22
+ options[OPTION_CHECK_ARGS] = check_args unless options.key?(OPTION_CHECK_ARGS)
23
+ options.freeze
24
+ end
25
+
26
+ def auto_validate?
27
+ options.key?(OPTION_AUTO_VALIDATE) ? options[OPTION_AUTO_VALIDATE] : DEFAULT_AUTO_VALIDATE
28
+ end
29
+
30
+ def check_args
31
+ options[OPTION_CHECK_ARGS]
16
32
  end
17
33
 
18
34
  def exist?
@@ -32,7 +48,7 @@ module EacRubyUtils
32
48
  end
33
49
 
34
50
  def command(*command_args)
35
- validate!
51
+ validate! if auto_validate?
36
52
  env.command(*executable_args, *command_args)
37
53
  end
38
54
 
@@ -50,6 +66,8 @@ module EacRubyUtils
50
66
 
51
67
  private
52
68
 
69
+ attr_writer :options
70
+
53
71
  def exist_uncached
54
72
  env.command(*executable_args, *check_args).execute!
55
73
  true
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/struct'
4
+
5
+ class Hash
6
+ # Returns an <tt>EacRubyUtils::Struct</tt> out of its receiver.
7
+ def to_struct
8
+ ::EacRubyUtils::Struct.new(self)
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pathname
4
+ # @return +block.call(self)+ if +self+ exists, +default_value+ otherwise.
5
+ def if_exist(default_value = nil)
6
+ return default_value unless exist?
7
+
8
+ block_given? ? yield(self) : self
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ class Pathname
6
+ def readlink_r
7
+ r = self
8
+ r = r.readlink while r.symlink?
9
+ r
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/speaker/receiver'
4
+
5
+ module EacRubyUtils
6
+ module Rspec
7
+ class StubSpeaker
8
+ include ::EacRubyUtils::Speaker::Receiver
9
+
10
+ def error(_string); end
11
+
12
+ def fatal_error(string)
13
+ error(string)
14
+ raise('Fatal error')
15
+ end
16
+
17
+ # @see EacRubyUtils::Speaker::Sender.input
18
+ def input(_question, _options = {})
19
+ raise 'Input requested'
20
+ end
21
+
22
+ def info(_string); end
23
+
24
+ def infom(_string); end
25
+
26
+ def infov(*_args); end
27
+
28
+ def out(_string = ''); end
29
+
30
+ def puts(_string = ''); end
31
+
32
+ def success(_string); end
33
+
34
+ def title(_string); end
35
+
36
+ def warn(_string); end
37
+ end
38
+ end
39
+ end
@@ -5,8 +5,15 @@ require 'eac_ruby_utils/abstract_methods'
5
5
  module EacRubyUtils
6
6
  module Speaker
7
7
  module Receiver
8
+ extend ::ActiveSupport::Concern
8
9
  extend ::EacRubyUtils::AbstractMethods
9
10
 
11
+ module ClassMethods
12
+ def on(*args, &block)
13
+ ::EacRubyUtils::Speaker.context.on(new(*args), &block)
14
+ end
15
+ end
16
+
10
17
  def error(_string)
11
18
  raise_abstract_method(__method__)
12
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.82.1'
4
+ VERSION = '0.86.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.82.1
4
+ version: 0.86.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-12-21 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -178,6 +178,7 @@ files:
178
178
  - lib/eac_ruby_utils/patches/hash.rb
179
179
  - lib/eac_ruby_utils/patches/hash/options_consumer.rb
180
180
  - lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
181
+ - lib/eac_ruby_utils/patches/hash/to_struct.rb
181
182
  - lib/eac_ruby_utils/patches/kernel.rb
182
183
  - lib/eac_ruby_utils/patches/kernel/nyi.rb
183
184
  - lib/eac_ruby_utils/patches/module.rb
@@ -204,8 +205,10 @@ files:
204
205
  - lib/eac_ruby_utils/patches/object/to_pathname.rb
205
206
  - lib/eac_ruby_utils/patches/pathname.rb
206
207
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
208
+ - lib/eac_ruby_utils/patches/pathname/if_exist.rb
207
209
  - lib/eac_ruby_utils/patches/pathname/mkpath_s.rb
208
210
  - lib/eac_ruby_utils/patches/pathname/parent_n.rb
211
+ - lib/eac_ruby_utils/patches/pathname/readlink_r.rb
209
212
  - lib/eac_ruby_utils/patches/regexp.rb
210
213
  - lib/eac_ruby_utils/patches/regexp/if_match.rb
211
214
  - lib/eac_ruby_utils/patches/regexp/to_parser.rb
@@ -222,6 +225,7 @@ files:
222
225
  - lib/eac_ruby_utils/rspec/setup.rb
223
226
  - lib/eac_ruby_utils/rspec/setup/conditionals.rb
224
227
  - lib/eac_ruby_utils/rspec/setup_manager.rb
228
+ - lib/eac_ruby_utils/rspec/stub_speaker.rb
225
229
  - lib/eac_ruby_utils/ruby.rb
226
230
  - lib/eac_ruby_utils/ruby/command.rb
227
231
  - lib/eac_ruby_utils/ruby/on_clean_environment.rb