eac_tools 0.6.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +27 -21
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +1 -0
  5. data/sub/avm/lib/avm/application_stereotypes/base/by_gem.rb +17 -0
  6. data/sub/avm/lib/avm/application_stereotypes/base/detection.rb +34 -0
  7. data/sub/avm/lib/avm/application_stereotypes/base.rb +21 -0
  8. data/sub/avm/lib/avm/application_stereotypes.rb +9 -0
  9. data/sub/avm/lib/avm/{instances/application.rb → applications/base.rb} +5 -6
  10. data/sub/avm/lib/avm/applications.rb +9 -0
  11. data/sub/avm/lib/avm/instances/base.rb +7 -2
  12. data/sub/avm/lib/avm/instances.rb +1 -1
  13. data/sub/avm/lib/avm/registry/application_stereotypes/build_available.rb +46 -0
  14. data/sub/avm/lib/avm/registry/application_stereotypes/stereotype_builder.rb +30 -0
  15. data/sub/avm/lib/avm/registry/application_stereotypes.rb +36 -0
  16. data/sub/avm/lib/avm/registry/{base.rb → from_gems.rb} +13 -4
  17. data/sub/avm/lib/avm/registry/instances.rb +16 -0
  18. data/sub/avm/lib/avm/registry/runners.rb +10 -0
  19. data/sub/avm/lib/avm/registry/scms.rb +10 -0
  20. data/sub/avm/lib/avm/registry/sources.rb +10 -0
  21. data/sub/avm/lib/avm/registry/with_path/cache.rb +31 -0
  22. data/sub/avm/lib/avm/registry/with_path.rb +33 -7
  23. data/sub/avm/lib/avm/registry.rb +3 -7
  24. data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
  25. data/sub/avm/lib/avm/sources/base/configuration.rb +23 -2
  26. data/sub/avm/lib/avm/sources/base/instance.rb +2 -2
  27. data/sub/avm/lib/avm/sources/base/locale.rb +1 -1
  28. data/sub/avm/lib/avm/sources/base/parent.rb +8 -11
  29. data/sub/avm/lib/avm/sources/base/subs_paths.rb +1 -1
  30. data/sub/avm/lib/avm/sources/base/testing.rb +4 -4
  31. data/sub/avm/lib/avm/sources/base.rb +4 -0
  32. data/sub/avm/lib/avm/sources/tests/builder.rb +5 -10
  33. data/sub/avm/lib/avm/version.rb +1 -1
  34. data/sub/avm/lib/avm/with_application_stereotype.rb +23 -0
  35. data/sub/avm/lib/avm/with_dynamic_runners.rb +42 -0
  36. data/sub/{avm-tools/spec/lib/avm/instances/application_spec.rb → avm/spec/lib/avm/applications/base_spec.rb} +3 -3
  37. data/sub/{avm-tools/spec/lib/avm/instances/application_spec_fixture.yml → avm/spec/lib/avm/applications/base_spec_fixture.yml} +0 -0
  38. data/sub/{avm-tools → avm}/spec/lib/avm/instances/base_spec.rb +0 -0
  39. data/sub/{avm-tools → avm}/spec/lib/avm/instances/base_spec_configs_storage.yml +0 -0
  40. data/sub/avm-eac_rails_base0/Gemfile +3 -0
  41. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  42. data/sub/avm-eac_redmine_plugin_base0/avm-eac_redmine_plugin_base0.gemspec +1 -1
  43. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base.rb +40 -2
  44. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/version.rb +1 -1
  45. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +1 -1
  46. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/bundler.rb +1 -1
  47. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rake.rb +14 -0
  48. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base.rb +12 -0
  49. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  50. data/sub/avm-tools/Gemfile +3 -0
  51. data/sub/avm-tools/avm-tools.gemspec +1 -1
  52. data/sub/avm-tools/lib/avm/tools/runner/app_src/info.rb +19 -0
  53. data/sub/avm-tools/lib/avm/tools/runner/application_stereotypes/list.rb +31 -0
  54. data/sub/avm-tools/lib/avm/tools/runner/application_stereotypes.rb +16 -0
  55. data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
  56. data/sub/eac_cli/Gemfile +3 -0
  57. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  58. data/sub/eac_config/Gemfile +8 -0
  59. data/sub/{avm-tools/sub/eac_config → eac_config}/eac_config.gemspec +0 -0
  60. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/entry.rb +0 -0
  61. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/entry_path.rb +5 -0
  62. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/envvars_node/entry.rb +0 -0
  63. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/envvars_node.rb +0 -0
  64. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/load_nodes_search.rb +0 -0
  65. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/load_path.rb +0 -0
  66. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/node.rb +6 -0
  67. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/node_entry.rb +0 -0
  68. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/node_uri.rb +0 -0
  69. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/old_configs/base.rb +0 -0
  70. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/old_configs/file.rb +0 -0
  71. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/old_configs.rb +0 -0
  72. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash/entry_key_error.rb +0 -0
  73. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash/node.rb +0 -0
  74. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash/path_search.rb +0 -0
  75. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash.rb +0 -0
  76. data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +25 -0
  77. data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +19 -0
  78. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/rspec/setup.rb +0 -0
  79. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/rspec.rb +0 -0
  80. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/version.rb +1 -1
  81. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/yaml_file_node/entry.rb +0 -0
  82. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/yaml_file_node.rb +0 -0
  83. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config.rb +0 -0
  84. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/entry_path_spec.rb +0 -0
  85. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/envvars_node/entry_spec.rb +0 -0
  86. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/envvars_node_spec.rb +0 -0
  87. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/old_configs_spec.rb +0 -0
  88. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/paths_hash_spec.rb +0 -0
  89. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec.rb +0 -0
  90. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +0 -0
  91. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +0 -0
  92. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +0 -0
  93. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +0 -0
  94. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/rubocop_spec.rb +0 -0
  95. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/spec_helper.rb +0 -0
  96. data/sub/eac_fs/Gemfile +3 -0
  97. data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
  98. data/sub/eac_ruby_base0/Gemfile +3 -0
  99. data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  100. data/sub/eac_ruby_utils/Gemfile +2 -10
  101. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  102. metadata +69 -58
  103. data/sub/avm/lib/avm/sources/base/runners.rb +0 -47
  104. data/sub/avm-tools/Gemfile.lock +0 -296
  105. data/sub/avm-tools/sub/eac_config/Gemfile +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccf0291272ccc68e5bc61d5245c96b17081d42319907a8dd2b242fe0dc0940ba
