avm-tools 0.104.0 → 0.105.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/instance_collector.rb +46 -0
  3. data/lib/avm/launcher/instances/runner_helper.rb +21 -15
  4. data/lib/avm/launcher/paths/logical.rb +5 -0
  5. data/lib/avm/tools/runner/launcher/instances.rb +7 -5
  6. data/lib/avm/tools/runner/launcher/projects.rb +2 -4
  7. data/lib/avm/tools/runner/launcher/publish.rb +2 -6
  8. data/lib/avm/tools/version.rb +1 -1
  9. data/vendor/avm/lib/avm/version.rb +1 -1
  10. data/vendor/avm/spec/lib/avm/git/commit/diff_tree_line_spec.rb +0 -1
  11. data/vendor/avm/spec/rubocop_spec.rb +1 -1
  12. data/vendor/avm/spec/spec_helper.rb +2 -17
  13. data/vendor/avm-apps/lib/avm/apps/version.rb +1 -1
  14. data/vendor/avm-apps/spec/rubocop_spec.rb +1 -1
  15. data/vendor/avm-apps/spec/spec_helper.rb +2 -101
  16. data/vendor/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
  17. data/vendor/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +1 -1
  18. data/vendor/avm-eac_asciidoctor_base0/spec/spec_helper.rb +2 -100
  19. data/vendor/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  20. data/vendor/avm-eac_rails_base1/spec/rubocop_spec.rb +1 -1
  21. data/vendor/avm-eac_rails_base1/spec/spec_helper.rb +2 -100
  22. data/vendor/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -1
  23. data/vendor/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  24. data/vendor/avm-eac_redmine_base0/spec/rubocop_spec.rb +1 -1
  25. data/vendor/avm-eac_redmine_base0/spec/spec_helper.rb +2 -100
  26. data/vendor/avm-eac_redmine_base0/template/avm/eac_redmine_base0/deploy/config/install.sh.template +1 -0
  27. data/vendor/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  28. data/vendor/avm-eac_webapp_base0/spec/rubocop_spec.rb +1 -1
  29. data/vendor/avm-eac_webapp_base0/spec/spec_helper.rb +2 -100
  30. data/vendor/eac_cli/eac_cli.gemspec +3 -3
  31. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  32. data/vendor/eac_cli/spec/rubocop_spec.rb +1 -1
  33. data/vendor/eac_cli/spec/spec_helper.rb +2 -101
  34. data/vendor/eac_config/eac_config.gemspec +2 -2
  35. data/vendor/eac_config/lib/eac_config/version.rb +1 -1
  36. data/vendor/eac_config/spec/rubocop_spec.rb +1 -1
  37. data/vendor/eac_config/spec/spec_helper.rb +2 -15
  38. data/vendor/eac_docker/eac_docker.gemspec +2 -2
  39. data/vendor/eac_docker/lib/eac_docker/container.rb +7 -3
  40. data/vendor/eac_docker/lib/eac_docker/images/templatized.rb +4 -0
  41. data/vendor/eac_docker/lib/eac_docker/rspec/setup.rb +17 -0
  42. data/vendor/eac_docker/lib/eac_docker/rspec.rb +2 -10
  43. data/vendor/eac_docker/lib/eac_docker/version.rb +1 -1
  44. data/vendor/eac_docker/spec/rubocop_spec.rb +1 -1
  45. data/vendor/eac_docker/spec/spec_helper.rb +2 -104
  46. data/vendor/eac_git/eac_git.gemspec +3 -3
  47. data/vendor/eac_git/lib/eac_git/rspec/setup.rb +23 -0
  48. data/vendor/eac_git/lib/eac_git/rspec.rb +1 -14
  49. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  50. data/vendor/eac_git/spec/rubocop_spec.rb +1 -1
  51. data/vendor/eac_git/spec/spec_helper.rb +2 -104
  52. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +4 -4
  53. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  54. data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +1 -1
  55. data/vendor/eac_ruby_base0/spec/spec_helper.rb +2 -101
  56. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +2 -2
  57. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  58. data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +1 -1
  59. data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +2 -101
  60. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/executable.rb +15 -3
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +75 -0
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +35 -0
  64. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/recursive_builder.rb +51 -0
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/default_setup.rb +20 -0
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +12 -0
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
  69. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  70. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/recursive_builder_spec.rb +65 -0
  71. data/vendor/eac_ruby_utils/spec/rubocop_check_spec.rb +1 -1
  72. data/vendor/eac_ruby_utils/spec/spec_helper.rb +6 -6
  73. data/vendor/eac_templates/lib/eac_templates/version.rb +1 -1
  74. data/vendor/eac_templates/spec/rubocop_spec.rb +1 -1
  75. data/vendor/eac_templates/spec/spec_helper.rb +2 -100
  76. metadata +13 -5
  77. data/lib/avm/eac_asciidoctor_base0.rb +0 -9
  78. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/conditional.rb +0 -35
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/rspec/stubbed_ssh.rb +0 -44
@@ -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.20'
16
- s.add_dependency 'eac_ruby_gems_utils', '~> 0.8'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.67'
15
+ s.add_dependency 'eac_cli', '~> 0.22', '>= 0.22.2'
16
+ s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '~> 0.9.5'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.70'
18
18
 
