avm 0.25.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/application_stereotypes/base/by_gem.rb +17 -0
- data/lib/avm/application_stereotypes/base/detection.rb +34 -0
- data/lib/avm/application_stereotypes/base.rb +21 -0
- data/lib/avm/application_stereotypes.rb +9 -0
- data/lib/avm/{instances/application.rb → applications/base.rb} +5 -6
- data/lib/avm/applications.rb +9 -0
- data/lib/avm/docker/image.rb +12 -2
- data/lib/avm/instances/base.rb +7 -2
- data/lib/avm/instances.rb +1 -1
- data/lib/avm/registry/application_stereotypes/build_available.rb +46 -0
- data/lib/avm/registry/application_stereotypes/stereotype_builder.rb +30 -0
- data/lib/avm/registry/application_stereotypes.rb +36 -0
- data/lib/avm/registry/{base.rb → from_gems.rb} +13 -4
- data/lib/avm/registry/instances.rb +16 -0
- data/lib/avm/registry/runners.rb +10 -0
- data/lib/avm/registry/scms.rb +10 -0
- data/lib/avm/registry/sources.rb +10 -0
- data/lib/avm/registry/with_path/cache.rb +31 -0
- data/lib/avm/registry/with_path.rb +33 -7
- data/lib/avm/registry.rb +3 -7
- data/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
- data/lib/avm/sources/base/configuration.rb +23 -2
- data/lib/avm/sources/base/instance.rb +2 -2
- data/lib/avm/sources/base/locale.rb +1 -1
- data/lib/avm/sources/base/parent.rb +8 -11
- data/lib/avm/sources/base/subs_paths.rb +1 -1
- data/lib/avm/sources/base/testing.rb +4 -4
- data/lib/avm/sources/base.rb +4 -0
- data/lib/avm/sources/tests/builder.rb +5 -10
- data/lib/avm/version.rb +1 -1
- data/lib/avm/with_application_stereotype.rb +23 -0
- data/lib/avm/with_dynamic_runners.rb +42 -0
- metadata +33 -5
- data/lib/avm/sources/base/runners.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d4a230abab5f14e443e55426f5deb3fa99d8570d57714c5128c50d3dff3340a
|
4
|
+
data.tar.gz: 71c879c6ee9fd1b3e3550142c9b78bfc101f8b863ac5ef812366cc3ff66e7c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cda7f5840e1d6ddf4c49732b9205b0c6ee9f31afa0d4ecfa41b343a96e9423704a76520544db021598567894b3a157ddbf034a892fc25be7792cd3bb47077666
|
7
|
+
data.tar.gz: 566e375d67d75cc9dfd8de54b1839e4e85308b37dd34e9a9b337114dca02d8808fbdef7d888cc9e348c65f7316bfdd542c540bf204c3f4316d11a2767bac5fef
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module ApplicationStereotypes
|
5
|
+
class Base
|
6
|
+
module ByGem
|
7
|
+
common_concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def by_gem(gem_name)
|
11
|
+
new(gem_name.gsub('-', '/').camelize)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module ApplicationStereotypes
|
5
|
+
class Base
|
6
|
+
module Detection
|
7
|
+
common_concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
# @return [Class<Avm::Sources::Base>, nil]
|
11
|
+
def detect(object)
|
12
|
+
return singleton_instance if
|
13
|
+
%w[name instance_class source_class].any? { |t| send("detect_by_#{t}?", object) }
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Boolean]
|
17
|
+
def detect_by_instance_class?(object)
|
18
|
+
object.is_a?(::Class) && singleton_instance.instance_class == object
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Boolean]
|
22
|
+
def detect_by_name?(object)
|
23
|
+
object.is_a?(::String) && singleton_instance.name == object
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean]
|
27
|
+
def detect_by_source_class?(object)
|
28
|
+
object.is_a?(::Class) && singleton_instance.source_class == object
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module ApplicationStereotypes
|
7
|
+
class Base
|
8
|
+
common_constructor :namespace_module, :instance_class, :source_class
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
def name
|
12
|
+
namespace_module.name.demodulize
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
def to_s
|
17
|
+
name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'avm/instances/entries'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module Avm
|
6
|
-
module
|
7
|
-
class
|
7
|
+
module Applications
|
8
|
+
class Base
|
8
9
|
include ::Avm::Instances::Entries
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(id)
|
13
|
-
@id = id.to_s
|
11
|
+
common_constructor :id do
|
12
|
+
self.id = id.to_s
|
14
13
|
end
|
15
14
|
|
16
15
|
def to_s
|
data/lib/avm/docker/image.rb
CHANGED
@@ -3,16 +3,26 @@
|
|
3
3
|
require 'avm/version'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
require 'eac_docker/images/templatized'
|
6
|
+
require 'eac_docker/registry'
|
6
7
|
|
7
8
|
module Avm
|
8
9
|
module Docker
|
9
10
|
class Image < ::EacDocker::Images::Templatized
|
11
|
+
DEFAULT_REGISTRY_NAME = 'local'
|
12
|
+
|
13
|
+
class << self
|
14
|
+
# @return [EacDocker::Registry]
|
15
|
+
def default_registry
|
16
|
+
::EacDocker::Registry.new(DEFAULT_REGISTRY_NAME)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
10
20
|
attr_reader :registry
|
11
21
|
attr_accessor :snapshot
|
12
22
|
attr_accessor :version
|
13
23
|
|
14
|
-
def initialize(registry)
|
15
|
-
@registry = registry
|
24
|
+
def initialize(registry = nil)
|
25
|
+
@registry = registry || self.class.default_registry
|
16
26
|
self.snapshot = true
|
17
27
|
self.version = true
|
18
28
|
end
|
data/lib/avm/instances/base.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/with_application_stereotype'
|
4
|
+
require 'avm/with_dynamic_runners'
|
3
5
|
require 'eac_ruby_utils/require_sub'
|
4
6
|
require 'eac_ruby_utils/simple_cache'
|
5
7
|
require 'avm/instances/entries'
|
@@ -7,10 +9,13 @@ require 'avm/instances/entries'
|
|
7
9
|
module Avm
|
8
10
|
module Instances
|
9
11
|
class Base
|
12
|
+
enable_abstract_methods
|
10
13
|
enable_listable
|
11
14
|
enable_simple_cache
|
12
15
|
require_sub __FILE__, include_modules: true
|
13
16
|
include ::Avm::Instances::Entries
|
17
|
+
include ::Avm::WithDynamicRunners
|
18
|
+
include ::Avm::WithApplicationStereotype
|
14
19
|
|
15
20
|
lists.add_string :access, :local, :ssh
|
16
21
|
|
@@ -19,8 +24,8 @@ module Avm
|
|
19
24
|
class << self
|
20
25
|
def by_id(id)
|
21
26
|
application_id, suffix = parse_id(id)
|
22
|
-
require 'avm/
|
23
|
-
new(::Avm::
|
27
|
+
require 'avm/applications/base'
|
28
|
+
new(::Avm::Applications::Base.new(application_id), suffix)
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
data/lib/avm/instances.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/registry/application_stereotypes/stereotype_builder'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
class ApplicationStereotypes
|
9
|
+
class BuildAvailable
|
10
|
+
enable_method_class
|
11
|
+
|
12
|
+
common_constructor :owner
|
13
|
+
|
14
|
+
def result
|
15
|
+
reset_buffer
|
16
|
+
read_instances_registry
|
17
|
+
read_sources_registry
|
18
|
+
buffer.values.map(&:build)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_accessor :buffer
|
24
|
+
|
25
|
+
def read_object(type, object)
|
26
|
+
buffer[object.stereotype_namespace_module] ||=
|
27
|
+
::Avm::Registry::ApplicationStereotypes::StereotypeBuilder
|
28
|
+
.new(object.stereotype_namespace_module)
|
29
|
+
buffer[object.stereotype_namespace_module].add_object(type, object)
|
30
|
+
end
|
31
|
+
|
32
|
+
def read_instances_registry
|
33
|
+
::Avm::Registry.instances.available.each { |instance| read_object(:instance, instance) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def read_sources_registry
|
37
|
+
::Avm::Registry.sources.available.each { |source| read_object(:source, source) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def reset_buffer
|
41
|
+
self.buffer = {}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/application_stereotypes/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
class ApplicationStereotypes
|
9
|
+
class StereotypeBuilder
|
10
|
+
common_constructor :namespace_module
|
11
|
+
|
12
|
+
def add_object(type, object)
|
13
|
+
attr_method = "#{type}_class"
|
14
|
+
raise "#{attr_method} is already present" if send(attr_method).present?
|
15
|
+
|
16
|
+
send("#{attr_method}=", object)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Avm::ApplicationStereotypes::Base]
|
20
|
+
def build
|
21
|
+
::Avm::ApplicationStereotypes::Base.new(namespace_module, instance_class, source_class)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_accessor :instance_class, :source_class
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Registry
|
7
|
+
class ApplicationStereotypes
|
8
|
+
require_sub __FILE__, require_dependency: true
|
9
|
+
enable_simple_cache
|
10
|
+
|
11
|
+
common_constructor :module_suffix
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def available_uncached
|
16
|
+
build_available
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Avm::Instances::Base, nil]
|
20
|
+
def class_detect(klass, detect_args)
|
21
|
+
r = ::Avm::Instances::Base.by_id(*detect_args)
|
22
|
+
r.application.stereotype.instance_class == klass ? r : nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def detect(*registered_initialize_args)
|
26
|
+
detect_optional(*registered_initialize_args) ||
|
27
|
+
raise_not_found(*registered_initialize_args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def detect_optional(*registered_initialize_args)
|
31
|
+
registered_modules.reverse.lazy
|
32
|
+
.map { |klass| class_detect(klass, registered_initialize_args) }.find(&:present?)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -5,18 +5,27 @@ require 'eac_ruby_utils/gems_registry'
|
|
5
5
|
|
6
6
|
module Avm
|
7
7
|
module Registry
|
8
|
-
class
|
8
|
+
class FromGems
|
9
|
+
enable_abstract_methods
|
9
10
|
enable_simple_cache
|
10
11
|
common_constructor :module_suffix
|
11
12
|
|
13
|
+
def available
|
14
|
+
registered_modules.reject(&:abstract?)
|
15
|
+
end
|
16
|
+
|
17
|
+
def class_detect(_klass, _detect_args)
|
18
|
+
raise_abstract_method __method__
|
19
|
+
end
|
20
|
+
|
12
21
|
def detect(*registered_initialize_args)
|
13
22
|
detect_optional(*registered_initialize_args) ||
|
14
23
|
raise_not_found(*registered_initialize_args)
|
15
24
|
end
|
16
25
|
|
17
26
|
def detect_optional(*registered_initialize_args)
|
18
|
-
|
19
|
-
.find(&:
|
27
|
+
available.reverse.lazy
|
28
|
+
.map { |klass| class_detect(klass, registered_initialize_args) }.find(&:present?)
|
20
29
|
end
|
21
30
|
|
22
31
|
def provider_module_suffix
|
@@ -39,7 +48,7 @@ module Avm
|
|
39
48
|
|
40
49
|
def raise_not_found(*args)
|
41
50
|
raise("No registered module valid for #{args}" \
|
42
|
-
" (Module suffix: #{module_suffix}, Available: #{
|
51
|
+
" (Module suffix: #{module_suffix}, Available: #{available.join(', ')})")
|
43
52
|
end
|
44
53
|
|
45
54
|
def registered_modules_uncached
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/base'
|
4
|
+
require 'avm/registry/from_gems'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
class Instances < ::Avm::Registry::FromGems
|
9
|
+
# @return [Avm::Instances::Base, nil]
|
10
|
+
def class_detect(klass, detect_args)
|
11
|
+
r = ::Avm::Instances::Base.by_id(*detect_args)
|
12
|
+
r.application.stereotype.instance_class == klass ? r : nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/registry/from_gems'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Registry
|
8
|
+
class WithPath < ::Avm::Registry::FromGems
|
9
|
+
class Cache
|
10
|
+
enable_simple_cache
|
11
|
+
common_constructor :owner
|
12
|
+
|
13
|
+
def detect_optional(path)
|
14
|
+
return nil if path.root?
|
15
|
+
return cached_paths.fetch(path) if cached_paths.key?(path)
|
16
|
+
|
17
|
+
detected = owner.detect_optional(path)
|
18
|
+
detected = detect_optional(path.parent) if detected.blank?
|
19
|
+
cached_paths[path] = detected
|
20
|
+
detected
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def cached_paths_uncached
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,22 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/registry/
|
3
|
+
require 'avm/registry/from_gems'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
|
6
6
|
module Avm
|
7
7
|
module Registry
|
8
|
-
class WithPath < ::Avm::Registry::
|
8
|
+
class WithPath < ::Avm::Registry::FromGems
|
9
|
+
require_sub __FILE__
|
10
|
+
|
11
|
+
# @return [Object, nil]
|
12
|
+
def class_detect(klass, detect_args)
|
13
|
+
r = klass.new(*detect_args)
|
14
|
+
r.valid? ? r : nil
|
15
|
+
end
|
16
|
+
|
9
17
|
def detect_by_path(path)
|
10
18
|
detect_by_path_optional(path) || raise_not_found(path)
|
11
19
|
end
|
12
20
|
|
13
21
|
def detect_by_path_optional(path)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
22
|
+
on_cache do
|
23
|
+
cache.detect_optional(path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_accessor :cache
|
30
|
+
|
31
|
+
def on_cache(&block)
|
32
|
+
cache.present? ? on_cache_with_cache(&block) : on_cache_with_no_cache(&block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_cache_with_cache(&block)
|
36
|
+
block.call
|
37
|
+
end
|
38
|
+
|
39
|
+
def on_cache_with_no_cache(&block)
|
40
|
+
self.cache = ::Avm::Registry::WithPath::Cache.new(self)
|
41
|
+
begin
|
42
|
+
block.call
|
43
|
+
ensure
|
44
|
+
self.cache = nil
|
18
45
|
end
|
19
|
-
nil
|
20
46
|
end
|
21
47
|
end
|
22
48
|
end
|
data/lib/avm/registry.rb
CHANGED
@@ -7,14 +7,14 @@ module Avm
|
|
7
7
|
module Registry
|
8
8
|
require_sub __FILE__
|
9
9
|
enable_listable
|
10
|
-
lists.add_symbol :category, :
|
10
|
+
lists.add_symbol :category, :application_stereotypes, :instances, :runners, :scms, :sources
|
11
11
|
|
12
12
|
WITH_PATH = [CATEGORY_SCMS, CATEGORY_SOURCES].freeze
|
13
13
|
|
14
14
|
class << self
|
15
15
|
enable_simple_cache
|
16
16
|
|
17
|
-
# @return [Array<Avm::Registry::
|
17
|
+
# @return [Array<Avm::Registry::FromGems>]
|
18
18
|
def registries
|
19
19
|
lists.category.values.map { |c| send(c) }
|
20
20
|
end
|
@@ -28,11 +28,7 @@ module Avm
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def registry_class(category)
|
31
|
-
|
32
|
-
::Avm::Registry::WithPath
|
33
|
-
else
|
34
|
-
::Avm::Registry::Base
|
35
|
-
end
|
31
|
+
::Avm::Registry.const_get(category.to_s.camelize)
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -7,7 +7,7 @@ require 'avm/registry'
|
|
7
7
|
.each do |registry|
|
8
8
|
context "when registry is #{registry}" do
|
9
9
|
it 'is not in the avm registry' do
|
10
|
-
expect(registry.
|
10
|
+
expect(registry.available).not_to include(described_class)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -9,8 +9,19 @@ module Avm
|
|
9
9
|
module Sources
|
10
10
|
class Base
|
11
11
|
module Configuration
|
12
|
+
PARENT_CONFIGURATION_SUFFIX = %w[subs at].freeze
|
12
13
|
CONFIGURATION_FILENAMES = %w[.avm.yml .avm.yaml].freeze
|
13
14
|
|
15
|
+
# @return [EacConfig::NodeEntry]
|
16
|
+
def configuration_entry(*entry_args)
|
17
|
+
parent_configuration.if_present do |v|
|
18
|
+
parent_entry = v.entry(*entry_args)
|
19
|
+
return parent_entry if parent_entry.found?
|
20
|
+
end
|
21
|
+
|
22
|
+
configuration.entry(*entry_args)
|
23
|
+
end
|
24
|
+
|
14
25
|
# @return [EacRubyUtils::Envs::Command, nil]
|
15
26
|
def configuration_value_to_env_command(value)
|
16
27
|
configuration_value_to_shell_words(value).if_present { |v| env.command(v).chdir(path) }
|
@@ -25,13 +36,13 @@ module Avm
|
|
25
36
|
|
26
37
|
# @return [Array<String>, nil]
|
27
38
|
def read_configuration_as_shell_words(key)
|
28
|
-
configuration_value_to_shell_words(
|
39
|
+
configuration_value_to_shell_words(configuration_entry(key).value)
|
29
40
|
end
|
30
41
|
|
31
42
|
# Utility to read a configuration as a [EacRubyUtils::Envs::Command].
|
32
43
|
# @return [EacRubyUtils::Envs::Command]
|
33
44
|
def read_configuration_as_env_command(key)
|
34
|
-
configuration_value_to_env_command(
|
45
|
+
configuration_value_to_env_command(configuration_entry(key).value)
|
35
46
|
end
|
36
47
|
|
37
48
|
private
|
@@ -44,6 +55,16 @@ module Avm
|
|
44
55
|
configuration_with_filename(CONFIGURATION_FILENAMES.first, false)
|
45
56
|
end
|
46
57
|
|
58
|
+
# @return [String]
|
59
|
+
def parent_configuration_prefix
|
60
|
+
PARENT_CONFIGURATION_SUFFIX + [relative_path]
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [EacConfig::PrefixedPathNode]
|
64
|
+
def parent_configuration_uncached
|
65
|
+
parent.if_present { |v| v.configuration.with_prefix(parent_configuration_prefix) }
|
66
|
+
end
|
67
|
+
|
47
68
|
# @return [EacConfig::YamlFileNode, nil]
|
48
69
|
def configuration_with_filename(filename, needs_exist)
|
49
70
|
file_path = path.join(filename)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/
|
3
|
+
require 'avm/applications/base'
|
4
4
|
require 'avm/instances/base'
|
5
5
|
|
6
6
|
module Avm
|
@@ -16,7 +16,7 @@ module Avm
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def application_uncached
|
19
|
-
::Avm::
|
19
|
+
::Avm::Applications::Base.new(path.basename)
|
20
20
|
end
|
21
21
|
|
22
22
|
def instance_uncached
|
@@ -6,11 +6,6 @@ module Avm
|
|
6
6
|
module Sources
|
7
7
|
class Base
|
8
8
|
module Parent
|
9
|
-
# @return [Avm::Sources::Base]
|
10
|
-
def parent
|
11
|
-
parent_by_option || parent_by_search
|
12
|
-
end
|
13
|
-
|
14
9
|
# @return [Avm::Sources::Base]
|
15
10
|
def parent_by_option
|
16
11
|
options[OPTION_PARENT]
|
@@ -18,12 +13,14 @@ module Avm
|
|
18
13
|
|
19
14
|
# @return [Avm::Sources::Base]
|
20
15
|
def parent_by_search
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
::Avm::Registry.sources.detect_by_path_optional(path.parent)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# @return [Avm::Sources::Base]
|
22
|
+
def parent_uncached
|
23
|
+
parent_by_option || parent_by_search
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
@@ -18,12 +18,12 @@ module Avm
|
|
18
18
|
|
19
19
|
# @return [Hash<String, EacRubyUtils::Envs::Command>, nil]
|
20
20
|
def configured_test_commands
|
21
|
-
configured_value_as_test_commands(
|
21
|
+
configured_value_as_test_commands(configuration_entry(TEST_COMMANDS_KEY).value)
|
22
22
|
end
|
23
23
|
|
24
24
|
# @return [Hash<String, EacRubyUtils::Envs::Command>, nil]
|
25
25
|
def configured_value_as_test_commands(value)
|
26
|
-
return nil if value.
|
26
|
+
return nil if value.nil?
|
27
27
|
|
28
28
|
[::EacRubyUtils::Envs::Command, ::Hash, ::Enumerable].each do |type|
|
29
29
|
next unless value.is_a?(type)
|
@@ -45,8 +45,8 @@ module Avm
|
|
45
45
|
# @return [Enumerable<EacRubyUtils::Envs::Command>]
|
46
46
|
def test_commands
|
47
47
|
configured_test_commands ||
|
48
|
-
configured_value_as_test_commands(configured_test_command)
|
49
|
-
|
48
|
+
configured_value_as_test_commands(configured_test_command) ||
|
49
|
+
default_test_commands
|
50
50
|
end
|
51
51
|
|
52
52
|
protected
|
data/lib/avm/sources/base.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'avm/registry'
|
4
4
|
require 'avm/scms/null'
|
5
|
+
require 'avm/with_application_stereotype'
|
6
|
+
require 'avm/with_dynamic_runners'
|
5
7
|
require 'eac_git'
|
6
8
|
require 'eac_ruby_utils/core_ext'
|
7
9
|
|
@@ -9,6 +11,8 @@ module Avm
|
|
9
11
|
module Sources
|
10
12
|
class Base
|
11
13
|
require_sub __FILE__, include_modules: true
|
14
|
+
include ::Avm::WithApplicationStereotype
|
15
|
+
include ::Avm::WithDynamicRunners
|
12
16
|
compare_by :path
|
13
17
|
enable_abstract_methods
|
14
18
|
enable_simple_cache
|
@@ -35,7 +35,7 @@ module Avm
|
|
35
35
|
# @return [Array<Avm::Sources::Tests::Single>]
|
36
36
|
def available_units
|
37
37
|
@available_units ||= ([main_source] + main_source.subs)
|
38
|
-
.
|
38
|
+
.flat_map { |a_source| create_source_units(a_source) }
|
39
39
|
end
|
40
40
|
|
41
41
|
def available_units_from_main
|
@@ -62,20 +62,15 @@ module Avm
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
# @return [Avm::Sources::Tests::Single]
|
66
|
-
def create_unit(source)
|
67
|
-
::Avm::Sources::Tests::Single.new(self, source)
|
68
|
-
end
|
69
|
-
|
70
65
|
# @return [Array<Avm::Sources::Tests::Single>]
|
71
66
|
def create_units(sources)
|
72
67
|
sources.flat_map { |a_source| create_source_units(a_source) }
|
73
68
|
end
|
74
69
|
|
75
70
|
# @return [Avm::Sources::Tests::Single]
|
76
|
-
def
|
77
|
-
r = available_units.
|
78
|
-
return r if r
|
71
|
+
def create_units_by_id(source_id)
|
72
|
+
r = available_units.select { |unit| unit.source.relative_path.to_path == source_id.to_s }
|
73
|
+
return r if r.any?
|
79
74
|
|
80
75
|
raise ::ArgumentError, "Source not found with ID=#{source_id}" \
|
81
76
|
"(Available: #{available_units.map(&:id).join(', ')})"
|
@@ -83,7 +78,7 @@ module Avm
|
|
83
78
|
|
84
79
|
# @return [Array<Avm::Sources::Tests::Single>]
|
85
80
|
def select_units_from_ids
|
86
|
-
include_ids.
|
81
|
+
include_ids.flat_map { |source_id| create_units_by_id(source_id) }
|
87
82
|
end
|
88
83
|
|
89
84
|
# @return [Array<Avm::Sources::Tests::Single>]
|
data/lib/avm/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner_with/subcommands'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module WithApplicationStereotype
|
8
|
+
common_concern do
|
9
|
+
include ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
# @return [Module]
|
14
|
+
def stereotype_namespace_module
|
15
|
+
module_parent.module_parent
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def stereotype_namespace_module
|
20
|
+
self.class.stereotype_namespace_module
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner_with/subcommands'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module WithDynamicRunners
|
8
|
+
# @return [Hash<String, EacCli::Runner>]
|
9
|
+
def extra_available_subcommands
|
10
|
+
extra_available_subcommands_from_runners_module
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Hash<String, EacCli::Runner>]
|
14
|
+
def extra_available_subcommands_from_runners_module
|
15
|
+
self.class.ancestors.reverse.inject({}) do |a, e|
|
16
|
+
a.merge(RunnersFromModule.new(e).result)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class RunnersFromModule
|
21
|
+
enable_simple_cache
|
22
|
+
common_constructor :the_module
|
23
|
+
|
24
|
+
# @return [Hash<String, EacCli::Runner>]
|
25
|
+
def result
|
26
|
+
return {} if runners_module.blank?
|
27
|
+
|
28
|
+
::EacCli::RunnerWith::Subcommands.subcommands_from_module(runners_module)
|
29
|
+
end
|
30
|
+
|
31
|
+
def runners_module_uncached
|
32
|
+
return nil if the_module.module_parent.blank?
|
33
|
+
|
34
|
+
begin
|
35
|
+
the_module.module_parent.const_get('Runners')
|
36
|
+
rescue ::NameError
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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.
|
4
|
+
version: 0.28.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-07-
|
11
|
+
date: 2022-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_cli
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.27.6
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: eac_config
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.9'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.9'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: eac_docker
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,6 +195,12 @@ extensions: []
|
|
181
195
|
extra_rdoc_files: []
|
182
196
|
files:
|
183
197
|
- lib/avm.rb
|
198
|
+
- lib/avm/application_stereotypes.rb
|
199
|
+
- lib/avm/application_stereotypes/base.rb
|
200
|
+
- lib/avm/application_stereotypes/base/by_gem.rb
|
201
|
+
- lib/avm/application_stereotypes/base/detection.rb
|
202
|
+
- lib/avm/applications.rb
|
203
|
+
- lib/avm/applications/base.rb
|
184
204
|
- lib/avm/data/instance.rb
|
185
205
|
- lib/avm/data/instance/files_unit.rb
|
186
206
|
- lib/avm/data/instance/package.rb
|
@@ -196,7 +216,6 @@ files:
|
|
196
216
|
- lib/avm/docker/runner.rb
|
197
217
|
- lib/avm/executables.rb
|
198
218
|
- lib/avm/instances.rb
|
199
|
-
- lib/avm/instances/application.rb
|
200
219
|
- lib/avm/instances/base.rb
|
201
220
|
- lib/avm/instances/base/auto_values.rb
|
202
221
|
- lib/avm/instances/base/auto_values/access.rb
|
@@ -225,8 +244,16 @@ files:
|
|
225
244
|
- lib/avm/launcher/publish/check_result.rb
|
226
245
|
- lib/avm/path_string.rb
|
227
246
|
- lib/avm/registry.rb
|
228
|
-
- lib/avm/registry/
|
247
|
+
- lib/avm/registry/application_stereotypes.rb
|
248
|
+
- lib/avm/registry/application_stereotypes/build_available.rb
|
249
|
+
- lib/avm/registry/application_stereotypes/stereotype_builder.rb
|
250
|
+
- lib/avm/registry/from_gems.rb
|
251
|
+
- lib/avm/registry/instances.rb
|
252
|
+
- lib/avm/registry/runners.rb
|
253
|
+
- lib/avm/registry/scms.rb
|
254
|
+
- lib/avm/registry/sources.rb
|
229
255
|
- lib/avm/registry/with_path.rb
|
256
|
+
- lib/avm/registry/with_path/cache.rb
|
230
257
|
- lib/avm/result.rb
|
231
258
|
- lib/avm/rspec.rb
|
232
259
|
- lib/avm/rspec/setup.rb
|
@@ -246,7 +273,6 @@ files:
|
|
246
273
|
- lib/avm/sources/base/instance.rb
|
247
274
|
- lib/avm/sources/base/locale.rb
|
248
275
|
- lib/avm/sources/base/parent.rb
|
249
|
-
- lib/avm/sources/base/runners.rb
|
250
276
|
- lib/avm/sources/base/subs.rb
|
251
277
|
- lib/avm/sources/base/subs_paths.rb
|
252
278
|
- lib/avm/sources/base/testing.rb
|
@@ -260,6 +286,8 @@ files:
|
|
260
286
|
- lib/avm/sync.rb
|
261
287
|
- lib/avm/version.rb
|
262
288
|
- lib/avm/version_number.rb
|
289
|
+
- lib/avm/with_application_stereotype.rb
|
290
|
+
- lib/avm/with_dynamic_runners.rb
|
263
291
|
homepage:
|
264
292
|
licenses: []
|
265
293
|
metadata: {}
|
@@ -1,47 +0,0 @@
|
|
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
|