avm-tools 0.113.3 → 0.114.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/launcher/context.rb +19 -8
  3. data/lib/avm/tools/runner/app_src/ruby/bundler/incompatible.rb +2 -2
  4. data/lib/avm/tools/runner/self.rb +2 -2
  5. data/lib/avm/tools/self.rb +0 -13
  6. data/lib/avm/tools/version.rb +1 -1
  7. data/sub/avm/lib/avm/instances/base/auto_values/data.rb +2 -2
  8. data/sub/avm/lib/avm/instances/base/auto_values/filesystem.rb +6 -8
  9. data/sub/avm/lib/avm/instances/entry.rb +10 -4
  10. data/sub/avm/lib/avm/instances/entry_keys.rb +1 -1
  11. data/sub/avm/lib/avm/self/instance.rb +8 -0
  12. data/sub/avm/lib/avm/version.rb +1 -1
  13. data/sub/avm-eac_rails_base0/avm-eac_rails_base0.gemspec +0 -1
  14. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/runners/base.rb +2 -0
  15. data/sub/avm-eac_rails_base0/lib/avm/eac_rails_base0/version.rb +1 -1
  16. data/sub/avm-eac_rails_base0/spec/lib/avm/eac_rails_base0/apache_path_spec.rb +1 -1
  17. data/sub/avm-eac_rails_base0/spec/spec_helper.rb +1 -5
  18. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  19. data/sub/avm-files/lib/avm/files/version.rb +1 -1
  20. data/sub/avm-git/avm-git.gemspec +1 -1
  21. data/sub/avm-git/lib/avm/git/issue/complete/commits.rb +3 -3
  22. data/sub/avm-git/lib/avm/git/issue/complete/git_subrepos.rb +1 -1
  23. data/sub/avm-git/lib/avm/git/issue/complete/local_branch.rb +13 -6
  24. data/sub/avm-git/lib/avm/git/issue/complete/local_tag.rb +3 -3
  25. data/sub/avm-git/lib/avm/git/issue/complete/push.rb +15 -9
  26. data/sub/avm-git/lib/avm/git/issue/complete/remote.rb +2 -2
  27. data/sub/avm-git/lib/avm/git/issue/complete/test.rb +1 -1
  28. data/sub/avm-git/lib/avm/git/issue/complete/tracker.rb +1 -1
  29. data/sub/avm-git/lib/avm/git/issue/complete/validation.rb +13 -5
  30. data/sub/avm-git/lib/avm/git/issue/complete/working_tree.rb +1 -1
  31. data/sub/avm-git/lib/avm/git/issue/complete.rb +22 -7
  32. data/sub/avm-git/lib/avm/git/revision_test.rb +1 -1
  33. data/sub/avm-git/lib/avm/git/version.rb +1 -1
  34. data/sub/eac_cli/eac_cli.gemspec +2 -2
  35. data/sub/eac_cli/lib/eac_cli/config/entry/options.rb +1 -1
  36. data/sub/eac_cli/lib/eac_cli/config/entry/undefined.rb +1 -1
  37. data/sub/eac_cli/lib/eac_cli/config/entry.rb +5 -1
  38. data/sub/eac_cli/lib/eac_cli/rspec/setup.rb +42 -0
  39. data/sub/eac_cli/lib/eac_cli/rspec.rb +9 -0
  40. data/sub/eac_cli/lib/eac_cli/speaker/constants.rb +13 -0
  41. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  42. data/sub/eac_config/eac_config.gemspec +1 -1
  43. data/sub/eac_config/lib/eac_config/entry.rb +4 -0
  44. data/sub/eac_config/lib/eac_config/node_entry.rb +4 -0
  45. data/sub/eac_config/lib/eac_config/rspec/setup.rb +19 -3
  46. data/sub/eac_config/lib/eac_config/version.rb +1 -1
  47. data/sub/eac_fs/lib/eac_fs/cached_download.rb +1 -1
  48. data/sub/eac_fs/lib/eac_fs/contexts.rb +21 -0
  49. data/sub/eac_fs/lib/eac_fs/logs/file.rb +4 -0
  50. data/sub/eac_fs/lib/eac_fs/logs.rb +5 -0
  51. data/sub/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +9 -4
  52. data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +16 -6
  53. data/sub/eac_fs/lib/eac_fs/{cache.rb → storage_tree.rb} +6 -8
  54. data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
  55. data/sub/eac_fs/spec/lib/eac_fs/{cache_spec.rb → storage_tree_spec.rb} +5 -5
  56. data/sub/eac_git/eac_git.gemspec +1 -1
  57. data/sub/eac_git/lib/eac_git/local/branch.rb +27 -0
  58. data/sub/eac_git/lib/eac_git/local/commit.rb +1 -0
  59. data/sub/eac_git/lib/eac_git/local/remotes.rb +20 -0
  60. data/sub/eac_git/lib/eac_git/local.rb +18 -0
  61. data/sub/eac_git/lib/eac_git/version.rb +1 -1
  62. data/sub/eac_ruby_base0/eac_ruby_base0.gemspec +2 -2
  63. data/sub/eac_ruby_base0/lib/eac_ruby_base0/application.rb +9 -5
  64. data/sub/eac_ruby_base0/lib/eac_ruby_base0/rspec/setup.rb +14 -0
  65. data/sub/eac_ruby_base0/lib/eac_ruby_base0/rspec.rb +9 -0
  66. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +28 -9
  67. data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  68. data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  69. data/sub/eac_ruby_utils/lib/eac_ruby_utils/context.rb +2 -0
  70. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/to_struct.rb +10 -0
  71. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/if_exist.rb +10 -0
  72. data/sub/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/readlink_r.rb +11 -0
  73. data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/stub_speaker.rb +39 -0
  74. data/sub/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +7 -0
  75. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  76. metadata +28 -19
  77. data/sub/eac_cli/lib/eac_cli/old_configs_bridge.rb +0 -39
  78. data/sub/eac_cli/lib/eac_cli/speaker/_constants.rb +0 -12
  79. data/sub/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +0 -22
