avm 0.56.1 → 0.58.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: c3fbdddcdbc848524b57336f7c1ac341950a1f725d4de87a64dde6951499d835
4
- data.tar.gz: bf01ee819ed341084e1dea109d318d0275d1661a3228048d98e873df544eacb9
3
+ metadata.gz: a50b6491d183f2df1d7423338b915f2017ec2bf147e6857806c27cdde72ef10d
4
+ data.tar.gz: 225020d14af638e08b723a00482794790715165b7cbe092e0833e301ba182993
5
5
  SHA512:
6
- metadata.gz: 22a5f8d897b2eeb7e19ca82e4f1e50c864a97ff08936a83dfcf4ede15d8510650ce8beb69b300d5800b7c825825cf200a9e1eb6672c4a097028857ec7b6384c3
7
- data.tar.gz: b3956dc0425e73d3a4579d1d50d9ad9704adc41079ba4fbf779d2f52edd31055ea255ee47bb8d88a52351124c583cc4b33ff0857ef65d1f57eb85ace1abdfef9
6
+ metadata.gz: e006a7a7a9be79a45abed6317db5de8c6097bd1f5269ec444dc43ad49852713e892c10685e1043f3eb93cfb40a0207739f025c16a758c47a3c3546a48014cc2e
7
+ data.tar.gz: 28d138623589418cb34db4ba74d7f0e1b1ecf87695ab5e49e2c62c0420c5631e2b09525952815d1a0b6c837367b1b4ce9123f1d42833ab08f1822aec5a5e2ba2
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/callbacks'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Data
8
+ module Callbacks
9
+ common_concern do
10
+ include ::ActiveSupport::Callbacks
11
+
12
+ %i[dump load].each do |action|
13
+ define_callbacks action
14
+
15
+ %i[before after].each do |callback|
16
+ method_name = "#{callback}_#{action}"
17
+ singleton_class.class_eval do
18
+ define_method method_name do |callback_method = nil, &block|
19
+ if callback_method
20
+ set_callback action, callback, callback_method
21
+ else
22
+ set_callback action, callback, &block
23
+ end
24
+ self
25
+ end
26
+ end
27
+
28
+ define_method method_name do |callback_method = nil, &block|
29
+ singleton_class.send(method_name, callback_method, &block)
30
+ self
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/data/package/dump'
4
- require 'avm/data/package/load'
3
+ require 'avm/data/callbacks'
4
+ require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Data
8
8
  class Package
9
- attr_reader :units
9
+ require_sub __FILE__
10
+ include ::Avm::Data::Callbacks
10
11
 
11
12
  def initialize(options)
12
- @units = {}
13
13
  options = options.to_options_consumer
14
14
  units = options.consume(:units)
15
15
  options.validate
@@ -19,7 +19,7 @@ module Avm
19
19
  end
20
20
 
21
21
  def add_unit(identifier, unit)
22
- @units[identifier.to_sym] = unit
22
+ units[identifier.to_sym] = unit
23
23
  end
24
24
 
25
25
  def dump(data_path, options = {})
@@ -31,11 +31,19 @@ module Avm
31
31
  end
32
32
 
33
33
  def dump_units_to_directory(directory)
34
- @units.each { |identifier, unit| unit.dump_to_directory(directory, identifier) }
34
+ run_callbacks :dump do
35
+ units.each { |identifier, unit| unit.dump_to_directory(directory, identifier) }
36
+ end
35
37
  end
36
38
 
37
39
  def load_units_from_directory(directory)
38
- @units.each { |identifier, unit| unit.load_from_directory(directory, identifier) }
40
+ run_callbacks :load do
41
+ units.each { |identifier, unit| unit.load_from_directory(directory, identifier) }
42
+ end
43
+ end
44
+
45
+ def units
46
+ @units ||= {}
39
47
  end
40
48
  end
41
49
  end
data/lib/avm/data/unit.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/data/callbacks'
3
4
  require 'eac_ruby_utils/core_ext'
4
- require 'active_support/callbacks'
5
5
 
6
6
  module Avm
7
7
  module Data
8
8
  class Unit
9
- include ::ActiveSupport::Callbacks
9
+ include ::Avm::Data::Callbacks
10
10
 
11
- define_callbacks :dump, :load
12
11
  enable_speaker
