avm 0.54.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a52ddaff3ca8d1d8b6923f5774a840e96579753deda0e37ed836c3d3de7139f4
4
- data.tar.gz: 03eb845b333bb37eddc9f59ed29a408e145b2a8ad26038e3ffde44f66801e9c4
3
+ metadata.gz: 2fe83959f89ed9d43c44578111aa230b740036e6d9231b5c80a6a59ba777d7cc
4
+ data.tar.gz: 48911ce71466c63dbe3e8dd4ab84f0ecfa061a1c7c55103150ce325bcf745462
5
5
  SHA512:
6
- metadata.gz: f44830cf5abc31bea03038ab8e551fc1202a6abb715af17ef3bdcbce6e26086adb3782749a861f420e7fc9c370bf110c9ba1d2a4d28e24ca24405b17249b8870
7
- data.tar.gz: c8e0b4282562b0dbadcc48c31730f2e976711612cd1d6e712f49db360140ca566b0e30894d3150ecf765762240dd80b8446fb06715c34c41849834d25589c1c1
6
+ metadata.gz: 210f097d0c4f57a0fa0a1bbf64e83e9d4a116250ba552f477401fbc5064eaa7f781c7ff1a3115b5a42844299728578cc13508c663031c2e287994d0507f7b488
7
+ data.tar.gz: 7b65907b3c3201914d97d1e3efa2a740b26dcb87cd820e689a81fdcfbb6e0e1d21619807a6a0f02759af964cae5f0278020eea4dce16672e8aad391bc6d8ee8d
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry'
4
+ require 'eac_ruby_utils/blank_not_blank'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Applications
9
+ class Base
10
+ module Publishing
11
+ PUBLISHABLE_KEY = 'publishable'
12
+
13
+ def publishable?
14
+ publishable_value ? true : false
15
+ end
16
+
17
+ def stereotype_publishable?(stereotype)
18
+ return publishable? unless publishable_value.is_a?(::Hash)
19
+
20
+ parse_publishable_value(publishable_value[stereotype.stereotype_name], true)
21
+ end
22
+
23
+ private
24
+
25
+ def publishable_value
26
+ parse_publishable_value(entry(PUBLISHABLE_KEY).optional_value, false)
27
+ end
28
+
29
+ def parse_publishable_value(value, hash_to_true) # rubocop:disable Metrics/CyclomaticComplexity
30
+ return value.with_indifferent_access if parse_publishable_value_hash?(value, hash_to_true)
31
+ return true if value.nil? || value == true
32
+ return false if value == false || value.is_a?(::EacRubyUtils::BlankNotBlank)
33
+
34
+ value ? true : false
35
+ end
36
+
37
+ def parse_publishable_value_hash?(value, hash_to_true)
38
+ !hash_to_true && value.is_a?(::Hash)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/entries/base'
4
+ require 'avm/instances/ids'
4
5
  require 'avm/registry'
5
6
  require 'eac_ruby_utils/core_ext'
6
7
 
@@ -22,23 +23,43 @@ module Avm
22
23
  end
23
24
 
24
25
  def instance(suffix)
25
- ::Avm::Instances::Base.new(self, suffix)
26
+ stereotype.instance_class.new(self, suffix)
26
27
  end
27
28
 
28
29
  def name
29
30
  entry(::Avm::Instances::EntryKeys::NAME).read
30
31
  end
31
32
 
33
+ # @return [String]
34
+ def local_instance_id
35
+ ::Avm::Instances::Ids.build(id, local_instance_suffix)
36
+ end
37
+
38
+ # @return [Pathname]
39
+ def local_source_path
40
+ local_source_path_entry.value!.to_pathname
41
+ end
42
+
43
+ # @return [EacConfig::Entry]
44
+ def local_source_path_entry
45
+ ::EacConfig::Node.context.current.entry([local_instance_id, 'install', 'path'])
46
+ end
47
+
48
+ # @return [String]
49
+ def local_instance_suffix
50
+ LOCAL_INSTANCE_SUFFIX
51
+ end
52
+
32
53
  private