@@ -3,7 +3,7 @@
3
3
  require 'eac_ruby_utils/core_ext'
4
4
 
5
5
  module EacCli
6
- class Config
6
+ class Config < ::SimpleDelegator
7
7
  class Entry
8
8
  module Undefined
9
9
  private
@@ -5,7 +5,7 @@ require 'eac_config/entry_path'
5
5
  require 'eac_ruby_utils/core_ext'
6
6
 
7
7
  module EacCli
8
- class Config
8
+ class Config < ::SimpleDelegator
9
9
  class Entry
10
10
  require_sub __FILE__, include_modules: true
11
11
  enable_listable
@@ -24,6 +24,10 @@ module EacCli
24
24
  input_value
25
25
  end
26
26
 
27
+ def secret_value
28
+ self.class.new(config, path, options.to_h.merge(noecho: true).to_h).value
29
+ end
30
+
27
31
  delegate :found?, :value=, to: :sub_entry
28
32
 
29
33
  private
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/config/entry'
4
+ require 'eac_cli/speaker'
5
+ require 'eac_ruby_utils/core_ext'
6
+ require 'eac_ruby_utils/speaker'
7
+
8
+ module EacCli
9
+ module Rspec
10
+ module Setup
11
+ def disable_input_request
12
+ disable_config_input_request
13
+ disable_speaker_input_request
14
+ end
15
+
16
+ def disable_config_input_request
17
+ rspec_config.before do
18
+ allow_any_instance_of(::EacCli::Config::Entry).to receive(:input_value) do |obj|
19
+ raise "Console input requested for entry (Path: #{obj.path})"
20
+ end
21
+ end
22
+ end
23
+
24
+ def disable_speaker_input_request
25
+ ::RSpec.configure do |config|
26
+ config.around do |example|
27
+ ::EacRubyUtils::Speaker
28
+ .context.on(::EacCli::Speaker.new(in_in: FailIfRequestInput.new)) { example.run }
29
+ end
30
+ end
31
+ end
32
+
33
+ class FailIfRequestInput
34
+ %w[gets noecho].each do |method|
35
+ define_method(method) do
36
+ raise "Input method requested: #{method}. Should not request input on RSpec."
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_exts'
4
+
5
+ module EacCli
6
+ module Rspec
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/by_reference'
4
+
5
+ module EacCli
6
+ class Speaker
7
+ module Constants
8
+ STDERR = ::EacRubyUtils::ByReference.new { $stderr }
9
+ STDIN = ::EacRubyUtils::ByReference.new { $stdin }
10
+ STDOUT = ::EacRubyUtils::ByReference.new { $stdout }
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.24.1'
4
+ VERSION = '0.26.1'
5
5
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
15
  s.add_dependency 'addressable'
