avm 0.74.0 → 0.76.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: 69fd41323b3ec2e08b3339520c7ac89b6a0a1f8504f662033e68f9a5f8d43eed
4
- data.tar.gz: 32aa288f19bcfc07f494479e1c1fe04c660d77fdc3435e63c81ff9beb1ea97b2
3
+ metadata.gz: 602c52da99b301910d47a70c9ea6f1d8f9f9755c848d2e76ab48ac1eccf30fdd
4
+ data.tar.gz: 71c8c4c0ef62594c171d62d073eb32dd81837f7ada1fd6666372ead450eab76e
5
5
  SHA512:
6
- metadata.gz: 9fac0d42acc16cc1cf70b6c5331c20171356354400de3473aa5341d8b2c01d7b6c6ea168778359d50a867e6637678b5ad85f0f8ccc7aa5ff44f5c126728576a1
7
- data.tar.gz: 36ae852382bacaeb8918cb351d3e9a7bff8db59476bd8ca3fa1ec88fcb20dbcad5546027b5b49a5789387017d59b1cc7b0d40fedb0c20c20f2234a0a3a28cf25
6
+ metadata.gz: 56204b4fea75fa041555a662779f1763957ce98ba643a6050d3e44b247ba7ae36196abb013b6aa47c912f94fdbcc62552f19faa7fae79287dd87ada7da6d960c
7
+ data.tar.gz: bd7e7c229db445f4a9c1a995a34a596f02d70a45d487c7feabe37a32b3766a01769dc9c726646784f31a322c0cd315d90f5a3e6919c90ed31915ba2a5d6da683
@@ -9,22 +9,17 @@ module Avm
9
9
  module Data
10
10
  class Dumper < ::Avm::Data::Performer
11
11
  DEFAULT_EXPIRE_TIME = 1.day
12
+ DEFAULT_OVERWRITE = false
13
+ DEFAULT_ROTATE = true
12
14
 
13
15
  enable_speaker
14
16
  enable_listable
15
- lists.add_symbol :existing, :denied, :overwrite, :rotate, :rotate_expired
16
- immutable_accessor :existing, :expire_time, :target_path
17
+ immutable_accessor :expire_time, :target_path
18
+ immutable_accessor :overwrite, :rotate, type: :boolean
17
19
 
18
- # @return [String, nil]
20
+ # @return [nil]
19
21
  def cannot_perform_reason
20
- return nil if !target_path.exist? ||
21
- [EXISTING_OVERWRITE, EXISTING_ROTATE].include?(existing)
22
-
23
- if existing == EXISTING_DENIED
24
- 'Data exist and overwriting is denied'
25
- elsif existing == EXISTING_ROTATE_EXPIRED && !target_path_expired?
26
- 'Data exist and yet is not expired'
27
- end
22
+ nil
28
23
  end
29
24
 
30
25
  # @return [Pathname]
@@ -37,7 +32,7 @@ module Avm
37
32
 
38
33
  # @return [Boolean]
39
34
  def target_path_expired?
40
- target_path_time.if_present(false) { |v| v >= expire_time }
35
+ target_path_time.if_present(true) { |v| v >= expire_time }
41
36
  end
42
37
 
43
38
  # @return [ActiveSupport::Duration, nil]
@@ -60,16 +55,20 @@ module Avm
60
55
  raise "\"#{temp_data_path}\" is not a file" unless temp_data_path.file?
61
56
  end
62
57
 
58
+ # @return [String, nil]
59
+ def do_rotate
60
+ return unless target_path.exist?
61
+ return unless rotate?
62
+
63
+ infom "Rotating \"#{target_path}\"..."
64
+ ::Avm::Data::Rotate.new(target_path).run
65
+ end
66
+
63
67
  # @return [Array<Symbol>]
64
68
  def excluded_units
65
69
  excludes.map(&:to_sym).sort
66
70
  end
67
71
 
68
- # @return [Symbol, nil]
69
- def existing_set_filter(value)
70
- value.nil? ? nil : self.class.lists.existing.value_validate!(value)
71
- end
72
-
73
72
  # @return [ActiveSupport::Duration]
74
73
  def expire_time_get_filter(value)
75
74
  value || DEFAULT_EXPIRE_TIME
@@ -91,13 +90,21 @@ module Avm
91
90
 
92
91
  # @return [self]
93
92
  def internal_perform
93
+ use_current? ? internal_perform_use_current : internal_perform_new
94
+ end
95
+
96
+ def internal_perform_new
94
97
  on_temp_data_file do
95
98
  build_temp_data_file
96
- rotate
99
+ do_rotate
97
100
  move_data_to_target_path
98
101
  end
99
102
  end
100
103
 
104
+ def internal_perform_use_current
105
+ infom "Dump \"#{target_path}\" exists and is unexpired"
106
+ end
107
+
101
108
  def move_data_to_target_path
102
109
  ::FileUtils.mv(temp_data_path, target_path.assert_parent)
103
110
  end
@@ -109,19 +116,27 @@ module Avm
109
116
  end
110
117
  end
111
118
 
112
- # @return [String, nil]
113
- def rotate
114
- return unless target_path.exist?
115
- return unless existing == EXISTING_ROTATE
119
+ # @return [Boolean]
120
+ def overwrite_get_filter(value)
121
+ value.nil? ? DEFAULT_OVERWRITE : value
122
+ end
116
123
 
117
- infom "Rotating \"#{target_path}\"..."
118
- ::Avm::Data::Rotate.new(target_path).run
124
+ def rotate_get_filter(value)
125
+ value.nil? ? DEFAULT_ROTATE : value
119
126
  end
120
127
 
121
128
  # @return [Pathname]
122
129
  def target_path_get_filter(value)