33
54
 
34
55
  # @return [Avm::Instances::Base]
35
56
  def local_instance_uncached
36
- instance(LOCAL_INSTANCE_SUFFIX)
57
+ instance(local_instance_suffix)
37
58
  end
38
59
 
39
60
  # @return [Avm::Sources::Base]
40
61
  def local_source_uncached
41
- ::Avm::Registry.sources.detect(local_instance.install_path)
62
+ ::Avm::Registry.sources.detect(local_source_path)
42
63
  end
43
64
  end
44
65
  end
@@ -46,6 +46,11 @@ module Avm
46
46
  optional_value || read
47
47
  end
48
48
 
49
+ def value!
50
+ optional_value.if_present { |v| return v }
51
+ context_entry.value!
52
+ end
53
+
49
54
  def write(value)
50
55
  context_entry.value = value
51
56
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/ids'
3
4
  require 'avm/with/application_stereotype'
4
5
  require 'avm/with/extra_subcommands'
5
6
  require 'eac_ruby_utils/require_sub'
@@ -23,18 +24,9 @@ module Avm
23
24
 
24
25
  class << self
25
26
  def by_id(id)
26
- application_id, suffix = parse_id(id)
27
+ parsed_id = ::Avm::Instances::Ids.parse!(id)
27
28
  require 'avm/applications/base'
28
- new(::Avm::Applications::Base.new(application_id), suffix)
29
- end
30
-
31
- private
32
-
33
- def parse_id(id)
34
- m = ID_PATTERN.match(id)
35
- return [m[1], m[2]] if m
36
-
37
- raise "ID Pattern no matched: \"#{id}\""
29
+ new(::Avm::Applications::Base.new(parsed_id.application_id), parsed_id.instance_suffix)
38
30
  end
39
31
  end
40
32
 
@@ -42,8 +34,9 @@ module Avm
42
34
  self.suffix = suffix.to_s
43
35
  end
44
36
 
37
+ # @return [String]
45
38
  def id
46
- "#{application.id}_#{suffix}"
39
+ ::Avm::Instances::Ids.build(application.id, suffix)
47
40
  end
48
41
 
49
42
  def to_s
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Instances
7
+ module Ids
8
+ ID_PARTS_SEPARATOR = '_'
9
+ ID_PATTERN = /\A([a-z0-9]+(?:\-[a-z0-9]+)*)_(.+)\z/.freeze
10
+ ID_PARSER = ID_PATTERN.to_parser do |m|
11
+ ::Struct.new(:application_id, :instance_suffix).new(m[1], m[2])
12
+ end
13
+
14
+ class << self
15
+ # @param application_id [String]
16
+ # @param instance_suffix [String]
17
+ # @return [String]
18
+ def build(application_id, instance_suffix)
19
+ [application_id, instance_suffix].join(ID_PARTS_SEPARATOR)
20
+ end
21
+
22
+ # @param id [String]
23
+ # @return [String]
24
+ def parse!(id)
25
+ ID_PARSER.parse!(id)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -54,6 +54,7 @@ module Avm
54
54
  end
55
55
 
56
56
  def write_cache_file(data)
57
+ cache_file_path.to_pathname.parent.mkpath
57
58
  ::File.write(cache_file_path, data.to_yaml)
58
59
  end
59
60
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'active_support/core_ext/hash/indifferent_access'
4
4
  require 'avm/launcher/context/instance_manager'
5
+ require 'eac_fs/contexts'
6
+ require 'eac_fs/core_ext'
5
7
  require 'eac_ruby_utils/simple_cache'
6
8
  require 'eac_cli/speaker'
7
9
  require 'avm/launcher/context/instance_discovery'
@@ -76,8 +78,9 @@ module Avm
76
78
  send("default_#{key}".underscore)
77
79
  end
78
80
 
81
+ # @return [String]
79
82
  def default_projects_root
80
- '.'
83
+ '.'.to_pathname.expand_path.to_path
81
84
  end
