avm 0.7.0 → 0.11.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: 3be29c02f4be9deec23c40452cf17ad0ce0478c6ae32508690d0a54bc9c4987a
4
- data.tar.gz: e63f5d086715190a1803f4289a48f9e25e56094d570d62f6ed5c22b0ceeb6084
3
+ metadata.gz: 4bc589fce7e7ecab9f13ac06d9f48990995ae1709ad593cb9a18053715f46508
4
+ data.tar.gz: a0e0fd0693719a46d2bd3d943b70cf13cef07ab89e96961a4f60f2fec343d3de
5
5
  SHA512:
6
- metadata.gz: 372b53edca7fe1187fa0faa39e145437779a3608b7ce7d248b2d5fe753520079c0542dda99a80b4936f09438f6bda1fceebdb78ce1b741e14854f10160468085
7
- data.tar.gz: 02bd6cdb0cdb4f02e7a202d69de40ca2c5f1c981af6198e8ce1e93b36380b0d39a436d36a358e58856675df9e040080ad6879367e013228cd6bfa3efb3e66735
6
+ metadata.gz: 767b4cb523ef822a6a58a799efb5f839cd22c5dd251abd7d25267c45cb7d8fdb52fddd177c02cd7bf2866f73c555a3ad840394611d5817cc5339ead385eab4c4
7
+ data.tar.gz: 450c6420ff3864834e4e1cc1191671d7f655c34be7deb60131fbf19651c9e07dff056d73646bd483f8cccec62bcbe1134771d3968030daae4a3d36ef110cf94e
@@ -7,6 +7,7 @@ module Avm
7
7
  class Base
8
8
  module AutoValues
9
9
  module Database
10
+ DEFAULT_EXTRA = ''
10
11
  DEFAULT_HOSTNAME = '127.0.0.1'
11
12
  DEFAULT_LIMIT = 5
