eac_ruby_utils 0.104.0 → 0.105.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_utils/envs/command/exec_error.rb +10 -0
- data/lib/eac_ruby_utils/envs/command/execute_result.rb +47 -0
- data/lib/eac_ruby_utils/envs/command.rb +3 -40
- data/lib/eac_ruby_utils/rspec/setup/setup_manager.rb +17 -0
- data/lib/eac_ruby_utils/rspec/setup.rb +8 -2
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c14027c7e1ef4db1c0b886d72d3053d6f7406468bf497bf0a644d988602ea6
|
4
|
+
data.tar.gz: 54eed81faaa197cf4b210c80df89c7f1ee414f99fae66275b2bab7a71e870b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf946355a2cf5ec6a7dfb568d7b751b48e8d34b28d6e963eca8204fffbfc375ce9772f32029161c8413ec2557aba9216dd59f2a528428d1dfd832c350989934e
|
7
|
+
data.tar.gz: 59a58657570e06311d85c82d0deca5dab659ef0477d14794a9cd069dd637208fe1c97458e902ded340babfaf95f3f8ae3635ab4bc3fc9f50df41e25d50f85f82
|
@@ -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
|
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
|
@@ -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
|
-
|
9
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2022-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -143,6 +143,8 @@ files:
|
|
143
143
|
- lib/eac_ruby_utils/envs/command.rb
|
144
144
|
- lib/eac_ruby_utils/envs/command/concat.rb
|
145
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
|
146
148
|
- lib/eac_ruby_utils/envs/command/extra_options.rb
|
147
149
|
- lib/eac_ruby_utils/envs/executable.rb
|
148
150
|
- lib/eac_ruby_utils/envs/file.rb
|
@@ -259,6 +261,7 @@ files:
|
|
259
261
|
- lib/eac_ruby_utils/rspec/default_setup.rb
|
260
262
|
- lib/eac_ruby_utils/rspec/setup.rb
|
261
263
|
- lib/eac_ruby_utils/rspec/setup/conditionals.rb
|
264
|
+
- lib/eac_ruby_utils/rspec/setup/setup_manager.rb
|
262
265
|
- lib/eac_ruby_utils/rspec/setup_manager.rb
|
263
266
|
- lib/eac_ruby_utils/rspec/stub_speaker.rb
|
264
267
|
- lib/eac_ruby_utils/ruby.rb
|