123
130
  (value || default_dump_path).to_pathname
124
131
  end
132
+
133
+ # @return [Boolean]
134
+ def use_current?
135
+ return false unless target_path.exist?
136
+ return false if overwrite?
137
+
138
+ !target_path_expired?
139
+ end
125
140
  end
126
141
  end
127
142
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/performer'
4
+ require 'avm/data/rotate'
5
+ require 'eac_ruby_utils/core_ext'
6
+ require 'eac_ruby_utils/fs/temp'
7
+
8
+ module Avm
9
+ module Data
10
+ class Loader < ::Avm::Data::Performer
11
+ immutable_accessor :source_path
12
+
13
+ # @return [String, nil]
14
+ def cannot_perform_reason
15
+ return 'Source path not set' if source_path.blank?
16
+ return "\"#{source_path}\" is not a file" unless source_path.file?
17
+
18
+ nil
19
+ end
20
+
21
+ protected
22
+
23
+ def internal_perform
24
+ data_owner.load(source_path, *include_excludes_arguments)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/data/package/base_performer'
3
4
  require 'avm/data/package/build_directory'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
  require 'minitar'
@@ -7,37 +8,27 @@ require 'minitar'
7
8
  module Avm
8
9
  module Data
9
10
  class Package
10
- class Load
11
+ class Load < ::Avm::Data::Package::BasePerformer
12
+ enable_method_class
11
13
  enable_speaker
12
14
  include ::Avm::Data::Package::BuildDirectory
13
15
 
14
- common_constructor :package, :data_file_path
16
+ attr_reader :source_path
15
17
 
16
- def runnable?
17
- cannot_run_reason.blank?
18
+ def initialize(package, source_path, options = {})
19
+ super(package, options)
20
+ @source_path = source_path.to_pathname
18
21
  end
19
22
 
20
- def cannot_run_reason
21
- return nil if data_file_exist?
22
-
23
- "Data file \"#{data_file_path}\" does not exist"
24
- end
25
-
26
- def run
27
- raise "Cannot run: #{cannot_run_reason}" unless runnable?
28
-
23
+ def result
29
24
  on_build_directory do
30
25
  extract_packages_to_build_directory
31
- package.load_units_from_directory(build_directory)
26
+ package.load_units_from_directory(build_directory, selected_units)
32
27
  end
33
28
  end
34
29
 
35
- def data_file_exist?
36
- ::File.exist?(data_file_path)
37
- end
38
-
39
30
  def extract_packages_to_build_directory
40
- ::Minitar.unpack(data_file_path, build_directory.to_path)
31
+ ::Minitar.unpack(source_path.to_path, build_directory.to_path)
41
32
  end
42
33
  end
43
34
  end
@@ -32,10 +32,6 @@ module Avm
32
32
  DATA_FILE_EXTENSION
33
33
  end
34
34
 
35
- def load(data_path)
36
- ::Avm::Data::Package::Load.new(self, data_path)
37
- end
38
-
39
35
  def dump_units_to_directory(directory, selected_units = nil)
40
36
  run_callbacks :dump do
41
37
  (selected_units || units).each do |identifier, unit|
@@ -44,9 +40,11 @@ module Avm
44
40
  end
45
41
  end
46
42
 
47
- def load_units_from_directory(directory)
43
+ def load_units_from_directory(directory, selected_units = nil)
48
44
  run_callbacks :load do
49
- units.each { |identifier, unit| unit.load_from_directory(directory, identifier) }
45
+ (selected_units || units).each do |identifier, unit|
46
+ unit.load_from_directory(directory, identifier)
47
+ end
50
48
  end
51
49
  end
52
50
 
@@ -19,7 +19,7 @@ module Avm
19
19
 
20
20
  # @return [self]
21
21
  def perform
22
- raise "Cannot run: #{cannot_run_reason}" unless performable?
22
+ raise "Cannot run: #{cannot_perform_reason}" unless performable?
23
23
 
24
24
  internal_perform
25
25
 
@@ -6,6 +6,11 @@ module Avm
6
6
  module Instances
7
7
  class Base
8
8
  module EntryKeys
9
+ # @return [Enumerable<String>]
10
+ def entry_keys
11
+ ::Avm::Instances::EntryKeys.all
12
+ end
13
+
9
14
  ::Avm::Instances::EntryKeys.all.each do |key|
10
15
  method_name = key.to_s.variableize
11
16
  define_method method_name do
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.74.0'
4
+ VERSION = '0.76.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.74.0
4
+ version: 0.76.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-21 00:00:00.000000000 Z
11
+ date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: '0.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.18'
26
+ version: '0.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eac_cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +31,9 @@ dependencies:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.35'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.35.1
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +41,9 @@ dependencies:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
43
  version: '0.35'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.35.1
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: eac_config
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +113,9 @@ dependencies:
107
113
  - - "~>"
108
114
  - !ruby/object:Gem::Version
109
115
  version: '0.117'
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 0.117.1
110
119
  type: :runtime
111
120
  prerelease: false
112
121
  version_requirements: !ruby/object:Gem::Requirement
@@ -114,6 +123,9 @@ dependencies:
114
123
  - - "~>"
115
124
  - !ruby/object:Gem::Version
116
125
  version: '0.117'
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 0.117.1
117
129
  - !ruby/object:Gem::Dependency
118
130
  name: eac_templates
119
131
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +246,7 @@ files:
234
246
  - lib/avm/data/callbacks.rb
235
247
  - lib/avm/data/clearer.rb
236
248
  - lib/avm/data/dumper.rb
249
+ - lib/avm/data/loader.rb
237
250
  - lib/avm/data/package.rb
238
251
  - lib/avm/data/package/base_performer.rb
239
252
  - lib/avm/data/package/build_directory.rb