eac_ruby_utils 0.85.0 → 0.88.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: 48f30b222067edfdcdc7d6a3656ceb73f0c8780d5a35830b9f0e5c8051a44b6b
4
- data.tar.gz: f461e7f88ad988a472df1141a232e125e0ed29b9532e3c74992a5fad5f81867b
3
+ metadata.gz: 2a3e785240ca74c309c1666c6cabbfd0d4b1533ee2fea2739272efe8925679bf
4
+ data.tar.gz: 76439955c6da58c19943e07fca3a8768e539d57b2684bd89d46ff64c64ed7f55
5
5
  SHA512:
6
- metadata.gz: be9046e777c84bf2680f519e1aafe808c974eba21ba285cb2fa8ec6e4598973f14e959a2432077810b90cfcaca4f195baf82bda18ea3b8acfdf647ce6487b3ed
7
- data.tar.gz: 6c9cdc45780225347171b3c4362f04af79b22f4fef2c1080d38d97001c1aace0226e111d0b02cb7f5e28d58acd2cea5d698457d57b07c0b2c8242f5af914b7ef
6
+ metadata.gz: c9700725a581ac9903843337f2ee962ec8f932e5f2aabfa448affca8ad306096857400273d6571e5c30886cbb17b120e7f5836bddbbcfcc3dc2ddba583473ee7
7
+ data.tar.gz: 1d11cbb29b0835442f20e05a326e17162a9ad1d9753af22e9f1e36ccfc956c87973e9a72bfa2880cf54d3f4257cb3909e97d08c511cc656cb8979f5580a50643
@@ -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
+ require 'eac_ruby_utils/fs/extname'
4
+ require 'pathname'
5
+
6
+ class Pathname
7
+ def basename_noext(limit = 1)
8
+ basename(::EacRubyUtils::Fs.extname(basename.to_path, limit))
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.85.0'
4
+ VERSION = '0.88.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.85.0
4
+ version: 0.88.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-23 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -203,7 +203,9 @@ 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
208
+ - lib/eac_ruby_utils/patches/pathname/basename_noext.rb
207
209
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
208
210
  - lib/eac_ruby_utils/patches/pathname/if_exist.rb
209
211
  - lib/eac_ruby_utils/patches/pathname/mkpath_s.rb