13
12
 
14
13
  %w[dump load].each do |action|
@@ -20,26 +19,6 @@ module Avm
20
19
  fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
21
20
  end
22
21
  CODE
23
-
24
- # Callbacks
25
- %w[before after].each do |callback|
26
- method = "#{callback}_#{action}"
27
- class_eval <<~CODE, __FILE__, __LINE__ + 1
28
- def self.#{method}(callback_method = nil, &block)
29
- if callback_method
30
- set_callback :#{action}, :#{callback}, callback_method
31
- else
32
- set_callback :#{action}, :#{callback}, &block
33
- end
34
- self
35
- end
36
-
37
- def #{method}(callback_method = nil, &block)
38
- singleton_class.#{method}(callback_method, &block)
39
- self
40
- end
41
- CODE
42
- end
43
22
  end
44
23
 
45
24
  def extension
@@ -15,7 +15,7 @@ module Avm
15
15
  .if_present do |v|
16
16
  ::File.join(
17
17
  v,
18
- "#{id}#{::Avm::Data::Instance::Package::Dump::DEFAULT_FILE_EXTENSION}"
18
+ "#{id}#{::Avm::Instances::Data::Package::Dump::DEFAULT_FILE_EXTENSION}"
19
19
  )
20
20
  end
21
21
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/data/unit'
4
+
5
+ module Avm
6
+ module Instances
7
+ module Data
8
+ class FilesUnit < ::Avm::Instances::Data::Unit
9
+ EXTENSION = '.tar.gz'
10
+
11
+ enable_listable
12
+ lists.add_symbol :option, :sudo_user
13
+
14
+ common_constructor :instance, :fs_path_subpath, :options, default: [{}],
15
+ super_args: -> { [instance] } do
16
+ self.fs_path_subpath = fs_path_subpath.to_pathname
17
+ self.options = self.class.lists.option.hash_keys_validate!(options)
18
+ end
19
+
20
+ before_load :clear_files
21
+
22
+ # @return [Pathname]
23
+ def files_path
24
+ fs_path_subpath
25
+ .expand_path(instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH))
26
+ end
27
+
28
+ def dump_command
29
+ instance_command('tar', '-czf', '-', '-C', files_path, '.')
30
+ end
31
+
32
+ def load_command
33
+ instance_command('tar', '-xzf', '-', '-C', files_path)
34
+ end
35
+
36
+ def clear_files
37
+ infom "Removing all files under #{files_path}..."
38
+ instance_command('mkdir', '-p', files_path).execute!
39
+ instance_command('find', files_path, '-mindepth', 1, '-delete').execute!
40
+ end
41
+
42
+ # @return [EacRubyUtils::Envs::Command]
43
+ def instance_command(*args)
44
+ args = ['sudo', '-Hu', sudo_user] + args if sudo_user.present?
45
+ instance.host_env.command(*args)
46
+ end
47
+
48
+ # @return [String, nil]
49
+ def sudo_user
50
+ options[OPTION_SUDO_USER]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -3,8 +3,8 @@
3
3
  require 'avm/data/package'
4
4
 
5
5
  module Avm
6
- module Data
7
- module Instance
6
+ module Instances
7
+ module Data
8
8
  class Package < ::Avm::Data::Package
9
9
  attr_reader :instance
10
10
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/unit'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Instances
8
+ module Data
9
+ class Unit < ::Avm::Data::Unit
10
+ common_constructor :instance
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Instances
7
+ module Data
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -5,6 +5,27 @@ require 'avm/registry/with_path'
5
5
  module Avm
6
6
  module Registry
7
7
  class Sources < ::Avm::Registry::WithPath
8
+ # @return [Avm::ApplicationStereotypes::Base]
9
+ def application_stereotype_by_name(name)
10
+ ::Avm::Registry.application_stereotypes.detect(name)
11
+ end
12
+
13
+ # @return [Avm::Sources::Base, nil]
14
+ def detect_optional(*detect_args)
15
+ detect_optional_by_configuration(*detect_args) || super
16
+ end
17
+
18
+ # @return [Avm::Sources::Base, nil]
19
+ def detect_optional_by_configuration(path, *detect_args)
20
+ source_configured_stereotype_name(path).if_present do |v|
21
+ application_stereotype_by_name(v).source_class.new(path, *detect_args)
22
+ end
23
+ end
24
+
25
+ # @return [String]
26
+ def source_configured_stereotype_name(path)
27
+ ::Avm::Sources::Base.new(path).stereotype_name_by_configuration
28
+ end
8
29
  end