4
- data.tar.gz: ced016860d0c5583ce85f9ffbe96ad52bbb5fb922dc8297adaa05f809a3c902f
3
+ metadata.gz: 3fa70fea2f112e1a4e35f04e36403b48e783741ef6422889bf1ff331ebeb9cea
4
+ data.tar.gz: cb5448c31e2221ae342b292d95c8110d0ec7d31a7cd71c864db87e8e26923059
5
5
  SHA512:
6
- metadata.gz: 19a09c17f37b1383f86694deb0c9a465bb952fd6496ab1533fe5888f91f4c009b3c8cabde44d40b7edabdff1b1dfb6540d961e0cd08c9383cb1b75b83bc309dd
7
- data.tar.gz: 1572dd79fde46ab7a10482bae41888bcfae0260a71db83e42ab0b00b14f6d4f290842d32b17de4ddbe53a96ae7bef7b210ece980ba870a53abf05c66ce27e623
6
+ metadata.gz: 35ff38d368bbbb072bbada779c08d9979cda147c3c15ffee5d4c9525942673ef9d94185c306bf23134bc85a69ea7b591c5fb099dc8ec584a41476c71c71f49d2
7
+ data.tar.gz: 7e91d791b04fee2aca1f883a4a72b7862c40cb24a574bebf8c61c5cfa54b12476bb312eb5494cc9e48a9379229ae6c140f06009ab332c55868810a2361dd2201
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.6.0)
4
+ eac_tools (0.9.0)
5
5
  avm-eac_generic_base0 (~> 0.3)
6
6
  avm-eac_rails_base0 (~> 0.5)
7
7
  avm-eac_rails_base1 (~> 0.4, >= 0.4.1)
8
8
  avm-eac_redmine_base0 (~> 0.9)