82
85
 
83
86
  def default_settings_file
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Instances
6
+ module Base
7
+ module Publishing
8
+ def publish?(stereotype)
9
+ publish_by_stereotype?(stereotype) && publish_by_application?(stereotype) &&
10
+ publish_by_context?(stereotype)
11
+ end
12
+
13
+ # @return [Boolean]
14
+ def publish_by_application?(stereotype)
15
+ application.stereotype_publishable?(stereotype)
16
+ end
17
+
18
+ # @return [Boolean]
19
+ def publish_by_context?(stereotype)
20
+ filter = ::Avm::Launcher::Context.current.publish_options[:stereotype]
21
+ filter.blank? ? true : filter == stereotype.name.demodulize
22
+ end
23
+
24
+ # @return [Boolean]
25
+ def publish_by_stereotype?(stereotype)
26
+ stereotype.publish_class.present?
27
+ end
28
+
29
+ # @return [Boolean]
30
+ delegate :publishable?, to: :application
31
+
32
+ def publish_check
33
+ stereotypes.each do |s|
34
+ next unless publish?(s)
35
+
36
+ puts "#{name.to_s.cyan}|#{s.label}|" \
37
+ "#{s.publish_class.new(self).check}"
38
+ end
39
+ end
40
+
41
+ def publish_run
42
+ stereotypes.each do |s|
43
+ next unless publish?(s)
44
+
45
+ infov(name, "publishing #{s.label}")
46
+ s.publish_class.new(self).run
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'base/cache'
4
3
  require 'avm/launcher/errors/non_project'
4
+ require 'avm/registry'
5
5
  require 'eac_ruby_utils/speaker/sender'
6
6
 
7
7
  module Avm
@@ -13,6 +13,7 @@ module Avm
13
13
  object.extend ::EacRubyUtils::SimpleCache
14
14
  object.extend ::EacRubyUtils::Speaker::Sender
15
15
  object.extend ::Avm::Launcher::Instances::Base::Cache
16
+ object.extend ::Avm::Launcher::Instances::Base::Publishing
16
17
  super
17
18
  end
18
19
 
@@ -27,8 +28,15 @@ module Avm
27
28
  end
28
29
  end
29
30
 
31
+ require_sub __FILE__
32
+
30
33
  attr_accessor :parent
31
34
 
35
+ # @return [Avm::Applications::Base]
36
+ def application
37
+ @application ||= ::Avm::Registry.applications.detect(project_name)
38
+ end
39
+
32
40
  def name
33
41
  logical
34
42
  end
@@ -47,24 +55,6 @@ module Avm
47
55
  stereotypes.any?
48
56
  end
49
57
 
50
- def publish_run
51
- stereotypes.each do |s|
52
- next unless publish?(s)
53
-
54
- infov(name, "publishing #{s.label}")
55
- s.publish_class.new(self).run
56
- end
57
- end
58
-
59
- def publish_check
60
- stereotypes.each do |s|
61
- next unless publish?(s)
62
-
63
- puts "#{name.to_s.cyan}|#{s.label}|" \
64
- "#{s.publish_class.new(self).check}"
65
- end
66
- end
67
-
68
58
  def project_name
69
59
  ::File.basename(logical)
70
60
  end
@@ -79,14 +69,6 @@ module Avm
79
69
 
80
70
  private
81
71
 
82
- def publish?(stereotype)
83
- return false unless stereotype.publish_class
84
- return false unless options.stereotype_publishable?(stereotype)
85
-
86
- filter = ::Avm::Launcher::Context.current.publish_options[:stereotype]
87
- filter.blank? ? true : filter == stereotype.name.demodulize
88
- end
89
-
90
72
  def options_uncached
91
73
  ::Avm::Launcher::Context.current.settings.instance_settings(self)
92
74
  end
@@ -8,7 +8,6 @@ module Avm
8
8
  class Settings
9
9
  DEFAULT_CURRENT_REVISION = 'origin/master'
