eac_ruby_utils 0.83.0 → 0.87.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: ead277954d30057deff2aadb9f960afabd477f983bacdd0dddd578ebfd5d1f69
4
- data.tar.gz: c385ec742ac8e478d289f00891caadda9ac8447b2d2b781c99cb8203c33a4ea6
3
+ metadata.gz: 1d4ecfbc2e97f7fb3f09539826cfeb26eca26eac7e12fd7ea396dbf1c26cdc88
4
+ data.tar.gz: dfb7c05df973182295f4ad73c118e1825d80130e7a446a5a395ecd3d9c361e35
5
5
  SHA512:
6
- metadata.gz: 70ab1feb4ce84b8239e709992a90a27b854c03038a8aced9a3ea56b1a3954177ef3af5b0ec4ebec84d1ac9045f20926038581b0d4aeef130ffb551c0959d4f28
7
- data.tar.gz: 31bb8905cbadfd73cf1514d9b1318e66bac201be7ae6e2537956bbebba5392c9f1ad61be8371fa7fbc08976d4491f7975d7ed899f10453d141582c5c19db36d4
6
+ metadata.gz: 7dc1d1cf517eee4582a0359aa3868fea24b4305ee365dcf2c8509db75180c021a428256f8ea32d21ce88ce29a43a5a016ed0dcec39143d84ec9b359802dc6d83
7
+ data.tar.gz: a7caf88e6692f6ff0ba15d0c231ca86bac511ef10eb539afaa3f4aac0556d50d19328822dac22ca8f5be69b4ef83cebfd06658ecaa9790f154ddc64ac6f0a1b9
@@ -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,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'addressable/uri'
5
+
6
+ class Object
7
+ # Convert +self+ to String and then to Addressable::URI. Return nil if +self+ is +blank?+.
8
+ #
9
+ # @return [Addressable::URI]
10
+ def to_uri
11
+ return self if is_a?(::Addressable::URI)
12
+
13
+ to_s.blank? ? nil : ::Addressable::URI.parse(to_s)
14
+ end
15
+ 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.83.0'
4
+ VERSION = '0.87.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.83.0
4
+ version: 0.87.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: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -203,10 +203,13 @@ files:
203
203
  - lib/eac_ruby_utils/patches/object/if_present.rb
204
204
  - lib/eac_ruby_utils/patches/object/if_respond.rb
205
205
  - lib/eac_ruby_utils/patches/object/to_pathname.rb
206
+ - lib/eac_ruby_utils/patches/object/to_uri.rb
206
207
  - lib/eac_ruby_utils/patches/pathname.rb
207
208
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
209
+ - lib/eac_ruby_utils/patches/pathname/if_exist.rb
208
210
  - lib/eac_ruby_utils/patches/pathname/mkpath_s.rb
209
211
  - lib/eac_ruby_utils/patches/pathname/parent_n.rb
212
+ - lib/eac_ruby_utils/patches/pathname/readlink_r.rb
210
213
  - lib/eac_ruby_utils/patches/regexp.rb
211
214
  - lib/eac_ruby_utils/patches/regexp/if_match.rb
212
215
  - lib/eac_ruby_utils/patches/regexp/to_parser.rb
@@ -223,6 +226,7 @@ files:
223
226
  - lib/eac_ruby_utils/rspec/setup.rb
224
227
  - lib/eac_ruby_utils/rspec/setup/conditionals.rb
225
228
  - lib/eac_ruby_utils/rspec/setup_manager.rb
229
+ - lib/eac_ruby_utils/rspec/stub_speaker.rb
226
230
  - lib/eac_ruby_utils/ruby.rb
227
231
  - lib/eac_ruby_utils/ruby/command.rb
228
232
  - lib/eac_ruby_utils/ruby/on_clean_environment.rb