19
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
19
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.10.0'
4
+ VERSION = '0.10.1'
5
5
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::EacRubyGemSupport::Rspec.default.describe_rubocop
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -1,103 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- RSpec.configure do |config|
19
- # rspec-expectations config goes here. You can use an alternate
20
- # assertion/expectation library such as wrong or the stdlib/minitest
21
- # assertions if you prefer.
22
- config.expect_with :rspec do |expectations|
23
- # This option will default to `true` in RSpec 4. It makes the `description`
24
- # and `failure_message` of custom matchers include text for helper methods
25
- # defined using `chain`, e.g.:
26
- # be_bigger_than(2).and_smaller_than(4).description
27
- # # => "be bigger than 2 and smaller than 4"
28
- # ...rather than:
29
- # # => "be bigger than 2"
30
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
- end
32
-
33
- # rspec-mocks config goes here. You can use an alternate test double
34
- # library (such as bogus or mocha) by changing the `mock_with` option here.
35
- config.mock_with :rspec do |mocks|
36
- # Prevents you from mocking or stubbing a method that does not exist on
37
- # a real object. This is generally recommended, and will default to
38
- # `true` in RSpec 4.
39
- mocks.verify_partial_doubles = true
40
- end
41
-
42
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
- # have no way to turn it off -- the option exists only for backwards
44
- # compatibility in RSpec 3). It causes shared context metadata to be
45
- # inherited by the metadata hash of host groups and examples, rather than
46
- # triggering implicit auto-inclusion in groups with matching metadata.
47
- config.shared_context_metadata_behavior = :apply_to_host_groups
48
-
49
- # The settings below are suggested to provide a good initial experience
50
- # with RSpec, but feel free to customize to your heart's content.
51
- # # This allows you to limit a spec run to individual examples or groups
52
- # # you care about by tagging them with `:focus` metadata. When nothing
53
- # # is tagged with `:focus`, all examples get run. RSpec also provides
54
- # # aliases for `it`, `describe`, and `context` that include `:focus`
55
- # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
- # config.filter_run_when_matching :focus
57
- #
58
- # # Allows RSpec to persist some state between runs in order to support
59
- # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
- # # you configure your source control system to ignore this file.
61
- # config.example_status_persistence_file_path = "spec/examples.txt"
62
- #
63
- # # Limits the available syntax to the non-monkey patched syntax that is
64
- # # recommended. For more details, see:
65
- # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
- # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
- # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
- # config.disable_monkey_patching!
69
- #
70
- # # This setting enables warnings. It's recommended, but in some cases may
71
- # # be too noisy due to issues in dependencies.
72
- # config.warnings = true
73
- #
74
- # # Many RSpec users commonly either run the entire suite or an individual
75
- # # file, and it's useful to allow more verbose output when running an
76
- # # individual spec file.
77
- # if config.files_to_run.one?
78
- # # Use the documentation formatter for detailed output,
79
- # # unless a formatter has already been configured
80
- # # (e.g. via a command-line flag).
81
- # config.default_formatter = "doc"
82
- # end
83
- #
84
- # # Print the 10 slowest examples and example groups at the
85
- # # end of the spec run, to help surface which specs are running
86
- # # particularly slow.
87
- # config.profile_examples = 10
88
- #
89
- # # Run specs in random order to surface order dependencies. If you find an
90
- # # order dependency and want to debug it, you can fix the order by providing
91
- # # the seed, which is printed after each run.
92
- # # --seed 1234
93
- # config.order = :random
94
- #
95
- # # Seed global randomization in this process using the `--seed` CLI option.
96
- # # Setting this allows you to use `--seed` to deterministically reproduce
97
- # # test failures related to randomization by passing the same `--seed` value
98
- # # as the one that triggered the failure.
99
- # Kernel.srand config.seed
100
-
101
- require 'eac_ruby_gem_support/rspec'
102
- ::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
103
- end
3
+ require 'eac_ruby_utils/rspec/default_setup'
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
@@ -23,8 +23,8 @@ Gem::Specification.new do |s|
23
23
  s.test_files = Dir['{spec}/**/*', '.rspec']