9
- avm-eac_redmine_plugin_base0 (~> 0.1, >= 0.1.1)
10
- avm-eac_ruby_base1 (~> 0.9)
11
- avm-tools (~> 0.121)
9
+ avm-eac_redmine_plugin_base0 (~> 0.3)
10
+ avm-eac_ruby_base1 (~> 0.11)
11
+ avm-tools (~> 0.123)
12
12
  eac_ruby_utils (~> 0.95, >= 0.95.2)
13
13
 
14
14
  PATH
@@ -36,7 +36,7 @@ PATH
36
36
  PATH
37
37
  remote: sub/avm-eac_redmine_base0
38
38
  specs:
39
- avm-eac_redmine_base0 (0.9.0)
39
+ avm-eac_redmine_base0 (0.9.1)
40
40
  avm-eac_rails_base1 (~> 0.4, >= 0.4.1)
41
41
  avm-eac_ubuntu_base0 (~> 0.3)
42
42
  curb (~> 0.9.11)
@@ -47,24 +47,24 @@ PATH
47
47
  PATH
48
48
  remote: sub/avm-eac_redmine_plugin_base0
49
49
  specs:
50
- avm-eac_redmine_plugin_base0 (0.1.1)
51
- avm-eac_ruby_base1 (~> 0.8, >= 0.8.1)
50
+ avm-eac_redmine_plugin_base0 (0.3.0)
51
+ avm-eac_ruby_base1 (~> 0.11)
52
52
  eac_ruby_utils (~> 0.95, >= 0.95.1)
53
53
 
54
54
  PATH
55
55
  remote: sub/avm-eac_ruby_base1
56
56
  specs:
57
- avm-eac_ruby_base1 (0.9.1)
58
- avm (~> 0.23)
57
+ avm-eac_ruby_base1 (0.11.0)
58
+ avm (~> 0.26)
59
59
  avm-eac_generic_base0 (~> 0.2)
60
60
  eac_ruby_utils (~> 0.95, >= 0.95.1)
61
61
 
62
62
  PATH
63
63
  remote: sub/avm-tools
64
64
  specs:
65
- avm-tools (0.121.2)
65
+ avm-tools (0.123.0)
66
66
  aranha-parsers (~> 0.4)
67
- avm (~> 0.22)
67
+ avm (~> 0.27)
68
68
  avm-eac_asciidoctor_base0 (~> 0.3, >= 0.3.4)
69
69
  avm-eac_rails_base0 (~> 0.3)
70
70
  avm-eac_redmine_base0 (~> 0.5, >= 0.5.2)
@@ -81,8 +81,9 @@ PATH
81
81
  PATH
82
82
  remote: sub/avm
83
83
  specs:
84
- avm (0.25.0)
84
+ avm (0.27.0)
85
85
  eac_cli (~> 0.27, >= 0.27.6)
86
+ eac_config (~> 0.9)
86
87
  eac_docker (~> 0.3)
87
88
  eac_git (~> 0.6)
88
89
  eac_ruby_utils (~> 0.95)
@@ -94,15 +95,22 @@ PATH
94
95
  PATH
95
96
  remote: sub/eac_cli
96
97
  specs:
97
- eac_cli (0.27.6)
98
+ eac_cli (0.27.7)
98
99
  colorize (~> 0.8.1)
99
100
  eac_config (~> 0.8)
100
101
  eac_ruby_utils (~> 0.95)
101
102
 
103
+ PATH
104
+ remote: sub/eac_config
105
+ specs:
106
+ eac_config (0.9.0)
107
+ addressable
108
+ eac_ruby_utils (~> 0.83)
109
+
102
110
  PATH
103
111
  remote: sub/eac_fs
104
112
  specs:
105
- eac_fs (0.12.2)
113
+ eac_fs (0.12.3)
106
114
  content-type
107
115
  eac_ruby_utils (~> 0.70)
108
116
  ruby-filemagic
@@ -110,7 +118,7 @@ PATH
110
118
  PATH
111
119
  remote: sub/eac_ruby_base0
112
120
  specs:
113
- eac_ruby_base0 (0.16.5)
121
+ eac_ruby_base0 (0.16.6)
114
122
  avm-eac_ruby_base1 (~> 0.8)
115
123
  eac_cli (~> 0.27, >= 0.27.5)
116
124
  eac_fs (~> 0.10)
@@ -119,7 +127,7 @@ PATH
119
127
  PATH
120
128
  remote: sub/eac_ruby_utils
121
129
  specs:
