avm 0.70.0 → 0.72.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: 2e2eb2f46518de88aca96c5a8cedf9c64abb72b862a657a195ef6ff081547cf4
4
- data.tar.gz: 0e516460bb5620cd9ceb9f6bfbfd04db263760a1ec294f1d67c8fe43c78dd81c
3
+ metadata.gz: 9ffe2b9afc29fb661c8ba611355b5404deaea76ff43aa31c59180035e8942acf
4
+ data.tar.gz: f66cf38833ff6ab3a0b1be19f739ce0620b79d8614828396440d11aade4d4525
5
5
  SHA512:
6
- metadata.gz: 2eb9e691468af8f7e927c2dc99c8d7a1ff5472a5cfa846bab185416062fd9e2ec338fe38a374837f4cc260aa2bbf9380b7bd85b156d53779087f4a14970b3e89
7
- data.tar.gz: 01dac660041abddfcebfa4b1bc56bcfe21d775c6393b6c575b0dba1ba3bec2286f0dfe15505ee3b17bc9222332dbd28e17f3333c0282f89bec9f4b178cef4442
6
+ metadata.gz: 52928731a9e75e5b7664b01b2ebe21121fa848b79220e80e6c216beecd03eb8593a3abf876086d69123fe1a15d11310395cd5edbfa2875cf3814978d4b8e36de
7
+ data.tar.gz: 560b52184f5ec719930168746726ab02c8768bc514a1f10cec54d5e5b08a0649c1b61711a59796fff5cdebc689faf80c2a4cd6400db54965ba953c6bbcaf49d2
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Data
7
+ class Clearer
8
+ enable_speaker
9
+
10
+ common_constructor :storage
11
+
12
+ # @return [self]
13
+ def perform
14
+ storage.clear
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Data
7
+ class Package
8
+ class Clear
9
+ enable_method_class
10
+ enable_speaker
11
+ common_constructor :package
12
+
13
+ # @return [void]
14
+ def result
15
+ package.units.each do |identifier, unit|
16
+ infov 'Clearing unit', identifier
17
+ unit.clear
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -14,7 +14,6 @@ module Avm
14
14
  include ::Avm::Data::Package::BuildDirectory
15
15
 
16
16
  DEFAULT_EXPIRE_TIME = 1.day
17
- DEFAULT_FILE_EXTENSION = '.tar'
18
17
 
19
18
  attr_reader :package, :data_file_path, :existing
20
19
 
@@ -73,15 +72,6 @@ module Avm
73
72
 
74
73
  private
75
74
 
76
- def download
77
- infom 'Downloading dump...'
78
- download_path = find_download_path
79
- dump_command.system!(output_file: download_path)
80
- fatal_error "File \"#{download_path}\" not saved" unless ::File.exist?(download_path)
81
- fatal_error "File \"#{download_path}\" is empty" if ::File.zero?(download_path)
82
- download_path
83
- end
84
-
85
75
  def move_download_to_final_dest(download_path)
86
76
  ::FileUtils.mkdir_p(::File.dirname(data_file_path))
87
77
  ::FileUtils.mv(download_path, data_file_path)
@@ -6,9 +6,11 @@ require 'eac_ruby_utils/core_ext'
6
6
  module Avm
7
7
  module Data
8
8
  class Package
9
- require_sub __FILE__
9
+ require_sub __FILE__, require_mode: :kernel
10
10
  include ::Avm::Data::Callbacks
11
11
 
12
+ DATA_FILE_EXTENSION = '.tar'
13
+
12
14
  def initialize(options)
13
15
  options = options.to_options_consumer
14
16
  units = options.consume(:units)
@@ -25,6 +27,11 @@ module Avm
25
27
  self
26
28
  end
27
29
 
30
+ # @return [String]
31
+ def data_file_extension
32
+ DATA_FILE_EXTENSION
33
+ end
34
+
28
35
  def dump(data_path, options = {})
29
36
  ::Avm::Data::Package::Dump.new(self, data_path, options)
30
37
  end
@@ -46,7 +53,7 @@ module Avm
46
53
  end
47
54
 
48
55
  # @param id [Symbol]
49
- # @return [Avm::Data::Unit]
56
+ # @return [Avm::Data::UnitWithCommands]
50
57
  def unit(identifier)
