avm-tools 0.94.1 → 0.97.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/app_src.rb +60 -0
  3. data/lib/avm/core_ext.rb +4 -0
  4. data/lib/avm/eac_asciidoctor_base0/deploy.rb +5 -5
  5. data/lib/avm/eac_webapp_base0/instance.rb +5 -2
  6. data/lib/avm/eac_webapp_base0/instance/subcommand_parent.rb +24 -0
  7. data/lib/avm/eac_webapp_base0/runner/data.rb +1 -0
  8. data/lib/avm/eac_webapp_base0/runner/data/dump.rb +1 -1
  9. data/lib/avm/eac_webapp_base0/runner/data/load.rb +1 -1
  10. data/lib/avm/git/issue/complete/_test.rb +2 -2
  11. data/lib/avm/instances/base.rb +6 -12
  12. data/lib/avm/instances/base/entry_keys.rb +17 -0
  13. data/lib/{eac_launcher → avm/launcher}/instances/error.rb +0 -0
  14. data/lib/avm/launcher/instances/runner_helper.rb +42 -0
  15. data/lib/avm/patches/class.rb +4 -0
  16. data/lib/avm/patches/eac_ruby_gems_utils.rb +4 -0
  17. data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +2 -2
  18. data/lib/avm/patches/object.rb +4 -0
  19. data/lib/avm/patches/object/fs_cache.rb +16 -0
  20. data/lib/avm/ruby/bundler.rb +11 -0
  21. data/lib/avm/ruby/bundler/incompatible_parser.rb +25 -0
  22. data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +25 -0
  23. data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +39 -0
  24. data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +19 -0
  25. data/lib/avm/ruby/bundler/incompatible_parser/line_buffer.rb +73 -0
  26. data/lib/avm/ruby/bundler/incompatible_parser/line_factory.rb +31 -0
  27. data/lib/avm/ruby/bundler/incompatible_parser/line_parser_base.rb +19 -0
  28. data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +26 -0
  29. data/lib/avm/ruby/gems/generator.rb +1 -5
  30. data/lib/avm/ruby/rubocop/_configured.rb +2 -2
  31. data/lib/avm/tools/runner/{local_project.rb → app_src.rb} +3 -3
  32. data/lib/avm/tools/runner/{local_project → app_src}/eac_asciidoctor_base0.rb +1 -1
  33. data/lib/avm/tools/runner/{local_project → app_src}/eac_asciidoctor_base0/build.rb +19 -7
  34. data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0.rb +1 -1
  35. data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0/build_chapters.rb +1 -1
  36. data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0/build_single.rb +1 -1
  37. data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0/info.rb +1 -1
  38. data/lib/avm/tools/runner/{local_project → app_src}/info.rb +1 -1
  39. data/lib/avm/tools/runner/{local_project → app_src}/ruby.rb +1 -1
  40. data/lib/avm/tools/runner/{local_project → app_src}/ruby/bundler.rb +4 -8
  41. data/lib/avm/tools/runner/{local_project → app_src}/ruby/bundler/gemfile_lock.rb +11 -14
  42. data/lib/avm/tools/runner/app_src/ruby/bundler/incompatible.rb +84 -0
  43. data/lib/avm/tools/runner/{local_project → app_src}/test.rb +1 -1
  44. data/lib/avm/tools/runner/{local_project → app_src}/update.rb +1 -1
  45. data/lib/avm/tools/runner/{local_project → app_src}/version_bump.rb +1 -1
  46. data/lib/avm/tools/runner/launcher.rb +3 -6
  47. data/lib/avm/tools/runner/launcher/instances.rb +10 -21
  48. data/lib/avm/tools/runner/launcher/projects.rb +10 -18
  49. data/lib/avm/tools/runner/launcher/publish.rb +18 -26
  50. data/lib/avm/tools/runner/ruby/rubocop.rb +9 -25
  51. data/lib/avm/tools/runner/self.rb +7 -15
  52. data/lib/avm/tools/runner/self/docker.rb +1 -1
  53. data/lib/avm/tools/version.rb +1 -1
  54. data/lib/eac_launcher/instances.rb +1 -1
  55. data/template/avm/ruby/gems/generator/static/spec/rubocop_spec.rb +1 -5
  56. data/template/avm/ruby/gems/generator/static/spec/spec_helper.rb +2 -0
  57. data/vendor/avm-apps/avm-apps.gemspec +1 -1
  58. data/vendor/avm-apps/lib/avm/apps/sources/configuration.rb +57 -0
  59. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_locale.rb +18 -0
  60. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_rubocop.rb +26 -0
  61. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_tests.rb +29 -0
  62. data/vendor/avm-apps/lib/avm/apps/version.rb +1 -1
  63. data/vendor/avm-apps/spec/rubocop_spec.rb +1 -5
  64. data/vendor/avm-apps/spec/spec_helper.rb +3 -0
  65. data/vendor/avm-eac_asciidoctor_base0/Gemfile +5 -0
  66. data/vendor/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +19 -0
  67. data/{lib/avm/local_projects.rb → vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0.rb} +1 -1
  68. data/{lib/avm/eac_asciidoctor_base0/project.rb → vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources.rb} +2 -4
  69. data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +15 -0
  70. data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build.rb +49 -0
  71. data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build/file.rb +30 -0
  72. data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +7 -0
  73. data/vendor/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +3 -0
  74. data/vendor/avm-eac_asciidoctor_base0/spec/spec_helper.rb +102 -0
  75. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  76. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +5 -1
  77. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +3 -1
  78. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
  79. data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +8 -1
  80. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  81. data/vendor/eac_cli/spec/rubocop_spec.rb +1 -5
  82. data/vendor/eac_cli/spec/spec_helper.rb +3 -0
  83. data/vendor/eac_docker/eac_docker.gemspec +1 -1
  84. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  85. data/vendor/eac_docker/spec/rubocop_spec.rb +1 -5
  86. data/vendor/eac_docker/spec/spec_helper.rb +3 -0
  87. data/vendor/eac_git/eac_git.gemspec +2 -1
  88. data/vendor/eac_git/lib/eac_git/local.rb +4 -0
  89. data/vendor/eac_git/lib/eac_git/local/commit.rb +53 -0
  90. data/vendor/eac_git/lib/eac_git/local/commit/changed_file.rb +46 -0
  91. data/vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb +32 -0
  92. data/vendor/eac_git/lib/eac_git/rspec.rb +6 -1
  93. data/{lib/avm/git/spec_helper.rb → vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb} +16 -13
  94. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  95. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec.rb +13 -0
  96. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.source.out +1 -0
  97. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
  98. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.source.out +1 -0
  99. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
  100. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.source.out +1 -0
  101. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
  102. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.source.out +2 -0
  103. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
  104. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
  105. data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
  106. data/vendor/eac_git/spec/lib/eac_git/local/commit_spec.rb +58 -0
  107. data/vendor/eac_git/spec/rubocop_spec.rb +1 -5
  108. data/vendor/eac_git/spec/spec_helper.rb +3 -0
  109. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +4 -4
  110. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +36 -0
  111. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
  112. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  113. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
  114. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +1 -5
  115. data/vendor/eac_ruby_base0/spec/spec_helper.rb +3 -0
  116. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +4 -3
  117. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +7 -10
  118. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +9 -2
  119. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  120. data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +1 -5
  121. data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +3 -0
  122. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +2 -1
  123. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb +6 -0
  124. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
  125. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +9 -1
  126. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
  127. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +4 -2
  128. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
  129. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
  130. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
  131. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
  132. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
  133. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +18 -5
  134. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  135. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
  136. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +9 -0
  137. data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -5
  138. data/vendor/eac_ruby_utils/spec/spec_helper.rb +3 -0
  139. metadata +90 -39
  140. data/lib/avm/eac_asciidoctor_base0/build.rb +0 -47
  141. data/lib/avm/eac_asciidoctor_base0/build/file.rb +0 -28
  142. data/lib/avm/instances/configuration.rb +0 -55
  143. data/lib/avm/instances/configuration/_locale.rb +0 -16
  144. data/lib/avm/instances/configuration/_rubocop.rb +0 -24
  145. data/lib/avm/instances/configuration/_tests.rb +0 -27
  146. data/lib/avm/local_projects/instance.rb +0 -62
  147. data/lib/eac_launcher/instances/runner_helper.rb +0 -42
  148. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
  149. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/fs/clearable_directory'