122
- eac_ruby_utils (0.95.2)
130
+ eac_ruby_utils (0.95.3)
123
131
  activesupport (>= 4, < 7)
124
132
  addressable (~> 2.6)
125
133
  bundler
@@ -183,9 +191,6 @@ GEM
183
191
  parslet (~> 2.0)
184
192
  curb (0.9.11)
185
193
  diff-lcs (1.5.0)
186
- eac_config (0.8.1)
187
- addressable
188
- eac_ruby_utils (~> 0.83)
189
194
  eac_docker (0.4.1)
190
195
  eac_ruby_utils (~> 0.74)
191
196
  eac_templates (~> 0.1)
@@ -289,7 +294,7 @@ GEM
289
294
  ruby-filemagic (0.7.3)
290
295
  ruby-progressbar (1.11.0)
291
296
  ruby2_keywords (0.0.5)
292
- tzinfo (2.0.4)
297
+ tzinfo (2.0.5)
293
298
  concurrent-ruby (~> 1.0)
294
299
  unicode-display_width (1.6.1)
295
300
  zeitwerk (2.6.0)
@@ -308,6 +313,7 @@ DEPENDENCIES
308
313
  avm-eac_ruby_base1!
309
314
  avm-tools!
310
315
  eac_cli!
316
+ eac_config!
311
317
  eac_fs!
312
318
  eac_ruby_base0!
313
319
  eac_ruby_gem_support (~> 0.5.1)
@@ -315,4 +321,4 @@ DEPENDENCIES
315
321
  eac_tools!
316
322
 
317
323
  BUNDLED WITH
318
- 2.3.17
324
+ 2.3.18
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.6.0'
4
+ VERSION = '0.9.0'
5
5
  end
data/sub/avm/avm.gemspec CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
15
  s.add_dependency 'eac_cli', '~> 0.27', '>= 0.27.6'
16
+ s.add_dependency 'eac_config', '~> 0.9'
16
17
  s.add_dependency 'eac_docker', '~> 0.3'
17
18
  s.add_dependency 'eac_git', '~> 0.6'
18
19
  s.add_dependency 'eac_ruby_utils', '~> 0.95'
@@ -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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module ApplicationStereotypes
7
+ require_sub __FILE__
8
+ end
9
+ 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 Instances
7
- class Application
7
+ module Applications
8
+ class Base
8
9
  include ::Avm::Instances::Entries
9
10
 
10
- attr_reader :id
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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Applications
7
+ require_sub __FILE__
8
+ end
9
+ 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/instances/application'
23
- new(::Avm::Instances::Application.new(application_id), suffix)
27
+ require 'avm/applications/base'
28
+ new(::Avm::Applications::Base.new(application_id), suffix)
24
29
  end
25
30
 
26
31
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Avm
4
4
  module Instances
5
- require 'avm/instances/application'
5
+ require 'avm/applications/base'
6
6
  require 'avm/instances/entries'
7
7
  end
8
8
  end
@@ -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 Base
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
- registered_modules.reverse.lazy.map { |klass| klass.new(*registered_initialize_args) }
19
- .find(&:valid?)
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: #{registered_modules.join(', ')})")
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,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry/from_gems'
4
+
5
+ module Avm
6
+ module Registry
7
+ class Runners < ::Avm::Registry::FromGems
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry/with_path'
4
+
5
+ module Avm
6
+ module Registry
7
+ class Scms < ::Avm::Registry::WithPath
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry/with_path'
4
+
5
+ module Avm
6
+ module Registry
7
+ class Sources < ::Avm::Registry::WithPath
8
+ end
9
+ end
10
+ 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/base'
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::Base
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
- current_path = path.to_pathname.expand_path
15
- until current_path.root?
16
- detect_optional(current_path).if_present { |v| return v }
17
- current_path = current_path.parent
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
@@ -7,14 +7,14 @@ module Avm
7
7
  module Registry
8
8
  require_sub __FILE__
9
9
  enable_listable
10
- lists.add_symbol :category, :instance_stereotypes, :runners, :scms, :sources
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::Base>]
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
- if WITH_PATH.include?(category)
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.registered_modules).not_to include(described_class)
10
+ expect(registry.available).not_to include(described_class)
11
11
  end
12
12
  end
13
13
  end