avm 0.20.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da4c32db86b5e0217282e7954683ff84d63ddc8b34a7413bc8b255090a5d15c
4
- data.tar.gz: b9c369085dcd50e3787c110c828b702eb44b5a1c28a3c036217e6dae19301da8
3
+ metadata.gz: 9dbfd028daf9c304679d35bee81282c6bfbee007613933e1482c9b3c58cf824d
4
+ data.tar.gz: 16bdf2e2fafcd9bfc52cdeabb555ff1ce392d8e4165661f3e74ca00b5304d2ee
5
5
  SHA512:
6
- metadata.gz: 419e7911860b01a11ab6cc5fa901abc5585adbb28d4e2c6cfcf27cb189b4f63abc631e961835ad150b86dada322cc30764996387a92aede230922b6b449e2d5e
7
- data.tar.gz: 2ee319d2462b5c8611d719b64d8e4c75376fd4c3d6e1752f8a88fcbe858a87cd058a28f7017cda47089c70436a86d2b4374e89a724c2d73201287d8f8405927b
6
+ metadata.gz: f649eb88ed02c4201cc7810836e923932772685eee29f7274f1fe8e3c1202205829607e093c817a52ad50ef12253e2d43415537e40b7b84d3082e73aa99d893e
7
+ data.tar.gz: 5ebb0af2860921456ee00f4c5867ae4e68f916977aacee5c915044e95cb53162ae34dc3df6abc11234456cce04abeb5f228aa2bd745b769d2f59b5cab4e94cfe
@@ -11,8 +11,7 @@ module Avm
11
11
 
12
12
  def detect(*registered_initialize_args)
13
13
  detect_optional(*registered_initialize_args) ||
14
- raise("No registered module valid for #{registered_initialize_args}" \
15
- " (Module suffix: #{module_suffix}, Available: #{registered_modules.join(', ')})")
14
+ raise_not_found(*registered_initialize_args)
16
15
  end
17
16
 
18
17
  def detect_optional(*registered_initialize_args)
@@ -38,6 +37,11 @@ module Avm
38
37
 
39
38
  private
40
39
 
40
+ def raise_not_found(*args)
41
+ raise("No registered module valid for #{args}" \
42
+ " (Module suffix: #{module_suffix}, Available: #{registered_modules.join(', ')})")
43
+ end
44
+
41
45
  def registered_modules_uncached
42
46
  registered_gems.flat_map { |registry| modules_from_registry(registry) }
43
47
  .select { |v| valid_registered_module?(v) }.uniq
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Registry
8
+ class WithPath < ::Avm::Registry::Base
9
+ def detect_by_path(path)
10
+ detect_by_path_optional(path) || raise_not_found(path)
11
+ end
12
+
13
+ def detect_by_path_optional(path)
14
+ current_path = path.to_pathname.expand_path
15
+ until current_path.root?
16
+ detect_optional(current_path).if_present { |v| return v }
17
+ current_path = current_path.parent
18
+ end
19
+ nil
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/avm/registry.rb CHANGED
@@ -9,6 +9,8 @@ module Avm
9
9
  enable_listable
10
10
  lists.add_symbol :category, :instance_stereotypes, :runners, :scms, :sources
11
11
 
12
+ WITH_PATH = [CATEGORY_SCMS, CATEGORY_SOURCES].freeze
13
+
12
14
  class << self
13
15
  enable_simple_cache
14
16
 
@@ -21,7 +23,15 @@ module Avm
21
23
 
22
24
  ::Avm::Registry.lists.category.each_value do |category|
23
25
  define_method "#{category}_uncached" do
24
- ::Avm::Registry::Base.new(category.to_s.camelize)
26
+ registry_class(category).new(category.to_s.camelize)
27
+ end
28
+ end
29
+
30
+ def registry_class(category)
31
+ if WITH_PATH.include?(category)
32
+ ::Avm::Registry::WithPath
33
+ else
34
+ ::Avm::Registry::Base
25
35
  end
26
36
  end
27
37
  end
