avm 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3439e5be72641bfbb2057567b3066ee5a9fa0bb230ac4b755e541a501b2f51af
4
- data.tar.gz: 47d2db526602f0054663417bf5e3d519408df59ba1e03c0fb16c9dc5ef23871e
3
+ metadata.gz: '0165809370dba684b9d456d8d28447e0d8cf625b9abe8f15a6b2d47aae905518'
4
+ data.tar.gz: f8f75c35fd20364008a777023f542cb505c4ee0774c093c1069d452a2656becf
5
5
  SHA512:
6
- metadata.gz: f50e41ecf763e2901de01276d03dffb24c4b1322ab28cca1c7d19a0860bddeef3433b42667209b480481c24e074bcbe05fb1148f13f6206427db1be33c160ca7
7
- data.tar.gz: 6d93ed47691853ae5a56c0577de8606ab72126fe4a83eefbf9d68ca6a88f1c6960369e8a183671fefdeb235b3a23550bbe5271d2d03382c7030de549948b0619
6
+ metadata.gz: ba30dc2ecb69636de16b65c6b2dc2b51e2e7014dec33f7958d9b8451cf515435868176d40570693e7f61b7e56a9896e0c40da3e98ce9e2c770acb2d06c339661
7
+ data.tar.gz: d54c9c0ba6c1fcbcd2f2dba2eff4fc360a300c0eccf6d801989a1f11eb44dd32ae740a6dc122768292dbc1a59e0c51773d2bf78770503d7ce51ccfa7bf91fe91
@@ -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
@@ -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,8 +21,6 @@ module Avm
20
21
 
21
22
  abstract_methods :update, :valid?
22
23
 
23
- delegate :locale, to: :old_configuration
24
-
25
24
  # @return [EacRubyUtils::Envs::LocalEnv]
26
25
  def env
27
26
  ::EacRubyUtils::Envs::LocalEnv.new
@@ -47,7 +46,7 @@ module Avm
47
46
 
48
47
  # @return [Avm::Scms::Base]
49
48
  def scm_uncached
50
- ::Avm::Registry.scms.detect(path)
49
+ ::Avm::Registry.scms.detect_optional(path) || ::Avm::Scms::Null.new(path)
51
50
  end
52
51
  end
53
52
  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.21.0'
4
+ VERSION = '0.22.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.21.0
4
+ version: 0.22.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-29 00:00:00.000000000 Z
11
+ date: 2022-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -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,13 @@ 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
246
249
  - lib/avm/sources/base/subs.rb
247
250
  - lib/avm/sources/base/subs_paths.rb
248
251
  - lib/avm/sources/base/testing.rb
249
252
  - lib/avm/sources/configuration.rb
250
- - lib/avm/sources/configuration/locale.rb
251
253
  - lib/avm/sources/configuration/rubocop.rb
252
- - lib/avm/sources/configuration/tests.rb
253
254
  - lib/avm/sources/tester.rb
254
255
  - lib/avm/sources/tests.rb
255
256
  - 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