24
24
 
25
25
  s.add_dependency 'bundler', '~> 2.2', '>= 2.2.17'
26
- s.add_dependency 'eac_ruby_utils', '~> 0.67'
26
+ s.add_dependency 'eac_ruby_utils', '~> 0.70'
27
27
 
28
28
  # Tests
29
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
29
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
30
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.9.4'
4
+ VERSION = '0.9.5'
5
5
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::EacRubyGemSupport::Rspec.default.describe_rubocop
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -1,103 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- RSpec.configure do |config|
19
- # rspec-expectations config goes here. You can use an alternate
20
- # assertion/expectation library such as wrong or the stdlib/minitest
21
- # assertions if you prefer.
22
- config.expect_with :rspec do |expectations|
23
- # This option will default to `true` in RSpec 4. It makes the `description`
24
- # and `failure_message` of custom matchers include text for helper methods
25
- # defined using `chain`, e.g.:
26
- # be_bigger_than(2).and_smaller_than(4).description
27
- # # => "be bigger than 2 and smaller than 4"
28
- # ...rather than:
29
- # # => "be bigger than 2"
30
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
- end
32
-
33
- # rspec-mocks config goes here. You can use an alternate test double
34
- # library (such as bogus or mocha) by changing the `mock_with` option here.
35
- config.mock_with :rspec do |mocks|
36
- # Prevents you from mocking or stubbing a method that does not exist on
37
- # a real object. This is generally recommended, and will default to
38
- # `true` in RSpec 4.
39
- mocks.verify_partial_doubles = true
40
- end
41
-
42
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
- # have no way to turn it off -- the option exists only for backwards
44
- # compatibility in RSpec 3). It causes shared context metadata to be
45
- # inherited by the metadata hash of host groups and examples, rather than
46
- # triggering implicit auto-inclusion in groups with matching metadata.
47
- config.shared_context_metadata_behavior = :apply_to_host_groups
48
-
49
- # The settings below are suggested to provide a good initial experience
50
- # with RSpec, but feel free to customize to your heart's content.
51
- # # This allows you to limit a spec run to individual examples or groups
52
- # # you care about by tagging them with `:focus` metadata. When nothing
53
- # # is tagged with `:focus`, all examples get run. RSpec also provides
54
- # # aliases for `it`, `describe`, and `context` that include `:focus`
55
- # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
- # config.filter_run_when_matching :focus
57
- #
58
- # # Allows RSpec to persist some state between runs in order to support
59
- # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
- # # you configure your source control system to ignore this file.
61
- # config.example_status_persistence_file_path = "spec/examples.txt"
62
- #
63
- # # Limits the available syntax to the non-monkey patched syntax that is
64
- # # recommended. For more details, see:
65
- # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
- # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
- # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
- # config.disable_monkey_patching!
69
- #
70
- # # This setting enables warnings. It's recommended, but in some cases may
71
- # # be too noisy due to issues in dependencies.
72
- # config.warnings = true
73
- #
74
- # # Many RSpec users commonly either run the entire suite or an individual
75
- # # file, and it's useful to allow more verbose output when running an
76
- # # individual spec file.
77
- # if config.files_to_run.one?
78
- # # Use the documentation formatter for detailed output,
79
- # # unless a formatter has already been configured
80
- # # (e.g. via a command-line flag).
81
- # config.default_formatter = "doc"
82
- # end
83
- #
84
- # # Print the 10 slowest examples and example groups at the
85
- # # end of the spec run, to help surface which specs are running
86
- # # particularly slow.
87
- # config.profile_examples = 10
88
- #
89
- # # Run specs in random order to surface order dependencies. If you find an
90
- # # order dependency and want to debug it, you can fix the order by providing
91
- # # the seed, which is printed after each run.
92
- # # --seed 1234
93
- # config.order = :random
94
- #
95
- # # Seed global randomization in this process using the `--seed` CLI option.
96
- # # Setting this allows you to use `--seed` to deterministically reproduce
97
- # # test failures related to randomization by passing the same `--seed` value
98
- # # as the one that triggered the failure.
99
- # Kernel.srand config.seed
100
-
101
- require 'eac_ruby_gem_support/rspec'
102
- ::EacRubyGemSupport::Rspec.setup(::File.expand_path('..', __dir__), config)
103
- end
3
+ require 'eac_ruby_utils/rspec/default_setup'
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency 'addressable', '~> 2.6'
20
20
  s.add_dependency 'filesize'
