eac_ruby_utils 0.103.0 → 0.105.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: 4a255c998a0548aa5e8367b8f620620ed10c3815cf6cfa7bb91a0f4375c819db
4
- data.tar.gz: 8b8dad7b6318319a4e4c2696c13b55f961d7cfa7042aa2723560d08cfec29f16
3
+ metadata.gz: a7c14027c7e1ef4db1c0b886d72d3053d6f7406468bf497bf0a644d988602ea6
4
+ data.tar.gz: 54eed81faaa197cf4b210c80df89c7f1ee414f99fae66275b2bab7a71e870b2e
5
5
  SHA512:
6
- metadata.gz: 35719457a0c1fd6e7899c2ed268fa3f6f699ec6cca8da046a4e0d6d6fcc785db7a91ddb2638c86af6ca0f49cb1cf5d1e63958795dfbf46eb6dc7c9a3a9ffc3cb
7
- data.tar.gz: f9586ed06df1e3fe7ecb358df065ce42c6c2231f2b964b2e8f908c877acbcee23e5c425e3722c17105f845e48109c6bfffcf021f115f92327de96436014bca6a
6
+ metadata.gz: cf946355a2cf5ec6a7dfb568d7b751b48e8d34b28d6e963eca8204fffbfc375ce9772f32029161c8413ec2557aba9216dd59f2a528428d1dfd832c350989934e
7
+ data.tar.gz: 59a58657570e06311d85c82d0deca5dab659ef0477d14794a9cd069dd637208fe1c97458e902ded340babfaf95f3f8ae3635ab4bc3fc9f50df41e25d50f85f82
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Envs
5
+ class Command
6
+ class ExecError < ::RuntimeError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/envs/command/exec_error'
4
+
5
+ module EacRubyUtils
6
+ module Envs
7
+ class Command
8
+ class ExecuteResult
9
+ attr_reader :r, :options
10
+
11
+ def initialize(result, options)
12
+ @r = result
13
+ @options = options
14
+ end
15
+
16
+ def result
17
+ return exit_code_zero_result if exit_code_zero?
18
+ return expected_error_result if expected_error?
19
+
20
+ raise ::EacRubyUtils::Envs::Command::ExecError, 'Failed!'
21
+ end
22
+
23
+ def success?
24
+ exit_code_zero? || expected_error?
25
+ end
26
+
27
+ private
28
+
29
+ def exit_code_zero?
30
+ r[:exit_code]&.zero?
31
+ end
32
+
33
+ def exit_code_zero_result
34
+ r[options[:output] || :stdout]
35
+ end
36
+
37
+ def expected_error_result
38
+ options[:exit_outputs][r[:exit_code]]
39
+ end
40
+
41
+ def expected_error?
42
+ options[:exit_outputs].is_a?(Hash) && options[:exit_outputs].key?(r[:exit_code])
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -55,7 +55,8 @@ module EacRubyUtils
55
55
  er = ExecuteResult.new(execute(options), options)
56
56
  return er.result if er.success?
57
57
 
58
- raise "execute! command failed: #{self}\n#{er.r.pretty_inspect}"
58
+ raise ::EacRubyUtils::Envs::Command::ExecError,
59
+ "execute! command failed: #{self}\n#{er.r.pretty_inspect}"
59
60
  end
60
61
 
61
62
  def execute(options = {})
@@ -77,7 +78,7 @@ module EacRubyUtils
77
78
  def system!(options = {})
78
79
  return if system(options)
79
80
 
80
- raise "system! command failed: #{self}"
81
+ raise ::EacRubyUtils::Envs::Command::ExecError, "system! command failed: #{self}"
81
82
  end
82
83
 
83
84
  def system(options = {})
@@ -129,44 +130,6 @@ module EacRubyUtils
129
130
  m = /^\@ESC_(.+)$/.match(arg)
130
131
  m ? m[1] : Shellwords.escape(arg)
131
132
  end
132
-
133
- class ExecuteResult
134
- attr_reader :r, :options
135
-
136
- def initialize(result, options)
137
- @r = result
138
- @options = options
139
- end
140
-
141
- def result
142
- return exit_code_zero_result if exit_code_zero?
143
- return expected_error_result if expected_error?
144
-
145
- raise 'Failed!'
146
- end
147
-
148
- def success?
149
- exit_code_zero? || expected_error?
150
- end
151
-
152
- private
153
-
154
- def exit_code_zero?
155
- r[:exit_code]&.zero?
156
- end
157
-
158
- def exit_code_zero_result
159
- r[options[:output] || :stdout]
160
- end
161
-
162
- def expected_error_result
163
- options[:exit_outputs][r[:exit_code]]
164
- end
165
-
166
- def expected_error?
167
- options[:exit_outputs].is_a?(Hash) && options[:exit_outputs].key?(r[:exit_code])
168
- end
169
- end
170
133
  end
171
134
  end
172
135
  end
@@ -13,7 +13,7 @@ module EacRubyUtils
13
13
  end
14
14
 
15
15
  class Setup
16
- common_constructor :method_class do
16
+ common_constructor :method_class, :static_method, default: [false] do
17
17
  perform
18
18
  end
19
19
 
