avm 0.70.0 → 0.71.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: 2e2eb2f46518de88aca96c5a8cedf9c64abb72b862a657a195ef6ff081547cf4
4
- data.tar.gz: 0e516460bb5620cd9ceb9f6bfbfd04db263760a1ec294f1d67c8fe43c78dd81c
3
+ metadata.gz: 02d8da25080bc20bd3138de4a659dcba371fc150255f823c8fac34ac03ecfbf3
4
+ data.tar.gz: a83f46dd107ca4dd342d9273cb1592d3dd129d6a6da5b2cfb2017d30b5452188
5
5
  SHA512:
6
- metadata.gz: 2eb9e691468af8f7e927c2dc99c8d7a1ff5472a5cfa846bab185416062fd9e2ec338fe38a374837f4cc260aa2bbf9380b7bd85b156d53779087f4a14970b3e89
7
- data.tar.gz: 01dac660041abddfcebfa4b1bc56bcfe21d775c6393b6c575b0dba1ba3bec2286f0dfe15505ee3b17bc9222332dbd28e17f3333c0282f89bec9f4b178cef4442
6
+ metadata.gz: 56fa769340dc76338317f62a4a8b8dd9537de35b4a29c8a2548db53f739d7f6160fdda83f648df74879f7ad03a7f40c7b8a2622957769833c365d5fad250db24
7
+ data.tar.gz: c464874fed76e5877450d76633908073d92a3fdaca4f40c4cf4189d491c1b95118a9aa87f4595e1abffb6ca85433709977e507baf0657e30ff7a1dc553bd28de
@@ -46,7 +46,7 @@ module Avm
46
46
  end
47
47
 
48
48
  # @param id [Symbol]
49
- # @return [Avm::Data::Unit]
49
+ # @return [Avm::Data::UnitWithCommands]
50
50
  def unit(identifier)
51
51
  units[identifier.to_sym] || raise("No unit found with identifier \"#{identifier}\"")
52
52
  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
@@ -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.71.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.71.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
@@ -112,14 +112,14 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0.114'
115
+ version: '0.115'
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.115'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: eac_templates
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -244,6 +244,7 @@ files:
244
244
  - lib/avm/data/package/load.rb
245
245
  - lib/avm/data/rotate.rb
246
246
  - lib/avm/data/unit.rb
247
+ - lib/avm/data/unit_with_commands.rb
247
248
  - lib/avm/docker.rb
248
249
  - lib/avm/docker/container.rb
249
250
  - lib/avm/docker/image.rb