12
13
  DEFAULT_PORTS = {
@@ -18,6 +19,10 @@ module Avm
18
19
  DEFAULT_SYSTEM = 'postgresql'
19
20
  DEFAULT_TIMEOUT = 5000
20
21
 
22
+ def auto_database_extra
23
+ database_auto_common('hostname') || DEFAULT_EXTRA
24
+ end
25
+
21
26
  def auto_database_name
22
27
  inherited_entry_value(::Avm::Instances::EntryKeys::DATABASE_ID,
23
28
  ::Avm::Instances::EntryKeys::DATABASE_NAME) || id
@@ -43,7 +43,7 @@ module Avm
43
43
 
44
44
  {
45
45
  '' => %w[fs_path host_id source_instance_id],
46
- database: %w[id hostname limit name password port system timeout username],
46
+ database: %w[id hostname limit name password port system timeout username extra],
47
47
  docker: %w[registry],
48
48
  mailer: {
49
49
  '' => %w[id from reply_to],
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/runners/base'
3
4
  require 'eac_cli/core_ext'
4
5
 
5
6
  module Avm
6
7
  module Instances
7
- class Runner
8
+ class Runner < ::Avm::Runners::Base
8
9
  class << self
9
10
  def instance_class
10
11
  ::Avm.const_get(stereotype_name).const_get('Instance')
@@ -12,11 +12,11 @@ module Avm
12
12
  def detect(*registered_initialize_args)
13
13
  detect_optional(*registered_initialize_args) ||
14
14
  raise("No registered module valid for #{registered_initialize_args}" \
15
- " (Module suffix: #{module_suffix})")
15
+ " (Module suffix: #{module_suffix}, Available: #{registered_modules.join(', ')})")
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
@@ -19,10 +19,6 @@ module Avm
19
19
 
20
20
  delegate :command_argument, :stereotype_name, to: :class
21
21
 
22
- runner_with :help, :subcommands do
23
- subcommands
24
- end
25
-
26
22
  def to_s
27
23
  stereotype_name
28
24
  end
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,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/yaml'
5
+ require 'shellwords'
6
+
7
+ module Avm
8
+ module Sources
9
+ class Base
10
+ module Configuration
11
+ # @return [Array<String>, nil]
12
+ def read_configuration_as_shell_words(key)
13
+ configuration[key].if_present do |v|
14
+ v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v.to_s)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ # @return [Hash]
21
+ def configuration_uncached
22
+ ::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?
26
+ end
27
+ {}
28
+ end
29
+
30
+ # @return [Avm::Sources::Configuration]
31
+ def old_configuration_uncached
32
+ ::Avm::Sources::Configuration.find_in_path(path)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ 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
@@ -7,16 +7,20 @@ require 'eac_ruby_utils/core_ext'
7
7
  module Avm
8
8
  module Sources
9
9
  class Base
10
- require_sub __FILE__
10
+ require_sub __FILE__, include_modules: true
11
+ compare_by :path
12
+ enable_abstract_methods
11
13
  enable_simple_cache
12
14
  enable_listable
13
15
  lists.add_symbol :option, :parent
14
16
  common_constructor :path, :options, default: [{}] do
15
- self.path = path.to_pathname
16
- self.options = self.class.lists.option.hash_keys_validate!(options)
17
+ self.path = path.to_pathname.expand_path
18
+ self.options = ::Avm::Sources::Base.lists.option.hash_keys_validate!(options)
17
19
  end
18
20
 
19
- delegate :locale, to: :configuration
21
+ abstract_methods :update, :valid?
22
+
23
+ delegate :locale, to: :old_configuration
20
24
  delegate :to_s, to: :path
21
25
 
22
26
  # @return [Avm::Sources::Base]
@@ -33,35 +37,15 @@ module Avm
33
37
 
34
38
  # @return [Enumerable<Avm::Sources::Base>]
35
39
  def subs
36
- git_repo.subrepos
37
- .map { |subrepo| self.class.new(subrepo.subpath.expand_path(path), parent: self) }
38
- end
39
-
40
- def update
41
- stereotype.update_source(self)
40
+ scm.subs.map { |subrepo| self.class.new(subrepo.path, parent: self) }
42
41
  end
43
42
 
44
43
  private
45
44
 
46
- # @return [Avm::Sources::Configuration]
47
- def configuration_uncached
48
- ::Avm::Sources::Configuration.find_in_path(path) || ::Avm::Sources::Configuration.new
49
- end
50
-
51
- # @return [EacGit::Local]
52
- def git_repo_uncached
53
- ::EacGit::Local.new(path)
54
- end
55
-
56
45
  # @return [Avm::Scms::Base]
57
46
  def scm_uncached
58
47
  ::Avm::Registry.scms.detect(path)
59
48
  end
60
-
61
- # @return [Avm::SourceStereotypes::Base]
62
- def stereotype_uncached
63
- ::Avm::Registry.source_stereotypes.detect(self)
64
- end
65
49
  end
66
50
  end
67
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 [EacFs::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
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/tests/performer'
4
+ require 'avm/sources/tests/single'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Sources
9
+ module Tests
10
+ class Builder
11
+ require_sub __FILE__
12
+ enable_immutable
13
+
14
+ immutable_accessor :include_main, :include_subs, type: :boolean
15
+ immutable_accessor :include_id, type: :array
16
+ common_constructor :main_source
17
+
18
+ def immutable_constructor_args
19
+ [main_source]
20
+ end
21
+
22
+ # @return [Avm::Sources::Tests::Performer]
23
+ def performer
24
+ ::Avm::Sources::Tests::Performer.new(self)
25
+ end
26
+
27
+ def selected_units
28
+ (select_units_from_subs + select_units_from_main + select_units_from_ids).sort.uniq
29
+ end
30
+
31
+ private
32
+
33
+ # @return [Array<Avm::Sources::Tests::Single>]
34
+ def available_units
35
+ @available_units ||= ([main_source] + main_source.subs)
36
+ .map { |a_source| create_unit(a_source) }
37
+ end
38
+
39
+ def available_units_from_main
40
+ create_units([main_source])
41
+ end
42
+
43
+ def available_units_from_subs
44
+ create_units(main_source.subs)
45
+ end
46
+
47
+ # @return [Avm::Sources::Tests::Single]
48
+ def create_unit(source)
49
+ ::Avm::Sources::Tests::Single.new(self, source)
50
+ end
51
+
52
+ # @return [Array<Avm::Sources::Tests::Single>]
53
+ def create_units(sources)
54
+ sources.map { |a_source| create_unit(a_source) }
55
+ end
56
+
57
+ # @return [Avm::Sources::Tests::Single]
58
+ def create_unit_by_id(source_id)
59
+ r = available_units.find { |unit| unit.id == source_id }
60
+ return r if r
61
+
62
+ raise ::ArgumentError, "Source not found with ID=#{source_id}" \
63
+ "(Available: #{available_units.map(&:id).join(', ')})"
64
+ end
65
+
66
+ # @return [Array<Avm::Sources::Tests::Single>]
67
+ def select_units_from_ids
68
+ include_ids.map { |source_id| create_unit_by_id(source_id) }
69
+ end
70
+
71
+ # @return [Array<Avm::Sources::Tests::Single>]
72
+ def select_units_from_main
73
+ include_main? ? available_units_from_main : []
74
+ end
75
+
76
+ # @return [Array<Avm::Sources::Tests::Single>]
77
+ def select_units_from_subs
78
+ include_subs? ? available_units_from_subs : []
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/tests/result'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Sources
8
+ module Tests
9
+ class Performer
10
+ enable_simple_cache
11
+
12
+ common_constructor(:owner)
13
+
14
+ def non_failed_units
15
+ units.reject(&:failed?)
16
+ end
17
+
18
+ def failed_units
19
+ units.select(&:failed?)
20
+ end
21
+
22
+ # @return [Boolean]
23
+ def successful?
24
+ failed_units.none?
25
+ end
26
+
27
+ protected
28
+
29
+ def units_uncached
30
+ owner.selected_units
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/enum'
4
+
5
+ module Avm
6
+ module Sources
7
+ module Tests
8
+ class Result < ::EacCli::Enum
9
+ enum :failed, :red
10
+ enum :nonexistent, :white
11
+ enum :sucessful, :green
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/tests/result'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_fs/logs'
6
+
7
+ module Avm
8
+ module Sources
9
+ module Tests
10
+ class Single
11
+ MAIN_SOURCE_ID = '#main'
12
+
13
+ compare_by :order_group, :id
14
+ enable_simple_cache
15
+ enable_speaker
16
+
17
+ common_constructor :builder, :source
18
+
19
+ delegate :logs, :result, to: :tester
20
+ delegate :to_s, to: :id
21
+
22
+ def failed?
23
+ result == ::Avm::Sources::Tests::Result::FAILED
24
+ end
25
+
26
+ # @return [String]
27
+ def id
28
+ if main?
29
+ MAIN_SOURCE_ID
30
+ else
31
+ relative_path_from_main_source.to_s
32
+ end
33
+ end
34
+
35
+ def main?
36
+ relative_path_from_main_source.to_s == '.'
37
+ end
38
+
39
+ def order_group
40
+ main? ? 1 : 0
41
+ end
42
+
43
+ # @return [Pathname]
44
+ def relative_path_from_main_source
45
+ source.path.relative_path_from(builder.main_source.path)
46
+ end
47
+
48
+ private
49
+
50
+ def tester_uncached
51
+ source.tester
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ module Tests
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ 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.7.0'
4
+ VERSION = '0.11.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.7.0
4
+ version: 0.11.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-04 00:00:00.000000000 Z
11
+ date: 2021-12-06 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,16 +230,24 @@ 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
237
  - lib/avm/sources.rb
238
238
  - lib/avm/sources/base.rb
239
+ - lib/avm/sources/base/configuration.rb
240
+ - lib/avm/sources/base/testing.rb
239
241
  - lib/avm/sources/configuration.rb
240
242
  - lib/avm/sources/configuration/_locale.rb
241
243
  - lib/avm/sources/configuration/_rubocop.rb
242
244
  - lib/avm/sources/configuration/_tests.rb
245
+ - lib/avm/sources/tester.rb
246
+ - lib/avm/sources/tests.rb
247
+ - lib/avm/sources/tests/builder.rb
248
+ - lib/avm/sources/tests/performer.rb
249
+ - lib/avm/sources/tests/result.rb
250
+ - lib/avm/sources/tests/single.rb
243
251
  - lib/avm/sync.rb
244
252
  - lib/avm/version.rb
245
253
  - lib/avm/version_number.rb
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module SourceStereotypes
7
- class Base
8
- enable_abstract_methods
9
- abstract_methods :valid?
10
- common_constructor :source
11
-
12
- def name
13
- self.class.name
14
- end
15
-
16
- def to_s
17
- name
18
- end
19
- end
20
- end
21
- end