eac_tools 0.8.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +25 -19
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/lib/avm/application_stereotypes/base.rb +21 -0
- data/sub/avm/lib/avm/application_stereotypes.rb +9 -0
- data/sub/avm/lib/avm/applications/base/stereotype.rb +31 -0
- data/sub/avm/lib/avm/applications/base.rb +45 -0
- data/sub/avm/lib/avm/applications.rb +9 -0
- data/sub/avm/lib/avm/docker/image.rb +12 -2
- data/sub/avm/lib/avm/instances/base.rb +7 -2
- data/sub/avm/lib/avm/instances.rb +1 -1
- data/sub/avm/lib/avm/registry/application_stereotypes/build_available.rb +46 -0
- data/sub/avm/lib/avm/registry/application_stereotypes/stereotype_builder.rb +30 -0
- data/sub/avm/lib/avm/registry/application_stereotypes.rb +52 -0
- data/sub/avm/lib/avm/registry/{base.rb → from_gems.rb} +13 -4
- data/sub/avm/lib/avm/registry/instances.rb +16 -0
- data/sub/avm/lib/avm/registry/runners.rb +10 -0
- data/sub/avm/lib/avm/registry/scms.rb +10 -0
- data/sub/avm/lib/avm/registry/sources.rb +10 -0
- data/sub/avm/lib/avm/registry/with_path/cache.rb +2 -2
- data/sub/avm/lib/avm/registry/with_path.rb +8 -2
- data/sub/avm/lib/avm/registry.rb +3 -7
- data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
- data/sub/avm/lib/avm/scms/base.rb +2 -0
- data/sub/avm/lib/avm/sources/base/instance.rb +2 -2
- data/sub/avm/lib/avm/sources/base.rb +4 -0
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm/lib/avm/with_application_stereotype.rb +23 -0
- data/sub/avm/lib/avm/with_dynamic_runners.rb +42 -0
- data/sub/{avm-tools/spec/lib/avm/instances/application_spec.rb → avm/spec/lib/avm/applications/base_spec.rb} +3 -3
- data/sub/{avm-tools/spec/lib/avm/instances/application_spec_fixture.yml → avm/spec/lib/avm/applications/base_spec_fixture.yml} +0 -0
- data/sub/{avm-tools → avm}/spec/lib/avm/instances/base_spec.rb +0 -0
- data/sub/{avm-tools → avm}/spec/lib/avm/instances/base_spec_configs_storage.yml +0 -0
- data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +2 -2
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb +61 -0
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker.rb +13 -0
- data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
- data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +2 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base.rb +14 -0
- data/sub/{avm-tools/lib/avm/tools/runner/eac_redmine_base0 → avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners}/docker.rb +3 -3
- data/sub/{avm-tools/lib/avm/tools/runner/eac_redmine_base0 → avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners}/project_rename.rb +3 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/runners.rb +13 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/runners/base.rb +25 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb +1 -3
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/docker.rb +19 -0
- data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
- data/sub/avm-tools/avm-tools.gemspec +1 -2
- data/sub/avm-tools/lib/avm/tools/runner/application_stereotypes/list.rb +31 -0
- data/sub/avm-tools/lib/avm/tools/runner/application_stereotypes.rb +16 -0
- data/sub/avm-tools/lib/avm/tools/runner/instance/info.rb +1 -0
- data/sub/avm-tools/lib/avm/tools/runner/instance.rb +6 -1
- data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
- data/sub/eac_docker/Gemfile +8 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/eac_docker.gemspec +3 -3
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/container.rb +4 -3
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/debug.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/executables.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/base.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/coded.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/named.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/templatized.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/registry.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/rspec/setup.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/rspec.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/version.rb +1 -1
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/executables_spec.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/coded_spec.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/templatized_spec.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/rubocop_spec.rb +0 -0
- data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/spec_helper.rb +0 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +22 -5
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable_spec.rb +34 -0
- metadata +62 -50
- data/sub/avm/lib/avm/instances/application.rb +0 -29
- data/sub/avm/lib/avm/sources/base/runners.rb +0 -47
- data/sub/avm-tools/Gemfile.lock +0 -291
- data/sub/avm-tools/lib/avm/tools/runner/eac_redmine_base0/dev_docker.rb +0 -17
- data/sub/avm-tools/lib/avm/tools/runner/eac_redmine_base0.rb +0 -15
- data/sub/avm-tools/sub/eac_docker/Gemfile +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf951e52229600803d874cf5338a82d4a5844fc2b6394efe31f5f6fe6e90e211
|
4
|
+
data.tar.gz: f30235f79e322f9c454de1e4260e660b06a6297dd391db4a1d6631ef97c9d2f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80341907f9a9c14fdda123bc57ee50266f9894e23f247e3c84849bccd6b7ede54a9aebe9fd10463ee61440fe8f834c60f27a03992b8eddb8002ac81bb29ed3a5
|
7
|
+
data.tar.gz: 298ec77d399c84bba732913eb5329373fa5b7500c4d09c2347f86f3ad899cce452fffcbbd7a9b893341c7f310dc1ed17ab9fd2c8473e3895c54ca05470990ee4
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eac_tools (0.
|
5
|
-
avm-eac_generic_base0 (~> 0.
|
4
|
+
eac_tools (0.11.0)
|
5
|
+
avm-eac_generic_base0 (~> 0.4)
|
6
6
|
avm-eac_rails_base0 (~> 0.5)
|
7
7
|
avm-eac_rails_base1 (~> 0.4, >= 0.4.1)
|
8
|
-
avm-eac_redmine_base0 (~> 0.
|
8
|
+
avm-eac_redmine_base0 (~> 0.11)
|
9
9
|
avm-eac_redmine_plugin_base0 (~> 0.3)
|
10
10
|
avm-eac_ruby_base1 (~> 0.11)
|
11
|
-
avm-tools (~> 0.
|
12
|
-
eac_ruby_utils (~> 0.
|
11
|
+
avm-tools (~> 0.125)
|
12
|
+
eac_ruby_utils (~> 0.96)
|
13
13
|
|
14
14
|
PATH
|
15
15
|
remote: sub/avm-eac_generic_base0
|
16
16
|
specs:
|
17
|
-
avm-eac_generic_base0 (0.
|
18
|
-
avm (~> 0.
|
19
|
-
eac_ruby_utils (~> 0.
|
17
|
+
avm-eac_generic_base0 (0.4.0)
|
18
|
+
avm (~> 0.28)
|
19
|
+
eac_ruby_utils (~> 0.96)
|
20
20
|
|
21
21
|
PATH
|
22
22
|
remote: sub/avm-eac_rails_base0
|
@@ -36,7 +36,9 @@ PATH
|
|
36
36
|
PATH
|
37
37
|
remote: sub/avm-eac_redmine_base0
|
38
38
|
specs:
|
39
|
-
avm-eac_redmine_base0 (0.
|
39
|
+
avm-eac_redmine_base0 (0.11.0)
|
40
|
+
avm (~> 0.29)
|
41
|
+
avm-eac_generic_base0 (~> 0.4)
|
40
42
|
avm-eac_rails_base1 (~> 0.4, >= 0.4.1)
|
41
43
|
avm-eac_ubuntu_base0 (~> 0.3)
|
42
44
|
curb (~> 0.9.11)
|
@@ -62,12 +64,11 @@ PATH
|
|
62
64
|
PATH
|
63
65
|
remote: sub/avm-tools
|
64
66
|
specs:
|
65
|
-
avm-tools (0.
|
67
|
+
avm-tools (0.125.0)
|
66
68
|
aranha-parsers (~> 0.4)
|
67
|
-
avm (~> 0.
|
69
|
+
avm (~> 0.27)
|
68
70
|
avm-eac_asciidoctor_base0 (~> 0.3, >= 0.3.4)
|
69
71
|
avm-eac_rails_base0 (~> 0.3)
|
70
|
-
avm-eac_redmine_base0 (~> 0.5, >= 0.5.2)
|
71
72
|
avm-eac_ruby_base1 (~> 0.8)
|
72
73
|
avm-eac_ubuntu_base0 (~> 0.3)
|
73
74
|
avm-files (~> 0.1)
|
@@ -81,7 +82,7 @@ PATH
|
|
81
82
|
PATH
|
82
83
|
remote: sub/avm
|
83
84
|
specs:
|
84
|
-
avm (0.
|
85
|
+
avm (0.29.0)
|
85
86
|
eac_cli (~> 0.27, >= 0.27.6)
|
86
87
|
eac_config (~> 0.9)
|
87
88
|
eac_docker (~> 0.3)
|
@@ -107,6 +108,13 @@ PATH
|
|
107
108
|
addressable
|
108
109
|
eac_ruby_utils (~> 0.83)
|
109
110
|
|
111
|
+
PATH
|
112
|
+
remote: sub/eac_docker
|
113
|
+
specs:
|
114
|
+
eac_docker (0.4.2)
|
115
|
+
eac_ruby_utils (~> 0.96)
|
116
|
+
eac_templates (~> 0.3, >= 0.3.1)
|
117
|
+
|
110
118
|
PATH
|
111
119
|
remote: sub/eac_fs
|
112
120
|
specs:
|
@@ -127,7 +135,7 @@ PATH
|
|
127
135
|
PATH
|
128
136
|
remote: sub/eac_ruby_utils
|
129
137
|
specs:
|
130
|
-
eac_ruby_utils (0.
|
138
|
+
eac_ruby_utils (0.96.0)
|
131
139
|
activesupport (>= 4, < 7)
|
132
140
|
addressable (~> 2.6)
|
133
141
|
bundler
|
@@ -191,9 +199,6 @@ GEM
|
|
191
199
|
parslet (~> 2.0)
|
192
200
|
curb (0.9.11)
|
193
201
|
diff-lcs (1.5.0)
|
194
|
-
eac_docker (0.4.1)
|
195
|
-
eac_ruby_utils (~> 0.74)
|
196
|
-
eac_templates (~> 0.1)
|
197
202
|
eac_git (0.12.1)
|
198
203
|
eac_ruby_utils (~> 0.83)
|
199
204
|
parseconfig (~> 1.0, >= 1.0.8)
|
@@ -248,7 +253,7 @@ GEM
|
|
248
253
|
minitest (5.16.2)
|
249
254
|
multipart-post (2.2.3)
|
250
255
|
net-ssh (4.2.0)
|
251
|
-
nokogiri (1.13.
|
256
|
+
nokogiri (1.13.8-x86_64-linux)
|
252
257
|
racc (~> 1.4)
|
253
258
|
ofx-parser (1.1.0)
|
254
259
|
hpricot (>= 0.6)
|
@@ -314,6 +319,7 @@ DEPENDENCIES
|
|
314
319
|
avm-tools!
|
315
320
|
eac_cli!
|
316
321
|
eac_config!
|
322
|
+
eac_docker!
|
317
323
|
eac_fs!
|
318
324
|
eac_ruby_base0!
|
319
325
|
eac_ruby_gem_support (~> 0.5.1)
|
@@ -321,4 +327,4 @@ DEPENDENCIES
|
|
321
327
|
eac_tools!
|
322
328
|
|
323
329
|
BUNDLED WITH
|
324
|
-
2.3.
|
330
|
+
2.3.18
|
data/lib/eac_tools/version.rb
CHANGED
@@ -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
|
@@ -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
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/entries'
|
4
|
+
require 'avm/registry'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Applications
|
9
|
+
class Base
|
10
|
+
enable_simple_cache
|
11
|
+
require_sub __FILE__, include_modules: true
|
12
|
+
include ::Avm::Instances::Entries
|
13
|
+
|
14
|
+
LOCAL_INSTANCE_SUFFIX = 'dev'
|
15
|
+
|
16
|
+
common_constructor :id do
|
17
|
+
self.id = id.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
id
|
22
|
+
end
|
23
|
+
|
24
|
+
def instance(suffix)
|
25
|
+
::Avm::Instances::Base.new(self, suffix)
|
26
|
+
end
|
27
|
+
|
28
|
+
def name
|
29
|
+
entry(::Avm::Instances::EntryKeys::NAME).read
|
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
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -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,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
|
@@ -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,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/instances/base'
|
4
|
+
require 'avm/sources/base'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Registry
|
9
|
+
class ApplicationStereotypes
|
10
|
+
require_sub __FILE__, require_dependency: true
|
11
|
+
enable_simple_cache
|
12
|
+
|
13
|
+
common_constructor :module_suffix
|
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
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def available_uncached
|
26
|
+
build_available
|
27
|
+
end
|
28
|
+
|
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 }
|
33
|
+
end
|
34
|
+
|
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 }
|
45
|
+
end
|
46
|
+
|
47
|
+
def raise_not_found(obj)
|
48
|
+
raise("No registered module valid for #{obj} (Available: #{available.join(', ')})")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
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 ? klass.by_id(*detect_args) : nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,11 +1,11 @@
|
|
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
9
|
class Cache
|
10
10
|
enable_simple_cache
|
11
11
|
common_constructor :owner
|
@@ -1,13 +1,19 @@
|
|
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
9
|
require_sub __FILE__
|
10
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
|
+
|
11
17
|
def detect_by_path(path)
|
12
18
|
detect_by_path_optional(path) || raise_not_found(path)
|
13
19
|
end
|
data/sub/avm/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
|
@@ -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
|
@@ -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
|