eac_ruby_utils 0.108.0 → 0.109.1
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 → base_command}/append_command_options.rb +1 -1
- data/lib/eac_ruby_utils/envs/{command → base_command}/concat.rb +5 -12
- data/lib/eac_ruby_utils/envs/{command → base_command}/debugging.rb +1 -1
- data/lib/eac_ruby_utils/envs/{command → base_command}/execution.rb +1 -1
- data/lib/eac_ruby_utils/envs/base_command/extra_options.rb +28 -0
- data/lib/eac_ruby_utils/envs/base_command.rb +45 -0
- data/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -10
- data/lib/eac_ruby_utils/envs/command.rb +3 -15
- data/lib/eac_ruby_utils/envs/composite_command.rb +45 -0
- data/lib/eac_ruby_utils/gems_registry/gem.rb +2 -1
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +23 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bff20dbb2a1dd1b005a28e508d41d93e1d430a4bdd7c936389556a97df7d300a
|
4
|
+
data.tar.gz: 4ecfde5c8b6d86634197324bf05fd02879ae55ee58c8dad5db8eaeca4f1bf0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce4e394feeb80d9907b52e497309aa1916f7b9f65413c72d00c18936bb77c7746a46ee0d1d4386fd3f3b7e2f5f1b77229e45b6ccd342b2b29a84a2c6aa4570ef
|
7
|
+
data.tar.gz: bd726557052663349699fab114fbf3ae209b081d024a3dfc6a54a8a3b0f18f6fe69b72bb5f13aaed27a7309adca5786b2e00f48b86774cdf66f4af89cb58f373
|
@@ -4,17 +4,18 @@ require 'eac_ruby_utils/struct'
|
|
4
4
|
|
5
5
|
module EacRubyUtils
|
6
6
|
module Envs
|
7
|
-
|
7
|
+
module BaseCommand
|
8
8
|
module Concat
|
9
9
|
AND_OPERATOR = '&&'
|
10
10
|
BEFORE_OPERATOR = ';'
|
11
11
|
OR_OPERATOR = '||'
|
12
12
|
PIPE_OPERATOR = '|'
|
13
13
|
|
14
|
+
# @param operator [Symbol]
|
15
|
+
# @return [EacRubyUtils::Envs::CompositeCommand]
|
14
16
|
def concat(operator, other_command)
|
15
|
-
|
16
|
-
|
17
|
-
))
|
17
|
+
require 'eac_ruby_utils/envs/composite_command'
|
18
|
+
::EacRubyUtils::Envs::CompositeCommand.new(operator, self, other_command)
|
18
19
|
end
|
19
20
|
|
20
21
|
# @return [EacRubyUtils::Envs::Command]
|
@@ -34,14 +35,6 @@ module EacRubyUtils
|
|
34
35
|
def pipe(other_command)
|
35
36
|
concat(PIPE_OPERATOR, other_command)
|
36
37
|
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def append_concat(command)
|
41
|
-
extra_options[:concat].if_present(command) do |v|
|
42
|
-
"#{command} #{v.operator} #{v.command.command}"
|
43
|
-
end
|
44
|
-
end
|
45
38
|
end
|
46
39
|
end
|
47
40
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
require 'shellwords'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Envs
|
9
|
+
module BaseCommand
|
10
|
+
module ExtraOptions
|
11
|
+
# @return [ActiveSupport::HashWithIndifferentAccess]
|
12
|
+
def extra_options
|
13
|
+
@extra_options ||= {}.with_indifferent_access
|
14
|
+
end
|
15
|
+
|
16
|
+
def status_result(status_code, result)
|
17
|
+
duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def status_results
|
23
|
+
extra_options[:status_results] ||= {}.with_indifferent_access
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'shellwords'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Envs
|
8
|
+
module BaseCommand
|
9
|
+
require_sub __FILE__
|
10
|
+
|
11
|
+
common_concern do
|
12
|
+
enable_abstract_methods
|
13
|
+
include ::EacRubyUtils::Envs::BaseCommand::Concat
|
14
|
+
include ::EacRubyUtils::Envs::BaseCommand::Debugging
|
15
|
+
include ::EacRubyUtils::Envs::BaseCommand::Execution
|
16
|
+
include ::EacRubyUtils::Envs::BaseCommand::ExtraOptions
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [EacRubyUtils::Envs::BaseEnv]
|
20
|
+
def env
|
21
|
+
raise_abstract_method __method__
|
22
|
+
end
|
23
|
+
|
24
|
+
def command(options = {})
|
25
|
+
append_command_options(
|
26
|
+
env.command_line(command_line_without_env),
|
27
|
+
options
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [String]
|
32
|
+
def command_line_without_env(_options = {})
|
33
|
+
raise_abstract_method __method__
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def escape(arg)
|
39
|
+
arg = arg.to_s
|
40
|
+
m = /^\@ESC_(.+)$/.match(arg)
|
41
|
+
m ? m[1] : Shellwords.escape(arg)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -12,18 +12,8 @@ module EacRubyUtils
|
|
12
12
|
duplicate_by_extra_options(chdir: dir)
|
13
13
|
end
|
14
14
|
|
15
|
-
def status_result(status_code, result)
|
16
|
-
duplicate_by_extra_options(status_results: status_results.merge(status_code => result))
|
17
|
-
end
|
18
|
-
|
19
15
|
private
|
20
16
|
|
21
|
-
attr_reader :extra_options
|
22
|
-
|
23
|
-
def status_results
|
24
|
-
extra_options[:status_results] ||= {}.with_indifferent_access
|
25
|
-
end
|
26
|
-
|
27
17
|
def append_chdir(command)
|
28
18
|
extra_options[:chdir].present? ? "(cd '#{extra_options[:chdir]}' ; #{command} )" : command
|
29
19
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
-
require '
|
4
|
+
require 'eac_ruby_utils/envs/base_command'
|
5
5
|
|
6
6
|
module EacRubyUtils
|
7
7
|
module Envs
|
8
8
|
class Command
|
9
9
|
require_sub __FILE__, include_modules: true, require_dependency: true
|
10
|
+
include ::EacRubyUtils::Envs::BaseCommand
|
10
11
|
|
11
12
|
class << self
|
12
13
|
# @param command [Array]
|
@@ -39,18 +40,11 @@ module EacRubyUtils
|
|
39
40
|
"#{args} [ENV: #{env}]"
|
40
41
|
end
|
41
42
|
|
42
|
-
def command(options = {})
|
43
|
-
append_command_options(
|
44
|
-
env.command_line(command_line_without_env),
|
45
|
-
options
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
43
|
# @return [String]
|
50
44
|
def command_line_without_env
|
51
45
|
c = args
|
52
46
|
c = c.map { |x| escape(x) }.join(' ') if c.is_a?(Enumerable)
|
53
|
-
append_chdir(
|
47
|
+
append_chdir(append_envvars(c))
|
54
48
|
end
|
55
49
|
|
56
50
|
protected
|
@@ -68,12 +62,6 @@ module EacRubyUtils
|
|
68
62
|
def duplicate_by_extra_options(set_extra_options)
|
69
63
|
duplicate(args, extra_options.merge(set_extra_options))
|
70
64
|
end
|
71
|
-
|
72
|
-
def escape(arg)
|
73
|
-
arg = arg.to_s
|
74
|
-
m = /^\@ESC_(.+)$/.match(arg)
|
75
|
-
m ? m[1] : Shellwords.escape(arg)
|
76
|
-
end
|
77
65
|
end
|
78
66
|
end
|
79
67
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/envs/base_command'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Envs
|
8
|
+
class CompositeCommand
|
9
|
+
include ::EacRubyUtils::Envs::BaseCommand
|
10
|
+
|
11
|
+
enable_listable
|
12
|
+
lists.add_string :operator, '&&' => :and, ';' => :before, '||' => :or, '|' => :pipe
|
13
|
+
|
14
|
+
common_constructor :operator, :left_command, :right_command do
|
15
|
+
self.operator = self.class.lists.operator.value_validate!(operator.to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [EacRubyUtils::Envs::BaseEnv]
|
19
|
+
delegate :env, to: :left_command
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def command_line_without_env(_options = {})
|
23
|
+
::Shellwords.join(['bash', '-c', bash_command])
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def bash_command
|
28
|
+
['set', '-euo', 'pipefail', OPERATOR_BEFORE, left_command_line, operator,
|
29
|
+
right_command_line].join(' ')
|
30
|
+
end
|
31
|
+
|
32
|
+
def left_command_line
|
33
|
+
left_command.command_line_without_env
|
34
|
+
end
|
35
|
+
|
36
|
+
def right_command_line
|
37
|
+
if right_command.env == left_command.env
|
38
|
+
right_command.command_line_without_env
|
39
|
+
else
|
40
|
+
right_command.command
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -69,8 +69,9 @@ module EacRubyUtils
|
|
69
69
|
.result
|
70
70
|
end
|
71
71
|
|
72
|
+
# @return [Array<Gem::Dependency>]
|
72
73
|
def gem_item_dependencies(item)
|
73
|
-
::Gem::Specification.find_by_name(item.name).dependencies
|
74
|
+
::Gem::Specification.find_by_name(item.name).dependencies.select(&:runtime?)
|
74
75
|
rescue ::Gem::MissingSpecError
|
75
76
|
[]
|
76
77
|
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.109.1
|
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-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '4.2'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: avm-eac_ubuntu_base0
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.4'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0.4'
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
110
|
name: eac_ruby_gem_support
|
97
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,14 +153,17 @@ files:
|
|
139
153
|
- lib/eac_ruby_utils/custom_format.rb
|
140
154
|
- lib/eac_ruby_utils/enum.rb
|
141
155
|
- lib/eac_ruby_utils/envs.rb
|
156
|
+
- lib/eac_ruby_utils/envs/base_command.rb
|
157
|
+
- lib/eac_ruby_utils/envs/base_command/append_command_options.rb
|
158
|
+
- lib/eac_ruby_utils/envs/base_command/concat.rb
|
159
|
+
- lib/eac_ruby_utils/envs/base_command/debugging.rb
|
160
|
+
- lib/eac_ruby_utils/envs/base_command/execution.rb
|
161
|
+
- lib/eac_ruby_utils/envs/base_command/extra_options.rb
|
142
162
|
- lib/eac_ruby_utils/envs/base_env.rb
|
143
163
|
- lib/eac_ruby_utils/envs/command.rb
|
144
|
-
- lib/eac_ruby_utils/envs/command/append_command_options.rb
|
145
|
-
- lib/eac_ruby_utils/envs/command/concat.rb
|
146
|
-
- lib/eac_ruby_utils/envs/command/debugging.rb
|
147
164
|
- lib/eac_ruby_utils/envs/command/envvars.rb
|
148
|
-
- lib/eac_ruby_utils/envs/command/execution.rb
|
149
165
|
- lib/eac_ruby_utils/envs/command/extra_options.rb
|
166
|
+
- lib/eac_ruby_utils/envs/composite_command.rb
|
150
167
|
- lib/eac_ruby_utils/envs/executable.rb
|
151
168
|
- lib/eac_ruby_utils/envs/execution_error.rb
|
152
169
|
- lib/eac_ruby_utils/envs/execution_result.rb
|