eac_tools 0.46.0 → 0.47.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -21
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm-eac_php_base0/avm-eac_php_base0.gemspec +3 -2
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/instances/base.rb +14 -0
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/instances.rb +11 -0
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/source_generators/base.rb +28 -0
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/source_generators.rb +11 -0
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/sources/base.rb +17 -0
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/sources.rb +11 -0
- data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/version.rb +1 -1
- data/sub/avm-eac_php_base0/spec/lib/avm/eac_php_base0/source_generators/base_spec.rb +8 -0
- data/sub/avm-eac_php_base0/spec/lib/avm/eac_php_base0/source_generators/base_spec_files/no_options/index.php +0 -0
- data/sub/avm-eac_php_base0/spec/lib/avm/eac_php_base0/sources/base_spec.rb +7 -0
- data/sub/avm-eac_php_base0/template/avm/eac_php_base0/source_generators/base/index.php +0 -0
- data/sub/avm-eac_postgresql_base0/avm-eac_postgresql_base0.gemspec +2 -2
- data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb +8 -2
- data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance_with.rb +5 -3
- data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb +1 -1
- data/sub/avm-git/avm-git.gemspec +3 -3
- data/sub/avm-git/lib/avm/git/launcher/base/underlying.rb +1 -1
- data/sub/avm-git/lib/avm/git/version.rb +1 -1
- data/sub/avm-tools/avm-tools.gemspec +2 -2
- data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
- data/sub/eac_fs/lib/eac_fs/storage_tree.rb +19 -0
- data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/append_command_options.rb +38 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/concat.rb +41 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/debugging.rb +19 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/execution.rb +52 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command/extra_options.rb +28 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/base_command.rb +45 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +3 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -10
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +28 -96
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/composite_command.rb +33 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/{command/exec_error.rb → execution_error.rb} +1 -3
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/execution_result.rb +45 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command_spec.rb +100 -0
- metadata +48 -17
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +0 -33
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/execute_result.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24f75dde80d4c4479e5f7bdd1203f9aa4fdd06dda99579b0c5212e24a9959c87
|
4
|
+
data.tar.gz: a3ea613d10868c65c5801a1876f043e7bc0512459d458f0f278c425ce13974be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca9448f7b5e0b23dc4df3bbd8efdba689a2741c672720971728c897e4c84296fb1a63d8b1b81f8dc629dc61f977e18333bca4d45f89cea40b08dc6c9d153fcb5
|
7
|
+
data.tar.gz: 304b367004e5d00ffb9efeb8a4fcf1151a6976dc525d6c1271115e539fa9b2eb91b1ba4b5c302e9660ae7e60ba3a47bd19fcfe51eca2fcf117ab370973705584
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eac_tools (0.
|
4
|
+
eac_tools (0.47.1)
|
5
5
|
avm (~> 0.57)
|
6
6
|
avm-eac_asciidoctor_base0 (~> 0.12)
|
7
7
|
avm-eac_generic_base0 (~> 0.8)
|
8
8
|
avm-eac_latex_base0 (~> 0.3)
|
9
|
-
avm-eac_php_base0 (~> 0.
|
9
|
+
avm-eac_php_base0 (~> 0.4)
|
10
|
+
avm-eac_postgresql_base0 (~> 0.2, >= 0.2.2)
|
10
11
|
avm-eac_rails_base0 (~> 0.8, >= 0.8.1)
|
11
12
|
avm-eac_rails_base1 (~> 0.7, >= 0.7.1)
|
12
13
|
avm-eac_redmine_base0 (~> 0.17)
|
@@ -14,8 +15,8 @@ PATH
|
|
14
15
|
avm-eac_ruby_base1 (~> 0.27, >= 0.27.1)
|
15
16
|
avm-eac_webapp_base0 (~> 0.12, >= 0.12.3)
|
16
17
|
avm-eac_wordpress_base0 (~> 0.2, >= 0.2.1)
|
17
|
-
avm-tools (~> 0.142, >= 0.142.
|
18
|
-
eac_ruby_utils (~> 0.
|
18
|
+
avm-tools (~> 0.142, >= 0.142.7)
|
19
|
+
eac_ruby_utils (~> 0.109)
|
19
20
|
|
20
21
|
PATH
|
21
22
|
remote: sub/aranha-parsers
|
@@ -58,16 +59,17 @@ PATH
|
|
58
59
|
PATH
|
59
60
|
remote: sub/avm-eac_php_base0
|
60
61
|
specs:
|
61
|
-
avm-eac_php_base0 (0.
|
62
|
-
avm-eac_generic_base0 (~> 0.
|
63
|
-
|
62
|
+
avm-eac_php_base0 (0.4.0)
|
63
|
+
avm-eac_generic_base0 (~> 0.8)
|
64
|
+
avm-eac_webapp_base0 (~> 0.12, >= 0.12.3)
|
65
|
+
eac_ruby_utils (~> 0.108)
|
64
66
|
|
65
67
|
PATH
|
66
68
|
remote: sub/avm-eac_postgresql_base0
|
67
69
|
specs:
|
68
|
-
avm-eac_postgresql_base0 (0.2.
|
69
|
-
avm (~> 0.
|
70
|
-
eac_ruby_utils (~> 0.
|
70
|
+
avm-eac_postgresql_base0 (0.2.2)
|
71
|
+
avm (~> 0.57)
|
72
|
+
eac_ruby_utils (~> 0.108)
|
71
73
|
|
72
74
|
PATH
|
73
75
|
remote: sub/avm-eac_python_base0
|
@@ -152,23 +154,23 @@ PATH
|
|
152
154
|
PATH
|
153
155
|
remote: sub/avm-git
|
154
156
|
specs:
|
155
|
-
avm-git (0.10.
|
156
|
-
avm (~> 0.
|
157
|
+
avm-git (0.10.1)
|
158
|
+
avm (~> 0.57)
|
157
159
|
avm-files (~> 0.6)
|
158
|
-
eac_git (~> 0.
|
159
|
-
eac_ruby_utils (~> 0.
|
160
|
+
eac_git (~> 0.14)
|
161
|
+
eac_ruby_utils (~> 0.108)
|
160
162
|
git (~> 1.12)
|
161
163
|
|
162
164
|
PATH
|
163
165
|
remote: sub/avm-tools
|
164
166
|
specs:
|
165
|
-
avm-tools (0.142.
|
167
|
+
avm-tools (0.142.7)
|
166
168
|
aranha-parsers (~> 0.14, >= 0.14.4)
|
167
|
-
avm (~> 0.
|
169
|
+
avm (~> 0.57)
|
168
170
|
avm-eac_ruby_base1 (~> 0.27, >= 0.27.1)
|
169
171
|
avm-eac_ubuntu_base0 (~> 0.3)
|
170
172
|
avm-files (~> 0.6)
|
171
|
-
avm-git (~> 0.10)
|
173
|
+
avm-git (~> 0.10, >= 0.10.1)
|
172
174
|
clipboard (~> 1.3, >= 1.3.6)
|
173
175
|
curb (~> 0.9, >= 0.9.11)
|
174
176
|
eac_git (~> 0.14)
|
@@ -218,7 +220,7 @@ PATH
|
|
218
220
|
PATH
|
219
221
|
remote: sub/eac_fs
|
220
222
|
specs:
|
221
|
-
eac_fs (0.
|
223
|
+
eac_fs (0.16.0)
|
222
224
|
content-type (~> 0.0, >= 0.0.2)
|
223
225
|
eac_ruby_utils (~> 0.107, >= 0.107.1)
|
224
226
|
ruby-filemagic (~> 0.7, >= 0.7.3)
|
@@ -242,7 +244,7 @@ PATH
|
|
242
244
|
PATH
|
243
245
|
remote: sub/eac_ruby_utils
|
244
246
|
specs:
|
245
|
-
eac_ruby_utils (0.
|
247
|
+
eac_ruby_utils (0.109.0)
|
246
248
|
activesupport (>= 4, < 7)
|
247
249
|
addressable (~> 2.8, >= 2.8.1)
|
248
250
|
bundler
|
@@ -337,7 +339,7 @@ GEM
|
|
337
339
|
parslet (2.0.0)
|
338
340
|
public_suffix (5.0.0)
|
339
341
|
racc (1.6.0)
|
340
|
-
rack (3.0.
|
342
|
+
rack (3.0.1)
|
341
343
|
rainbow (3.1.1)
|
342
344
|
rchardet (1.8.0)
|
343
345
|
rexml (3.2.5)
|
@@ -410,4 +412,4 @@ DEPENDENCIES
|
|
410
412
|
eac_tools!
|
411
413
|
|
412
414
|
BUNDLED WITH
|
413
|
-
2.3.
|
415
|
+
2.3.26
|
data/lib/eac_tools/version.rb
CHANGED
@@ -12,8 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = Dir['{lib,locale,template}/**/*']
|
14
14
|
|
15
|
-
s.add_dependency 'avm-eac_generic_base0', '~> 0.
|
16
|
-
s.add_dependency '
|
15
|
+
s.add_dependency 'avm-eac_generic_base0', '~> 0.8'
|
16
|
+
s.add_dependency 'avm-eac_webapp_base0', '~> 0.12', '>= 0.12.3'
|
17
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.108'
|
17
18
|
|
18
19
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5', '>= 0.5.1'
|
19
20
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_webapp_base0/instances/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module EacPhpBase0
|
8
|
+
module Instances
|
9
|
+
class Base < ::Avm::EacWebappBase0::Instances::Base
|
10
|
+
FILES_UNITS = {}.freeze
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/source_generators/base'
|
4
|
+
require 'eac_templates/core_ext'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module EacPhpBase0
|
9
|
+
module SourceGenerators
|
10
|
+
class Base < ::Avm::SourceGenerators::Base
|
11
|
+
OPTIONS = {}.freeze
|
12
|
+
|
13
|
+
enable_speaker
|
14
|
+
enable_simple_cache
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def option_list
|
18
|
+
OPTIONS.inject(super) { |a, e| a.option(*e) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def perform
|
23
|
+
template.apply(self, target_path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_webapp_base0/sources/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module EacPhpBase0
|
8
|
+
module Sources
|
9
|
+
class Base < ::Avm::EacWebappBase0::Sources::Base
|
10
|
+
# @return [Boolean]
|
11
|
+
def valid?
|
12
|
+
path.glob('*.php').any?(&:file?)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
File without changes
|
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = Dir['{lib}/**/*']
|
14
14
|
|
15
|
-
s.add_dependency 'avm', '~> 0.
|
16
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
15
|
+
s.add_dependency 'avm', '~> 0.57'
|
16
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.108'
|
17
17
|
|
18
18
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.4'
|
19
19
|
end
|
@@ -27,12 +27,18 @@ module Avm
|
|
27
27
|
.envvar('PGPASSWORD', password)
|
28
28
|
end
|
29
29
|
|
30
|
+
# @return [EacRubyUtils::Envs::Command]
|
30
31
|
def dump_gzip_command
|
31
|
-
dump_command.
|
32
|
+
dump_command.pipe(env.command('gzip', '-9', '-c'))
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
def password_command_argument
|
37
|
+
"@ESC_PGPASSWORD=#{password}"
|
32
38
|
end
|
33
39
|
|
34
40
|
def psql_command(database = true)
|
35
|
-
env.command(
|
41
|
+
env.command(password_command_argument, 'psql', *common_command_args(database))
|
36
42
|
end
|
37
43
|
|
38
44
|
def psql_command_command(sql, database = true)
|
@@ -8,9 +8,11 @@ module Avm
|
|
8
8
|
module InstanceWith
|
9
9
|
def pg
|
10
10
|
@pg ||= ::Avm::EacPostgresqlBase0::Instance.new(
|
11
|
-
host_env,
|
12
|
-
|
13
|
-
|
11
|
+
host_env, host: database_hostname,
|
12
|
+
port: database_port,
|
13
|
+
user: database_username,
|
14
|
+
password: database_password,
|
15
|
+
name: database_name
|
14
16
|
)
|
15
17
|
end
|
16
18
|
end
|
data/sub/avm-git/avm-git.gemspec
CHANGED
@@ -12,10 +12,10 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = Dir['{lib}/**/*']
|
14
14
|
|
15
|
-
s.add_dependency 'avm', '~> 0.
|
15
|
+
s.add_dependency 'avm', '~> 0.57'
|
16
16
|
s.add_dependency 'avm-files', '~> 0.6'
|
17
|
-
s.add_dependency 'eac_git', '~> 0.
|
18
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
17
|
+
s.add_dependency 'eac_git', '~> 0.14'
|
18
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.108'
|
19
19
|
s.add_dependency 'git', '~> 1.12'
|
20
20
|
|
21
21
|
s.add_development_dependency 'aranha-parsers', '~> 0.8', '>= 0.8.5'
|
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
16
|
|
17
17
|
s.add_dependency 'aranha-parsers', '~> 0.14', '>= 0.14.4'
|
18
|
-
s.add_dependency 'avm', '~> 0.
|
18
|
+
s.add_dependency 'avm', '~> 0.57'
|
19
19
|
s.add_dependency 'avm-eac_ruby_base1', '~> 0.27', '>= 0.27.1'
|
20
20
|
s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
|
21
21
|
s.add_dependency 'avm-files', '~> 0.6'
|
22
|
-
s.add_dependency 'avm-git', '~> 0.10'
|
22
|
+
s.add_dependency 'avm-git', '~> 0.10', '>= 0.10.1'
|
23
23
|
s.add_dependency 'clipboard', '~> 1.3', '>= 1.3.6'
|
24
24
|
s.add_dependency 'curb', '~> 0.9', '>= 0.9.11'
|
25
25
|
s.add_dependency 'eac_git', '~> 0.14'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
4
5
|
require 'fileutils'
|
5
6
|
|
6
7
|
module EacFs
|
@@ -33,12 +34,30 @@ module EacFs
|
|
33
34
|
read
|
34
35
|
end
|
35
36
|
|
37
|
+
# @return [Object]
|
38
|
+
def read_or_store_yaml(use_cache = true)
|
39
|
+
write_yaml(yield) unless stored? && use_cache
|
40
|
+
|
41
|
+
read_yaml
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Object, nil]
|
45
|
+
def read_yaml
|
46
|
+
r = read
|
47
|
+
r.nil? ? nil : ::EacRubyUtils::Yaml.load(r)
|
48
|
+
end
|
49
|
+
|
36
50
|
def write(value)
|
37
51
|
assert_directory_on_path
|
38
52
|
::File.write(content_path, value)
|
39
53
|
value
|
40
54
|
end
|
41
55
|
|
56
|
+
def write_yaml(object)
|
57
|
+
write(::EacRubyUtils::Yaml.dump(object))
|
58
|
+
object
|
59
|
+
end
|
60
|
+
|
42
61
|
def child(*child_path_parts)
|
43
62
|
self.class.new(path, *child_path_parts)
|
44
63
|
end
|
@@ -0,0 +1,38 @@
|
|
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
|
+
class AppendCommandOptions
|
10
|
+
enable_method_class
|
11
|
+
common_constructor :command, :command_line, :options
|
12
|
+
|
13
|
+
def result
|
14
|
+
r = command_line
|
15
|
+
r = input.command + ' | ' + r if input
|
16
|
+
r = "cat #{Shellwords.escape(input_file)} | #{r}" if input_file
|
17
|
+
r += ' > ' + Shellwords.escape(output_file) if output_file
|
18
|
+
r
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [EacRubyUtils::Envs::Command, nil]
|
22
|
+
def input
|
23
|
+
options[:input]
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Pathname, nil]
|
27
|
+
def input_file
|
28
|
+
options[:input_file].if_present(&:to_pathname)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Pathname, nil]
|
32
|
+
def output_file
|
33
|
+
options[:output_file].if_present(&:to_pathname)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/struct'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Envs
|
7
|
+
module BaseCommand
|
8
|
+
module Concat
|
9
|
+
AND_OPERATOR = '&&'
|
10
|
+
BEFORE_OPERATOR = ';'
|
11
|
+
OR_OPERATOR = '||'
|
12
|
+
PIPE_OPERATOR = '|'
|
13
|
+
|
14
|
+
# @param operator [Symbol]
|
15
|
+
# @return [EacRubyUtils::Envs::CompositeCommand]
|
16
|
+
def concat(operator, other_command)
|
17
|
+
require 'eac_ruby_utils/envs/composite_command'
|
18
|
+
::EacRubyUtils::Envs::CompositeCommand.new(operator, self, other_command)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [EacRubyUtils::Envs::Command]
|
22
|
+
def and(other_command)
|
23
|
+
concat(AND_OPERATOR, other_command)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [EacRubyUtils::Envs::Command]
|
27
|
+
def before(other_command)
|
28
|
+
concat(BEFORE_OPERATOR, other_command)
|
29
|
+
end
|
30
|
+
|
31
|
+
def or(other_command)
|
32
|
+
concat(OR_OPERATOR, other_command)
|
33
|
+
end
|
34
|
+
|
35
|
+
def pipe(other_command)
|
36
|
+
concat(PIPE_OPERATOR, other_command)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
module Envs
|
5
|
+
module BaseCommand
|
6
|
+
module Debugging
|
7
|
+
def debug?
|
8
|
+
ENV['DEBUG'].to_s.strip != ''
|
9
|
+
end
|
10
|
+
|
11
|
+
# Print a message if debugging is enabled.
|
12
|
+
def debug_print(message)
|
13
|
+
message = message.to_s
|
14
|
+
puts message.if_respond(:light_red, message) if debug?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/envs/execution_error'
|
4
|
+
require 'eac_ruby_utils/envs/execution_result'
|
5
|
+
require 'eac_ruby_utils/envs/process'
|
6
|
+
require 'eac_ruby_utils/envs/spawn'
|
7
|
+
require 'pp'
|
8
|
+
|
9
|
+
module EacRubyUtils
|
10
|
+
module Envs
|
11
|
+
module BaseCommand
|
12
|
+
module Execution
|
13
|
+
def execute!(options = {})
|
14
|
+
options[:exit_outputs] = status_results.merge(options[:exit_outputs].presence || {})
|
15
|
+
er = ::EacRubyUtils::Envs::ExecutionResult.new(execute(options), options)
|
16
|
+
return er.result if er.success?
|
17
|
+
|
18
|
+
raise ::EacRubyUtils::Envs::ExecutionError,
|
19
|
+
"execute! command failed: #{self}\n#{er.r.pretty_inspect}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute(options = {})
|
23
|
+
c = command(options)
|
24
|
+
debug_print("BEFORE: #{c}")
|
25
|
+
t1 = Time.now
|
26
|
+
r = ::EacRubyUtils::Envs::Process.new(c).to_h
|
27
|
+
i = Time.now - t1
|
28
|
+
debug_print("AFTER [#{i}]: #{c}")
|
29
|
+
r
|
30
|
+
end
|
31
|
+
|
32
|
+
def spawn(options = {})
|
33
|
+
c = command(options)
|
34
|
+
debug_print("SPAWN: #{c}")
|
35
|
+
::EacRubyUtils::Envs::Spawn.new(c)
|
36
|
+
end
|
37
|
+
|
38
|
+
def system!(options = {})
|
39
|
+
return if system(options)
|
40
|
+
|
41
|
+
raise ::EacRubyUtils::Envs::ExecutionError, "system! command failed: #{self}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def system(options = {})
|
45
|
+
c = command(options)
|
46
|
+
debug_print(c)
|
47
|
+
Kernel.system(c)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
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
|