16
- s.add_dependency 'eac_ruby_utils', '~> 0.81'
16
+ s.add_dependency 'eac_ruby_utils', '~> 0.83'
17
17
 
18
18
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
19
19
  end
@@ -18,6 +18,10 @@ module EacConfig
18
18
  node_entry.if_present(&:node)
19
19
  end
20
20
 
21
+ def secret_value
22
+ node_entry.if_present(&:secret_value)
23
+ end
24
+
21
25
  def value
22
26
  node_entry.if_present(&:value)
23
27
  end
@@ -14,5 +14,9 @@ module EacConfig
14
14
  end
15
15
 
16
16
  abstract_methods :found?, :value, :value=
17
+
18
+ def secret_value
19
+ value
20
+ end
17
21
  end
18
22
  end
@@ -29,10 +29,18 @@ module EacConfig
29
29
  ::EacConfig::EnvvarsNode.new.load_path.entry
30
30
  end
31
31
 
32
- def stub_eac_config_node(&node_builder)
32
+ # Wraps a RSpec example in a EacConfig node using a alternative file.
33
+ #
34
+ # @param target_example [RSpec::Core::ExampleGroup] The example to wrap. If not provided,
35
+ # it is applied to all examples.
36
+ # @param target_file [Pathname] The file used by the EacConfig node. If not provided, a
37
+ # temporary file is used.
38
+ # @param node_builder [Proc] Should return the desired EacConfig node. If not provided, a
39
+ # EacConfig::YamlFileNode is created.
40
+ def stub_eac_config_node(target_example = nil, target_file = nil, &node_builder)
33
41
  parent_self = self
34
- rspec_config.around do |example|
35
- ::EacRubyUtils::Fs::Temp.on_file do |file|
42
+ (target_example || rspec_config).around do |example|
43
+ parent_self.stub_eac_config_node_on_file(target_file) do |file|
36
44
  ::EacConfig::Node
37
45
  .context.on(parent_self.stub_eac_config_node_build(file, &node_builder)) do
38
46
  example.run
@@ -44,6 +52,14 @@ module EacConfig
44
52
  def stub_eac_config_node_build(file, &node_builder)
45
53
  node_builder.present? ? node_builder.call(file) : ::EacConfig::YamlFileNode.new(file)
46
54
  end
55
+
56
+ def stub_eac_config_node_on_file(target_file)
57
+ if target_file
58
+ yield(target_file.to_pathname)
59
+ else
60
+ ::EacRubyUtils::Fs::Temp.on_file { |file| yield(file) }
61
+ end
62
+ end
47
63
  end
48
64
  end
49
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.6.0'
4
+ VERSION = '0.8.0'
5
5
  end
@@ -13,7 +13,7 @@ module Avm
13
13
  end
14
14
 
15
15
  def assert
16
- download unless fs_cache.cached?
16
+ download unless fs_cache.stored?
17
17
  end
18
18
 
19
19
  def download
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/context'
5
+
6
+ module EacFs
7
+ class Contexts
8
+ TYPES = %i[cache config data].freeze
9
+
10
+ class << self
11
+ TYPES.each do |type|
12
+ class_eval <<~CODE, __FILE__, __LINE__ + 1
13
+ # @return [EacRubyUtils::Context<EacFs::StorageTree>]
14
+ def #{type}
15
+ @#{type} ||= ::EacRubyUtils::Context.new
16
+ end
17
+ CODE
18
+ end
19
+ end
20
+ end
21
+ end
@@ -13,6 +13,10 @@ module EacFs
13
13
 
14
14
  delegate :remove, to: :file
15
15
 
16
+ def clean
17
+ file.truncate(0) if file.exist?
18
+ end
19
+
16
20
  def file_size
17
21
  file.file? ? file.size : 0
18
22
  end
@@ -23,6 +23,11 @@ module EacFs
23
23
  self
24
24
  end
25
25
 
26
+ # @return [EacFs::Logs]
27
+ def clean_all
28
+ log_set.values.each(&:clean)
29
+ end
30
+
26
31
  # @return [EacFs::Logs]
27
32
  def remove_all
28
33
  log_set.each_key { |label| remove(label) }
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_fs/cache'
3
+ require 'eac_fs/contexts'
4
4
 
5
5
  class Module