9
30
  end
10
31
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ module Stereotype
9
+ STEREOTYPE_NAME_KEY = 'stereotype'
10
+
11
+ # @return [String, nil]
12
+ def stereotype_name_by_configuration
13
+ configuration.entry(STEREOTYPE_NAME_KEY).value
14
+ end
15
+ end
16
+ end
17
+ end
18
+ 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.56.1'
4
+ VERSION = '0.58.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.56.1
4
+ version: 0.58.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-11-15 00:00:00.000000000 Z
11
+ date: 2022-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.15'
81
+ version: '0.16'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.15'
88
+ version: '0.16'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: eac_git
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -106,20 +106,20 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '0.107'
109
+ version: '0.109'
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 0.107.1
112
+ version: 0.109.1
113
113
  type: :runtime
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '0.107'
119
+ version: '0.109'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: 0.107.1
122
+ version: 0.109.1
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: eac_templates
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -263,10 +263,7 @@ files:
263
263
  - lib/avm/applications/base.rb
264
264
  - lib/avm/applications/base/publishing.rb
265
265
  - lib/avm/applications/base/stereotype.rb
266
- - lib/avm/data/instance.rb
267
- - lib/avm/data/instance/files_unit.rb
268
- - lib/avm/data/instance/package.rb
269
- - lib/avm/data/instance/unit.rb
266
+ - lib/avm/data/callbacks.rb
270
267
  - lib/avm/data/package.rb
271
268
  - lib/avm/data/package/dump.rb
272
269
  - lib/avm/data/package/load.rb
@@ -316,6 +313,10 @@ files:
316
313
  - lib/avm/instances/base/entry_keys.rb
317
314
  - lib/avm/instances/base/install.rb
318
315
  - lib/avm/instances/base/web.rb
316
+ - lib/avm/instances/data.rb
317
+ - lib/avm/instances/data/files_unit.rb
318
+ - lib/avm/instances/data/package.rb
319
+ - lib/avm/instances/data/unit.rb
319
320
  - lib/avm/instances/docker_image.rb
320
321
  - lib/avm/instances/entry_keys.rb
321
322
  - lib/avm/instances/ids.rb
@@ -393,6 +394,7 @@ files:
393
394
  - lib/avm/sources/base/instance.rb
394
395
  - lib/avm/sources/base/locale.rb
395
396
  - lib/avm/sources/base/parent.rb
397
+ - lib/avm/sources/base/stereotype.rb
396
398
  - lib/avm/sources/base/subs.rb
397
399
  - lib/avm/sources/base/subs_paths.rb
398
400
  - lib/avm/sources/base/testing.rb
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/data/instance/unit'
4
-
5
- module Avm
6
- module Data
7
- module Instance
8
- class FilesUnit < ::Avm::Data::Instance::Unit
9
- EXTENSION = '.tar.gz'
10
-
11
- attr_reader :fs_path_subpath
12
-
13
- def initialize(instance, fs_path_subpath)
14
- super(instance)
15
- @fs_path_subpath = fs_path_subpath
16
- end
17
-
18
- before_load :clear_files
19
-
20
- def files_path
21
- ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH),
22
- fs_path_subpath)
23
- end
24
-
25
- def dump_command
26
- instance.host_env.command('tar', '-czf', '-', '-C', files_path, '.')
27
- end
28
-
29
- def load_command
30
- instance.host_env.command('tar', '-xzf', '-', '-C', files_path)
31
- end
32
-
33
- def clear_files
34
- infom "Removing all files under #{files_path}..."
35
- instance.host_env.command('mkdir', '-p', files_path).execute!
36
- instance.host_env.command('find', files_path, '-mindepth', 1, '-delete').execute!
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/data/unit'
4
-
5
- module Avm
6
- module Data
7
- module Instance
8
- class Unit < ::Avm::Data::Unit
9
- attr_reader :instance
10
-
11
- def initialize(instance)
12
- @instance = instance
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
5
-
6
- module Avm
7
- module Data
8
- module Instance
9
- end
10
- end
11
- end