@@ -29,7 +29,9 @@ module EacRubyUtils
29
29
  end
30
30
 
31
31
  def sender_module
32
- method_class.module_parent
32
+ r = method_class.module_parent
33
+ r = r.singleton_class if static_method
34
+ r
33
35
  end
34
36
  end
35
37
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/static_method_class'
4
+
5
+ class Module
6
+ def enable_static_method_class
7
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::StaticMethodClass)
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Rspec
5
+ module Setup
6
+ module SetupManager
7
+ # @return [Pathname]
8
+ delegate :app_root_path, to: :setup_manager
9
+
10
+ # @return [EacRubyUtils::Rspec::SetupManager]
11
+ def setup_manager
12
+ ::RSpec.configuration.setup_manager
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -5,8 +5,14 @@ require 'eac_ruby_utils/core_ext'
5
5
  module EacRubyUtils
6
6
  module Rspec
7
7
  module Setup
8
- extend ::ActiveSupport::Concern
9
- require_sub __FILE__, include_modules: true
8
+ require_sub __FILE__
9
+
10
+ def self.extended(obj)
11
+ obj.extend(::EacRubyUtils::Rspec::Setup::Conditionals)
12
+ obj.rspec_config.add_setting :setup_manager
13
+ obj.rspec_config.setup_manager = obj
14
+ obj.rspec_config.include(::EacRubyUtils::Rspec::Setup::SetupManager)
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/method_class'
4
+ require 'eac_ruby_utils/patches/module/common_concern'
5
+
6
+ module EacRubyUtils
7
+ module StaticMethodClass
8
+ common_concern do
9
+ ::EacRubyUtils::MethodClass::Setup.new(self, true)
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.103.0'
4
+ VERSION = '0.105.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.103.0
4
+ version: 0.105.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-09-13 00:00:00.000000000 Z
11
+ date: 2022-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -37,6 +37,9 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '2.8'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.8.1
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,6 +47,9 @@ dependencies:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
49
  version: '2.8'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.8.1
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: bundler
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +143,8 @@ files:
137
143
  - lib/eac_ruby_utils/envs/command.rb
138
144
  - lib/eac_ruby_utils/envs/command/concat.rb
139
145
  - lib/eac_ruby_utils/envs/command/envvars.rb
146
+ - lib/eac_ruby_utils/envs/command/exec_error.rb
147
+ - lib/eac_ruby_utils/envs/command/execute_result.rb
140
148
  - lib/eac_ruby_utils/envs/command/extra_options.rb
141
149
  - lib/eac_ruby_utils/envs/executable.rb
142
150
  - lib/eac_ruby_utils/envs/file.rb
@@ -189,8 +197,10 @@ files:
189
197
  - lib/eac_ruby_utils/patches/class.rb
190
198
  - lib/eac_ruby_utils/patches/class/abstract.rb
191
199
  - lib/eac_ruby_utils/patches/class/common_constructor.rb
200
+ - lib/eac_ruby_utils/patches/class/method_class.rb
192
201
  - lib/eac_ruby_utils/patches/class/self_included_modules.rb
193
202
  - lib/eac_ruby_utils/patches/class/settings_provider.rb
203
+ - lib/eac_ruby_utils/patches/class/static_method_class.rb
194
204
  - lib/eac_ruby_utils/patches/enumerable.rb
195
205
  - lib/eac_ruby_utils/patches/enumerable/boolean_combinations.rb
196
206
  - lib/eac_ruby_utils/patches/enumerator.rb
@@ -210,7 +220,6 @@ files:
210
220
  - lib/eac_ruby_utils/patches/module/i18n_translate.rb
211
221
  - lib/eac_ruby_utils/patches/module/immutable.rb
212
222
  - lib/eac_ruby_utils/patches/module/listable.rb
213
- - lib/eac_ruby_utils/patches/module/method_class.rb
214
223
  - lib/eac_ruby_utils/patches/module/module_parent.rb
215
224
  - lib/eac_ruby_utils/patches/module/patch.rb
216
225
  - lib/eac_ruby_utils/patches/module/require_sub.rb
@@ -252,6 +261,7 @@ files:
252
261
  - lib/eac_ruby_utils/rspec/default_setup.rb
253
262
  - lib/eac_ruby_utils/rspec/setup.rb
254
263
  - lib/eac_ruby_utils/rspec/setup/conditionals.rb
264
+ - lib/eac_ruby_utils/rspec/setup/setup_manager.rb
255
265
  - lib/eac_ruby_utils/rspec/setup_manager.rb
256
266
  - lib/eac_ruby_utils/rspec/stub_speaker.rb
257
267
  - lib/eac_ruby_utils/ruby.rb
@@ -265,6 +275,7 @@ files:
265
275
  - lib/eac_ruby_utils/speaker.rb
266
276
  - lib/eac_ruby_utils/speaker/receiver.rb
267
277
  - lib/eac_ruby_utils/speaker/sender.rb
278
+ - lib/eac_ruby_utils/static_method_class.rb
268
279
  - lib/eac_ruby_utils/string_delimited.rb
269
280
  - lib/eac_ruby_utils/struct.rb
270
281
  - lib/eac_ruby_utils/version.rb