avm 0.18.0 → 0.20.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: 678a691cf2ccbd86589577affeb607bb74543347909778401e317b5ada020dd9
4
- data.tar.gz: b0dd033965eab254607c952def3dd5a57fc737d00dcd621df72d8e13fd76a212
3
+ metadata.gz: 4da4c32db86b5e0217282e7954683ff84d63ddc8b34a7413bc8b255090a5d15c
4
+ data.tar.gz: b9c369085dcd50e3787c110c828b702eb44b5a1c28a3c036217e6dae19301da8
5
5
  SHA512:
6
- metadata.gz: 36a26e3f0f9068ebac2edad0883af7a336887fffb79fff26db99653a7a250a1ce7f7f317d5bb9223464f5a061448a33aaaae016c1ff21d0d1423e52768c2a22f
7
- data.tar.gz: c627d6f37382c3c5ebfe9200288c6ef8bafa95999b39d08647b1071b08c54f8d13e6fa7abef151818c4d8e3bd52e9cc9e012f3c51dc2d0eae7bb61687f7ea4ad
6
+ metadata.gz: 419e7911860b01a11ab6cc5fa901abc5585adbb28d4e2c6cfcf27cb189b4f63abc631e961835ad150b86dada322cc30764996387a92aede230922b6b449e2d5e
7
+ data.tar.gz: 2ee319d2462b5c8611d719b64d8e4c75376fd4c3d6e1752f8a88fcbe858a87cd058a28f7017cda47089c70436a86d2b4374e89a724c2d73201287d8f8405927b
@@ -9,8 +9,8 @@ module Avm
9
9
  module AutoValues
10
10
  module Mailer
11
11
  ::Avm::Instances::EntryKeys.all.select { |c| c.to_s.start_with?('mailer.') }
12
- .reject { |c| c == ::Avm::Instances::EntryKeys::MAILER_ID }
13
- .each do |mailer_key|
12
+ .reject { |c| c == ::Avm::Instances::EntryKeys::MAILER_ID }
13
+ .each do |mailer_key|
14
14
  define_method ::Avm::Instances::Entry.auto_value_method_name(mailer_key) do
15
15
  mailer_auto_common(mailer_key)
16
16
  end
@@ -17,7 +17,7 @@ module Avm
17
17
 
18
18
  def detect_optional(*registered_initialize_args)
19
19
  registered_modules.reverse.lazy.map { |klass| klass.new(*registered_initialize_args) }
20
- .find(&:valid?)
20
+ .find(&:valid?)
21
21
  end
22
22
 
23
23
  def provider_module_suffix
@@ -40,7 +40,7 @@ module Avm
40
40
 
41
41
  def registered_modules_uncached
42
42
  registered_gems.flat_map { |registry| modules_from_registry(registry) }
43
- .select { |v| valid_registered_module?(v) }.uniq
43
+ .select { |v| valid_registered_module?(v) }.uniq
44
44
  end
45
45
 
46
46
  def modules_from_registry(registry)
@@ -4,7 +4,7 @@ require 'avm/registry'
4
4
 
5
5
  ::RSpec.shared_examples 'not_in_avm_registry' do |registry_method = nil|
6
6
  registry_method.if_present(::Avm::Registry.registries) { |v| [::Avm::Registry.send(v)] }
7
- .each do |registry|
7
+ .each do |registry|
8
8
  context "when registry is #{registry}" do
9
9
  it 'is not in the avm registry' do
10
10
  expect(registry.registered_modules).not_to include(described_class)
data/lib/avm/scms/base.rb CHANGED
@@ -6,6 +6,7 @@ module Avm
6
6
  module Scms
7
7
  class Base
8
8
  enable_abstract_methods
9
+ enable_simple_cache
9
10
  abstract_methods :update, :valid?
10
11
  common_constructor :path do
11
12
  self.path = path.to_pathname
@@ -28,6 +29,18 @@ module Avm
28
29
  def to_s
29
30
  name
30
31
  end