21
21
  s.add_dependency 'net-ssh', '~> 4.2'
22
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
22
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3', '>= 0.3.2'
23
23
  end
@@ -22,7 +22,7 @@ module EacRubyUtils
22
22
  def validate
23
23
  return nil if exist?
24
24
 
25
- "Program \"#{name}\" not found in environment #{env}"
25
+ "Program \"#{::Shellwords.join(executable_args)}\" not found in environment #{env}"
26
26
  end
27
27
 
28
28
  def validate!
@@ -33,13 +33,25 @@ module EacRubyUtils
33
33
 
34
34
  def command(*command_args)
35
35
  validate!
36
- env.command(name, *command_args)
36
+ env.command(*executable_args, *command_args)
37
+ end
38
+
39
+ def executable_args
40
+ executable_args_from_envvar || [name]
41
+ end
42
+
43
+ def executable_args_envvar
44
+ "#{name}_command".variableize.upcase
45
+ end
46
+
47
+ def executable_args_from_envvar
48
+ ENV[executable_args_envvar].if_present { |v| ::Shellwords.split(v) }
37
49
  end
38
50
 
39
51
  private
40
52
 
41
53
  def exist_uncached
42
- env.command(name, *check_args).execute!
54
+ env.command(*executable_args, *check_args).execute!
43
55
  true
44
56
  rescue Errno::ENOENT
