eac_tools 0.82.0 → 0.83.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +45 -40
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +4 -3
  5. data/sub/avm/lib/avm/data/rotate.rb +1 -1
  6. data/sub/avm/lib/avm/launcher/instances/base/publishing.rb +1 -1
  7. data/sub/avm/lib/avm/registry/from_gems.rb +2 -2
  8. data/sub/avm/lib/avm/rspec/shared_examples/avm_file_formats_with_fixtures.rb +0 -1
  9. data/sub/avm/lib/avm/source_generators/base.rb +1 -0
  10. data/sub/avm/lib/avm/source_generators/runner.rb +6 -0
  11. data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
  12. data/sub/avm/lib/avm/version.rb +1 -1
  13. data/sub/avm/spec/lib/avm/launcher/instances/base_spec_files/projects/avm-tools_stub/avm-tools.gemspec +1 -0
  14. data/sub/avm/spec/lib/avm/launcher/instances/base_spec_files/projects/ruby_gem_stub/ruby_gem_stub.gemspec +1 -0
  15. data/sub/avm-eac_asciidoctor_base0/Gemfile +2 -2
  16. data/sub/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +6 -5
  17. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb +5 -3
  18. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb +2 -2
  19. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base/document.rb +2 -2
  20. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +1 -3
  21. data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  22. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/file_formats/base_spec.rb +1 -1
  23. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec.rb +18 -18
  24. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec_files/pre_processed_root_body.adoc +1 -0
  25. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build_spec.rb +3 -3
  26. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec.rb +1 -1
  27. data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/base_spec.rb +2 -2
  28. data/sub/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +1 -1
  29. data/sub/avm-eac_asciidoctor_base0/spec/spec_helper/eac_asciidoctor_base0_stubs.rb +1 -1
  30. data/sub/avm-eac_asciidoctor_base0/spec/spec_helper.rb +3 -3
  31. data/sub/avm-eac_python_base0/Gemfile +2 -2
  32. data/sub/avm-eac_python_base0/avm-eac_python_base0.gemspec +5 -4
  33. data/sub/avm-eac_python_base0/lib/avm/eac_python_base0/executables.rb +1 -1
  34. data/sub/avm-eac_python_base0/lib/avm/eac_python_base0/version.rb +1 -1
  35. data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec.rb +1 -1
  36. data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec_files/python_code.source +1 -1
  37. data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec_files/python_code.target +1 -1
  38. data/sub/avm-eac_python_base0/spec/rubocop_spec.rb +1 -1
  39. data/sub/avm-eac_python_base0/spec/spec_helper.rb +1 -1
  40. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
  41. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb +2 -1
  42. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  43. metadata +14 -144
  44. data/sub/eac_cli/Gemfile +0 -8
  45. data/sub/eac_cli/eac_cli.gemspec +0 -22
  46. data/sub/eac_cli/lib/eac_cli/config/entry/options.rb +0 -58
  47. data/sub/eac_cli/lib/eac_cli/config/entry/undefined.rb +0 -31
  48. data/sub/eac_cli/lib/eac_cli/config/entry.rb +0 -60
  49. data/sub/eac_cli/lib/eac_cli/config.rb +0 -17
  50. data/sub/eac_cli/lib/eac_cli/core_ext.rb +0 -6
  51. data/sub/eac_cli/lib/eac_cli/default_runner.rb +0 -14
  52. data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +0 -105
  53. data/sub/eac_cli/lib/eac_cli/definition/argument_option.rb +0 -21
  54. data/sub/eac_cli/lib/eac_cli/definition/boolean_option.rb +0 -27
  55. data/sub/eac_cli/lib/eac_cli/definition/error.rb +0 -8
  56. data/sub/eac_cli/lib/eac_cli/definition/option/initialize_args_parser.rb +0 -48
  57. data/sub/eac_cli/lib/eac_cli/definition/option.rb +0 -73
  58. data/sub/eac_cli/lib/eac_cli/definition/option_or_positional.rb +0 -43
  59. data/sub/eac_cli/lib/eac_cli/definition/positional.rb +0 -53
  60. data/sub/eac_cli/lib/eac_cli/definition.rb +0 -109
  61. data/sub/eac_cli/lib/eac_cli/enum.rb +0 -45
  62. data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +0 -80
  63. data/sub/eac_cli/lib/eac_cli/old_configs/password_entry_reader.rb +0 -16
  64. data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +0 -44
  65. data/sub/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +0 -25
  66. data/sub/eac_cli/lib/eac_cli/old_configs.rb +0 -35
  67. data/sub/eac_cli/lib/eac_cli/parser/alternative/any_options.rb +0 -19
  68. data/sub/eac_cli/lib/eac_cli/parser/alternative/argv.rb +0 -19
  69. data/sub/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +0 -24
  70. data/sub/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +0 -37
  71. data/sub/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +0 -29
  72. data/sub/eac_cli/lib/eac_cli/parser/alternative/options.rb +0 -29
  73. data/sub/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +0 -30
  74. data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +0 -54
  75. data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +0 -103
  76. data/sub/eac_cli/lib/eac_cli/parser/collector.rb +0 -55
  77. data/sub/eac_cli/lib/eac_cli/parser/error.rb +0 -15
  78. data/sub/eac_cli/lib/eac_cli/parser.rb +0 -34
  79. data/sub/eac_cli/lib/eac_cli/patches/object/runner_with.rb +0 -26
  80. data/sub/eac_cli/lib/eac_cli/patches/object.rb +0 -5
  81. data/sub/eac_cli/lib/eac_cli/patches.rb +0 -4
  82. data/sub/eac_cli/lib/eac_cli/rspec/setup.rb +0 -42
  83. data/sub/eac_cli/lib/eac_cli/rspec.rb +0 -9
  84. data/sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb +0 -38
  85. data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +0 -36
  86. data/sub/eac_cli/lib/eac_cli/runner/context.rb +0 -63
  87. data/sub/eac_cli/lib/eac_cli/runner/context_responders/base.rb +0 -24
  88. data/sub/eac_cli/lib/eac_cli/runner/context_responders/parent.rb +0 -27
  89. data/sub/eac_cli/lib/eac_cli/runner/context_responders/runner.rb +0 -20
  90. data/sub/eac_cli/lib/eac_cli/runner/context_responders/runner_missing_method.rb +0 -32
  91. data/sub/eac_cli/lib/eac_cli/runner/context_responders/set.rb +0 -44
  92. data/sub/eac_cli/lib/eac_cli/runner/context_responders.rb +0 -11
  93. data/sub/eac_cli/lib/eac_cli/runner/exit.rb +0 -14
  94. data/sub/eac_cli/lib/eac_cli/runner/for_context.rb +0 -40
  95. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +0 -45
  96. data/sub/eac_cli/lib/eac_cli/runner.rb +0 -50
  97. data/sub/eac_cli/lib/eac_cli/runner_with/confirmation.rb +0 -44
  98. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +0 -63
  99. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +0 -81
  100. data/sub/eac_cli/lib/eac_cli/runner_with/help/layout.rb +0 -40
  101. data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +0 -53
  102. data/sub/eac_cli/lib/eac_cli/runner_with/input.rb +0 -36
  103. data/sub/eac_cli/lib/eac_cli/runner_with/output.rb +0 -58
  104. data/sub/eac_cli/lib/eac_cli/runner_with/output_item/base_formatter.rb +0 -15
  105. data/sub/eac_cli/lib/eac_cli/runner_with/output_item/csv_formatter.rb +0 -23
  106. data/sub/eac_cli/lib/eac_cli/runner_with/output_item/yaml_formatter.rb +0 -18
  107. data/sub/eac_cli/lib/eac_cli/runner_with/output_item.rb +0 -42
  108. data/sub/eac_cli/lib/eac_cli/runner_with/output_list/base_formatter.rb +0 -30
  109. data/sub/eac_cli/lib/eac_cli/runner_with/output_list/csv_formatter.rb +0 -26
  110. data/sub/eac_cli/lib/eac_cli/runner_with/output_list/yaml_formatter.rb +0 -23
  111. data/sub/eac_cli/lib/eac_cli/runner_with/output_list.rb +0 -42
  112. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands/definition_concern.rb +0 -10
  113. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +0 -129
  114. data/sub/eac_cli/lib/eac_cli/runner_with.rb +0 -9
  115. data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +0 -56
  116. data/sub/eac_cli/lib/eac_cli/speaker/constants.rb +0 -13
  117. data/sub/eac_cli/lib/eac_cli/speaker/input_blocked.rb +0 -16
  118. data/sub/eac_cli/lib/eac_cli/speaker/input_requested.rb +0 -8
  119. data/sub/eac_cli/lib/eac_cli/speaker/list.rb +0 -61
  120. data/sub/eac_cli/lib/eac_cli/speaker/options.rb +0 -38
  121. data/sub/eac_cli/lib/eac_cli/speaker.rb +0 -127
  122. data/sub/eac_cli/lib/eac_cli/version.rb +0 -5
  123. data/sub/eac_cli/lib/eac_cli.rb +0 -7
  124. data/sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +0 -18
  125. data/sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb +0 -14
  126. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative/subcommands_spec.rb +0 -58
  127. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +0 -89
  128. data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +0 -79
  129. data/sub/eac_cli/spec/lib/eac_cli/runner_spec.rb +0 -129
  130. data/sub/eac_cli/spec/lib/eac_cli/runner_with/confirmation_spec.rb +0 -42
  131. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +0 -21
  132. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +0 -51
  133. data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +0 -81
  134. data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -98
  135. data/sub/eac_cli/spec/lib/eac_cli/speaker_spec.rb +0 -32
  136. data/sub/eac_cli/spec/rubocop_spec.rb +0 -3
  137. data/sub/eac_cli/spec/spec_helper.rb +0 -4
  138. data/sub/eac_config/Gemfile +0 -8
  139. data/sub/eac_config/eac_config.gemspec +0 -19
  140. data/sub/eac_config/lib/eac_config/entries.rb +0 -35
  141. data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +0 -13
  142. data/sub/eac_config/lib/eac_config/entry.rb +0 -64
  143. data/sub/eac_config/lib/eac_config/entry_path.rb +0 -89
  144. data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +0 -54
  145. data/sub/eac_config/lib/eac_config/envvars_node.rb +0 -35
  146. data/sub/eac_config/lib/eac_config/load_nodes_search.rb +0 -39
  147. data/sub/eac_config/lib/eac_config/load_path.rb +0 -28
  148. data/sub/eac_config/lib/eac_config/node.rb +0 -81
  149. data/sub/eac_config/lib/eac_config/node_entry.rb +0 -28
  150. data/sub/eac_config/lib/eac_config/node_uri/instanciate_single.rb +0 -29
  151. data/sub/eac_config/lib/eac_config/node_uri.rb +0 -45
  152. data/sub/eac_config/lib/eac_config/old_configs/base.rb +0 -43
  153. data/sub/eac_config/lib/eac_config/old_configs/file.rb +0 -47
  154. data/sub/eac_config/lib/eac_config/old_configs.rb +0 -75
  155. data/sub/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +0 -8
  156. data/sub/eac_config/lib/eac_config/paths_hash/node.rb +0 -67
  157. data/sub/eac_config/lib/eac_config/paths_hash/path_search.rb +0 -39
  158. data/sub/eac_config/lib/eac_config/paths_hash.rb +0 -63
  159. data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +0 -25
  160. data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +0 -19
  161. data/sub/eac_config/lib/eac_config/rspec/setup.rb +0 -65
  162. data/sub/eac_config/lib/eac_config/rspec.rb +0 -9
  163. data/sub/eac_config/lib/eac_config/version.rb +0 -5
  164. data/sub/eac_config/lib/eac_config/yaml_file_node/entry.rb +0 -36
  165. data/sub/eac_config/lib/eac_config/yaml_file_node/self_entries.rb +0 -72
  166. data/sub/eac_config/lib/eac_config/yaml_file_node.rb +0 -54
  167. data/sub/eac_config/lib/eac_config.rb +0 -7
  168. data/sub/eac_config/spec/lib/eac_config/entry_path_spec.rb +0 -30
  169. data/sub/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +0 -14
  170. data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +0 -51
  171. data/sub/eac_config/spec/lib/eac_config/old_configs_spec.rb +0 -46
  172. data/sub/eac_config/spec/lib/eac_config/paths_hash_spec.rb +0 -88
  173. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +0 -88
  174. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +0 -10
  175. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +0 -4
  176. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +0 -4
  177. data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +0 -10
  178. data/sub/eac_config/spec/rubocop_spec.rb +0 -3
  179. data/sub/eac_config/spec/spec_helper.rb +0 -4
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/old_configs'
4
-
5
- RSpec.describe EacCli::OldConfigs do
6
- describe '#entry_key_to_envvar_name' do
7
- {
8
- 'a.entry.value' => 'A_ENTRY_VALUE',
9
- 'appli-cation_0.var_one' => 'APPLICATION_0_VAR_ONE'
10
- }.each do |input, expected_result|
11
- it { expect(described_class.entry_key_to_envvar_name(input)).to eq(expected_result) }
12
- end
13
- end
14
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/definition/alternative'
4
- require 'eac_cli/parser/alternative'
5
-
6
- RSpec.describe EacCli::Parser::Alternative, '#subcommands' do
7
- let(:instance) { described_class.new(alternative, argv) }
8
- let(:actual_parsed) { instance.parsed.to_h.symbolize_keys }
9
- let(:alternative) do
10
- r = EacCli::Definition::Alternative.new
11
- r.bool_opt '-b', '--opt1', 'A boolean option'
12
- r.arg_opt '-a', '--opt2', 'A argument option'
13
- r.subcommands
14
- r
15
- end
16
-
17
- context 'with all values' do
18
- let(:argv) { %w[--opt1 --opt2 OPT2 CMD CMD_ARG_1 --CMD_ARG_2] }
19
- let(:parsed_expected) do
20
- {
21
- opt1: true, opt2: 'OPT2',
22
- EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
23
- EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => %w[CMD_ARG_1 --CMD_ARG_2]
24
- }
25
- end
26
-
27
- it { expect(instance.error).to be_blank }
28
- it { expect(actual_parsed).to eq(parsed_expected) }
29
- end
30
-
31
- context 'with only required values' do
32
- let(:argv) { %w[CMD] }
33
- let(:parsed_expected) do
34
- {
35
- opt1: false, opt2: nil,
36
- EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => 'CMD',
37
- EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
38
- }
39
- end
40
-
41
- it { expect(instance.error).to be_blank }
42
- it { expect(actual_parsed).to eq(parsed_expected) }
43
- end
44
-
45
- context 'without required values' do
46
- let(:argv) { %w[--opt1] }
47
- let(:parsed_expected) do
48
- {
49
- opt1: true, opt2: nil,
50
- EacCli::Definition::Alternative::SUBCOMMAND_NAME_ARG => nil,
51
- EacCli::Definition::Alternative::SUBCOMMAND_ARGS_ARG => []
52
- }
53
- end
54
-
55
- it { expect(instance.error).to be_present }
56
- it { expect(actual_parsed).to eq(parsed_expected) }
57
- end
58
- end
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/definition/alternative'
4
- require 'eac_cli/parser/alternative'
5
-
6
- RSpec.describe EacCli::Parser::Alternative do
7
- let(:instance) { described_class.new(alternative, argv) }
8
- let(:actual_parsed) { instance.parsed.to_h.symbolize_keys }
9
-
10
- context 'without subcommands' do
11
- let(:alternative) do
12
- r = EacCli::Definition::Alternative.new
13
- r.bool_opt '-b', '--opt1', 'A boolean option'
14
- r.arg_opt '-a', '--opt2', 'A argument option'
15
- r.bool_opt '-c', '--opt3', 'A required boolean option', required: true
16
- r.pos_arg :pos1
17
- r.pos_arg :pos2, optional: true, repeat: true
18
- r
19
- end
20
-
21
- context 'with all values' do
22
- let(:argv) { %w[--opt1 --opt2 OPT2 --opt3 POS1 POS2_1 POS2_2] }
23
- let(:parsed_expected) do
24
- {
25
- opt1: true, opt2: 'OPT2', opt3: true, pos1: 'POS1', pos2: %w[POS2_1 POS2_2]
26
- }
27
- end
28
-
29
- it { expect(instance.error).to be_blank }
30
- it { expect(actual_parsed).to eq(parsed_expected) }
31
- end
32
-
33
- context 'with only required values' do
34
- let(:argv) { %w[--opt3 POS1] }
35
- let(:parsed_expected) { { opt1: false, opt2: nil, opt3: true, pos1: 'POS1', pos2: [] } }
36
-
37
- it { expect(instance.error).to be_blank }
38
- it { expect(actual_parsed).to eq(parsed_expected) }
39
- end
40
-
41
- context 'with double dash' do
42
- let(:argv) { %w[--opt3 POS1 -- --opt1 --] }
43
- let(:parsed_expected) do
44
- { opt1: false, opt2: nil, opt3: true, pos1: 'POS1', pos2: %w[--opt1 --] }
45
- end
46
-
47
- it { expect(instance.error).to be_blank }
48
- it { expect(actual_parsed).to eq(parsed_expected) }
49
- end
50
-
51
- context 'without required positional' do
52
- let(:argv) { %w[--opt1 --opt3] }
53
- let(:parsed_expected) { { opt1: true, opt2: nil, opt3: true, pos1: nil, pos2: [] } }
54
-
55
- it { expect(instance.error).to be_present }
56
- it { expect(actual_parsed).to eq(parsed_expected) }
57
- end
58
-
59
- context 'without required option' do
60
- let(:argv) { %w[--opt1 POS1] }
61
- let(:parsed_expected) { { opt1: true, opt2: nil, opt3: false, pos1: 'POS1', pos2: [] } }
62
-
63
- it { expect(instance.error).to be_present }
64
- it { expect(actual_parsed).to eq(parsed_expected) }
65
- end
66
-
67
- context 'without any required option or positional' do
68
- let(:argv) { %w[] }
69
- let(:parsed_expected) { { opt1: false, opt2: nil, opt3: false, pos1: nil, pos2: [] } }
70
-
71
- it { expect(instance.error).to be_present }
72
- it { expect(actual_parsed).to eq(parsed_expected) }
73
- end
74
-
75
- context 'with excedent positional' do
76
- let(:alternative) do
77
- r = EacCli::Definition::Alternative.new
78
- r.pos_arg :pos1
79
- r
80
- end
81
-
82
- let(:argv) { %w[POS1 POS2] }
83
- let(:parsed_expected) { { pos1: 'POS1' } }
84
-
85
- it { expect(instance.error).to be_present }
86
- it { expect(actual_parsed).to eq(parsed_expected) }
87
- end
88
- end
89
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
-
5
- RSpec.describe EacCli::Runner, '#for_context' do
6
- let(:parent_runner_class) do
7
- example = self
8
- Class.new do
9
- include example.described_class
10
-
11
- def self.name
12
- 'ParentRunnerClass'
13
- end
14
-
15
- for_context :method_for_context
16
-
17
- def run; end
18
-
19
- def method_for_context; end
20
-
21
- def method_not_for_context; end
22
- end
23
- end
24
-
25
- let(:child_runner_class1) do # rubocop:disable RSpec/IndexedLet
26
- example = self
27
- Class.new do
28
- include example.described_class
29
-
30
- def self.name
31
- 'ChildRunnerClass1'
32
- end
33
-
34
- def run
35
- method_for_context
36
- runner_context.call(:method_for_context)
37
- runner_context.call(:method_not_for_context)
38
- end
39
- end
40
- end
41
-
42
- let(:child_runner_class2) do # rubocop:disable RSpec/IndexedLet
43
- example = self
44
- Class.new do
45
- include example.described_class
46
-
47
- def self.name
48
- 'ChildRunnerClass2'
49
- end
50
-
51
- def run
52
- method_not_for_context
53
- end
54
- end
55
- end
56
-
57
- let(:parent_runner) { parent_runner_class.create }
58
- let(:context_args) { [{ argv: [], parent: parent_runner }] }
59
- let(:child_runner) { child_runner_class.create(*context_args) }
60
-
61
- it { expect(parent_runner.for_context?(:method_for_context)).to be(true) }
62
- it { expect(parent_runner.for_context?(:method_not_for_context)).to be(false) }
63
-
64
- context 'when method is for context' do
65
- let(:child_runner_class) { child_runner_class1 }
66
-
67
- it do
68
- expect { child_runner.run }.not_to raise_error
69
- end
70
- end
71
-
72
- context 'when method is not for context' do
73
- let(:child_runner_class) { child_runner_class2 }
74
-
75
- it do
76
- expect { child_runner.run }.to raise_error(NameError)
77
- end
78
- end
79
- end
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
-
5
- RSpec.describe EacCli::Runner do
6
- let(:runner_class) do
7
- the_module = described_class
8
- Class.new do
9
- include the_module
10
-
11
- runner_definition do
12
- arg_opt '-o', '--opt1', 'A arg option.'
13
- bool_opt '-p', '--opt2', 'A boolean option'
14
- arg_opt '-q', '--opt4', 'A repeatable argument option.', repeat: true
15
- bool_opt '-r', '--opt5', 'A repeatable boolean option', repeat: true
16
- arg_opt '-s', '--opt6', 'A argument option with default value', default: 'DEFAULT'
17
- pos_arg :pos1
18
- pos_arg :pos2, repeat: true, optional: true
19
- alt do
20
- bool_opt '-a', '--opt3', 'A boolean option in a alternative.', required: true
21
- end
22
- end
23
-
24
- def run; end
25
- end
26
- end
27
-
28
- let(:instance) { runner_class.create(argv) }
29
- let(:parsed_actual) { instance.parsed.to_h.symbolize_keys }
30
-
31
- context 'when all args are supplied' do
32
- let(:argv) { %w[--opt1 aaa --opt2 bbb ccc ddd --opt6 6] }
33
- let(:parsed_expected) do
34
- { opt1: 'aaa', opt2: true, opt3: false, opt4: [], opt5: 0, opt6: '6', pos1: 'bbb',
35
- pos2: %w[ccc ddd] }
36
- end
37
-
38
- it { expect(parsed_actual).to eq(parsed_expected) }
39
- it { expect(instance.parsed.opt1).to eq('aaa') }
40
- it { expect(instance.parsed.opt2?).to be(true) }
41
- it { expect(instance.parsed.pos1).to eq('bbb') }
42
- it { expect(instance.parsed.pos2).to eq(%w[ccc ddd]) }
43
- end
44
-
45
- context 'with long option and argument in same position' do
46
- let(:argv) { %w[--opt1=aaa pos1] }
47
-
48
- it { expect(instance.parsed.opt1).to eq('aaa') }
49
- end
50
-
51
- context 'with valid grouped short options' do
52
- let(:argv) { %w[-po aaa pos1] }
53
-
54
- it { expect(instance.parsed.opt1).to eq('aaa') }
55
- it { expect(instance.parsed.opt2?).to be(true) }
56
- end
57
-
58
- context 'with invalid grouped short options' do
59
- let(:argv) { %w[-op aaa pos1] }
60
-
61
- it do
62
- expect { instance.parsed }.to raise_error(EacCli::Parser::Error)
63
- end
64
- end
65
-
66
- context 'when only required args are supplied' do
67
- let(:argv) { %w[bbb] }
68
- let(:parsed_expected) do
69
- { opt1: nil, opt2: false, opt3: false, opt4: [], opt5: 0, opt6: 'DEFAULT', pos1: 'bbb',
70
- pos2: [] }
71
- end
72
-
73
- it { expect(parsed_actual).to eq(parsed_expected) }
74
- it { expect(instance.parsed.opt1).to be_nil }
75
- it { expect(instance.parsed.opt2?).to be(false) }
76
- it { expect(instance.parsed.pos1).to eq('bbb') }
77
- it { expect(instance.parsed.pos2).to eq([]) }
78
- end
79
-
80
- context 'when required args are not supplied' do
81
- let(:argv) { %w[] }
82
-
83
- it do
84
- expect { instance.parsed }.to raise_error(EacCli::Parser::Error)
85
- end
86
- end
87
-
88
- context 'when alternative args are supplied' do
89
- let(:argv) { %w[--opt3] }
90
- let(:parsed_expected) do
91
- { opt1: nil, opt2: false, opt3: true, opt4: [], opt5: 0, opt6: 'DEFAULT', pos1: nil,
92
- pos2: [] }
93
- end
94
-
95
- it { expect(parsed_actual).to eq(parsed_expected) }
96
- it { expect(instance.parsed.opt3?).to be(true) }
97
- end
98
-
99
- context 'when repeated options are supplied' do
100
- let(:argv) { %w[--opt5 -rrr --opt4=A -q B --opt4 C AAA] }
101
- let(:parsed_expected) do
102
- { opt1: nil, opt2: false, opt3: false, opt4: %w[A B C], opt5: 4, opt6: 'DEFAULT', pos1: 'AAA',
103
- pos2: [] }
104
- end
105
-
106
- it { expect(parsed_actual).to eq(parsed_expected) }
107
- end
108
-
109
- context 'when extra args are not supplied' do
110
- let(:runner_class) do
111
- the_module = described_class
112
- Class.new do
113
- include the_module
114
-
115
- runner_definition do
116
- pos_arg :pos1
117
- end
118
-
119
- def run; end
120
- end
121
- end
122
-
123
- let(:argv) { %w[aaa bbb] }
124
-
125
- it do
126
- expect { instance.parsed }.to raise_error(EacCli::Parser::Error)
127
- end
128
- end
129
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner_with/confirmation'
4
-
5
- RSpec.describe EacCli::RunnerWith::Confirmation do
6
- let(:runner) do
7
- the_module = described_class
8
- Class.new do
9
- include the_module
10
-
11
- runner_definition do
12
- desc 'A stub runner.'
13
- end
14
-
15
- def run
16
- if confirm?
17
- Kernel.puts 'Accepted'
18
- else
19
- Kernel.puts 'Denied'
20
- end
21
- end
22
- end
23
- end
24
-
25
- let(:instance) { runner.create(argv: runner_argv) }
26
-
27
- context 'without --no option' do
28
- let(:runner_argv) { %w[--no] }
29
-
30
- it do
31
- expect { instance.run }.to output("Denied\n").to_stdout_from_any_process
32
- end
33
- end
34
-
35
- context 'without --yes option' do
36
- let(:runner_argv) { %w[--yes] }
37
-
38
- it do
39
- expect { instance.run }.to output("Accepted\n").to_stdout_from_any_process
40
- end
41
- end
42
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner_with/help/layout'
4
-
5
- RSpec.describe EacCli::RunnerWith::Help::Layout do
6
- describe '#list_section' do
7
- {
8
- ['Options', ['Option A', 'Option B']] => <<~TEXT
9
- Options:
10
- Option A
11
- Option B
12
- TEXT
13
- }.each do |source, expected|
14
- context "when source is #{source}" do
15
- it do
16
- expect(described_class.list_section(*source)).to eq(expected)
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,51 +0,0 @@
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
- [
24
- ['--help'],
25
- ['trash-pos-arg-before', '--help', 'trash-pos-arg-after', '--any-option', '-XYZ',
26
- 'other-trash-arg']
27
- ].each do |runner_argv|
28
- context "when runner ARGV is #{runner_argv}" do
29
- let(:instance) { runner.create(argv: runner_argv) }
30
- let(:expected_output_source) do
31
- <<~OUTPUT
32
- A stub runner.
33
-
34
- Usage:
35
- __PROGRAM__ [options] <a_argument>
36
- __PROGRAM__ --help
37
-
38
- Options:
39
- -h --help Show help.
40
- OUTPUT
41
- end
42
- let(:expected_output) do
43
- expected_output_source.gsub('__PROGRAM__', instance.program_name)
44
- end
45
-
46
- it 'show help text' do
47
- expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
48
- end
49
- end
50
- end
51
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner_with/output'
4
- require 'eac_ruby_utils/fs/temp'
5
-
6
- RSpec.describe EacCli::RunnerWith::Output do
7
- let(:runner) do
8
- the_module = described_class
9
- Class.new do
10
- include the_module
11
-
12
- attr_accessor :temp_dir
13
-
14
- runner_definition do
15
- desc 'A stub root runner.'
16
- pos_arg :input_text
17
- end
18
-
19
- def run
20
- run_output
21
- end
22
-
23
- def output_content
24
- parsed.input_text
25
- end
26
-
27
- def default_file_to_output
28
- temp_dir.join('default_file')
29
- end
30
- end
31
- end
32
-
33
- let(:stub_text) { 'STUB_TEXT' }
34
- let(:instance) do
35
- r = runner.create(argv: runner_argv)
36
- r.temp_dir = temp_dir
37
- r
38
- end
39
- let(:temp_dir) { EacRubyUtils::Fs::Temp.directory }
40
-
41
- after { temp_dir.remove }
42
-
43
- context 'without --output option' do
44
- let(:runner_argv) { [stub_text] }
45
-
46
- it do
47
- expect { instance.run }.to output(stub_text).to_stdout_from_any_process
48
- end
49
- end
50
-
51
- context 'without --output option as to stdout' do
52
- let(:runner_argv) { ['--output', EacCli::RunnerWith::Output::STDOUT_OPTION, stub_text] }
53
-
54
- it do
55
- expect { instance.run }.to output(stub_text).to_stdout_from_any_process
56
- end
57
- end
58
-
59
- context 'without --output option as to default file' do
60
- let(:output_file) { temp_dir.join('default_file') }
61
- let(:runner_argv) do
62
- ['--output', EacCli::RunnerWith::Output::DEFAULT_FILE_OPTION,
63
- stub_text]
64
- end
65
-
66
- before { instance.run }
67
-
68
- it { expect(output_file).to exist }
69
- it { expect(output_file.read).to eq(stub_text) }
70
- end
71
-
72
- context 'with --output option' do
73
- let(:output_file) { temp_dir.join('a output file') }
74
- let(:runner_argv) { ['--output', output_file.to_path, stub_text] }
75
-
76
- before { instance.run }
77
-
78
- it { expect(output_file).to exist }
79
- it { expect(output_file.read).to eq(stub_text) }
80
- end
81
- end
@@ -1,98 +0,0 @@
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
- for_context :method_in_parent_runner
23
-
24
- def method_in_parent_runner; end
25
- end
26
- end
27
-
28
- let(:child_runner) do
29
- Class.new do
30
- include EacCli::Runner
31
-
32
- runner_definition do
33
- bool_opt '-c', '--child-opt', 'A boolean option.'
34
- pos_arg :child_var
35
- end
36
-
37
- def run
38
- runner_context.call(:method_in_parent_runner)
39
- method_in_parent_runner
40
- end
41
- end
42
- end
43
-
44
- let(:instance) { parent_runner.create(argv: parent_argv) }
45
-
46
- context 'when subcommand is supplied' do
47
- let(:parent_argv) { %w[--root-var 123 child-cmd --child-opt 456] }
48
-
49
- it { expect(instance.parsed.root_var).to eq('123') }
50
- it { expect(instance.parsed.subcommand).to eq('child-cmd') }
51
- it { expect(instance.parsed.subcommand_args).to eq(%w[--child-opt 456]) }
52
- it { expect(instance.subcommand_runner.parsed.child_opt).to be(true) }
53
- it { expect(instance.subcommand_runner.parsed.child_var).to eq('456') }
54
-
55
- it do
56
- expect { instance.run_run }.not_to raise_error
57
- end
58
- end
59
-
60
- context 'when subcommand is not supplied' do
61
- let(:instance) { parent_runner.create(%w[456]) }
62
-
63
- it do
64
- expect { instance.run }.to raise_error(EacCli::Parser::Error)
65
- end
66
- end
67
-
68
- context 'with help' do
69
- let(:instance) { parent_runner.create(%w[--help]) }
70
- let(:expected_output_source) do
71
- <<~OUTPUT
72
- A stub root runner.
73
-
74
- Usage:
75
- __PROGRAM__ [options] __SUBCOMMANDS__ [<subcommand_args>...]
76
- __PROGRAM__ --help
77
-
78
- Options:
79
- -r --root-var=<value> A root variable.
80
- -h --help Show help.
81
-
82
- Subcommands:
83
- child-cmd
84
- OUTPUT
85
- end
86
- let(:expected_output) do
87
- expected_output_source.gsub('__PROGRAM__', instance.program_name)
88
- end
89
-
90
- before do
91
- parent_runner.include(EacCli::RunnerWith::Help)
92
- end
93
-
94
- it 'show help text' do
95
- expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
96
- end
97
- end
98
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/speaker'
4
-
5
- RSpec.describe EacCli::Speaker do
6
- let(:instance) { described_class.new }
7
-
8
- describe '#input' do
9
- it 'recover value from hash list' do
10
- allow(instance).to receive(:request_string).and_return('opt1')
11
- list = { opt1: 'value1', opt2: 'value2' }
12
- expect(instance.input('Question', list: list)).to eq('value1')
13
- end
14
-
15
- it 'recover value from array list' do
16
- allow(instance).to receive(:request_string).and_return('OPT1')
17
- list = %w[opt1 opt2]
18
- expect(instance.input('Question', list: list)).to eq('opt1')
19
- end
20
-
21
- {
22
- 'yes' => true, 'y' => true, 'Y' => true, 'NO' => false, 'no' => false, 'n' => false
23
- }.each do |input, expected|
24
- context "when bool: true and input is \"#{input}\"" do
25
- it "return #{expected}" do
26
- allow(instance).to receive(:request_string).and_return(input)
27
- expect(instance.input('Question', bool: true)).to eq(expected)
28
- end
29
- end
30
- end
31
- end
32
- end