6
- # @return [EacFs::Cache]
7
- def fs_cache
8
- ::EacFs::Cache.context.current.child('fs_cache', *name.split('::'))
6
+ ::EacFs::Contexts::TYPES.each do |type|
7
+ method_name = "fs_#{type}"
8
+ class_eval <<~CODE, __FILE__, __LINE__ + 1
9
+ # @return [EacFs::StorageTree]
10
+ def #{method_name}
11
+ ::EacFs::Contexts.#{type}.current.child('#{method_name}', *name.split('::'))
12
+ end
13
+ CODE
9
14
  end
10
15
  end
@@ -1,17 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_fs/contexts'
3
4
  require 'eac_fs/patches/module/fs_cache'
4
5
 
5
6
  class Object
6
- # @return [EacFs::Cache]
7
- def fs_cache
8
- oid = fs_cache_object_id
9
- oid = [oid.to_s] unless oid.is_a?(::Enumerable)
10
- oid.inject(self.class.fs_cache) { |a, e| a.child(e.to_s) }
7
+ ::EacFs::Contexts::TYPES.each do |type|
8
+ class_eval <<~CODE, __FILE__, __LINE__ + 1
9
+ # @return [EacFs::StorageTree]
10
+ def fs_#{type}
11
+ oid = fs_object_id_by_type(:'#{type}')
12
+ oid = [oid.to_s] unless oid.is_a?(::Enumerable)
13
+ oid.inject(self.class.fs_#{type}) { |a, e| a.child(e.to_s) }
14
+ end
15
+ CODE
11
16
  end
12
17
 
13
18
  # @return [String, Array<String>]
14
- def fs_cache_object_id
19
+ def fs_object_id
15
20
  raise 'Abstract method hit'
16
21
  end
22
+
23
+ def fs_object_id_by_type(type)
24
+ method = "fs_#{type}_object_id"
25
+ respond_to?(method) ? send(method) : fs_object_id
26
+ end
17
27
  end
@@ -4,9 +4,7 @@ require 'eac_ruby_utils/core_ext'
4
4
  require 'fileutils'
5
5
 
6
6
  module EacFs
7
- class Cache
8
- enable_context
9
-
7
+ class StorageTree
10
8
  CONTENT_FILE_NAME = '__content__'
11
9
 
12
10
  attr_reader :path
@@ -18,19 +16,19 @@ module EacFs
18
16
  end
19
17
 
20
18
  def clear
21
- return unless cached?
19
+ return unless stored?
22
20
 
23
21
  ::File.unlink(content_path)
24
22
  end
25
23
 
26
24
  def read
27
- return nil unless cached?
25
+ return nil unless stored?
28
26
 
29
27
  ::File.read(content_path)
30
28
  end
31
29
 
32
- def read_or_cache
33
- write(yield) unless cached?
30
+ def read_or_store
31
+ write(yield) unless stored?
34
32
 
35
33
  read
36
34
  end
@@ -45,7 +43,7 @@ module EacFs
45
43
  self.class.new(path, *child_path_parts)
46
44
  end
47
45
 
48
- def cached?
46
+ def stored?
49
47
  ::File.exist?(content_path)
50
48
  end
51
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacFs
4
- VERSION = '0.8.1'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/core_ext/object/blank'
4
- require 'eac_fs/cache'
4
+ require 'eac_fs/storage_tree'
5
5
 
6
- RSpec.describe ::EacFs::Cache do
6
+ RSpec.describe ::EacFs::StorageTree do
7
7
  let(:tmpdir) { ::Dir.mktmpdir }
8
8
  let(:instance) { described_class.new(tmpdir, 'instance') }
9
9
 
10
10
  it { expect(instance.read).to be_blank }
11
- it { expect(instance.cached?).to eq(false) }
11
+ it { expect(instance.stored?).to eq(false) }
12
12
 
13
13
  context 'when instance is writed' do
14
14
  before { instance.write('STUB') }
15
15
 
16
16
  it { expect(instance.read).to eq('STUB') }
17
- it { expect(instance.cached?).to eq(true) }
17
+ it { expect(instance.stored?).to eq(true) }
18
18
 
19
19
  context 'when instance is cleared' do
20
20
  before { instance.clear }
21
21
 
22
22
  it { expect(instance.read).to be_blank }
23
- it { expect(instance.cached?).to eq(false) }
23
+ it { expect(instance.stored?).to eq(false) }
24
24
  end
25
25
  end
26
26
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,vendor}/**/*']
14
14
 
15
- s.add_dependency 'eac_ruby_utils', '~> 0.74'
15
+ s.add_dependency 'eac_ruby_utils', '~> 0.83'
16
16
  s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
