ehbrs-tools 0.15.0 → 0.16.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/runner.rb +4 -7
- data/lib/ehbrs/runner/finances.rb +4 -7
- data/lib/ehbrs/runner/finances/bb_browser.rb +5 -10
- data/lib/ehbrs/runner/fs.rb +4 -7
- data/lib/ehbrs/runner/fs/used_space.rb +4 -5
- data/lib/ehbrs/runner/google.rb +4 -7
- data/lib/ehbrs/runner/google/translate.rb +7 -12
- data/lib/ehbrs/runner/self.rb +4 -7
- data/lib/ehbrs/runner/self/test.rb +5 -10
- data/lib/ehbrs/runner/vg.rb +4 -7
- data/lib/ehbrs/runner/vg/ips.rb +9 -14
- data/lib/ehbrs/runner/vg/wii.rb +10 -13
- data/lib/ehbrs/runner/videos.rb +3 -5
- data/lib/ehbrs/runner/videos/extract.rb +10 -13
- data/lib/ehbrs/runner/videos/probe.rb +6 -9
- data/lib/ehbrs/runner/videos/series.rb +5 -8
- data/lib/ehbrs/runner/videos/series/rename.rb +9 -12
- data/lib/ehbrs/runner/videos/unsupported.rb +9 -13
- data/lib/ehbrs/runner/web_utils.rb +5 -7
- data/lib/ehbrs/runner/web_utils/videos.rb +4 -6
- data/lib/ehbrs/runner/web_utils/videos/download.rb +8 -11
- data/lib/ehbrs/runner/web_utils/videos/upload.rb +8 -11
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/vg/wii/wit/parsers/dump.rb +10 -5
- data/lib/ehbrs/videos/file.rb +4 -8
- data/lib/ehbrs/videos/series/rename/file/options.rb +3 -13
- data/lib/ehbrs/videos/track.rb +20 -10
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +2 -0
- data/lib/ehbrs/videos/unsupported/checks/invalid_extension.rb +2 -0
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +1 -1
- data/lib/ehbrs/videos/unsupported/profiles/base.rb +17 -3
- data/lib/ehbrs/videos/unsupported/profiles/philco.rb +5 -4
- data/vendor/aranha-parsers/Gemfile +5 -0
- data/vendor/aranha-parsers/aranha-parsers.gemspec +23 -0
- data/vendor/aranha-parsers/lib/aranha/parsers.rb +9 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +79 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/base.rb +47 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/item.rb +24 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/item_list.rb +29 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node.rb +13 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/base.rb +36 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +126 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/invalid_state_exception.rb +8 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/patches.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/patches/ofx_parser.rb +38 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address.rb +55 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/file.rb +31 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_get.rb +25 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb +45 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +49 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_target_fixtures.rb +77 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +78 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +7 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address/http_get_spec.rb +21 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address_spec.rb +74 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec.rb +27 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml +1 -0
- data/vendor/aranha-parsers/spec/lib/rubocop_check_spec.rb +7 -0
- data/vendor/aranha-parsers/spec/spec_helper.rb +8 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition.rb +49 -22
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +17 -1
- data/vendor/eac_cli/lib/eac_cli/{parser/options_collection.rb → definition/help_formatter.rb} +20 -49
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +21 -4
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +1 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner.rb +17 -5
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +19 -2
- data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +18 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +101 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +35 -0
- data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +59 -39
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +85 -0
- data/vendor/eac_docker/lib/eac_docker/container.rb +24 -0
- data/vendor/eac_docker/lib/eac_docker/images/coded.rb +39 -0
- data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +26 -0
- data/vendor/eac_docker/lib/eac_docker/registry.rb +17 -0
- data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
- data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec.rb +12 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +1 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec.rb +17 -0
- data/vendor/eac_docker/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +1 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/blank_not_blank.rb +19 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/base.rb +43 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs/file.rb +12 -31
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +7 -104
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +46 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +21 -58
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb +67 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/path_search.rb +39 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +2 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +11 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/blank_not_blank_spec.rb +16 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/configs_spec.rb +15 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/paths_hash_spec.rb +52 -13
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +30 -2
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/convert_job.rb +91 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +51 -0
- metadata +108 -13
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -21
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -49
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +0 -31
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +0 -21
@@ -4,67 +4,87 @@ require 'eac_ruby_utils/console/docopt_runner'
|
|
4
4
|
require 'eac_cli/runner'
|
5
5
|
|
6
6
|
RSpec.describe ::EacCli::Runner do
|
7
|
-
let(:
|
8
|
-
|
7
|
+
let(:runner_class) do
|
8
|
+
the_module = described_class
|
9
|
+
::Class.new do
|
10
|
+
include the_module
|
11
|
+
|
12
|
+
runner_definition do
|
13
|
+
arg_opt '-o', '--opt1', 'A arg option.'
|
14
|
+
bool_opt '-o', '--opt2', 'A boolean option'
|
15
|
+
pos_arg :pos1
|
16
|
+
pos_arg :pos2, repeat: true, optional: true
|
17
|
+
alt do
|
18
|
+
bool_opt '-a', '--opt3', 'A boolean option in a alternative.', required: true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
9
22
|
def run; end
|
10
23
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:instance) { runner_class.create(argv) }
|
27
|
+
let(:parsed_actual) { instance.parsed.to_h.symbolize_keys }
|
28
|
+
|
29
|
+
context 'when all args are supplied' do
|
30
|
+
let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd] }
|
31
|
+
let(:parsed_expected) do
|
32
|
+
{ opt1: 'aaa', opt2: true, opt3: false, pos1: 'bbb',
|
33
|
+
pos2: %w[ccc ddd] }
|
16
34
|
end
|
17
|
-
|
35
|
+
|
36
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
37
|
+
it { expect(instance.parsed.opt1).to eq('aaa') }
|
38
|
+
it { expect(instance.parsed.opt2?).to eq(true) }
|
39
|
+
it { expect(instance.parsed.pos1).to eq('bbb') }
|
40
|
+
it { expect(instance.parsed.pos2).to eq(%w[ccc ddd]) }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when only required args are supplied' do
|
44
|
+
let(:argv) { %w[bbb] }
|
45
|
+
let(:parsed_expected) { { opt1: nil, opt2: false, opt3: false, pos1: 'bbb', pos2: [] } }
|
46
|
+
|
47
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
48
|
+
it { expect(instance.parsed.opt1).to be_nil }
|
49
|
+
it { expect(instance.parsed.opt2?).to eq(false) }
|
50
|
+
it { expect(instance.parsed.pos1).to eq('bbb') }
|
51
|
+
it { expect(instance.parsed.pos2).to eq([]) }
|
18
52
|
end
|
19
53
|
|
20
|
-
|
54
|
+
context 'when required args are not supplied' do
|
55
|
+
let(:argv) { %w[] }
|
21
56
|
|
22
|
-
|
57
|
+
it do
|
58
|
+
expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when alternative args are supplied' do
|
63
|
+
let(:argv) { %w[--opt3] }
|
64
|
+
let(:parsed_expected) { { opt1: nil, opt2: false, opt3: true, pos1: nil, pos2: [] } }
|
23
65
|
|
24
|
-
|
25
|
-
|
66
|
+
it { expect(parsed_actual).to eq(parsed_expected) }
|
67
|
+
it { expect(instance.parsed.opt3?).to eq(true) }
|
68
|
+
end
|
26
69
|
|
27
|
-
context '
|
70
|
+
context 'when extra args are not supplied' do
|
28
71
|
let(:runner_class) do
|
29
72
|
the_module = described_class
|
30
73
|
::Class.new do
|
31
74
|
include the_module
|
32
75
|
|
33
76
|
runner_definition do
|
34
|
-
arg_opt '-o', '--opt1', 'A arg option.'
|
35
|
-
bool_opt '-o', '--opt2', 'A boolean option'
|
36
77
|
pos_arg :pos1
|
37
|
-
pos_arg :pos2, repeat: true, optional: true
|
38
78
|
end
|
39
79
|
|
40
80
|
def run; end
|
41
81
|
end
|
42
82
|
end
|
43
83
|
|
44
|
-
|
45
|
-
let(:instance) { runner_class.create(%w[--opt1 aaa --opt2 bbb ccc ddd]) }
|
46
|
-
|
47
|
-
it { expect(instance.parsed.opt1).to eq('aaa') }
|
48
|
-
it { expect(instance.parsed.opt2?).to eq(true) }
|
49
|
-
it { expect(instance.parsed.pos1).to eq('bbb') }
|
50
|
-
it { expect(instance.parsed.pos2).to eq(%w[ccc ddd]) }
|
51
|
-
end
|
84
|
+
let(:argv) { %w[aaa bbb] }
|
52
85
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
it { expect(instance.parsed.opt1).to be_nil }
|
57
|
-
it { expect(instance.parsed.opt2?).to eq(false) }
|
58
|
-
it { expect(instance.parsed.pos1).to eq('bbb') }
|
59
|
-
it { expect(instance.parsed.pos2).to eq([]) }
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when required args are not supplied' do
|
63
|
-
let(:instance) { runner_class.create(%w[]) }
|
64
|
-
|
65
|
-
it do
|
66
|
-
expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
|
67
|
-
end
|
86
|
+
it do
|
87
|
+
expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
|
68
88
|
end
|
69
89
|
end
|
70
90
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner_with/help'
|
4
|
+
require 'eac_ruby_utils/fs/temp'
|
5
|
+
|
6
|
+
RSpec.describe ::EacCli::RunnerWith::Help do
|
7
|
+
let(:runner) do
|
8
|
+
the_module = described_class
|
9
|
+
Class.new do
|
10
|
+
include the_module
|
11
|
+
|
12
|
+
runner_definition do
|
13
|
+
desc 'A stub runner.'
|
14
|
+
pos_arg :a_argument
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
puts 'Runner run'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:runner_argv) { ['--help'] }
|
24
|
+
let(:instance) { runner.create(argv: runner_argv) }
|
25
|
+
let(:expected_output) do
|
26
|
+
<<~OUTPUT
|
27
|
+
A stub runner.
|
28
|
+
|
29
|
+
Usage:
|
30
|
+
__PROGRAM__ [options] <a_argument>
|
31
|
+
__PROGRAM__ --help
|
32
|
+
|
33
|
+
Options:
|
34
|
+
-h --help Show help.
|
35
|
+
|
36
|
+
OUTPUT
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'show help text' do
|
40
|
+
expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner_with/output_file'
|
4
|
+
require 'eac_ruby_utils/fs/temp'
|
5
|
+
|
6
|
+
RSpec.describe ::EacCli::RunnerWith::OutputFile do
|
7
|
+
let(:runner) do
|
8
|
+
the_module = described_class
|
9
|
+
Class.new do
|
10
|
+
include the_module
|
11
|
+
|
12
|
+
runner_definition do
|
13
|
+
desc 'A stub root runner.'
|
14
|
+
pos_arg :input_text
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
run_output
|
19
|
+
end
|
20
|
+
|
21
|
+
def output_content
|
22
|
+
parsed.input_text
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:stub_text) { 'STUB_TEXT' }
|
28
|
+
let(:instance) { runner.create(argv: runner_argv) }
|
29
|
+
|
30
|
+
context 'without --output-file option' do
|
31
|
+
let(:runner_argv) { [stub_text] }
|
32
|
+
|
33
|
+
it do
|
34
|
+
expect { instance.run }.to output(stub_text).to_stdout_from_any_process
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with --output-file option' do
|
39
|
+
let(:output_file) { ::EacRubyUtils::Fs::Temp.file }
|
40
|
+
let(:runner_argv) { ['--output-file', output_file.to_path, stub_text] }
|
41
|
+
|
42
|
+
before do
|
43
|
+
instance.run
|
44
|
+
end
|
45
|
+
|
46
|
+
after do
|
47
|
+
output_file.remove
|
48
|
+
end
|
49
|
+
|
50
|
+
it { expect(output_file).to exist }
|
51
|
+
it { expect(output_file.read).to eq(stub_text) }
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner'
|
4
|
+
require 'eac_cli/runner_with/help'
|
5
|
+
require 'eac_cli/runner_with/subcommands'
|
6
|
+
|
7
|
+
RSpec.describe ::EacCli::RunnerWith::Subcommands do
|
8
|
+
let(:parent_runner) do
|
9
|
+
the_module = described_class
|
10
|
+
the_child = child_runner
|
11
|
+
Class.new do
|
12
|
+
include the_module
|
13
|
+
const_set('ChildCmd', the_child)
|
14
|
+
|
15
|
+
runner_definition do
|
16
|
+
desc 'A stub root runner.'
|
17
|
+
arg_opt '-r', '--root-var', 'A root variable.'
|
18
|
+
subcommands
|
19
|
+
end
|
20
|
+
|
21
|
+
delegate :root_var, to: :parsed
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:child_runner) do
|
26
|
+
::Class.new do
|
27
|
+
include ::EacCli::Runner
|
28
|
+
|
29
|
+
runner_definition do
|
30
|
+
bool_opt '-c', '--child-opt', 'A boolean option.'
|
31
|
+
pos_arg :child_var
|
32
|
+
end
|
33
|
+
|
34
|
+
def run; end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:instance) { parent_runner.create(argv: parent_argv) }
|
39
|
+
|
40
|
+
context 'when subcommand is supplied' do
|
41
|
+
let(:parent_argv) { %w[--root-var 123 child-cmd --child-opt 456] }
|
42
|
+
|
43
|
+
it { expect(instance.parsed.root_var).to eq('123') }
|
44
|
+
it { expect(instance.parsed.subcommand).to eq('child-cmd') }
|
45
|
+
it { expect(instance.parsed.subcommand_args).to eq(%w[--child-opt 456]) }
|
46
|
+
it { expect(instance.subcommand_runner.parsed.child_opt).to eq(true) }
|
47
|
+
it { expect(instance.subcommand_runner.parsed.child_var).to eq('456') }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when subcommand is not supplied' do
|
51
|
+
let(:instance) { parent_runner.create(%w[456]) }
|
52
|
+
|
53
|
+
it do
|
54
|
+
expect { instance.run }.to raise_error(::EacCli::Parser::Error)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with help' do
|
59
|
+
let(:instance) { parent_runner.create(%w[--help]) }
|
60
|
+
let(:expected_output) do
|
61
|
+
<<~OUTPUT
|
62
|
+
A stub root runner.
|
63
|
+
|
64
|
+
Usage:
|
65
|
+
__PROGRAM__ [options] __SUBCOMMANDS__ [<subcommand_args>...]
|
66
|
+
__PROGRAM__ --help
|
67
|
+
|
68
|
+
Options:
|
69
|
+
-r --root-var=<value> A root variable.
|
70
|
+
-h --help Show help.
|
71
|
+
|
72
|
+
Subcommands:
|
73
|
+
child-cmd
|
74
|
+
OUTPUT
|
75
|
+
end
|
76
|
+
|
77
|
+
before do
|
78
|
+
parent_runner.include(::EacCli::RunnerWith::Help)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'show help text' do
|
82
|
+
expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -8,6 +8,7 @@ module EacDocker
|
|
8
8
|
immutable_accessor :interactive, :temporary, :tty, type: :boolean
|
9
9
|
immutable_accessor :env, type: :hash
|
10
10
|
immutable_accessor :command_arg, :volume, type: :array
|
11
|
+
attr_reader :id
|
11
12
|
common_constructor :image
|
12
13
|
|
13
14
|
def immutable_constructor_args
|
@@ -16,6 +17,23 @@ module EacDocker
|
|
16
17
|
|
17
18
|
alias immutable_volume volume
|
18
19
|
|
20
|
+
def hostname
|
21
|
+
::EacDocker::Executables.docker.command(
|
22
|
+
'inspect', '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}',
|
23
|
+
id
|
24
|
+
).execute!.strip
|
25
|
+
end
|
26
|
+
|
27
|
+
def on_detached
|
28
|
+
command = ::EacDocker::Executables.docker.command(*(%w[run --detach] + run_command_args))
|
29
|
+
self.id = command.execute!.strip
|
30
|
+
begin
|
31
|
+
yield(self)
|
32
|
+
ensure
|
33
|
+
stop
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
19
37
|
def volume(left_part, right_part = null)
|
20
38
|
immutable_volume(right_part.if_present(left_part) { |v| "#{left_part}:#{v}" })
|
21
39
|
end
|
@@ -29,8 +47,14 @@ module EacDocker
|
|
29
47
|
command_args
|
30
48
|
end
|
31
49
|
|
50
|
+
def stop
|
51
|
+
::EacDocker::Executables.docker.command('stop', id).execute!
|
52
|
+
end
|
53
|
+
|
32
54
|
private
|
33
55
|
|
56
|
+
attr_writer :id
|
57
|
+
|
34
58
|
def run_command_boolean_args
|
35
59
|
r = []
|
36
60
|
r << '--interactive' if interactive?
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_docker/executables'
|
4
|
+
require 'eac_docker/images/base'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module EacDocker
|
8
|
+
module Images
|
9
|
+
class Coded < ::EacDocker::Images::Base
|
10
|
+
enable_simple_cache
|
11
|
+
enable_immutable
|
12
|
+
immutable_accessor :tag
|
13
|
+
common_constructor :path do
|
14
|
+
self.path = path.to_pathname
|
15
|
+
end
|
16
|
+
|
17
|
+
def immutable_constructor_args
|
18
|
+
[path]
|
19
|
+
end
|
20
|
+
|
21
|
+
def provide
|
22
|
+
id
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def id_uncached
|
29
|
+
::EacDocker::Executables.docker.command(*build_args).execute!.strip
|
30
|
+
end
|
31
|
+
|
32
|
+
def build_args
|
33
|
+
args = %w[build --quiet]
|
34
|
+
args += ['--tag', tag] if tag.present?
|
35
|
+
args + [path.to_path]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_docker/images/base'
|
4
|
+
require 'eac_docker/images/coded'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
require 'eac_ruby_utils/fs/temp'
|
7
|
+
|
8
|
+
module EacDocker
|
9
|
+
module Images
|
10
|
+
class Templatized < ::EacDocker::Images::Base
|
11
|
+
enable_immutable
|
12
|
+
immutable_accessor :tag
|
13
|
+
|
14
|
+
def provide
|
15
|
+
::EacRubyUtils::Fs::Temp.on_directory do |provide_dir|
|
16
|
+
template.apply(self, provide_dir)
|
17
|
+
coded_image(provide_dir).tag(tag).provide
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def coded_image(provide_dir)
|
22
|
+
::EacDocker::Images::Coded.new(provide_dir)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|