32
+
33
+ private
34
+
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
43
+ end
31
44
  end
32
45
  end
33
46
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_config/yaml_file_node'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'eac_ruby_utils/yaml'
5
6
  require 'shellwords'
@@ -10,26 +11,33 @@ module Avm
10
11
  module Configuration
11
12
  # @return [Array<String>, nil]
12
13
  def read_configuration_as_shell_words(key)
13
- configuration[key].if_present do |v|
14
+ configuration.entry(key).value.if_present do |v|
14
15
  v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v.to_s)
15
16
  end
16
17
  end
17
18
 
18
19
  private
19
20
 
20
- # @return [Hash]
21
+ # @return [EacConfig::YamlFileNode]
21
22
  def configuration_uncached
22
23
  ::Avm::Sources::Configuration::FILENAMES.each do |filename|
23
- file_path = path.join(filename)
24
- return ::EacRubyUtils::Yaml.load_file(file_path).with_indifferent_access if
25
- file_path.exist?
24
+ configuration_with_filename(filename, true)
26
25
  end
27
- {}
26
+ configuration_with_filename(::Avm::Sources::Configuration::FILENAMES.first, false)
27
+ end
28
+
29
+ # @return [EacConfig::YamlFileNode, nil]
30
+ def configuration_with_filename(filename, needs_exist)
31
+ file_path = path.join(filename)
32
+ return ::EacConfig::YamlFileNode.new(file_path) if !needs_exist || file_path.exist?
33
+
34
+ nil
28
35
  end
29
36
 
30
37
  # @return [Avm::Sources::Configuration]
31
38
  def old_configuration_uncached
32
- ::Avm::Sources::Configuration.find_in_path(path)
39
+ ::Avm::Sources::Configuration.find_in_path(path) ||
40
+ ::Avm::Sources::Configuration.temp_instance
33
41
  end
34
42
  end
35
43
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ module Parent
9
+ # @return [Avm::Sources::Base]
10
+ def parent
11
+ parent_by_option || parent_by_search
12
+ end
13
+
14
+ # @return [Avm::Sources::Base]
15
+ def parent_by_option
16
+ options[OPTION_PARENT]
17
+ end
18
+
19
+ # @return [Avm::Sources::Base]
20
+ def parent_by_search
21
+ parent_path = path.parent
22
+ until parent_path.root?
23
+ ::Avm::Registry.sources.detect_optional(parent_path).if_present { |v| return v }
24
+ parent_path = parent_path.parent
25
+ end
26
+ nil
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/base/subs_paths'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Sources
8
+ class Base
9
+ module Subs
10
+ CONFIGURATION_SUBS_EXCLUDE_PATHS_KEY = 'subs.exclude_path'
11
+ CONFIGURATION_SUBS_INCLUDE_PATHS_KEY = 'subs.include_path'
12
+ SUBS_EXCLUDE_PATHS_DEFAULT = [].freeze
13
+ SUBS_INCLUDE_PATHS_DEFAULT = ['sub/*'].freeze
14
+
15
+ # @return [Enumerable<Avm::Sources::Base>]
16
+ def subs
17
+ subs_paths_to_search
18
+ .map { |sub_path| ::Avm::Registry.sources.detect_optional(sub_path, parent: self) }
19
+ .reject(&:blank?)
20
+ .sort_by { |sub| [sub.path] }
21
+ end
22
+
23
+ def subs_paths_to_search
24
+ subs_include_paths.flat_map do |subs_include_path|
25
+ ::Pathname.glob(path.join(subs_include_path)).reject do |sub_path|
26
+ subs_exclude_paths.any? do |subs_exclude_path|
27
+ sub_path.fnmatch?(path.join(subs_exclude_path).to_path)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ %i[include exclude].each do |type|
34
+ %i[path paths configured_paths default_paths].each do |method_suffix|
35
+ obj_method_name = "subs_#{type}_path_obj"
36
+
37
+ define_method "subs_#{type}_#{method_suffix}" do
38
+ send(obj_method_name).send(method_suffix)
39
+ end
40
+
41
+ define_method "#{obj_method_name}_uncached" do
42
+ ::Avm::Sources::Base::SubsPaths.new(
43
+ self,
44
+ self.class.const_get("CONFIGURATION_SUBS_#{type}_PATHS_KEY".upcase),
45
+ self.class.const_get("SUBS_#{type}_PATHS_DEFAULT".upcase)
46
+ )
47
+ end
48
+
49
+ private "#{obj_method_name}_uncached" # rubocop:disable Style/AccessModifierDeclarations
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ class SubsPaths
9
+ SUBS_PATH_SEPARATOR = ':'
10
+
11
+ common_constructor :source, :configuration_key, :default_paths
12
+
13
+ # @return [String]
14
+ def path
15
+ paths.join(SUBS_PATH_SEPARATOR)
16
+ end
17
+
18
+ # @return [Array<String>]
19
+ def paths
20
+ configured_paths || default_paths
21
+ end
22
+
23
+ # @return [Array<String>]
24
+ def configured_paths
25
+ source.configuration.entry(configuration_key).value.if_present do |v|
26
+ v.split(SUBS_PATH_SEPARATOR)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -21,12 +21,6 @@ module Avm
21
21
  abstract_methods :update, :valid?
