avm 0.9.0 → 0.10.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: d91283f650ac7149bffe3855f56221278b7b0f9f746f21664dfae12bd1c12676
4
- data.tar.gz: edbdead4c7ea2190f3e3fa4f28f02d778c48e6e42356f79b1b489692c8cae03e
3
+ metadata.gz: 38b3cb78a40be49432757cf6da098d59bf73ff4873b19c6797fdba2d7e4d287f
4
+ data.tar.gz: 5fe80c98b3c824af779750f5c1068c963c2ffbe178162dfc13b48d601c6fc966
5
5
  SHA512:
6
- metadata.gz: 6d6dabb1ba231db6ee5d6acab7f1a3ff2a1dcf0d0682628e640d3937b8340d596cda65d0bb2da782bcc2c722608d57f25565e6157a529bf5a213525e8ed571c5
7
- data.tar.gz: 16c6d0697d89b1e6b08eab24ceafd842827d57a30106de1235e375c3d204408162da4d8b27c4feec3b16b4839e304720f2907f473cca7a9c5128463512092ab8
6
+ metadata.gz: ce0716e32d4450fddd8707145357b4d36aae42a173e0d91e7adbab4087ad833d57917376a3d43cc2bf65fc4bc3a401fc6db8d537e1e9a1a8d158c0702fca3093
7
+ data.tar.gz: e71070a17e331c95aa719131f0e3ffe9af461150cc3ae8b0df05a0e192ecc58fb02f7dee38e8394fafce5ee890b4528c34661a58b44ff4b73cac6c84c7c471a0
@@ -16,7 +16,7 @@ module Avm
16
16
  end
17
17
 
18
18
  def detect_optional(*registered_initialize_args)
19
- registered_modules.lazy.map { |klass| klass.new(*registered_initialize_args) }
19
+ registered_modules.reverse.lazy.map { |klass| klass.new(*registered_initialize_args) }
20
20
  .find(&:valid?)
21
21
  end
22
22
 
@@ -39,18 +39,20 @@ module Avm
39
39
  private
40
40
 
41
41
  def registered_modules_uncached
42
- (single_registered_modules + provider_registered_modules)
43
- .select { |v| valid_registered_module?(v) }.uniq.sort_by { |s| [s.name] }
42
+ registered_gems.flat_map { |registry| modules_from_registry(registry) }
43
+ .select { |v| valid_registered_module?(v) }.uniq
44
44
  end
45
45
 
46
- def single_registered_modules
47
- single_instance_registry.registered.map(&:registered_module)
46
+ def modules_from_registry(registry)
47
+ if registry.registry.module_suffix == provider_module_suffix
48
+ registry.registered_module.new.all
49
+ else
50
+ [registry.registered_module]
51
+ end
48
52
  end
49
53
 
50
- def provider_registered_modules
51
- provider_registry.registered.map(&:registered_module).flat_map do |provider_class|
52
- provider_class.new.all
53
- end
54
+ def registered_gems
55
+ (single_instance_registry.registered + provider_registry.registered).sort
54
56
  end
55
57
 
56
58
  def single_instance_registry_uncached
data/lib/avm/registry.rb CHANGED
@@ -7,7 +7,7 @@ module Avm
7
7
  module Registry
8
8
  require_sub __FILE__
9
9
  enable_listable
10
- lists.add_symbol :category, :instance_stereotypes, :runners, :scms, :source_stereotypes
10
+ lists.add_symbol :category, :instance_stereotypes, :runners, :scms, :sources
11
11
 
12
12
  class << self
13
13
  enable_simple_cache
data/lib/avm/scms/base.rb CHANGED
@@ -20,6 +20,11 @@ module Avm
20
20
  self.class.name.demodulize
21
21
  end
22
22
 
23
+ # @return [Enumerable<Avm::Scms::Base>]
24
+ def subs
25
+ raise_abstract_method __method__
26
+ end
27
+
23
28
  def to_s
24
29
  name
25
30
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Scms
5
+ class Inflector
6
+ class << self
7
+ def default_instance
8
+ @default_instance ||= new
9
+ end
10
+ end
11
+
12
+ ISSUE_POINTER_NAME_PREFIX = 'issue_'
13
+ POINTER_NAME_TO_ISSUE_PATTERN = /\A#{Regexp.quote(ISSUE_POINTER_NAME_PREFIX)}(\d+)\z/.freeze
14
+ POINTER_NAME_TO_ISSUE_PARSER = POINTER_NAME_TO_ISSUE_PATTERN.to_parser { |m| m[1] }
15
+
16
+ # @return [String, nil]
17
+ def pointer_name_to_issue_id(pointer_name)
18
+ POINTER_NAME_TO_ISSUE_PARSER.parse(pointer_name)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
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 Testing
9
+ # @return [Avm::Sources::Tester]
10
+ def tester
11
+ tester_class.new(self)
12
+ end
13
+
14
+ # @return [Class<Avm::Sources::Tester>
15
+ def tester_class
16
+ Avm::Sources::Tester
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -9,17 +9,19 @@ module Avm
9
9
  class Base
10
10
  require_sub __FILE__, include_modules: true
11
11
  compare_by :path
12
+ enable_abstract_methods
12
13
  enable_simple_cache
13
14
  enable_listable
14
15
  lists.add_symbol :option, :parent
15
16
  common_constructor :path, :options, default: [{}] do
16
17
  self.path = path.to_pathname.expand_path
17
- self.options = self.class.lists.option.hash_keys_validate!(options)
18
+ self.options = ::Avm::Sources::Base.lists.option.hash_keys_validate!(options)
18
19
  end