data/lib/avm/scms/base.rb CHANGED
@@ -33,13 +33,8 @@ module Avm
33
33
  private
34
34
 
35
35
  # @return [Avm::Scms::Base]
36
- def parent_scm
37
- parent_path = path.parent
38
- until parent_path.root?
39
- ::Avm::Registry.scms.detect_optional(parent_path).if_present { |v| return v }
40
- parent_path = parent_path.parent
41
- end
42
- nil
36
+ def parent_scm_uncached
37
+ ::Avm::Registry.scms.detect_by_path_optional(path.parent)
43
38
  end
44
39
  end
45
40
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Scms
8
+ class Null < ::Avm::Scms::Base
9
+ def update
10
+ # Do nothing
11
+ end
12
+ end
13
+ end
14
+ end
@@ -9,6 +9,8 @@ module Avm
9
9
  module Sources
10
10
  class Base
11
11
  module Configuration
12
+ CONFIGURATION_FILENAMES = %w[.avm.yml .avm.yaml].freeze
13
+
12
14
  # @return [Array<String>, nil]
13
15
  def read_configuration_as_shell_words(key)
14
16
  configuration.entry(key).value.if_present do |v|
@@ -16,14 +18,22 @@ module Avm
16
18
  end
17
19
  end
18
20
 
21
+ # Utility to read a configuration as a [EacRubyUtils::Envs::Command].
22
+ # @return [EacRubyUtils::Envs::Command]
23
+ def read_configuration_as_env_command(key)
24
+ read_configuration_as_shell_words(key).if_present do |v|
25
+ env.command(v).chdir(path)
26
+ end
27
+ end
28
+
19
29
  private
20
30
 
21
31
  # @return [EacConfig::YamlFileNode]
22
32
  def configuration_uncached
23
- ::Avm::Sources::Configuration::FILENAMES.each do |filename|
33
+ CONFIGURATION_FILENAMES.each do |filename|
24
34
  configuration_with_filename(filename, true)
25
35
  end
26
- configuration_with_filename(::Avm::Sources::Configuration::FILENAMES.first, false)
36
+ configuration_with_filename(CONFIGURATION_FILENAMES.first, false)
27
37
  end
28
38
 
29
39
  # @return [EacConfig::YamlFileNode, nil]
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'i18n'
5
+
6
+ module Avm
7
+ module Sources
8
+ class Base
9
+ module Locale
10
+ LOCALE_KEY = 'locale'
11
+
12
+ def locale
13
+ configured_locale || default_locale
14
+ end
15
+
16
+ def configured_locale
17
+ configuration.entry(LOCALE_KEY).value
18
+ end
19
+
20
+ def default_locale
21
+ ::I18n.default_locale
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/base/subs_paths'
4
+ require 'eac_cli/runner_with/subcommands'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Sources
9
+ class Base
10
+ module Runners
11
+ # @return [Hash<String, EacCli::Runner>]
12
+ def extra_available_subcommands
13
+ extra_available_subcommands_from_runners_module
14
+ end
15
+
16
+ # @return [Hash<String, EacCli::Runner>]
17
+ def extra_available_subcommands_from_runners_module
18
+ self.class.ancestors.reverse.inject({}) do |a, e|
19
+ a.merge(RunnersFromModule.new(e).result)
20
+ end
21
+ end
22
+
23
+ class RunnersFromModule
24
+ enable_simple_cache
25
+ common_constructor :the_module
26
+
27
+ # @return [Hash<String, EacCli::Runner>]
28
+ def result
29
+ return {} if runners_module.blank?
30
+
31
+ ::EacCli::RunnerWith::Subcommands.subcommands_from_module(runners_module)
32
+ end
33
+
34
+ def runners_module_uncached
35
+ return nil if the_module.module_parent.blank?
36
+
37
+ begin
38
+ the_module.module_parent.const_get('Runners')
39
+ rescue ::NameError
40
+ nil
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -6,6 +6,12 @@ module Avm
6
6
  module Sources
7
7
  class Base
8
8
  module Testing