45
57
  false
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'eac_ruby_utils/recursive_builder'
5
+ require 'eac_ruby_utils/simple_cache'
6
+
7
+ module EacRubyUtils
8
+ class GemsRegistry
9
+ class Gem
10
+ include ::Comparable
11
+ include ::EacRubyUtils::SimpleCache
12
+
13
+ attr_reader :registry, :gemspec
14
+
15
+ def initialize(registry, gemspec)
16
+ @registry = registry
17
+ @gemspec = gemspec
18
+ end
19
+
20
+ def depend_on(gem)
21
+ dependencies.lazy.map(&:name).include?(gem.gemspec.name)
22
+ end
23
+
24
+ def dependencies
25
+ @dependencies ||= dependencies_uncached # dependencies_uncached
26
+ end
27
+
28
+ def <=>(other)
29
+ sd = depend_on(other)
30
+ od = other.depend_on(self)
31
+ return 1 if sd && !od
32
+ return -1 if od && !sd
33
+
34
+ gemspec.name <=> other.gemspec.name
35
+ end
36
+
37
+ def found?
38
+ lib_file_found? && registered_module.is_a?(::Module)
39
+ end
40
+
41
+ def lib_file_found?
42
+ gemspec.require_paths.any? do |require_path|
43
+ ::Pathname.new(require_path).expand_path(gemspec.gem_dir).join(path_to_require + '.rb')
44
+ .file?
45
+ end
46
+ end
47
+
48
+ def registered_module
49
+ return nil unless lib_file_found?
50
+
51
+ require path_to_require
52
+ path_to_require.classify.constantize
53
+ end
54
+
55
+ # @return [String]
56
+ def path_to_require
57
+ gemspec.name.gsub('-', '/') + '/' + registry.module_suffix.underscore
58
+ end
59
+
60
+ private
61
+
62
+ def dependencies_uncached
63
+ ::EacRubyUtils::RecursiveBuilder
64
+ .new(gemspec) { |item| gem_item_dependencies(item) }
65
+ .result
66
+ end
67
+
68
+ def gem_item_dependencies(item)
69
+ ::Gem::Specification.find_by_name(item.name).dependencies
70
+ rescue ::Gem::MissingSpecError
71
+ []
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'eac_ruby_utils/gems_registry/gem'
5
+
6
+ module EacRubyUtils
7
+ # Search in each gem for a class determined by registry and run the method "register" on each
8
+ # found.
9
+ #
10
+ # Example:
11
+ # * The module suffix is `TheClass`;
12
+ # * A gem with name "my-lib" is being analyzed
13
+ # * If a require for "my/lib/the_class" is succesful the class/module `My::Lib::TheClass` will
14
+ # be collected.
15
+ class GemsRegistry
16
+ attr_reader :module_suffix
17
+
18
+ def initialize(module_suffix)
19
+ @module_suffix = module_suffix
20
+ end
21
+
22
+ # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
23
+ def registered
24
+ @registered ||= all_gems.select(&:found?)
25
+ end
26
+
27
+ private
28
+
29
+ # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
30
+ def all_gems
31
+ ::Gem::Specification.map { |gemspec| ::EacRubyUtils::GemsRegistry::Gem.new(self, gemspec) }
32
+ .sort
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/simple_cache'
4
+
5
+ module EacRubyUtils
6
+ class RecursiveBuilder
7
+ include ::EacRubyUtils::SimpleCache
8
+
9
+ attr_reader :root, :neighbors_block
10
+
11
+ def initialize(root, &neighbors_block)
12
+ @root = root
13
+ @neighbors_block = neighbors_block
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :added, :to_check
19
+
20
+ def result_uncached
21
+ @added = []
22
+ @to_check = []
23
+ item_try_add_to_check(root)
24
+ while check_next_item
25
+ # Do nothing
26
+ end
27
+ added
28
+ end
29
+
30
+ def item_try_add_to_check(item)
31
+ to_check << item unless item_added?(item)
32
+ end
33
+
34
+ def item_added?(item)
35
+ added.include?(item) || to_check.include?(item)
36
+ end
37
+
38
+ def check_next_item
39
+ return false unless to_check.any?
40
+
41
+ item = to_check.shift
42
+ added << item
43
+ item_neighborhs(item).each { |sub_item| item_try_add_to_check(sub_item) }
44
+ true
45
+ end
46
+
47
+ def item_neighborhs(item)
48
+ neighbors_block.call(item)
49
+ end
50
+ end
51
+ end