10
10
  DEFAULT_PUBLISH_REMOTE = 'publish'
11
- PUBLISHABLE_KEY = :publishable
12
11
 
13
12
  common_constructor :data do
14
13
  self.data = (data.is_a?(Hash) ? data : {}).with_indifferent_access
@@ -21,34 +20,6 @@ module Avm
21
20
  def git_publish_remote
22
21
  data[__method__] || DEFAULT_PUBLISH_REMOTE
23
22
  end
24
-
25
- def publishable?
26
- publishable_value ? true : false
27
- end
28
-
29
- def stereotype_publishable?(stereotype)
30
- return publishable? unless publishable_value.is_a?(::Hash)
31
-
32
- parse_publishable_value(publishable_value[stereotype.stereotype_name], true)
33
- end
34
-
35
- private
36
-
37
- def publishable_value
38
- parse_publishable_value(data[PUBLISHABLE_KEY], false)
39
- end
40
-
41
- def parse_publishable_value(value, hash_to_true)
42
- return value.with_indifferent_access if parse_publishable_value_hash?(value, hash_to_true)
43
- return true if value.nil? || value == true
44
- return false if value == false
45
-
46
- value ? true : false
47
- end
48
-
49
- def parse_publishable_value_hash?(value, hash_to_true)
50
- !hash_to_true && value.is_a?(::Hash)
51
- end
52
23
  end
53
24
  end
54
25
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/applications/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Registry
8
+ class Applications
9
+ def initialize(*args); end
10
+
11
+ # @return [Array<Avm::Applications::Base>]
12
+ def available
13
+ detected.values
14
+ end
15
+
16
+ # @return [Avm::Applications::Base]
17
+ def detect(id)
18
+ id = id.to_s
19
+ detected[id] = ::Avm::Applications::Base.new(id) unless detected.key?(id)
20
+ detected[id]
21
+ end
22
+
23
+ private
24
+
25
+ # @return [Hash<String, Avm::Applications::Base>]
26
+ def detected
27
+ @detected ||= {}
28
+ end
29
+ end
30
+ end
31
+ end
data/lib/avm/registry.rb CHANGED
@@ -7,7 +7,7 @@ module Avm
7
7
  module Registry
8
8
  require_sub __FILE__
9
9
  enable_listable
10
- lists.add_symbol :category, :application_stereotypes, :file_formats, :instances,
10
+ lists.add_symbol :category, :applications, :application_stereotypes, :file_formats, :instances,
11
11
  :launcher_stereotypes, :runners, :scms, :source_generators, :sources
12
12
 
13
13
  class << self
@@ -21,6 +21,15 @@ module Avm
21
21
  require "avm/rspec/shared_examples/#{example}"
22
22
  end
23
23
  end
24
+
25
+ # @return [self]
26
+ def stub_avm_contexts
27
+ stub_eac_config_node
28
+ stub_eac_fs_contexts
29
+ stub_eac_speaker
30
+
31
+ self
32
+ end
24
33
  end
25
34
  end
26
35
  end
@@ -7,20 +7,8 @@ module Avm
7
7
  module Sources
8
8
  class Base
9
9
  module Instance
10
- DEFAULT_INSTANCE_SUFFIX = 'dev'
11
-
12
- def instance_suffix
13
- DEFAULT_INSTANCE_SUFFIX
14
- end
15
-
16
- private
17
-
18
- def application_uncached
19
- ::Avm::Applications::Base.new(path.basename)
20
- end
21
-
22
- def instance_uncached
23
- ::Avm::Instances::Base.new(application, DEFAULT_INSTANCE_SUFFIX)
10
+ def instance
11
+ application.local_instance
24
12
  end
25
13
  end
26
14
  end
data/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.54.0'
4
+ VERSION = '0.56.0'
5
5
  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.54.0
4
+ version: 0.56.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-10-29 00:00:00.000000000 Z
11
+ date: 2022-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -36,34 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.28'
39
+ version: '0.29'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.28'
46
+ version: '0.29'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_config
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.11'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.11.1
53
+ version: '0.12'
57
54
  type: :runtime