17
17
 
18
18
  s.add_development_dependency 'aranha-parsers', '~> 0.8', '>= 0.8.2'
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacGit
6
+ class Local
7
+ class Branch
8
+ REFS_PREFIX = 'refs/heads/'
9
+
10
+ common_constructor :local, :name
11
+
12
+ # @return [String]
13
+ def current_commit_id
14
+ local.rev_parse(full_ref_name, true)
15
+ end
16
+
17
+ # @return [Boolean]
18
+ def exist?
19
+ local.command('show-ref', '--quiet', full_ref_name).execute.fetch(:exit_code).zero?
20
+ end
21
+
22
+ def full_ref_name
23
+ "#{REFS_PREFIX}#{name}"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -13,6 +13,7 @@ module EacGit
13
13
  author_name: '%an', author_email: '%ae', author_date: '%ai',
14
14
  subject: '%s',
15
15
  author_all: '%an <%ae>, %ai',
16
+ commit_hash: '%H', abbreviated_commit_hash: '%h',
16
17
  commiter_name: '%cn', commiter_email: '%ce', commiter_date: '%ci',
17
18
  commiter_all: '%cn <%ce>, %ci',
18
19
  raw_body: '%B'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_git/local/remote'
5
+
6
+ module EacGit
7
+ class Local
8
+ module Remotes
9
+ def remote(name)
10
+ ::EacGit::Local::Remote.new(self, name)
11
+ end
12
+
13
+ def remotes
14
+ command('remote').execute!.each_line.map(&:strip).reject(&:blank?).map do |name|
15
+ remote(name)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -30,6 +30,14 @@ module EacGit
30
30
  root_path <=> other.root_path
31
31
  end
32
32
 
33
+ # Retrieves a local branch.
34
+ #
35
+ # @param name [String] Ex.: for "refs/heads/master", name should be "master".
36
+ # @return [EacGit::Local::Branch]
37
+ def branch(name)
38
+ ::EacGit::Local::Branch.new(self, name)
39
+ end
40
+
33
41
  def commit(ref, required = false)
34
42
  rev_parse(ref, required).if_present { |v| ::EacGit::Local::Commit.new(self, v) }
35
43
  end
@@ -44,6 +52,16 @@ module EacGit
44
52
  source.to_s.strip.if_present(nil) { |v| ::EacGit::Local::Commit.new(self, v) }
45
53
  end
46
54
 
55
+ # Retrieves the current local branch.
56
+ #
57
+ # @return [EacGit::Local::Branch, nil]
58
+ def current_branch
59
+ command('symbolic-ref', '--quiet', HEAD_REFERENCE)
60
+ .execute!(exit_outputs: { 256 => '' })
61
+ .gsub(%r{\Arefs/heads/}, '').strip
62
+ .if_present { |v| branch(v) }
63
+ end
64
+
47
65
  def descendant?(descendant, ancestor)
48
66
  base = merge_base(descendant, ancestor)
49
67
  return false if base.blank?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacGit
4
- VERSION = '0.10.0'
4
+ VERSION = '0.12.0'
5
5
  end
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'eac_cli', '~> 0.24', '>= 0.24.1'
16
- s.add_dependency 'eac_fs', '~> 0.3'
15
+ s.add_dependency 'eac_cli', '~> 0.26'
16
+ s.add_dependency 'eac_fs', '~> 0.10'
17
17
  s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '~> 0.9.6'
18
18
  s.add_dependency 'eac_ruby_utils', '~> 0.70'
19
19
 
@@ -3,7 +3,8 @@
3
3
  require 'eac_cli/config'
4
4
  require 'eac_config/envvars_node'
5
5
  require 'eac_config/yaml_file_node'
6
- require 'eac_fs/cache'
6
+ require 'eac_fs/contexts'
7
+ require 'eac_fs/storage_tree'
7
8
  require 'eac_ruby_base0/application_xdg'
8
9
  require 'eac_ruby_gems_utils/gem'
9
10
  require 'eac_ruby_utils/core_ext'
@@ -43,10 +44,13 @@ module EacRubyBase0
43
44
  delegate "#{item}_xdg_env", "#{item}_dir", to: :app_xdg
44
45
  end
45
46
 
