avm 0.27.0 → 0.30.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.rb +11 -1
- data/lib/avm/applications/base/stereotype.rb +31 -0
- data/lib/avm/applications/base.rb +17 -0
- data/lib/avm/docker/image.rb +12 -2
- data/lib/avm/registry/application_stereotypes/build_available.rb +9 -6
- data/lib/avm/registry/application_stereotypes/stereotype_builder.rb +8 -5
- data/lib/avm/registry/application_stereotypes.rb +26 -10
- data/lib/avm/registry/instances.rb +1 -1
- data/lib/avm/registry/source_generators.rb +16 -0
- data/lib/avm/registry.rb +2 -1
- data/lib/avm/scms/base.rb +2 -0
- data/lib/avm/source_generators/base.rb +29 -0
- data/lib/avm/source_generators.rb +9 -0
- data/lib/avm/version.rb +1 -1
- data/lib/avm/with_application_stereotype.rb +11 -1
- metadata +6 -4
- data/lib/avm/application_stereotypes/base/by_gem.rb +0 -17
- data/lib/avm/application_stereotypes/base/detection.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 056fb39001835d22921692f1801a184d8b94852259e282520eb992ce5ffa29f4
|
4
|
+
data.tar.gz: 4f951bd5a35dfe20f25c27f67e7c6ee6c1db3cc4a6d9a8529d614b57bd655cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69a12b474da5a2aa07e41250569f4ce0786e51800958157b6d437a74480f5244e5f2846ca7b8ee2c495a5907adf8c7d289f7eef8e313244cc8ccc8f2066ef29e
|
7
|
+
data.tar.gz: a52eb72873f40f8fe55ed3009ecb3b3914512f8a17159f1dbed1aeda3383d76911947c7eef2ccb7a33af1a3c8294ee0767f18a6dc4a03cf78a8faa1f9f998325
|
@@ -5,7 +5,11 @@ require 'eac_ruby_utils/core_ext'
|
|
5
5
|
module Avm
|
6
6
|
module ApplicationStereotypes
|
7
7
|
class Base
|
8
|
-
|
8
|
+
enable_listable
|
9
|
+
lists.add_symbol :resource, :instance, :source, :source_generator
|
10
|
+
common_constructor :namespace_module, :resources do
|
11
|
+
self.resources = self.class.lists.resource.hash_keys_validate!(resources)
|
12
|
+
end
|
9
13
|
|
10
14
|
# @return [String]
|
11
15
|
def name
|
@@ -16,6 +20,12 @@ module Avm
|
|
16
20
|
def to_s
|
17
21
|
name
|
18
22
|
end
|
23
|
+
|
24
|
+
lists.resource.each_value do |resource|
|
25
|
+
define_method "#{resource}_class" do
|
26
|
+
resources[resource]
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/registry'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Applications
|
7
|
+
class Base
|
8
|
+
module Stereotype
|
9
|
+
# @return [Avm::ApplicationStereotypes::Base, nil]
|
10
|
+
def stereotype_by_configuration
|
11
|
+
entry('stereotype').optional_value.if_present do |v|
|
12
|
+
::Avm::Registry.application_stereotypes.detect(v)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Avm::ApplicationStereotypes::Base, nil]
|
17
|
+
def stereotype_by_source
|
18
|
+
::Avm::Registry.application_stereotypes.detect_optional(local_source.class)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# @return [Avm::ApplicationStereotypes::Base]
|
24
|
+
def stereotype_uncached
|
25
|
+
stereotype_by_configuration || stereotype_by_source ||
|
26
|
+
raise("Could not find stereotype for application \"#{self}\"")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'avm/instances/entries'
|
4
|
+
require 'avm/registry'
|
4
5
|
require 'eac_ruby_utils/core_ext'
|
5
6
|
|
6
7
|
module Avm
|
7
8
|
module Applications
|
8
9
|
class Base
|
10
|
+
enable_simple_cache
|
11
|
+
require_sub __FILE__, include_modules: true
|
9
12
|
include ::Avm::Instances::Entries
|
10
13
|
|
14
|
+
LOCAL_INSTANCE_SUFFIX = 'dev'
|
15
|
+
|
11
16
|
common_constructor :id do
|
12
17
|
self.id = id.to_s
|
13
18
|
end
|
@@ -23,6 +28,18 @@ module Avm
|
|
23
28
|
def name
|
24
29
|
entry(::Avm::Instances::EntryKeys::NAME).read
|
25
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# @return [Avm::Instances::Base]
|
35
|
+
def local_instance_uncached
|
36
|
+
instance(LOCAL_INSTANCE_SUFFIX)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Avm::Sources::Base]
|
40
|
+
def local_source_uncached
|
41
|
+
::Avm::Registry.sources.detect(local_instance.fs_path)
|
42
|
+
end
|
26
43
|
end
|
27
44
|
end
|
28
45
|
end
|
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
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/application_stereotypes/base'
|
3
4
|
require 'avm/registry/application_stereotypes/stereotype_builder'
|
4
5
|
require 'eac_ruby_utils/core_ext'
|
5
6
|
|
@@ -13,8 +14,7 @@ module Avm
|
|
13
14
|
|
14
15
|
def result
|
15
16
|
reset_buffer
|
16
|
-
|
17
|
-
read_sources_registry
|
17
|
+
read_registries
|
18
18
|
buffer.values.map(&:build)
|
19
19
|
end
|
20
20
|
|
@@ -29,12 +29,15 @@ module Avm
|
|
29
29
|
buffer[object.stereotype_namespace_module].add_object(type, object)
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
::Avm::
|
32
|
+
def read_registries
|
33
|
+
::Avm::ApplicationStereotypes::Base.lists.resource.each_value do |resource|
|
34
|
+
read_registry(resource)
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
::Avm::Registry.
|
38
|
+
def read_registry(resource)
|
39
|
+
::Avm::Registry.send(resource.to_s.pluralize).available
|
40
|
+
.each { |obj| read_object(resource, obj) }
|
38
41
|
end
|
39
42
|
|
40
43
|
def reset_buffer
|
@@ -10,20 +10,23 @@ module Avm
|
|
10
10
|
common_constructor :namespace_module
|
11
11
|
|
12
12
|
def add_object(type, object)
|
13
|
-
|
14
|
-
raise "#{attr_method} is already present" if
|
13
|
+
type = type.to_sym
|
14
|
+
raise "#{attr_method} is already present" if resources.key?(type)
|
15
15
|
|
16
|
-
|
16
|
+
resources[::Avm::ApplicationStereotypes::Base.lists.resource.value_validate!(type)] =
|
17
|
+
object
|
17
18
|
end
|
18
19
|
|
19
20
|
# @return [Avm::ApplicationStereotypes::Base]
|
20
21
|
def build
|
21
|
-
::Avm::ApplicationStereotypes::Base.new(namespace_module,
|
22
|
+
::Avm::ApplicationStereotypes::Base.new(namespace_module, resources)
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
25
26
|
|
26
|
-
|
27
|
+
def resources
|
28
|
+
@resources ||= {}
|
29
|
+
end
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/instances/base'
|
4
|
+
require 'avm/sources/base'
|
3
5
|
require 'eac_ruby_utils/core_ext'
|
4
6
|
|
5
7
|
module Avm
|
@@ -10,26 +12,40 @@ module Avm
|
|
10
12
|
|
11
13
|
common_constructor :module_suffix
|
12
14
|
|
15
|
+
def detect(obj)
|
16
|
+
detect_optional(obj) || raise_not_found(obj)
|
17
|
+
end
|
18
|
+
|
19
|
+
def detect_optional(obj)
|
20
|
+
detect_by_instance_class(obj) || detect_by_source_class(obj) || detecy_by_name(obj)
|
21
|
+
end
|
22
|
+
|
13
23
|
private
|
14
24
|
|
15
25
|
def available_uncached
|
16
26
|
build_available
|
17
27
|
end
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
def detect_by_instance_class(obj)
|
30
|
+
return nil unless obj.is_a?(::Class) && obj < ::Avm::Instances::Base
|
31
|
+
|
32
|
+
available.find { |a| a.instance_class == obj }
|
23
33
|
end
|
24
34
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
35
|
+
def detecy_by_name(obj)
|
36
|
+
return nil unless obj.is_a?(::String)
|
37
|
+
|
38
|
+
available.find { |a| a.name == obj }
|
39
|
+
end
|
40
|
+
|
41
|
+
def detect_by_source_class(obj)
|
42
|
+
return nil unless obj.is_a?(::Class) && obj < ::Avm::Sources::Base
|
43
|
+
|
44
|
+
available.find { |a| a.source_class == obj }
|
28
45
|
end
|
29
46
|
|
30
|
-
def
|
31
|
-
|
32
|
-
.map { |klass| class_detect(klass, registered_initialize_args) }.find(&:present?)
|
47
|
+
def raise_not_found(obj)
|
48
|
+
raise("No registered module valid for #{obj} (Available: #{available.join(', ')})")
|
33
49
|
end
|
34
50
|
end
|
35
51
|
end
|
@@ -9,7 +9,7 @@ module Avm
|
|
9
9
|
# @return [Avm::Instances::Base, nil]
|
10
10
|
def class_detect(klass, detect_args)
|
11
11
|
r = ::Avm::Instances::Base.by_id(*detect_args)
|
12
|
-
r.application.stereotype.instance_class == klass ?
|
12
|
+
r.application.stereotype.instance_class == klass ? klass.by_id(*detect_args) : nil
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -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 SourceGenerators < ::Avm::Registry::FromGems
|
9
|
+
# @return [Avm::Instances::Base, nil]
|
10
|
+
def class_detect(klass, detect_args)
|
11
|
+
stereotype_name, target_path = detect_args
|
12
|
+
klass.application_stereotype.name == stereotype_name ? klass.new(target_path) : nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/avm/registry.rb
CHANGED
@@ -7,7 +7,8 @@ module Avm
|
|
7
7
|
module Registry
|
8
8
|
require_sub __FILE__
|
9
9
|
enable_listable
|
10
|
-
lists.add_symbol :category, :application_stereotypes, :instances, :runners, :scms,
|
10
|
+
lists.add_symbol :category, :application_stereotypes, :instances, :runners, :scms,
|
11
|
+
:source_generators, :sources
|
11
12
|
|
12
13
|
WITH_PATH = [CATEGORY_SCMS, CATEGORY_SOURCES].freeze
|
13
14
|
|
data/lib/avm/scms/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'avm/with_application_stereotype'
|
3
4
|
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module Avm
|
@@ -7,6 +8,7 @@ module Avm
|
|
7
8
|
class Base
|
8
9
|
enable_abstract_methods
|
9
10
|
enable_simple_cache
|
11
|
+
include ::Avm::WithApplicationStereotype
|
10
12
|
abstract_methods :update, :valid?
|
11
13
|
common_constructor :path do
|
12
14
|
self.path = path.to_pathname
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/with_application_stereotype'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module SourceGenerators
|
8
|
+
class Base
|
9
|
+
include ::Avm::WithApplicationStereotype
|
10
|
+
common_constructor :target_path do
|
11
|
+
self.target_path = target_path.to_pathname
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform
|
15
|
+
assert_clear_directory
|
16
|
+
apply_template
|
17
|
+
end
|
18
|
+
|
19
|
+
def assert_clear_directory
|
20
|
+
target_path.mkpath
|
21
|
+
raise "\"#{target_path}\" is not empty" if target_path.children.any?
|
22
|
+
end
|
23
|
+
|
24
|
+
def apply_template
|
25
|
+
template.apply(self, target_path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/avm/version.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_cli/runner_with/subcommands'
|
4
3
|
require 'eac_ruby_utils/core_ext'
|
5
4
|
|
6
5
|
module Avm
|
@@ -10,6 +9,17 @@ module Avm
|
|
10
9
|
end
|
11
10
|
|
12
11
|
module ClassMethods
|
12
|
+
# @return [Avm::ApplicationStereotype::Base]
|
13
|
+
def application_stereotype
|
14
|
+
@application_stereotype ||=
|
15
|
+
::Avm::Registry.application_stereotypes.detect(application_stereotype_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String]
|
19
|
+
def application_stereotype_name
|
20
|
+
stereotype_namespace_module.name.demodulize
|
21
|
+
end
|
22
|
+
|
13
23
|
# @return [Module]
|
14
24
|
def stereotype_namespace_module
|
15
25
|
module_parent.module_parent
|
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.30.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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_cli
|
@@ -197,10 +197,9 @@ files:
|
|
197
197
|
- lib/avm.rb
|
198
198
|
- lib/avm/application_stereotypes.rb
|
199
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
200
|
- lib/avm/applications.rb
|
203
201
|
- lib/avm/applications/base.rb
|
202
|
+
- lib/avm/applications/base/stereotype.rb
|
204
203
|
- lib/avm/data/instance.rb
|
205
204
|
- lib/avm/data/instance/files_unit.rb
|
206
205
|
- lib/avm/data/instance/package.rb
|
@@ -251,6 +250,7 @@ files:
|
|
251
250
|
- lib/avm/registry/instances.rb
|
252
251
|
- lib/avm/registry/runners.rb
|
253
252
|
- lib/avm/registry/scms.rb
|
253
|
+
- lib/avm/registry/source_generators.rb
|
254
254
|
- lib/avm/registry/sources.rb
|
255
255
|
- lib/avm/registry/with_path.rb
|
256
256
|
- lib/avm/registry/with_path/cache.rb
|
@@ -267,6 +267,8 @@ files:
|
|
267
267
|
- lib/avm/self/docker_image.rb
|
268
268
|
- lib/avm/self/instance.rb
|
269
269
|
- lib/avm/self/instance/entry_keys.rb
|
270
|
+
- lib/avm/source_generators.rb
|
271
|
+
- lib/avm/source_generators/base.rb
|
270
272
|
- lib/avm/sources.rb
|
271
273
|
- lib/avm/sources/base.rb
|
272
274
|
- lib/avm/sources/base/configuration.rb
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,34 +0,0 @@
|
|
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
|