58
55
  prerelease: false
59
56
  version_requirements: !ruby/object:Gem::Requirement
60
57
  requirements:
61
58
  - - "~>"
62
59
  - !ruby/object:Gem::Version
63
- version: '0.11'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 0.11.1
60
+ version: '0.12'
67
61
  - !ruby/object:Gem::Dependency
68
62
  name: eac_docker
69
63
  requirement: !ruby/object:Gem::Requirement
@@ -84,14 +78,14 @@ dependencies:
84
78
  requirements:
85
79
  - - "~>"
86
80
  - !ruby/object:Gem::Version
87
- version: '0.13'
81
+ version: '0.15'
88
82
  type: :runtime
89
83
  prerelease: false
90
84
  version_requirements: !ruby/object:Gem::Requirement
91
85
  requirements:
92
86
  - - "~>"
93
87
  - !ruby/object:Gem::Version
94
- version: '0.13'
88
+ version: '0.15'
95
89
  - !ruby/object:Gem::Dependency
96
90
  name: eac_git
97
91
  requirement: !ruby/object:Gem::Requirement
@@ -112,20 +106,20 @@ dependencies:
112
106
  requirements:
113
107
  - - "~>"
114
108
  - !ruby/object:Gem::Version
115
- version: '0.106'
109
+ version: '0.107'
116
110
  - - ">="
117
111
  - !ruby/object:Gem::Version
118
- version: 0.106.1
112
+ version: 0.107.1
119
113
  type: :runtime
120
114
  prerelease: false
121
115
  version_requirements: !ruby/object:Gem::Requirement
122
116
  requirements:
123
117
  - - "~>"
124
118
  - !ruby/object:Gem::Version
125
- version: '0.106'
119
+ version: '0.107'
126
120
  - - ">="
127
121
  - !ruby/object:Gem::Version
128
- version: 0.106.1
122
+ version: 0.107.1
129
123
  - !ruby/object:Gem::Dependency
130
124
  name: eac_templates
131
125
  requirement: !ruby/object:Gem::Requirement
@@ -267,6 +261,7 @@ files:
267
261
  - lib/avm/application_stereotypes/base.rb
268
262
  - lib/avm/applications.rb
269
263
  - lib/avm/applications/base.rb
264
+ - lib/avm/applications/base/publishing.rb
270
265
  - lib/avm/applications/base/stereotype.rb
271
266
  - lib/avm/data/instance.rb
272
267
  - lib/avm/data/instance/files_unit.rb
@@ -323,6 +318,7 @@ files:
323
318
  - lib/avm/instances/base/web.rb
324
319
  - lib/avm/instances/docker_image.rb
325
320
  - lib/avm/instances/entry_keys.rb
321
+ - lib/avm/instances/ids.rb
326
322
  - lib/avm/instances/runner.rb
327
323
  - lib/avm/launcher.rb
328
324
  - lib/avm/launcher/context.rb
@@ -338,6 +334,7 @@ files:
338
334
  - lib/avm/launcher/instances.rb
339
335
  - lib/avm/launcher/instances/base.rb
340
336
  - lib/avm/launcher/instances/base/cache.rb
337
+ - lib/avm/launcher/instances/base/publishing.rb
341
338
  - lib/avm/launcher/instances/error.rb
342
339
  - lib/avm/launcher/instances/runner_helper.rb
343
340
  - lib/avm/launcher/instances/settings.rb
@@ -355,6 +352,7 @@ files:
355
352
  - lib/avm/registry/application_stereotypes.rb
356
353
  - lib/avm/registry/application_stereotypes/build_available.rb
357
354
  - lib/avm/registry/application_stereotypes/stereotype_builder.rb
355
+ - lib/avm/registry/applications.rb
358
356
  - lib/avm/registry/file_formats.rb
359
357
  - lib/avm/registry/from_gems.rb
360
358
  - lib/avm/registry/instances.rb