19
20
 
21
+ abstract_methods :update, :valid?
22
+
20
23
  delegate :locale, to: :old_configuration
21
24
  delegate :to_s, to: :path
22
- delegate :tester, to: :stereotype
23
25
 
24
26
  # @return [Avm::Sources::Base]
25
27
  def parent
@@ -35,30 +37,15 @@ module Avm
35
37
 
36
38
  # @return [Enumerable<Avm::Sources::Base>]
37
39
  def subs
38
- git_repo.subrepos
39
- .map { |subrepo| self.class.new(subrepo.subpath.expand_path(path), parent: self) }
40
- end
41
-
42
- def update
43
- stereotype.update_source(self)
40
+ scm.subs.map { |subrepo| self.class.new(subrepo.path, parent: self) }
44
41
  end
45
42
 
46
43
  private
47
44
 
48
- # @return [EacGit::Local]
49
- def git_repo_uncached
50
- ::EacGit::Local.new(path)
51
- end
52
-
53
45
  # @return [Avm::Scms::Base]
54
46
  def scm_uncached
55
47
  ::Avm::Registry.scms.detect(path)
56
48
  end
57
-
58
- # @return [Avm::SourceStereotypes::Base]
59
- def stereotype_uncached
60
- ::Avm::Registry.source_stereotypes.detect(self)
61
- end
62
49
  end
63
50
  end
64
51
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Tester
8
+ enable_abstract_methods
9
+ common_constructor :source
10
+
11
+ abstract_methods :result, :logs
12
+
13
+ # @return [EacRubyUtils::Fs::Logs]
14
+ def logs
15
+ raise_abstract_method __method__
16
+ end
17
+
18
+ # @return [Avm::Sources::Tests::Result]
19
+ def result
20
+ raise_abstract_method __method__
21
+ end
22
+ end
23
+ end
24
+ 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.9.0'
4
+ VERSION = '0.10.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.9.0
4
+ version: 0.10.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: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2021-11-26 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.77'
67
+ version: '0.80'
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.77'
74
+ version: '0.80'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: eac_templates
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -230,18 +230,19 @@ files:
230
230
  - lib/avm/runners/base.rb
231
231
  - lib/avm/scms/base.rb
232
232
  - lib/avm/scms/commit.rb
233
+ - lib/avm/scms/inflector.rb
233
234
  - lib/avm/self/docker_image.rb
234
235
  - lib/avm/self/instance.rb
235
236
  - lib/avm/self/instance/entry_keys.rb
236
- - lib/avm/source_stereotypes/base.rb
237
- - lib/avm/source_stereotypes/tester.rb
238
237
  - lib/avm/sources.rb
239
238
  - lib/avm/sources/base.rb
240
239
  - lib/avm/sources/base/configuration.rb
240
+ - lib/avm/sources/base/testing.rb
241
241
  - lib/avm/sources/configuration.rb
242
242
  - lib/avm/sources/configuration/_locale.rb
243
243
  - lib/avm/sources/configuration/_rubocop.rb
244
244
  - lib/avm/sources/configuration/_tests.rb
245
+ - lib/avm/sources/tester.rb
245
246
  - lib/avm/sources/tests.rb
246
247
  - lib/avm/sources/tests/builder.rb
247
248
  - lib/avm/sources/tests/performer.rb
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/source_stereotypes/tester'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/envs'
6
-
7
- module Avm
8
- module SourceStereotypes
9
- class Base
10
- common_constructor :source
11
-
12
- def name
13
- self.class.name
14
- end
15
-
16
- # @return [Avm::SourceStereotypes::Tester]
17
- def tester
18
- tester_class.new(self)
19
- end
20
-
21
- # @return [Class<Avm::SourceStereotypes::Tester>
22
- def tester_class
23
- Avm::SourceStereotypes::Tester
24
- end
25
-
26
- def to_s
27
- name
28
- end
29
-
30
- def valid?
31
- true
32
- end
33
- end
34
- end
35
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module SourceStereotypes
7
- class Tester
8
- TEST_COMMAND_CONFIGURATION_KEY = :test_command
9
-
10
- enable_simple_cache
11
- common_constructor :source_stereotype
12
- delegate :source, to: :source_stereotype
13
-
14
- # @return [EacRubyUtils::Envs::Command, nil]
15
- def test_command
16
- source.read_configuration_as_shell_words(TEST_COMMAND_CONFIGURATION_KEY)
17
- .if_present do |args|
18
- ::EacRubyUtils::Envs.local.command(args).chdir(source.path)
19
- end
20
- end
21
-
22
- private
23
-
24
- def logs_uncached
25
- ::EacRubyUtils::Fs::Logs.new.add(:stdout).add(:stderr)
26
- end
27
-
28
- # @return [Avm::Sources::Tests::Result]
29
- def result_uncached
30
- return ::Avm::Sources::Tests::Result::NONEXISTENT if test_command.blank?
31
-
32
- if execute_command_and_log(test_command)
33
- ::Avm::Sources::Tests::Result::SUCESSFUL
34
- else
35
- ::Avm::Sources::Tests::Result::FAILED
36
- end
37
- end
38
-
39
- def run_test_command
40
- execute_command_and_log(test_command)
41
- end
42
-
43
- # @return [true, false]
44
- def execute_command_and_log(command)
45
- r = command.execute
46
- logs[:stdout].write(r[:stdout])
47
- logs[:stderr].write(r[:stderr])
48
- r[:exit_code].zero?
49
- end
50
- end
51
- end
52
- end