46
- def self_fs_cache
47
- @self_fs_cache ||= ::EacFs::Cache.new(
48
- cache_dir.join(::EacFs::Cache.name.parameterize)
49
- )
47
+ ::EacFs::Contexts::TYPES.each do |type|
48
+ class_eval <<CODE, __FILE__, __LINE__ + 1
49
+ # @return [EacFs::StorageTree]
50
+ def self_fs_#{type}
51
+ @self_fs_#{type} ||= ::EacFs::StorageTree.new(#{type}_dir.join('eac_fs'))
52
+ end
53
+ CODE
50
54
  end
51
55
 
52
56
  def home_dir
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyBase0
6
+ module Rspec
7
+ module Setup
8
+ def self.extended(obj)
9
+ obj.disable_input_request
10
+ obj.stub_eac_config_node
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_exts'
4
+
5
+ module EacRubyBase0
6
+ module Rspec
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -3,12 +3,11 @@
3
3
  require 'eac_cli/core_ext'
4
4
  require 'eac_cli/speaker'
5
5
  require 'eac_config/node'
6
- require 'eac_fs/cache'
6
+ require 'eac_fs/contexts'
7
7
  require 'eac_ruby_utils/speaker'
8
8
 
9
9
  module EacRubyBase0
10
10
  module Runner
11
- require_sub __FILE__
12
11
  enable_speaker
13
12
  common_concern do
14
13
  include ::EacCli::RunnerWith::Help
@@ -37,14 +36,15 @@ module EacRubyBase0
37
36
  runner_context.call(:application).version.to_s
38
37
  end
39
38
 
40
- def on_context
41
- ::EacRubyUtils::Speaker.context.on(build_speaker) do
42
- ::EacConfig::Node.context.on(runner_context.call(:application).build_config) do
43
- ::EacFs::Cache.context.on(application.self_fs_cache) do
44
- yield
45
- end
46
- end
39
+ def on_context(&block)
40
+ top_block = block
41
+ available_contexts.each do |context|
42
+ next if context.object.any?
43
+
44
+ last_block = top_block
45
+ top_block = ::Proc.new { context.object.on(context.builder.call, &last_block) }
47
46
  end
47
+ top_block.call
48
48
  end
49
49
 
50
50
  def show_version
@@ -63,11 +63,30 @@ module EacRubyBase0
63
63
 
64
64
  private
65
65
 
66
+ # @return [Array<EacRubyUtils::Struct>]
67
+ def available_contexts
68
+ (filesystem_available_contexts + [
69
+ [:config, ::EacConfig::Node.context, -> { runner_context.call(:application).build_config }],
70
+ [:speaker, ::EacRubyUtils::Speaker.context, -> { build_speaker }]
71
+ ]).map { |row| available_context_row_to_struct(row) }
72
+ end
73
+
74
+ def available_context_row_to_struct(row)
75
+ %i[type object builder].zip(row).to_h.to_struct
76
+ end
77
+
66
78
  def build_speaker
67
79
  options = {}
68
80
  options[:err_out] = ::StringIO.new if parsed.quiet?
69
81
  options[:in_in] = FailIfRequestInput.new if parsed.no_input?
70
82
  ::EacCli::Speaker.new(options)
71
83
  end
84
+
85
+ def filesystem_available_contexts
86
+ ::EacFs::Contexts::TYPES.map do |type|
87
+ key = "fs_#{type}".to_sym
88
+ [key, ::EacFs::Contexts.send(type), -> { application.send("self_#{key}") }]
89
+ end
90
+ end
72
91
  end
73
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.13.2'
4
+ VERSION = '0.16.1'
5
5
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.files = Dir['{lib}/**/*', 'MIT-LICENSE', 'README.rdoc']
17
17
 
18
- s.add_dependency 'activesupport', '>= 4.0'
18
+ s.add_dependency 'activesupport', '>= 4', '< 7'
19
19
  s.add_dependency 'addressable', '~> 2.6'
20
20
  s.add_dependency 'filesize'
21
21
  s.add_dependency 'net-ssh', '~> 4.2'
@@ -2,6 +2,8 @@
2
2
 
3
3
  module EacRubyUtils
4
4
  class Context
5
+ delegate :any?, to: :stack
6
+
5
7
  def current
6
8
  optional_current || raise('No elements in context')
7
9
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/struct'
4
+
5
+ class Hash
6
+ # Returns an <tt>EacRubyUtils::Struct</tt> out of its receiver.
7
+ def to_struct
8
+ ::EacRubyUtils::Struct.new(self)
9
+ end
10
+ end