51
58
  units[identifier.to_sym] || raise("No unit found with identifier \"#{identifier}\"")
52
59
  end
data/lib/avm/data/unit.rb CHANGED
@@ -6,72 +6,43 @@ require 'eac_ruby_utils/core_ext'
6
6
  module Avm
7
7
  module Data
8
8
  class Unit
9
- include ::Avm::Data::Callbacks
10
-
9
+ acts_as_abstract(
10
+ do_clear: [],
11
+ do_dump: [:dump_path],
12
+ do_load: [:dump_path],
13
+ dump_path_extension: []
14
+ )
11
15
  enable_speaker
16
+ include ::Avm::Data::Callbacks
12
17
 
13
- %w[dump load].each do |action|
14
- method_name = "#{action}_command"
15
- class_eval <<~CODE, __FILE__, __LINE__ + 1
16
- # Should be overrided.
17
- # @return [EacRubyUtils::Envs::Command]
18
- def #{method_name}
19
- fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
20
- end
21
- CODE
22
- end
23
-
24
- def extension
25
- singleton_class.const_get('EXTENSION')
26
- rescue NameError
27
- ''
28
- end
29
-
30
- def name
31
- self.class
32
- end
33
-
34
- def load_from_directory(directory, identifier)
35
- load(unit_on_directory_path(directory, identifier))
36
- end
37
-
38
- def dump_to_directory(directory, identifier)
39
- dump(unit_on_directory_path(directory, identifier))
18
+ # @param dump_path [Pathname]
19
+ # @return [void]
20
+ def clear
21
+ run_callbacks(:dump) { do_clear }
40
22
  end
41
23
 
42
- def dump(data_path)
24
+ # @param dump_path [Pathname]
25
+ # @return [void]
26
+ def dump(dump_path)
43
27
  run_callbacks :dump do
44
- infom "Dumping unit \"#{name}\" to \"#{data_path}\"..."
45
- do_dump(data_path)
28
+ infom "Dumping unit \"#{name}\" to \"#{dump_path}\"..."
29
+ do_dump(dump_path)
46
30
  end
47
31
  end
48
32
 
49
- # @return [Struct(:key, :subpath), nil]
50
- def installation_files_data
51
- nil
52
- end
53
-
54
- def load(data_path)
33
+ # @param dump_path [Pathname]
34
+ # @return [void]
35
+ def load(dump_path)
55
36
  run_callbacks :load do
56
- infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
57
- do_load(data_path)
37
+ clear
38
+ infom "Loading unit \"#{name}\" from \"#{dump_path}\"..."
39
+ do_load(dump_path)
58
40
  end
59
41
  end
60
42
 
61
- protected
62
-
63
- def do_dump(data_path)
64
- dump_command.execute!(output_file: data_path)
65
- end
66
-
67
- def do_load(data_path)
68
- load_command.execute!(input_file: data_path)
69
- end
70
-
71
- private
72
-
73
- def unit_on_directory_path(directory, identifier)
74
- ::File.join(directory, "#{identifier}#{extension}")
43
+ # @return [String]
44
+ def name
45
+ self.class.name
75
46
  end
76
47
  end
77
48
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/callbacks'
4
+ require 'avm/data/unit'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Data
9
+ class UnitWithCommands < ::Avm::Data::Unit
10
+ acts_as_abstract
11
+
12
+ abstract_method :dump_command
13
+ abstract_method :load_command
14
+
15
+ # @return [String]
16
+ def dump_path_extension
17
+ singleton_class.const_get('EXTENSION')
18
+ rescue NameError
19
+ ''
20
+ end
21
+
22
+ def load_from_directory(directory, identifier)
23
+ load(unit_on_directory_path(directory, identifier))
24
+ end
25
+
26
+ def dump_to_directory(directory, identifier)
27
+ dump(unit_on_directory_path(directory, identifier))
28
+ end
29
+
30
+ # @return [Struct(:key, :subpath), nil]
31
+ def installation_files_data
32
+ nil
33
+ end
34
+
35
+ protected
36
+
37
+ def do_dump(data_path)
38
+ dump_command.execute!(output_file: data_path)
39
+ end
40
+
41
+ def do_load(data_path)
42
+ load_command.execute!(input_file: data_path)
43
+ end
44
+
45
+ private
46
+
47
+ def unit_on_directory_path(directory, identifier)
48
+ ::File.join(directory, "#{identifier}#{dump_path_extension}")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -116,10 +116,6 @@ module Avm
116
116
  def version?