22
22
 
23
23
  delegate :locale, to: :old_configuration
24
- delegate :to_s, to: :path
25
-
26
- # @return [Avm::Sources::Base]
27
- def parent
28
- options[OPTION_PARENT]
29
- end
30
24
 
31
25
  # @return [Pathname]
32
26
  def relative_path
@@ -35,9 +29,8 @@ module Avm
35
29
  path.relative_path_from(parent.path)
36
30
  end
37
31
 
38
- # @return [Enumerable<Avm::Sources::Base>]
39
- def subs
40
- scm.subs.map { |subrepo| ::Avm::Registry.sources.detect(subrepo.path, parent: self) }
32
+ def to_s
33
+ "#{self.class}[#{path}]"
41
34
  end
42
35
 
43
36
  private
@@ -6,10 +6,12 @@ require 'i18n'
6
6
  module Avm
7
7
  module Sources
8
8
  class Configuration < ::EacConfig::OldConfigs
9
- LOCALE_KEY = :locale
9
+ module Locale
10
+ LOCALE_KEY = :locale
10
11
 
11
- def locale
12
- read_entry(LOCALE_KEY) || ::I18n.default_locale
12
+ def locale
13
+ read_entry(LOCALE_KEY) || ::I18n.default_locale
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Sources
5
+ class Configuration < ::EacConfig::OldConfigs
6
+ module Rubocop
7
+ RUBOCOP_COMMAND_KEY = 'ruby.rubocop.command'
8
+ RUBOCOP_GEMFILE_KEY = 'ruby.rubocop.gemfile'
9
+
10
+ def rubocop_command
11
+ read_command(RUBOCOP_COMMAND_KEY)
12
+ end
13
+
14
+ def rubocop_gemfile
15
+ gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY)
16
+ return nil if gemfile_path.blank?
17
+
18
+ gemfile_path = gemfile_path.to_pathname.expand_path(storage_path.parent)
19
+ return gemfile_path if gemfile_path.file?
20
+
21
+ raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
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
@@ -7,7 +7,7 @@ require 'yaml'
7
7
  module Avm
8
8
  module Sources
9
9
  class Configuration < ::EacConfig::OldConfigs
10
- require_sub __FILE__
10
+ require_sub __FILE__, include_modules: true
11
11
 
12
12
  FILENAMES = %w[.avm.yml .avm.yaml].freeze
13
13
 
@@ -28,6 +28,10 @@ module Avm
28
28
  nil
29
29
  end
30
30
 
31
+ def temp_instance
32
+ new(::Tempfile.new(['.avm', '.yaml']))
33
+ end
34
+
31
35
  private
32
36
 
