avm-tools 0.62.1 → 0.62.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/launcher/context/instance_manager.rb +76 -0
- data/lib/avm/launcher/context/instance_manager/cached_instance.rb +37 -0
- data/lib/avm/launcher/context/instance_manager/cached_instances.rb +35 -0
- data/lib/avm/launcher/errors/base.rb +10 -0
- data/lib/avm/launcher/errors/non_project.rb +15 -0
- data/lib/avm/launcher/instances/base.rb +94 -0
- data/lib/avm/launcher/instances/base/cache.rb +43 -0
- data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +5 -4
- data/lib/avm/tools/version.rb +1 -1
- data/lib/eac_launcher/context.rb +2 -2
- data/lib/eac_launcher/context/instance_discovery.rb +2 -2
- data/lib/eac_launcher/git/sub_warp_base.rb +3 -2
- data/lib/eac_launcher/instances.rb +2 -2
- data/lib/eac_launcher/instances/error.rb +7 -3
- data/lib/eac_launcher/paths/logical.rb +2 -2
- data/lib/eac_launcher/publish/base.rb +2 -2
- metadata +8 -4
- data/lib/eac_launcher/context/instance_manager.rb +0 -95
- data/lib/eac_launcher/instances/base.rb +0 -91
- data/lib/eac_launcher/instances/base/cache.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 023b291269b46cb2a272642eac7febb8cbecd15429aeae61435260d0977c0958
|
4
|
+
data.tar.gz: 4ff8f6c8c50ad54a5f7b84be35780e7a221608c7e955a0cb2e241b6f31aa88e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df68926e69e0e8912f73e452fd50b218909620040eb2a69a0695ddce9542f8616e881cd455248df8a9cb89028f6ad9ff9d66aa204c7c79ba0559d317779c2e56
|
7
|
+
data.tar.gz: 155dbcdd721e28b5d4cd021ddb25f35daf4b4f26c2b530cb5ba21377c72ee7a0329a5149831a6031d0c7cfd12e777254b251954774ea7eb9e317b7d57f034f10
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_launcher/publish/check_result'
|
5
|
+
require('yaml')
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Launcher
|
9
|
+
class Context
|
10
|
+
class InstanceManager
|
11
|
+
require_sub __FILE__
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :context
|
14
|
+
|
15
|
+
def publish_state_set(instance, stereotype_name, check_status)
|
16
|
+
data = cached_instances_file_content_uncached
|
17
|
+
data[instance.logical] ||= {}
|
18
|
+
data[instance.logical][:publish_state] ||= {}
|
19
|
+
data[instance.logical][:publish_state][stereotype_name] = check_status
|
20
|
+
write_cache_file(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def pending_instances
|
24
|
+
instances.select { |instance| pending_instance?(instance) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def instances_uncached
|
30
|
+
(cached_instances || search_instances).select(&:included?)
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_instances
|
34
|
+
cache_instances(::EacLauncher::Context::InstanceDiscovery.new(context).instances)
|
35
|
+
end
|
36
|
+
|
37
|
+
def cached_instances
|
38
|
+
return nil if context.recache
|
39
|
+
return nil unless cached_instances_file_content
|
40
|
+
|
41
|
+
CachedInstances.new(self, cached_instances_file_content).instances
|
42
|
+
end
|
43
|
+
|
44
|
+
def cached_instances_file_content_uncached
|
45
|
+
r = YAML.load_file(cache_file_path)
|
46
|
+
r.is_a?(::Hash) ? r : nil
|
47
|
+
rescue Errno::ENOENT
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def cache_instances(instances)
|
52
|
+
write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
|
53
|
+
instances
|
54
|
+
end
|
55
|
+
|
56
|
+
def write_cache_file(data)
|
57
|
+
::File.write(cache_file_path, data.to_yaml)
|
58
|
+
end
|
59
|
+
|
60
|
+
def cache_file_path
|
61
|
+
::File.join(context.cache_root, 'instances.yml')
|
62
|
+
end
|
63
|
+
|
64
|
+
def pending_instance?(instance)
|
65
|
+
data = cached_instances_file_content
|
66
|
+
return false unless data[instance.logical]
|
67
|
+
return false unless data[instance.logical][:publish_state].is_a?(Hash)
|
68
|
+
|
69
|
+
data[instance.logical][:publish_state].any? do |_k, v|
|
70
|
+
::EacLauncher::Publish::CheckResult.pending_status?(v)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/instances/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceManager
|
10
|
+
class CachedInstance
|
11
|
+
enable_console_speaker
|
12
|
+
enable_simple_cache
|
13
|
+
common_constructor :cached_instances, :data
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def instance_uncached
|
18
|
+
::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
|
19
|
+
rescue ::Avm::Launcher::Errors::NonProject
|
20
|
+
warn "Cached instance \"#{data[:logical]}\" not found"
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def parent_instance_uncached
|
25
|
+
data[:parent]
|
26
|
+
.if_present { |v| cached_instances.by_logical_path(v) }
|
27
|
+
.if_present(&:instance)
|
28
|
+
end
|
29
|
+
|
30
|
+
def path_uncached
|
31
|
+
::EacLauncher::Paths::Logical.from_h(cached_instances.context, data)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/context/instance_manager/cached_instance'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
class Context
|
9
|
+
class InstanceManager
|
10
|
+
class CachedInstances
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :context, :content
|
13
|
+
|
14
|
+
def instances
|
15
|
+
content.keys.map { |k| by_logical_path(k).instance }.reject(&:blank?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def by_logical_path(key)
|
19
|
+
cached_instances[key].if_blank do
|
20
|
+
cached_instances[key] = ::Avm::Launcher::Context::InstanceManager::CachedInstance.new(
|
21
|
+
self, content.fetch(key)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def cached_instances_uncached
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/launcher/errors/base'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Launcher
|
7
|
+
module Errors
|
8
|
+
class NonProject < ::Avm::Launcher::Errors::Base
|
9
|
+
def initialize(path)
|
10
|
+
super("#{path} is not a project")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base/cache'
|
4
|
+
require 'avm/launcher/errors/non_project'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module Launcher
|
8
|
+
module Instances
|
9
|
+
module Base
|
10
|
+
class << self
|
11
|
+
def extend_object(object)
|
12
|
+
object.extend ::EacRubyUtils::SimpleCache
|
13
|
+
object.extend ::EacRubyUtils::Console::Speaker
|
14
|
+
object.extend ::Avm::Launcher::Instances::Base::Cache
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def instanciate(path, parent)
|
19
|
+
unless path.is_a?(::Avm::Launcher::Instances::Base)
|
20
|
+
raise ::Avm::Launcher::Errors::NonProject, path unless path.project?
|
21
|
+
|
22
|
+
path.extend(::Avm::Launcher::Instances::Base)
|
23
|
+
path.parent = parent
|
24
|
+
end
|
25
|
+
path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_accessor :parent
|
30
|
+
|
31
|
+
def name
|
32
|
+
logical
|
33
|
+
end
|
34
|
+
|
35
|
+
def stereotype?(stereotype)
|
36
|
+
stereotypes.include?(stereotype)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_parent_path
|
40
|
+
return self unless @parent
|
41
|
+
|
42
|
+
logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
|
43
|
+
end
|
44
|
+
|
45
|
+
def project?
|
46
|
+
stereotypes.any?
|
47
|
+
end
|
48
|
+
|
49
|
+
def publish_run
|
50
|
+
stereotypes.each do |s|
|
51
|
+
next unless publish?(s)
|
52
|
+
|
53
|
+
infov(name, "publishing #{s.label}")
|
54
|
+
s.publish_class.new(self).run
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def publish_check
|
59
|
+
stereotypes.each do |s|
|
60
|
+
next unless publish?(s)
|
61
|
+
|
62
|
+
puts "#{name.to_s.cyan}|#{s.label}|" \
|
63
|
+
"#{s.publish_class.new(self).check}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def project_name
|
68
|
+
::File.basename(logical)
|
69
|
+
end
|
70
|
+
|
71
|
+
def included?
|
72
|
+
!::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_h
|
76
|
+
super.to_h.merge(parent: parent ? parent.logical : nil)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def publish?(stereotype)
|
82
|
+
return false unless stereotype.publish_class
|
83
|
+
|
84
|
+
filter = ::EacLauncher::Context.current.publish_options[:stereotype]
|
85
|
+
filter.blank? ? true : filter == stereotype.name.demodulize
|
86
|
+
end
|
87
|
+
|
88
|
+
def options_uncached
|
89
|
+
::EacLauncher::Context.current.settings.instance_settings(self)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module Launcher
|
5
|
+
module Instances
|
6
|
+
module Base
|
7
|
+
module Cache
|
8
|
+
def cache_path(subpath)
|
9
|
+
File.join(cache_root, subpath)
|
10
|
+
end
|
11
|
+
|
12
|
+
def cache_key(key, &block)
|
13
|
+
v = cache_key_get(key)
|
14
|
+
return v if v.present? || block.nil?
|
15
|
+
|
16
|
+
v = yield
|
17
|
+
cache_key_write(key, v)
|
18
|
+
v
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def cache_key_get(key)
|
24
|
+
File.file?(cache_key_path(key)) ? File.read(cache_key_path(key)) : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def cache_key_write(key, value)
|
28
|
+
FileUtils.mkdir_p(File.dirname(cache_key_path(key)))
|
29
|
+
File.write(cache_key_path(key), value)
|
30
|
+
end
|
31
|
+
|
32
|
+
def cache_key_path(key)
|
33
|
+
File.join(cache_root, 'keys', key.parameterize)
|
34
|
+
end
|
35
|
+
|
36
|
+
def cache_root
|
37
|
+
File.join(::EacLauncher::Context.current.cache_root, name.parameterize)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/simple_cache'
|
4
4
|
require 'eac_launcher/git/sub_warp_base'
|
5
|
-
require '
|
5
|
+
require 'avm/launcher/errors/base'
|
6
6
|
require 'eac_launcher/paths/real'
|
7
7
|
require 'eac_launcher/vendor/github'
|
8
8
|
|
@@ -32,8 +32,9 @@ module Avm
|
|
32
32
|
return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
|
33
33
|
parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
|
34
34
|
|
35
|
-
raise EacLauncher::Instances::
|
36
|
-
|
35
|
+
raise EacLauncher::Instances::Errors::Base,
|
36
|
+
"Subrepo parent hash \"#{subrepo_parent_hash}\"" \
|
37
|
+
" not found in \"#{parent_git_warped}\""
|
37
38
|
end
|
38
39
|
|
39
40
|
def subrepo_parent_hash
|
@@ -41,7 +42,7 @@ module Avm
|
|
41
42
|
h = data['Pull Parent']
|
42
43
|
return h if h.present?
|
43
44
|
|
44
|
-
raise EacLauncher::Instances::
|
45
|
+
raise EacLauncher::Instances::Errors::Base, "Subrepo parent hash is blank: #{data}"
|
45
46
|
end
|
46
47
|
|
47
48
|
def init_aux
|
data/lib/avm/tools/version.rb
CHANGED
data/lib/eac_launcher/context.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/core_ext/hash/indifferent_access'
|
4
|
+
require 'avm/launcher/context/instance_manager'
|
4
5
|
require 'eac_ruby_utils/simple_cache'
|
5
6
|
require 'eac_ruby_utils/console/speaker'
|
6
7
|
require 'eac_launcher/context/instance_discovery'
|
7
|
-
require 'eac_launcher/context/instance_manager'
|
8
8
|
require 'eac_launcher/context/settings'
|
9
9
|
require 'eac_launcher/paths/logical'
|
10
10
|
require 'eac_launcher/project'
|
@@ -39,7 +39,7 @@ module EacLauncher
|
|
39
39
|
@settings = ::EacLauncher::Context::Settings.new(build_option(:settings_file))
|
40
40
|
@cache_root = build_option(:cache_root)
|
41
41
|
@publish_options = { new: false, confirm: false, stereotype: nil }
|
42
|
-
@instance_manager = ::
|
42
|
+
@instance_manager = ::Avm::Launcher::Context::InstanceManager.new(self)
|
43
43
|
@recache = false
|
44
44
|
end
|
45
45
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'ruby-progressbar'
|
4
|
-
require '
|
4
|
+
require 'avm/launcher/instances/base'
|
5
5
|
|
6
6
|
module EacLauncher
|
7
7
|
class Context
|
@@ -22,7 +22,7 @@ module EacLauncher
|
|
22
22
|
update_progress_format(path)
|
23
23
|
on_rescued_path_instances(path) do |r|
|
24
24
|
if path.project?
|
25
|
-
parent_instance = ::
|
25
|
+
parent_instance = ::Avm::Launcher::Instances::Base.instanciate(path, parent_instance)
|
26
26
|
r << path
|
27
27
|
end
|
28
28
|
children = path.children
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'avm/projects/stereotype'
|
4
|
+
require 'avm/launcher/errors/base'
|
4
5
|
|
5
6
|
module EacLauncher
|
6
7
|
module Git
|
@@ -11,7 +12,7 @@ module EacLauncher
|
|
11
12
|
r = find_parent_instance(instance.parent)
|
12
13
|
return r if r
|
13
14
|
|
14
|
-
::EacLauncher::Instances::
|
15
|
+
::EacLauncher::Instances::Errors::Base.new('Git parent not found')
|
15
16
|
end
|
16
17
|
|
17
18
|
def find_parent_instance(current)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
3
|
+
require 'avm/launcher/errors/base'
|
4
|
+
require 'avm/launcher/instances/base'
|
5
5
|
require 'eac_launcher/instances/runner_helper'
|
6
6
|
require 'eac_launcher/instances/settings'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/stereotypes'
|
3
|
+
require 'avm/projects/stereotypes'
|
4
4
|
require 'eac_launcher/paths/real'
|
5
5
|
|
6
6
|
module EacLauncher
|
@@ -68,7 +68,7 @@ module EacLauncher
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def warped_uncached
|
71
|
-
if is_a?(::
|
71
|
+
if is_a?(::Avm::Launcher::Instances::Base)
|
72
72
|
stereotypes.each do |s|
|
73
73
|
return s.warp_class.new(self) if s.warp_class
|
74
74
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'avm/launcher/errors/base'
|
4
4
|
|
5
5
|
module EacLauncher
|
6
6
|
module Publish
|
@@ -35,7 +35,7 @@ module EacLauncher
|
|
35
35
|
|
36
36
|
def check_with_rescue
|
37
37
|
internal_check
|
38
|
-
rescue ::EacLauncher::Instances::
|
38
|
+
rescue ::EacLauncher::Instances::Errors::Base => e
|
39
39
|
::EacLauncher::Publish::CheckResult.blocked("Error: #{e}")
|
40
40
|
rescue ::EacLauncher::Git::Error => e
|
41
41
|
::EacLauncher::Publish::CheckResult.blocked("Git error: #{e}")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.62.
|
4
|
+
version: 0.62.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
@@ -363,6 +363,13 @@ files:
|
|
363
363
|
- lib/avm/instances/entries.rb
|
364
364
|
- lib/avm/instances/entries/entry_reader.rb
|
365
365
|
- lib/avm/instances/entry_keys.rb
|
366
|
+
- lib/avm/launcher/context/instance_manager.rb
|
367
|
+
- lib/avm/launcher/context/instance_manager/cached_instance.rb
|
368
|
+
- lib/avm/launcher/context/instance_manager/cached_instances.rb
|
369
|
+
- lib/avm/launcher/errors/base.rb
|
370
|
+
- lib/avm/launcher/errors/non_project.rb
|
371
|
+
- lib/avm/launcher/instances/base.rb
|
372
|
+
- lib/avm/launcher/instances/base/cache.rb
|
366
373
|
- lib/avm/local_projects.rb
|
367
374
|
- lib/avm/local_projects/instance.rb
|
368
375
|
- lib/avm/local_projects/jobs/update.rb
|
@@ -487,7 +494,6 @@ files:
|
|
487
494
|
- lib/eac_launcher.rb
|
488
495
|
- lib/eac_launcher/context.rb
|
489
496
|
- lib/eac_launcher/context/instance_discovery.rb
|
490
|
-
- lib/eac_launcher/context/instance_manager.rb
|
491
497
|
- lib/eac_launcher/context/settings.rb
|
492
498
|
- lib/eac_launcher/git.rb
|
493
499
|
- lib/eac_launcher/git/base.rb
|
@@ -503,8 +509,6 @@ files:
|
|
503
509
|
- lib/eac_launcher/git/sub_warp_base.rb
|
504
510
|
- lib/eac_launcher/git/warp_base.rb
|
505
511
|
- lib/eac_launcher/instances.rb
|
506
|
-
- lib/eac_launcher/instances/base.rb
|
507
|
-
- lib/eac_launcher/instances/base/cache.rb
|
508
512
|
- lib/eac_launcher/instances/error.rb
|
509
513
|
- lib/eac_launcher/instances/runner_helper.rb
|
510
514
|
- lib/eac_launcher/instances/settings.rb
|
@@ -1,95 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_launcher/publish/check_result'
|
4
|
-
require('yaml')
|
5
|
-
|
6
|
-
module EacLauncher
|
7
|
-
class Context
|
8
|
-
class InstanceManager
|
9
|
-
include ::EacRubyUtils::SimpleCache
|
10
|
-
|
11
|
-
def initialize(context)
|
12
|
-
@context = context
|
13
|
-
end
|
14
|
-
|
15
|
-
def publish_state_set(instance, stereotype_name, check_status)
|
16
|
-
data = cached_instances_file_content_uncached
|
17
|
-
data[instance.logical] ||= {}
|
18
|
-
data[instance.logical][:publish_state] ||= {}
|
19
|
-
data[instance.logical][:publish_state][stereotype_name] = check_status
|
20
|
-
write_cache_file(data)
|
21
|
-
end
|
22
|
-
|
23
|
-
def pending_instances
|
24
|
-
instances.select { |instance| pending_instance?(instance) }
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def instances_uncached
|
30
|
-
(cached_instances || search_instances).select(&:included?)
|
31
|
-
end
|
32
|
-
|
33
|
-
def search_instances
|
34
|
-
cache_instances(::EacLauncher::Context::InstanceDiscovery.new(@context).instances)
|
35
|
-
end
|
36
|
-
|
37
|
-
def cached_instances
|
38
|
-
return nil if @context.recache
|
39
|
-
return nil unless cached_instances_file_content
|
40
|
-
|
41
|
-
CachedInstances.new(cached_instances_file_content).instances
|
42
|
-
end
|
43
|
-
|
44
|
-
def cached_instances_file_content_uncached
|
45
|
-
r = YAML.load_file(cache_file_path)
|
46
|
-
r.is_a?(::Hash) ? r : nil
|
47
|
-
rescue Errno::ENOENT
|
48
|
-
nil
|
49
|
-
end
|
50
|
-
|
51
|
-
def cache_instances(instances)
|
52
|
-
write_cache_file(Hash[instances.map { |i| [i.logical, i.to_h] }])
|
53
|
-
instances
|
54
|
-
end
|
55
|
-
|
56
|
-
def write_cache_file(data)
|
57
|
-
::File.write(cache_file_path, data.to_yaml)
|
58
|
-
end
|
59
|
-
|
60
|
-
def cache_file_path
|
61
|
-
::File.join(@context.cache_root, 'instances.yml')
|
62
|
-
end
|
63
|
-
|
64
|
-
def pending_instance?(instance)
|
65
|
-
data = cached_instances_file_content
|
66
|
-
return false unless data[instance.logical]
|
67
|
-
return false unless data[instance.logical][:publish_state].is_a?(Hash)
|
68
|
-
|
69
|
-
data[instance.logical][:publish_state].any? do |_k, v|
|
70
|
-
::EacLauncher::Publish::CheckResult.pending_status?(v)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class CachedInstances
|
75
|
-
def initialize(content)
|
76
|
-
@content = content
|
77
|
-
@instances = {}
|
78
|
-
end
|
79
|
-
|
80
|
-
def instances
|
81
|
-
@content.keys.map { |k| by_logical_path(k) }
|
82
|
-
end
|
83
|
-
|
84
|
-
def by_logical_path(key)
|
85
|
-
return @instances[key] if @instances.key?(key)
|
86
|
-
|
87
|
-
h = @content[key]
|
88
|
-
parent_instance = h[:parent] ? by_logical_path(h[:parent]) : nil
|
89
|
-
path = ::EacLauncher::Paths::Logical.from_h(@context, h)
|
90
|
-
@instances[key] = ::EacLauncher::Instances::Base.instanciate(path, parent_instance)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'base/cache'
|
4
|
-
|
5
|
-
module EacLauncher
|
6
|
-
module Instances
|
7
|
-
module Base
|
8
|
-
class << self
|
9
|
-
def extend_object(object)
|
10
|
-
object.extend ::EacRubyUtils::SimpleCache
|
11
|
-
object.extend ::EacRubyUtils::Console::Speaker
|
12
|
-
object.extend ::EacLauncher::Instances::Base::Cache
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
def instanciate(path, parent)
|
17
|
-
unless path.is_a?(::EacLauncher::Instances::Base)
|
18
|
-
raise "#{path} is not a project" unless path.project?
|
19
|
-
|
20
|
-
path.extend(::EacLauncher::Instances::Base)
|
21
|
-
path.parent = parent
|
22
|
-
end
|
23
|
-
path
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
attr_accessor :parent
|
28
|
-
|
29
|
-
def name
|
30
|
-
logical
|
31
|
-
end
|
32
|
-
|
33
|
-
def stereotype?(stereotype)
|
34
|
-
stereotypes.include?(stereotype)
|
35
|
-
end
|
36
|
-
|
37
|
-
def to_parent_path
|
38
|
-
return self unless @parent
|
39
|
-
|
40
|
-
logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
|
41
|
-
end
|
42
|
-
|
43
|
-
def project?
|
44
|
-
stereotypes.any?
|
45
|
-
end
|
46
|
-
|
47
|
-
def publish_run
|
48
|
-
stereotypes.each do |s|
|
49
|
-
next unless publish?(s)
|
50
|
-
|
51
|
-
infov(name, "publishing #{s.label}")
|
52
|
-
s.publish_class.new(self).run
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def publish_check
|
57
|
-
stereotypes.each do |s|
|
58
|
-
next unless publish?(s)
|
59
|
-
|
60
|
-
puts "#{name.to_s.cyan}|#{s.label}|" \
|
61
|
-
"#{s.publish_class.new(self).check}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def project_name
|
66
|
-
::File.basename(logical)
|
67
|
-
end
|
68
|
-
|
69
|
-
def included?
|
70
|
-
!::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
|
71
|
-
end
|
72
|
-
|
73
|
-
def to_h
|
74
|
-
super.to_h.merge(parent: parent ? parent.logical : nil)
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def publish?(stereotype)
|
80
|
-
return false unless stereotype.publish_class
|
81
|
-
|
82
|
-
filter = ::EacLauncher::Context.current.publish_options[:stereotype]
|
83
|
-
filter.blank? ? true : filter == stereotype.name.demodulize
|
84
|
-
end
|
85
|
-
|
86
|
-
def options_uncached
|
87
|
-
::EacLauncher::Context.current.settings.instance_settings(self)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module EacLauncher
|
4
|
-
module Instances
|
5
|
-
module Base
|
6
|
-
module Cache
|
7
|
-
def cache_path(subpath)
|
8
|
-
File.join(cache_root, subpath)
|
9
|
-
end
|
10
|
-
|
11
|
-
def cache_key(key, &block)
|
12
|
-
v = cache_key_get(key)
|
13
|
-
return v if v.present? || block.nil?
|
14
|
-
|
15
|
-
v = yield
|
16
|
-
cache_key_write(key, v)
|
17
|
-
v
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def cache_key_get(key)
|
23
|
-
File.file?(cache_key_path(key)) ? File.read(cache_key_path(key)) : nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def cache_key_write(key, value)
|
27
|
-
FileUtils.mkdir_p(File.dirname(cache_key_path(key)))
|
28
|
-
File.write(cache_key_path(key), value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def cache_key_path(key)
|
32
|
-
File.join(cache_root, 'keys', key.parameterize)
|
33
|
-
end
|
34
|
-
|
35
|
-
def cache_root
|
36
|
-
File.join(::EacLauncher::Context.current.cache_root, name.parameterize)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|