avm 0.54.0 → 0.55.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a52ddaff3ca8d1d8b6923f5774a840e96579753deda0e37ed836c3d3de7139f4
4
- data.tar.gz: 03eb845b333bb37eddc9f59ed29a408e145b2a8ad26038e3ffde44f66801e9c4
3
+ metadata.gz: 4a1e14183c236b827b6b39bc79d7fb1a1ab6ace3284d897e634d692581db10f8
4
+ data.tar.gz: 2c03c7564a37f2df94acd5b22b0288eaff35179b3f41c41ae7924db4cd54afa5
5
5
  SHA512:
6
- metadata.gz: f44830cf5abc31bea03038ab8e551fc1202a6abb715af17ef3bdcbce6e26086adb3782749a861f420e7fc9c370bf110c9ba1d2a4d28e24ca24405b17249b8870
7
- data.tar.gz: c8e0b4282562b0dbadcc48c31730f2e976711612cd1d6e712f49db360140ca566b0e30894d3150ecf765762240dd80b8446fb06715c34c41849834d25589c1c1
6
+ metadata.gz: 933eceb86eea9a697e57cfd6219449cc2f07fdaabde00facdf67a69d7eb26f1f46b843fd19686a096fb4d2bb6a2396203c98b7d831780df68ae8db2dd4c0f728
7
+ data.tar.gz: 8030a0bff5ea657b2a4c196b68cb0d3b27984a276bce196609b090564206dc130966d0e880242226931fa79f4d1f9ba2ffec3a0c7151c466cc38686ba6142ef6
@@ -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
@@ -21,6 +21,14 @@ 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_speaker
29
+
30
+ self
31
+ end
24
32
  end
25
33
  end
26
34
  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.55.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.55.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-02 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.14'
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.14'
95
89
  - !ruby/object:Gem::Dependency
96
90
  name: eac_git
97
91
  requirement: !ruby/object:Gem::Requirement
@@ -112,20 +106,14 @@ dependencies:
112
106
  requirements:
113
107
  - - "~>"
114
108
  - !ruby/object:Gem::Version
115
- version: '0.106'
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: 0.106.1
109
+ version: '0.107'
119
110
  type: :runtime
120
111
  prerelease: false
121
112
  version_requirements: !ruby/object:Gem::Requirement
122
113
  requirements:
123
114
  - - "~>"
124
115
  - !ruby/object:Gem::Version
125
- version: '0.106'
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: 0.106.1
116
+ version: '0.107'
129
117
  - !ruby/object:Gem::Dependency
130
118
  name: eac_templates
131
119
  requirement: !ruby/object:Gem::Requirement
@@ -323,6 +311,7 @@ files:
323
311
  - lib/avm/instances/base/web.rb
324
312
  - lib/avm/instances/docker_image.rb
325
313
  - lib/avm/instances/entry_keys.rb
314
+ - lib/avm/instances/ids.rb
326
315
  - lib/avm/instances/runner.rb
327
316
  - lib/avm/launcher.rb
328
317
  - lib/avm/launcher/context.rb