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 +4 -4
- data/lib/avm/data/dumper.rb +39 -24
- data/lib/avm/data/loader.rb +28 -0
- data/lib/avm/data/package/load.rb +10 -19
- data/lib/avm/data/package.rb +4 -6
- data/lib/avm/data/performer.rb +1 -1
- data/lib/avm/instances/base/entry_keys.rb +5 -0
- data/lib/avm/version.rb +1 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 602c52da99b301910d47a70c9ea6f1d8f9f9755c848d2e76ab48ac1eccf30fdd
|
4
|
+
data.tar.gz: 71c8c4c0ef62594c171d62d073eb32dd81837f7ada1fd6666372ead450eab76e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56204b4fea75fa041555a662779f1763957ce98ba643a6050d3e44b247ba7ae36196abb013b6aa47c912f94fdbcc62552f19faa7fae79287dd87ada7da6d960c
|
7
|
+
data.tar.gz: bd7e7c229db445f4a9c1a995a34a596f02d70a45d487c7feabe37a32b3766a01769dc9c726646784f31a322c0cd315d90f5a3e6919c90ed31915ba2a5d6da683
|
data/lib/avm/data/dumper.rb
CHANGED
@@ -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
|
-
|
16
|
-
immutable_accessor :
|
17
|
+
immutable_accessor :expire_time, :target_path
|
18
|
+
immutable_accessor :overwrite, :rotate, type: :boolean
|
17
19
|
|
18
|
-
# @return [
|
20
|
+
# @return [nil]
|
19
21
|
def cannot_perform_reason
|
20
|
-
|
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(
|
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
|
-
|
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 [
|
113
|
-
def
|
114
|
-
|
115
|
-
|
119
|
+
# @return [Boolean]
|
120
|
+
def overwrite_get_filter(value)
|
121
|
+
value.nil? ? DEFAULT_OVERWRITE : value
|
122
|
+
end
|
116
123
|
|
117
|
-
|
118
|
-
|
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
|
-
|
16
|
+
attr_reader :source_path
|
15
17
|
|
16
|
-
def
|
17
|
-
|
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
|
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(
|
31
|
+
::Minitar.unpack(source_path.to_path, build_directory.to_path)
|
41
32
|
end
|
42
33
|
end
|
43
34
|
end
|
data/lib/avm/data/package.rb
CHANGED
@@ -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
|
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
|
|
data/lib/avm/data/performer.rb
CHANGED
@@ -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
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.
|
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-
|
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.
|
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.
|
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
|