9
+ TEST_COMMAND_KEY = 'test.command'
10
+
11
+ def configured_test_command
12
+ read_configuration_as_env_command(TEST_COMMAND_KEY)
13
+ end
14
+
9
15
  # @return [Avm::Sources::Tester]
10
16
  def tester
11
17
  tester_class.new(self)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/registry'
4
+ require 'avm/scms/null'
4
5
  require 'eac_git'
5
6
  require 'eac_ruby_utils/core_ext'
6
7
 
@@ -20,7 +21,10 @@ module Avm
20
21
 
21
22
  abstract_methods :update, :valid?
22
23
 
23
- delegate :locale, to: :old_configuration
24
+ # @return [EacRubyUtils::Envs::LocalEnv]
25
+ def env
26
+ ::EacRubyUtils::Envs::LocalEnv.new
27
+ end
24
28
 
25
29
  # @return [Pathname]
26
30
  def relative_path
@@ -37,7 +41,7 @@ module Avm
37
41
 
38
42
  # @return [Avm::Scms::Base]
39
43
  def scm_uncached
40
- ::Avm::Registry.scms.detect(path)
44
+ ::Avm::Registry.scms.detect_optional(path) || ::Avm::Scms::Null.new(path)
41
45
  end
42
46
  end
43
47
  end
data/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.20.0'
4
+ VERSION = '0.23.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-25 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.23'
19
+ version: '0.27'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.23.1
22
+ version: 0.27.6
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '0.23'
29
+ version: '0.27'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.23.1
32
+ version: 0.27.6
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: eac_docker
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +226,7 @@ files:
226
226
  - lib/avm/path_string.rb
227
227
  - lib/avm/registry.rb
228
228
  - lib/avm/registry/base.rb
229
+ - lib/avm/registry/with_path.rb
229
230
  - lib/avm/result.rb
230
231
  - lib/avm/rspec.rb
231
232
  - lib/avm/rspec/setup.rb
@@ -235,6 +236,7 @@ files:
235
236
  - lib/avm/scms/base.rb
236
237
  - lib/avm/scms/commit.rb
237
238
  - lib/avm/scms/inflector.rb
239
+ - lib/avm/scms/null.rb
238
240
  - lib/avm/self/docker_image.rb
239
241
  - lib/avm/self/instance.rb
240
242
  - lib/avm/self/instance/entry_keys.rb
@@ -242,14 +244,14 @@ files:
242
244
  - lib/avm/sources/base.rb
243
245
  - lib/avm/sources/base/configuration.rb
244
246
  - lib/avm/sources/base/instance.rb
247
+ - lib/avm/sources/base/locale.rb
245
248
  - lib/avm/sources/base/parent.rb
249
+ - lib/avm/sources/base/runners.rb
246
250
  - lib/avm/sources/base/subs.rb
247
251
  - lib/avm/sources/base/subs_paths.rb
248
252
  - lib/avm/sources/base/testing.rb
249
253
  - lib/avm/sources/configuration.rb
250
- - lib/avm/sources/configuration/locale.rb
251
254
  - lib/avm/sources/configuration/rubocop.rb
252
- - lib/avm/sources/configuration/tests.rb
253
255
  - lib/avm/sources/tester.rb
254
256
  - lib/avm/sources/tests.rb
255
257
  - lib/avm/sources/tests/builder.rb
@@ -1,18 +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 Sources
8
- class Configuration < ::EacConfig::OldConfigs
9
- module Locale
10
- LOCALE_KEY = :locale
11
-
12
- def locale
13
- read_entry(LOCALE_KEY) || ::I18n.default_locale
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/patches/eac_ruby_gems_utils/gem'
4
-
5
- module Avm
6
- module Sources
7
- class Configuration < ::EacConfig::OldConfigs
8
- module Tests
9
- BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
10
- TEST_COMMAND_KEY = 'test.command'
11
-
12
- def any_test_command
13
- bundle_test_command || test_command
14
- end
15
-
16
- def test_command
17
- read_command(TEST_COMMAND_KEY)
18
- end
19
-
20
- def bundle_test_command
21
- read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v|
22
- args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
23
- ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end