5
-
6
- module Avm
7
- module EacAsciidoctorBase0
8
- class Build
9
- require_sub __FILE__
10
- enable_console_speaker
11
- enable_simple_cache
12
- enable_listable
13
- lists.add_symbol :option, :target_directory
14
- common_constructor :project, :options, default: [{}] do
15
- self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
16
- end
17
-
18
- SOURCE_EXTNAMES = %w[.adoc .asc].freeze
19
-
20
- def run
21
- infov 'Files to build', source_files.count
22
- target_directory.clear
23
- source_files.each(&:run)
24
- end
25
-
26
- def default_target_directory
27
- project.root.join('build')
28
- end
29
-
30
- def target_directory
31
- ::EacRubyUtils::Fs::ClearableDirectory.new(
32
- options[OPTION_TARGET_DIRECTORY] || default_target_directory
33
- )
34
- end
35
-
36
- def source_files_uncached
37
- r = []
38
- project.root.children.each do |child|
39
- next unless SOURCE_EXTNAMES.include?(child.extname)
40
-
41
- r << ::Avm::EacAsciidoctorBase0::Build::File.new(self, child.basename)
42
- end
43
- r
44
- end
45
- end
46
- end
47
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'asciidoctor'
4
-
5
- module Avm
6
- module EacAsciidoctorBase0
7
- class Build
8
- class File
9
- enable_console_speaker
10
- common_constructor :build, :subpath
11
-
12
- def run
13
- infov 'Building', subpath
14
- ::Asciidoctor.convert_file source_path.to_path,
15
- to_file: target_path.to_path, safe: :unsafe, mkdirs: true
16
- end
17
-
18
- def source_path
19
- build.project.root.join(subpath)
20
- end
21
-
22
- def target_path
23
- build.target_directory.join(subpath).basename_sub('.*') { |b| "#{b}.html" }
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/configs'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'yaml'
6
-
7
- module Avm
8
- module Instances
9
- class Configuration < ::EacRubyUtils::Configs
10
- require_sub __FILE__
11
-
12
- FILENAMES = %w[.avm.yml .avm.yaml].freeze
13
-
14
- class << self
15
- def find_by_path(path)
16
- path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
17
- internal_find_path(path.expand_path)
18
- end
19
-
20
- def find_in_path(path)
21
- absolute_pathname = path.to_pathname.expand_path
22
- if absolute_pathname.directory?
23
- FILENAMES.each do |filename|
24
- file = absolute_pathname.join(filename)
25
- return new(file) if file.exist?
26
- end
27
- end
28
- nil
29
- end
30
-
31
- private
32
-
33
- def internal_find_path(absolute_pathname)
34
- r = find_in_path(absolute_pathname)
35
- return r if r.present?
36
-
37
- internal_find_path(absolute_pathname.dirname) unless absolute_pathname.root?
38
- end
39
- end
40
-
41
- def initialize(path)
42
- super(nil, storage_path: path)
43
- end
44
-
45
- # Utility to read a configuration as a [EacRubyUtils::Envs::Command].
46
- # @return [EacRubyUtils::Envs::Command]
47
- def read_command(key)
48
- read_entry(key).if_present do |v|
49
- args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
50
- ::EacRubyUtils::Envs.local.command(args).chdir(::File.dirname(storage_path))
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/patches/eac_ruby_gems_utils/gem'
4
- require 'i18n'
5
-
6
- module Avm
7
- module Instances
8
- class Configuration < ::EacRubyUtils::Configs
9
- LOCALE_KEY = :locale
10
-
11
- def locale
12
- read_entry(LOCALE_KEY) || ::I18n.default_locale
13
- end
14
- end
15
- end
16
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Instances
5
- class Configuration < ::EacRubyUtils::Configs
6
- RUBOCOP_COMMAND_KEY = 'ruby.rubocop.command'
7
- RUBOCOP_GEMFILE_KEY = 'ruby.rubocop.gemfile'
8
-
9
- def rubocop_command
10
- read_command(RUBOCOP_COMMAND_KEY)
11
- end
12
-
13
- def rubocop_gemfile
14
- gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY)
15
- return nil if gemfile_path.blank?
16
-
17
- gemfile_path = gemfile_path.to_pathname.expand_path(storage_path.parent)
18
- return gemfile_path if gemfile_path.file?
19
-
20
- raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file"
21
- end
22
- end
23
- end
24
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/patches/eac_ruby_gems_utils/gem'
4
-
5
- module Avm
6
- module Instances
7
- class Configuration < ::EacRubyUtils::Configs
8
- BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
9
- TEST_COMMAND_KEY = 'test.command'
10
-
11
- def any_test_command
12
- bundle_test_command || test_command
13
- end
14
-
15
- def test_command
16
- read_command(TEST_COMMAND_KEY)
17
- end
18
-
19
- def bundle_test_command
20
- read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v|
21
- args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
22
- ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/instances/configuration'
4
- require 'eac_launcher/paths/real'
5
- require 'eac_ruby_utils/core_ext'
6
- require 'avm/projects/stereotypes'
7
- require 'i18n'
8
-
9
- module Avm
10
- module LocalProjects
11
- class Instance
12
- enable_simple_cache
13
- common_constructor :path do
14
- self.path = path.to_pathname
15
- source_stereotypes_mixins
16
- end
17
-
18
- delegate :to_s, to: :path
19
-
20
- def locale
21
- configuration.if_present(&:locale) || ::I18n.default_locale
22
- end
23
-
24
- # Backward compatibility with [EacLauncher::Paths::Logical].
25
- # @return [EacLauncher::Paths::Real].
26
- def real
27
- ::EacLauncher::Paths::Real.new(path.to_path)
28
- end
29
-
30
- def run_job(job, job_args = [])
31
- stereotypes.each { |stereotype| run_stereotype_job(stereotype, job, job_args) }
32
- end
33
-
34
- private
35
-
36
- # @return [Avm::Instances::Configuration]
37
- def configuration_uncached
38
- ::Avm::Instances::Configuration.find_in_path(path)
39
- end
40
-
41
- def run_stereotype_job(stereotype, job, job_args)
42
- job_class_method = "#{job}_class"
43
- if stereotype.send(job_class_method).present?
44
- puts stereotype.label + ": #{job} class found. Running..."
45
- stereotype.send(job_class_method).new(self, *job_args).run
46
- else
47
- puts stereotype.label + ": #{job} class not found"
48
- end
49
- end
50
-
51
- def stereotypes_uncached
52
- ::Avm::Projects::Stereotypes.list.select { |s| s.match?(self) }
53
- end
54
-
55
- def source_stereotypes_mixins
56
- stereotypes.each do |s|
57
- s.local_project_mixin_module.if_present { |v| singleton_class.include(v) }
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/console/docopt_runner'
4
- require 'eac_ruby_utils/console/speaker'
5
-
6
- module EacLauncher
7
- module Instances
8
- class RunnerHelper < ::EacRubyUtils::Console::DocoptRunner
9
- include ::EacRubyUtils::Console::Speaker
10
-
11
- def context
12
- @context ||= ::EacLauncher::Context.current
13
- end
14
-
15
- def find_instances(instance_name)
16
- context.instances.select { |instance| instance_match?(instance, instance_name) }
17
- end
18
-
19
- def instance_match?(instance, instance_name)
20
- ::File.fnmatch?(instance_name, instance.name)
21
- end
22
-
23
- def instances
24
- if options['--all']
25
- context.instances
26
- elsif options['--pending']
27
- context.pending_instances
28
- else
29
- options['<instance_path>'].flat_map { |p| find_instances(p) }
30
- end
31
- end
32
-
33
- def instance_stereotypes(instance)
34
- instance.stereotypes.map(&:label).join(', ')
35
- end
36
-
37
- def instance_label(instance)
38
- "#{instance.name} [#{instance_stereotypes(instance)}]"
39
- end
40
- end
41
- end
42
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/abstract_methods'
6
-
7
- module EacCli
8
- module RunnerWith
9
- module OutputFile
10
- common_concern do
11
- include ::EacCli::Runner
12
- include ::EacRubyUtils::AbstractMethods
13
-
14
- abstract_methods :output_content
15
-
16
- runner_definition do
17
- arg_opt '-o', '--output-file', 'Output to file.'
18
- end
19
- end
20
-
21
- def run_output
22
- if parsed.output_file.present?
23
- ::File.write(parsed.output_file, output_content)
24
- else
25
- $stdout.write(output_content)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,53 +0,0 @@
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