117
117
  !parsed.no_version?
118
118
  end
119
-
120
- def instance
121
- runner_context.call(:instance)
122
- end
123
119
  end
124
120
  end
125
121
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/data/package/dump'
4
3
  require 'avm/self/instance'
5
4
 
6
5
  module Avm
@@ -15,7 +14,7 @@ module Avm
15
14
  .if_present do |v|
16
15
  ::File.join(
17
16
  v,
18
- "#{id}#{::Avm::Instances::Data::Package::Dump::DEFAULT_FILE_EXTENSION}"
17
+ "#{id}#{data_package.data_file_extension}"
19
18
  )
20
19
  end
21
20
  end
@@ -34,6 +34,16 @@ module Avm
34
34
  self.suffix = suffix.to_s
35
35
  end
36
36
 
37
+ # @return [Avm::Instances::Data::Package]
38
+ def data_package
39
+ @data_package ||= data_package_create
40
+ end
41
+
42
+ # @return [Avm::Instances::Data::Package]
43
+ def data_package_create
44
+ ::Avm::Instances::Data::Package.new(self)
45
+ end
46
+
37
47
  # @return [String]
38
48
  def id
39
49
  ::Avm::Instances::Ids.build(application.id, suffix)
@@ -17,8 +17,6 @@ module Avm
17
17
  self.options = self.class.lists.option.hash_keys_validate!(options)
18
18
  end
19
19
 
20
- before_load :clear
21
-
22
20
  # @return [Pathname]
23
21
  def files_path
24
22
  fs_path_subpath
@@ -33,8 +31,7 @@ module Avm
33
31
  instance_command('tar', '-xzf', '-', '-C', files_path)
34
32
  end
35
33
 
36
- def clear
37
- infom "Removing all files under #{files_path}..."
34
+ def do_clear
38
35
  instance_command('mkdir', '-p', files_path).execute!
39
36
  instance_command('find', files_path, '-mindepth', 1, '-delete').execute!
40
37
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/data/unit'
3
+ require 'avm/data/unit_with_commands'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
7
7
  module Instances
8
8
  module Data
9
- class Unit < ::Avm::Data::Unit
9
+ class Unit < ::Avm::Data::UnitWithCommands
10
10
  common_constructor :instance
11
11
 
12
12
  # @return [Pathname]
13
13
  def data_default_dump_path
14
14
  instance.data_default_dump_path.to_pathname.basename_sub('.*') do |b|
15
- "#{b}_#{identifier}#{extension}"
15
+ "#{b}_#{identifier}#{dump_path_extension}"
16
16
  end
17
17
  end
18
18
 
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.70.0'
4
+ VERSION = '0.72.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.70.0
4
+ version: 0.72.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: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.17'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.17.1
19
+ version: '0.18'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.17'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.17.1
26
+ version: '0.18'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: eac_cli
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -37,6 +31,9 @@ dependencies:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
33
  version: '0.33'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.33.1
40
37
  type: :runtime
41
38
  prerelease: false
42
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,6 +41,9 @@ dependencies:
44
41
  - - "~>"
45
42
  - !ruby/object:Gem::Version
46
43
  version: '0.33'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.33.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_config
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,14 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0.114'
115
+ version: '0.116'
116
116
  type: :runtime
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.114'
122
+ version: '0.116'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: eac_templates
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -238,12 +238,15 @@ files:
238
238
  - lib/avm/applications/base/publishing.rb
239
239
  - lib/avm/applications/base/stereotype.rb
240
240
  - lib/avm/data/callbacks.rb
241
+ - lib/avm/data/clearer.rb
241
242
  - lib/avm/data/package.rb
242
243
  - lib/avm/data/package/build_directory.rb
244
+ - lib/avm/data/package/clear.rb
243
245
  - lib/avm/data/package/dump.rb
244
246
  - lib/avm/data/package/load.rb
245
247
  - lib/avm/data/rotate.rb
246
248
  - lib/avm/data/unit.rb
249
+ - lib/avm/data/unit_with_commands.rb
247
250
  - lib/avm/docker.rb
248
251
  - lib/avm/docker/container.rb
249
252
  - lib/avm/docker/image.rb