avm-tools 0.94.2 → 0.98.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/app_src.rb +60 -0
- data/lib/avm/core_ext.rb +4 -0
- data/lib/avm/docker/runner.rb +22 -30
- data/lib/avm/eac_asciidoctor_base0/deploy.rb +5 -5
- data/lib/avm/eac_rails_base1/runner/bundle.rb +0 -1
- data/lib/avm/eac_rails_base1/runner/code_runner.rb +0 -1
- data/lib/avm/eac_rails_base1/runner/rails_server.rb +0 -1
- data/lib/avm/eac_webapp_base0/instance.rb +5 -2
- data/lib/avm/eac_webapp_base0/instance/subcommand_parent.rb +24 -0
- data/lib/avm/eac_webapp_base0/runner/data.rb +1 -0
- data/lib/avm/eac_webapp_base0/runner/data/dump.rb +1 -1
- data/lib/avm/eac_webapp_base0/runner/data/load.rb +1 -1
- data/lib/avm/git/issue/complete/_test.rb +2 -2
- data/lib/avm/instances/base.rb +6 -12
- data/lib/avm/instances/base/entry_keys.rb +17 -0
- data/lib/{eac_launcher → avm/launcher}/instances/error.rb +0 -0
- data/lib/avm/launcher/instances/runner_helper.rb +41 -0
- data/lib/avm/patches/class.rb +4 -0
- data/lib/avm/patches/eac_ruby_gems_utils.rb +4 -0
- data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +2 -2
- data/lib/avm/patches/object.rb +4 -0
- data/lib/avm/patches/object/fs_cache.rb +16 -0
- data/lib/avm/ruby/bundler.rb +11 -0
- data/lib/avm/ruby/bundler/incompatible_parser.rb +25 -0
- data/lib/avm/ruby/bundler/incompatible_parser/depends_on.rb +25 -0
- data/lib/avm/ruby/bundler/incompatible_parser/gem_conflict.rb +39 -0
- data/lib/avm/ruby/bundler/incompatible_parser/in_gemfile.rb +19 -0
- data/lib/avm/ruby/bundler/incompatible_parser/line_buffer.rb +73 -0
- data/lib/avm/ruby/bundler/incompatible_parser/line_factory.rb +31 -0
- data/lib/avm/ruby/bundler/incompatible_parser/line_parser_base.rb +19 -0
- data/lib/avm/ruby/bundler/incompatible_parser/version_requirement.rb +26 -0
- data/lib/avm/ruby/gems/generator.rb +1 -5
- data/lib/avm/ruby/rubocop/_configured.rb +2 -2
- data/lib/avm/tools/runner/{local_project.rb → app_src.rb} +3 -3
- data/lib/avm/tools/runner/app_src/eac_asciidoctor_base0.rb +14 -0
- data/lib/avm/tools/runner/{local_project → app_src}/eac_asciidoctor_base0/build.rb +19 -7
- data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0.rb +1 -2
- data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0/build_chapters.rb +1 -2
- data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0/build_single.rb +1 -2
- data/lib/avm/tools/runner/{local_project → app_src}/eac_writings_base0/info.rb +1 -2
- data/lib/avm/tools/runner/app_src/info.rb +22 -0
- data/lib/avm/tools/runner/{local_project → app_src}/ruby.rb +1 -1
- data/lib/avm/tools/runner/{local_project → app_src}/ruby/bundler.rb +1 -1
- data/lib/avm/tools/runner/{local_project → app_src}/ruby/bundler/gemfile_lock.rb +1 -1
- data/lib/avm/tools/runner/app_src/ruby/bundler/incompatible.rb +84 -0
- data/lib/avm/tools/runner/{local_project → app_src}/test.rb +6 -9
- data/lib/avm/tools/runner/app_src/update.rb +22 -0
- data/lib/avm/tools/runner/{local_project → app_src}/version_bump.rb +1 -1
- data/lib/avm/tools/runner/eac_asciidoctor_base0.rb +0 -1
- data/lib/avm/tools/runner/eac_rails_base0.rb +0 -1
- data/lib/avm/tools/runner/eac_redmine_base0.rb +0 -1
- data/lib/avm/tools/runner/eac_wordpress_base0.rb +0 -1
- data/lib/avm/tools/runner/eac_writings_base0.rb +0 -1
- data/lib/avm/tools/runner/git.rb +0 -1
- data/lib/avm/tools/runner/git/commit.rb +0 -1
- data/lib/avm/tools/runner/git/dirty_files.rb +17 -22
- data/lib/avm/tools/runner/git/issue.rb +21 -36
- data/lib/avm/tools/runner/git/organize.rb +6 -9
- data/lib/avm/tools/runner/git/revisions_test.rb +14 -25
- data/lib/avm/tools/runner/git/subrepo.rb +3 -6
- data/lib/avm/tools/runner/git/subrepo/check.rb +10 -13
- data/lib/avm/tools/runner/git/subrepo/clone.rb +2 -3
- data/lib/avm/tools/runner/git/subrepo/fix.rb +2 -3
- data/lib/avm/tools/runner/launcher.rb +3 -6
- data/lib/avm/tools/runner/launcher/instances.rb +10 -21
- data/lib/avm/tools/runner/launcher/projects.rb +10 -18
- data/lib/avm/tools/runner/launcher/publish.rb +18 -26
- data/lib/avm/tools/runner/ruby/rubocop.rb +9 -25
- data/lib/avm/tools/runner/self.rb +7 -15
- data/lib/avm/tools/runner/self/docker.rb +1 -1
- data/lib/avm/tools/version.rb +1 -1
- data/lib/eac_launcher/instances.rb +1 -1
- data/template/avm/ruby/gems/generator/static/spec/rubocop_spec.rb +1 -5
- data/template/avm/ruby/gems/generator/static/spec/spec_helper.rb +2 -0
- data/vendor/avm-apps/avm-apps.gemspec +1 -1
- data/vendor/avm-apps/lib/avm/apps/sources/configuration.rb +57 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration/_locale.rb +18 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration/_rubocop.rb +26 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration/_tests.rb +29 -0
- data/vendor/avm-apps/lib/avm/apps/version.rb +1 -1
- data/vendor/avm-apps/spec/rubocop_spec.rb +1 -5
- data/vendor/avm-apps/spec/spec_helper.rb +3 -0
- data/vendor/avm-eac_asciidoctor_base0/Gemfile +5 -0
- data/vendor/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +20 -0
- data/{lib/avm/local_projects.rb → vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0.rb} +1 -1
- data/{lib/avm/eac_asciidoctor_base0/project.rb → vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources.rb} +2 -4
- data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +19 -0
- data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build.rb +49 -0
- data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/build/file.rb +30 -0
- data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner.rb +30 -0
- data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runner/build.rb +54 -0
- data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +7 -0
- data/vendor/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +3 -0
- data/vendor/avm-eac_asciidoctor_base0/spec/spec_helper.rb +102 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +3 -1
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +8 -1
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/rubocop_spec.rb +1 -5
- data/vendor/eac_cli/spec/spec_helper.rb +3 -0
- data/vendor/eac_docker/eac_docker.gemspec +1 -1
- data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
- data/vendor/eac_docker/spec/rubocop_spec.rb +1 -5
- data/vendor/eac_docker/spec/spec_helper.rb +3 -0
- data/vendor/eac_git/eac_git.gemspec +2 -1
- data/vendor/eac_git/lib/eac_git/local.rb +4 -0
- data/vendor/eac_git/lib/eac_git/local/commit.rb +53 -0
- data/vendor/eac_git/lib/eac_git/local/commit/changed_file.rb +46 -0
- data/vendor/eac_git/lib/eac_git/local/commit/diff_tree_line.rb +32 -0
- data/vendor/eac_git/lib/eac_git/rspec.rb +6 -1
- data/{lib/avm/git/spec_helper.rb → vendor/eac_git/lib/eac_git/rspec/stubbed_git_local_repo.rb} +16 -13
- data/vendor/eac_git/lib/eac_git/version.rb +1 -1
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec.rb +13 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.source.out +1 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/add.target.yaml +7 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.source.out +1 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/modify.target.yaml +7 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.source.out +1 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/remove.target.yaml +7 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.source.out +2 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml +13 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.source.out +2 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename_modify.target.yaml +13 -0
- data/vendor/eac_git/spec/lib/eac_git/local/commit_spec.rb +58 -0
- data/vendor/eac_git/spec/rubocop_spec.rb +1 -5
- data/vendor/eac_git/spec/spec_helper.rb +3 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +4 -4
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/input.rb +36 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/output.rb +58 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/output_spec.rb +81 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +1 -5
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +3 -0
- data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +4 -3
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +7 -10
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +9 -2
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
- data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +1 -5
- data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +3 -0
- data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +2 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb +6 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/logs.rb +63 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +9 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +4 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/regexp/to_parser.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +4 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/regexp_parser.rb +34 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +10 -29
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +69 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +18 -5
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +9 -0
- data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -5
- data/vendor/eac_ruby_utils/spec/spec_helper.rb +3 -0
- metadata +120 -39
- data/lib/avm/eac_asciidoctor_base0/build.rb +0 -47
- data/lib/avm/eac_asciidoctor_base0/build/file.rb +0 -28
- data/lib/avm/instances/configuration.rb +0 -55
- data/lib/avm/instances/configuration/_locale.rb +0 -16
- data/lib/avm/instances/configuration/_rubocop.rb +0 -24
- data/lib/avm/instances/configuration/_tests.rb +0 -27
- data/lib/avm/local_projects/instance.rb +0 -62
- data/lib/avm/tools/runner/local_project/eac_asciidoctor_base0.rb +0 -32
- data/lib/avm/tools/runner/local_project/info.rb +0 -25
- data/lib/avm/tools/runner/local_project/update.rb +0 -25
- data/lib/eac_launcher/instances/runner_helper.rb +0 -42
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +0 -30
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +0 -53
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_git/local/commit/diff_tree_line'
|
4
|
+
|
5
|
+
RSpec.describe ::EacGit::Local::Commit::DiffTreeLine, git: true do
|
6
|
+
include_examples 'source_target_fixtures', __FILE__ do
|
7
|
+
def source_data(source_file)
|
8
|
+
::File.read(source_file).each_line.map do |line|
|
9
|
+
described_class.new(line).fields
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
:000000 100644 0000000000000000000000000000000000000000 f380aec0bd8dd777edac43b11636e46cad04273a A nomes.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
:100644 100644 40bcdecb4214cd8a3fcf96cd25a2beb87e7e7cd8 4a30dfae816b984f05cfb594e0d5958bb8c387ae M nomes.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
:100644 000000 10728718a2915256ab162f1e05178ebff9efa6ce 0000000000000000000000000000000000000000 D nomes3.txt
|
data/vendor/eac_git/spec/lib/eac_git/local/commit/diff_tree_line_spec_files/rename.target.yaml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
- src_mode: '100644'
|
3
|
+
dst_mode: '000000'
|
4
|
+
src_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
|
5
|
+
dst_sha1: '0000000000000000000000000000000000000000'
|
6
|
+
status: D
|
7
|
+
path: nomes.txt
|
8
|
+
- src_mode: '000000'
|
9
|
+
dst_mode: '100644'
|
10
|
+
src_sha1: '0000000000000000000000000000000000000000'
|
11
|
+
dst_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
|
12
|
+
status: A
|
13
|
+
path: nomes2.txt
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
- src_mode: '100644'
|
3
|
+
dst_mode: '000000'
|
4
|
+
src_sha1: 4a30dfae816b984f05cfb594e0d5958bb8c387ae
|
5
|
+
dst_sha1: '0000000000000000000000000000000000000000'
|
6
|
+
status: D
|
7
|
+
path: nomes2.txt
|
8
|
+
- src_mode: '000000'
|
9
|
+
dst_mode: '100644'
|
10
|
+
src_sha1: '0000000000000000000000000000000000000000'
|
11
|
+
dst_sha1: 10728718a2915256ab162f1e05178ebff9efa6ce
|
12
|
+
status: A
|
13
|
+
path: nomes3.txt
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_git/local'
|
4
|
+
require 'eac_git/local/commit'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
RSpec.describe ::EacGit::Local::Commit, git: true do
|
8
|
+
let(:git) { stubbed_git_local_repo }
|
9
|
+
|
10
|
+
let(:first_commit_sha1) do
|
11
|
+
git.file('a.txt').write('AAA')
|
12
|
+
git.file('b.txt').write('BBB')
|
13
|
+
git.command('add', '.').execute!
|
14
|
+
git.command('commit', '-m', 'First commit.').execute!
|
15
|
+
git.rev_parse('HEAD')
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:second_commit_sha1) do
|
19
|
+
first_commit_sha1
|
20
|
+
git.file('a.txt').write('AAAAA')
|
21
|
+
git.file('b.txt').delete
|
22
|
+
git.file('ç.txt').write('CCC')
|
23
|
+
git.command('add', '.').execute!
|
24
|
+
git.command('commit', '-m', 'Second commit.').execute!
|
25
|
+
git.rev_parse('HEAD')
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:first_commit) { described_class.new(git, first_commit_sha1) }
|
29
|
+
let(:second_commit) { described_class.new(git, second_commit_sha1) }
|
30
|
+
|
31
|
+
describe '#changed_files' do
|
32
|
+
it { expect(first_commit.changed_files.count).to eq(2) }
|
33
|
+
it { expect(second_commit.changed_files.count).to eq(3) }
|
34
|
+
|
35
|
+
{
|
36
|
+
'first_commit' => %w[a.txt b.txt],
|
37
|
+
'second_commit' => %w[a.txt b.txt ç.txt]
|
38
|
+
}.each do |commit_name, filenames|
|
39
|
+
filenames.each do |filename|
|
40
|
+
it "find file \"#{filename}\" in commit \"#{commit_name}\"" do
|
41
|
+
commit = send(commit_name)
|
42
|
+
file = commit.changed_files.find { |f| f.path == filename }
|
43
|
+
expect(file).to be_a(::EacGit::Local::Commit::ChangedFile)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#changed_files_size' do
|
50
|
+
it { expect(first_commit.changed_files_size).to eq(6) }
|
51
|
+
it { expect(second_commit.changed_files_size).to eq(8) }
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#root_child?' do
|
55
|
+
it { expect(first_commit.root_child?).to eq(true) }
|
56
|
+
it { expect(second_commit.root_child?).to eq(false) }
|
57
|
+
end
|
58
|
+
end
|
@@ -1,7 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
RSpec.describe ::RuboCop, slow: true do
|
6
|
-
include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
|
7
|
-
end
|
3
|
+
::EacRubyGemSupport::Rspec.default.describe_rubocop
|
@@ -97,7 +97,10 @@ RSpec.configure do |config|
|
|
97
97
|
# # test failures related to randomization by passing the same `--seed` value
|
98
98
|
# # as the one that triggered the failure.
|
99
99
|
# Kernel.srand config.seed
|
100
|
+
require 'eac_ruby_gem_support/rspec'
|
101
|
+
::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
|
100
102
|
end
|
101
103
|
|
102
104
|
require 'eac_git/rspec'
|
103
105
|
::EacGit::Rspec.configure
|
106
|
+
require 'aranha/parsers/spec/source_target_fixtures_example'
|
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = Dir['{lib}/**/*']
|
14
14
|
|
15
|
-
s.add_dependency 'eac_cli', '~> 0.
|
16
|
-
s.add_dependency 'eac_ruby_gems_utils', '~> 0.
|
17
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
15
|
+
s.add_dependency 'eac_cli', '~> 0.15', '>= 0.15.1'
|
16
|
+
s.add_dependency 'eac_ruby_gems_utils', '~> 0.8'
|
17
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.60'
|
18
18
|
|
19
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.
|
19
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
|
20
20
|
end
|
@@ -0,0 +1,36 @@
|
|
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 EacRubyBase0
|
8
|
+
module RunnerWith
|
9
|
+
module Input
|
10
|
+
STDIN_OPTION = '-'
|
11
|
+
BLANK_OPTION = '+'
|
12
|
+
DEFAULT_DEFAULT_INPUT_OPTION = BLANK_OPTION
|
13
|
+
|
14
|
+
common_concern do
|
15
|
+
enable_settings_provider
|
16
|
+
include ::EacCli::Runner
|
17
|
+
|
18
|
+
runner_definition do
|
19
|
+
arg_opt '-i', '--input', 'Input from file.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def input_content
|
24
|
+
case input_option
|
25
|
+
when STDIN_OPTION then $stdin.read
|
26
|
+
when BLANK_OPTION then ''
|
27
|
+
else input_option.to_pathname.read
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def input_option
|
32
|
+
parsed.input || setting_value(:default_input_option, default: DEFAULT_DEFAULT_INPUT_OPTION)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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 EacRubyBase0
|
8
|
+
module RunnerWith
|
9
|
+
module Output
|
10
|
+
STDOUT_OPTION = '-'
|
11
|
+
DEFAULT_FILE_OPTION = '+'
|
12
|
+
DEFAULT_DEFAULT_OUTPUT_OPTION = STDOUT_OPTION
|
13
|
+
DEFAULT_DEFAULT_FILE_TO_OUTPUT = 'output'
|
14
|
+
|
15
|
+
common_concern do
|
16
|
+
enable_abstract_methods
|
17
|
+
enable_settings_provider
|
18
|
+
include ::EacCli::Runner
|
19
|
+
|
20
|
+
abstract_methods :output_content
|
21
|
+
|
22
|
+
runner_definition do
|
23
|
+
arg_opt '-o', '--output', 'Output to file.'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_output
|
28
|
+
file = file_to_output
|
29
|
+
if file
|
30
|
+
file.to_pathname.write(output_content)
|
31
|
+
else
|
32
|
+
$stdout.write(output_content)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def output_option
|
37
|
+
parsed.output || default_output_option_value
|
38
|
+
end
|
39
|
+
|
40
|
+
def file_to_output
|
41
|
+
case output_option
|
42
|
+
when STDOUT_OPTION then nil
|
43
|
+
when DEFAULT_FILE_OPTION then default_file_to_output_value
|
44
|
+
else output_option
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_output_option_value
|
49
|
+
setting_value(:default_output_option,
|
50
|
+
default: DEFAULT_DEFAULT_OUTPUT_OPTION)
|
51
|
+
end
|
52
|
+
|
53
|
+
def default_file_to_output_value
|
54
|
+
setting_value(:default_file_to_output, default: DEFAULT_DEFAULT_FILE_TO_OUTPUT)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_base0/runner_with/output'
|
4
|
+
require 'eac_ruby_utils/fs/temp'
|
5
|
+
|
6
|
+
RSpec.describe ::EacRubyBase0::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', ::EacRubyBase0::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', ::EacRubyBase0::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,7 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
RSpec.describe ::RuboCop, slow: true do
|
6
|
-
include_examples 'rubocop_check', ::File.expand_path('..', __dir__)
|
7
|
-
end
|
3
|
+
::EacRubyGemSupport::Rspec.default.describe_rubocop
|
@@ -97,4 +97,7 @@ RSpec.configure do |config|
|
|
97
97
|
# # test failures related to randomization by passing the same `--seed` value
|
98
98
|
# # as the one that triggered the failure.
|
99
99
|
# Kernel.srand config.seed
|
100
|
+
|
101
|
+
require 'eac_ruby_gem_support/rspec'
|
102
|
+
::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
|
100
103
|
end
|
@@ -19,11 +19,12 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.rdoc_options = ['--charset=UTF-8']
|
20
20
|
|
21
21
|
s.require_paths = ['lib']
|
22
|
-
s.files =
|
23
|
-
s.test_files =
|
22
|
+
s.files = Dir['{lib}/**/*', 'Gemfile']
|
23
|
+
s.test_files = Dir['{spec}/**/*', '.rspec']
|
24
24
|
|
25
|
+
s.add_dependency 'bundler', '~> 2.2', '>= 2.2.17'
|
25
26
|
s.add_dependency 'eac_ruby_utils', '~> 0.29'
|
26
27
|
|
27
28
|
# Tests
|
28
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.
|
29
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
|
29
30
|
end
|
@@ -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/fs/logs'
|
4
5
|
require 'eac_ruby_utils/fs_cache'
|
5
6
|
require 'eac_ruby_utils/listable'
|
6
7
|
require 'eac_ruby_utils/on_clean_ruby_environment'
|
@@ -27,20 +28,16 @@ module EacRubyGemsUtils
|
|
27
28
|
self.class.name.demodulize.gsub(/Test\z/, '')
|
28
29
|
end
|
29
30
|
|
30
|
-
def stdout_cache
|
31
|
-
root_cache.child('stdout')
|
32
|
-
end
|
33
|
-
|
34
|
-
def stderr_cache
|
35
|
-
root_cache.child('stderr')
|
36
|
-
end
|
37
|
-
|
38
31
|
def to_s
|
39
32
|
"#{gem}[#{name}]"
|
40
33
|
end
|
41
34
|
|
42
35
|
private
|
43
36
|
|
37
|
+
def logs_uncached
|
38
|
+
::EacRubyUtils::Fs::Logs.new.add(:stdout).add(:stderr)
|
39
|
+
end
|
40
|
+
|
44
41
|
def result_uncached
|
45
42
|
return RESULT_NONEXISTENT unless elegible?
|
46
43
|
|
@@ -53,8 +50,8 @@ module EacRubyGemsUtils
|
|
53
50
|
|
54
51
|
def exec_run_with_log
|
55
52
|
r = exec_run
|
56
|
-
|
57
|
-
|
53
|
+
logs[:stdout].write(r[:stdout])
|
54
|
+
logs[:stderr].write(r[:stderr])
|
58
55
|
r[:exit_code].zero?
|
59
56
|
end
|
60
57
|
|