33
37
  def internal_find_path(absolute_pathname)
@@ -33,7 +33,7 @@ module Avm
33
33
  # @return [Array<Avm::Sources::Tests::Single>]
34
34
  def available_units
35
35
  @available_units ||= ([main_source] + main_source.subs)
36
- .map { |a_source| create_unit(a_source) }
36
+ .map { |a_source| create_unit(a_source) }
37
37
  end
38
38
 
39
39
  def available_units_from_main
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.18.0'
4
+ VERSION = '0.20.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.18.0
4
+ version: 0.20.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-05-07 00:00:00.000000000 Z
11
+ date: 2022-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.80'
67
+ version: '0.95'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.80'
74
+ version: '0.95'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: eac_templates
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -146,34 +146,34 @@ dependencies:
146
146
  requirements:
147
147
  - - "~>"
148
148
  - !ruby/object:Gem::Version
149
- version: '0.7'
150
- - - ">="
149
+ version: '0.14'
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.7.2
152
+ version: 0.14.1
153
153
  type: :development
154
154
  prerelease: false
155
155
  version_requirements: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0.7'
160
- - - ">="
159
+ version: '0.14'
160
+ - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: 0.7.2
162
+ version: 0.14.1
163
163
  - !ruby/object:Gem::Dependency
164
164
  name: eac_ruby_gem_support
165
165
  requirement: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: '0.2'
169
+ version: 0.5.1
170
170
  type: :development
171
171
  prerelease: false
172
172
  version_requirements: !ruby/object:Gem::Requirement
173
173
  requirements:
174
174
  - - "~>"
175
175
  - !ruby/object:Gem::Version
176
- version: '0.2'
176
+ version: 0.5.1
177
177
  description:
178
178
  email:
179
179
  executables: []
@@ -242,11 +242,14 @@ files:
242
242
  - lib/avm/sources/base.rb
243
243
  - lib/avm/sources/base/configuration.rb
244
244
  - lib/avm/sources/base/instance.rb
245
+ - lib/avm/sources/base/parent.rb
246
+ - lib/avm/sources/base/subs.rb
247
+ - lib/avm/sources/base/subs_paths.rb
245
248
  - lib/avm/sources/base/testing.rb
246
249
  - lib/avm/sources/configuration.rb
247
- - lib/avm/sources/configuration/_locale.rb
248
- - lib/avm/sources/configuration/_rubocop.rb
249
- - lib/avm/sources/configuration/_tests.rb
250
+ - lib/avm/sources/configuration/locale.rb
251
+ - lib/avm/sources/configuration/rubocop.rb
252
+ - lib/avm/sources/configuration/tests.rb
250
253
  - lib/avm/sources/tester.rb
251
254
  - lib/avm/sources/tests.rb
252
255
  - lib/avm/sources/tests/builder.rb
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Sources
5
- class Configuration < ::EacConfig::OldConfigs
6
- RUBOCOP_COMMAND_KEY = 'ruby.rubocop.command'
7
- RUBOCOP_GEMFILE_KEY = 'ruby.rubocop.gemfile'
8
-
9
- def rubocop_command
10
- read_command(RUBOCOP_COMMAND_KEY)
11
- end
12
-
13
- def rubocop_gemfile
14
- gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY)
15
- return nil if gemfile_path.blank?
16
-
17
- gemfile_path = gemfile_path.to_pathname.expand_path(storage_path.parent)
18
- return gemfile_path if gemfile_path.file?
19
-
20
- raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file"
21
- end
22
- end
23
- end
24
- end
@@ -1,27 +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
- BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
9
- TEST_COMMAND_KEY = 'test.command'
10
-
11
- def any_test_command
12
- bundle_test_command || test_command
13
- end
14
-
15
- def test_command
16
- read_command(TEST_COMMAND_KEY)
17
- end
18
-
19
- def bundle_test_command
20
- read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v|
21
- args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
22
- ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root
23
- end
24
- end
25
- end
26
- end
27
- end