eac_tools 0.67.1 → 0.69.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: '0650351188a8e6d37ba2f6de9f72aaafea66701164cd576ada4fb32ffaba32cc'
4
- data.tar.gz: 748edc307ad72537a3bbfa167e537fcf9747f44b1ed49b71e58e24fa470de65b
3
+ metadata.gz: 154479f83d348a92c4679896b5823cde655434bff03318a87f1327504a60b666
4
+ data.tar.gz: 1af0723d19a94caaf7eae6af5fc4151cf2bd2bb108e29c335dfe721e1f4714ff
5
5
  SHA512:
6
- metadata.gz: e08048e32da53d1cb6a81053e9412661102a9d1fdb2e2f9370a6a783b4a0e09b3edfa0cb96a79b452578bfed7ab443ee61f89208b786a600ec3679be0247e224
7
- data.tar.gz: f5e0fa874e7a5c6992a0f7a0fac38ed3c85a0b2005857eaabf22ec3faab481d3852e8f971d5b0415c474a1ca704878f62341366f4bcf15bcc0820f0891bed9b4
6
+ metadata.gz: 0103ea3d0b34d1e27e9e940c9e654e968bd4dde5b348c38180fd3bd95f9c569712c95dcd53ff37f1e5cd90db4d95c6c8542429f3ac71ed2037fd162bbc507264
7
+ data.tar.gz: 1d6bc0ab13de8660b2baa316fd86333e3ecff40217f52ea35023598781dd8f1a98ab6aedf8143791a99d4f56b55dc0dad6f2578bb1c6e6629f035bd455572a31
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.67.1)
5
- avm (~> 0.73, >= 0.73.1)
4
+ eac_tools (0.69.0)
5
+ avm (~> 0.75)
6
6
  avm-eac_asciidoctor_base0 (~> 0.19)
7
7
  avm-eac_generic_base0 (~> 0.12)
8
8
  avm-eac_latex_base0 (~> 0.3, >= 0.3.1)
@@ -17,18 +17,18 @@ PATH
17
17
  avm-eac_webapp_base0 (~> 0.17, >= 0.17.2)
18
18
  avm-eac_wordpress_base0 (~> 0.3, >= 0.3.1)
19
19
  avm-git (~> 0.13, >= 0.13.3)
20
- avm-tools (~> 0.149)
20
+ avm-tools (~> 0.151)
21
21
  eac_ruby_utils (~> 0.117)
22
22
 
23
23
  PATH
24
24
  remote: sub/aranha-parsers
25
25
  specs:
26
- aranha-parsers (0.18.0)
26
+ aranha-parsers (0.19.0)
27
27
  activesupport (>= 4.0.0)
28
28
  addressable (~> 2.8, >= 2.8.4)
29
- eac_envs-http (~> 0.3, >= 0.3.1)
30
- eac_ruby_utils (~> 0.116)
31
- nokogiri (~> 1.14, >= 1.14.4)
29
+ eac_envs-http (~> 0.3, >= 0.3.2)
30
+ eac_ruby_utils (~> 0.117)
31
+ nokogiri (~> 1.15, >= 1.15.1)
32
32
  ofx-parser (~> 1.1)
33
33
 
34
34
  PATH
@@ -174,13 +174,13 @@ PATH
174
174
  PATH
175
175
  remote: sub/avm-tools
176
176
  specs:
177
- avm-tools (0.149.0)
178
- aranha-parsers (~> 0.18)
179
- avm (~> 0.73)
177
+ avm-tools (0.151.0)
178
+ aranha-parsers (~> 0.19)
179
+ avm (~> 0.75)
180
180
  avm-eac_ruby_base1 (~> 0.30, >= 0.30.3)
181
- avm-eac_ubuntu_base0 (~> 0.4, >= 0.4.2)
181
+ avm-eac_ubuntu_base0 (~> 0.4, >= 0.4.3)
182
182
  avm-files (~> 0.6, >= 0.6.2)
183
- avm-git (~> 0.13, >= 0.13.2)
183
+ avm-git (~> 0.13, >= 0.13.3)
184
184
  clipboard (~> 1.3, >= 1.3.6)
185
185
  curb (~> 0.9, >= 0.9.11)
186
186
  eac_git (~> 0.14, >= 0.14.1)
@@ -192,8 +192,8 @@ PATH
192
192
  PATH
193
193
  remote: sub/avm
194
194
  specs:
195
- avm (0.73.1)
196
- aranha-parsers (~> 0.18)
195
+ avm (0.75.0)
196
+ aranha-parsers (~> 0.19)
197
197
  eac_cli (~> 0.35)
198
198
  eac_config (~> 0.12)
199
199
  eac_docker (~> 0.7)
@@ -335,7 +335,7 @@ GEM
335
335
  htmlbeautifier (1.4.2)
336
336
  i18n (1.13.0)
337
337
  concurrent-ruby (~> 1.0)
338
- jaro_winkler (1.5.4)
338
+ jaro_winkler (1.5.5)
339
339
  minitar (0.9)
340
340
  minitest (5.18.0)
341
341
  multipart-post (2.3.0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.67.1'
4
+ VERSION = '0.69.0'
5
5
  end
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'activesupport', '>= 4.0.0'
16
16
  s.add_dependency 'addressable', '~> 2.8', '>= 2.8.4'
17
- s.add_dependency 'eac_envs-http', '~> 0.3', '>= 0.3.1'
18
- s.add_dependency 'eac_ruby_utils', '~> 0.116'
19
- s.add_dependency 'nokogiri', '~> 1.14', '>= 1.14.4'
17
+ s.add_dependency 'eac_envs-http', '~> 0.3', '>= 0.3.2'
18
+ s.add_dependency 'eac_ruby_utils', '~> 0.117'
19
+ s.add_dependency 'nokogiri', '~> 1.15', '>= 1.15.1'
20
20
  s.add_dependency 'ofx-parser', '~> 1.1'
21
21
 
22
22
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
@@ -10,11 +10,6 @@ module Aranha
10
10
  class Default < ::Aranha::Parsers::Html::Node::Base
11
11
  require_sub __FILE__, include_modules: true
12
12
 
13
- def array_value(node, xpath)
14
- r = node_set_value(node, xpath).map { |n| n.text.strip }
15
- r.join('|')
16
- end
17
-
18
13
  def join_value(node, xpath)
19
14
  m = ''
20
15
  node_set_value(node, xpath).each do |n|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Parsers
5
- VERSION = '0.18.0'
5
+ VERSION = '0.19.0'
6
6
  end
7
7
  end
data/sub/avm/avm.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'aranha-parsers', '~> 0.18'
15
+ s.add_dependency 'aranha-parsers', '~> 0.19'
16
16
  s.add_dependency 'eac_cli', '~> 0.35'
17
17
  s.add_dependency 'eac_config', '~> 0.12'
18
18
  s.add_dependency 'eac_docker', '~> 0.7'
@@ -0,0 +1,142 @@
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 Dumper < ::Avm::Data::Performer
11
+ DEFAULT_EXPIRE_TIME = 1.day
12
+ DEFAULT_OVERWRITE = false
13
+ DEFAULT_ROTATE = true
14
+
15
+ enable_speaker
16
+ enable_listable
17
+ immutable_accessor :expire_time, :target_path
18
+ immutable_accessor :overwrite, :rotate, type: :boolean
19
+
20
+ # @return [nil]
21
+ def cannot_perform_reason
22
+ nil
23
+ end
24
+
25
+ # @return [Pathname]
26
+ def default_dump_path
27
+ r = data_owner.data_default_dump_path
28
+ include_excludes_path_suffix.if_present(r) do |v|
29
+ r.basename_sub('.*') { |b| "#{b}#{v}#{r.extname}" }
30
+ end
31
+ end
32
+
33
+ # @return [Boolean]
34
+ def target_path_expired?
35
+ target_path_time.if_present(true) { |v| v >= expire_time }
36
+ end
37
+
38
+ # @return [ActiveSupport::Duration, nil]
39
+ def target_path_time
40
+ target_path.exist? ? ::Time.now - ::File.mtime(target_path) : nil
41
+ end
42
+
43
+ protected
44
+
45
+ attr_reader :temp_data_path
46
+
47
+ # @return [Array<Symbol>]
48
+ def all_units
49
+ data_owner.units.keys.sort
50
+ end
51
+
52
+ def build_temp_data_file
53
+ data_owner.dump(temp_data_path, *include_excludes_arguments)
54
+ raise "\"#{temp_data_path}\" do not exist" unless temp_data_path.exist?
55
+ raise "\"#{temp_data_path}\" is not a file" unless temp_data_path.file?
56
+ end
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
+
67
+ # @return [Array<Symbol>]
68
+ def excluded_units
69
+ excludes.map(&:to_sym).sort
70
+ end
71
+
72
+ # @return [ActiveSupport::Duration]
73
+ def expire_time_get_filter(value)
74
+ value || DEFAULT_EXPIRE_TIME
75
+ end
76
+
77
+ # @return [String]
78
+ def include_excludes_path_suffix
79
+ return nil unless data_owner.respond_to?(:units)
80
+
81
+ r = included_units.any? ? included_units : all_units
82
+ r -= excluded_units if excluded_units.any?
83
+ r.any? && r != all_units ? "_#{r.join('-')}" : ''
84
+ end
85
+
86
+ # @return [Array<Symbol>]
87
+ def included_units
88
+ includes.map(&:to_sym).sort
89
+ end
90
+
91
+ # @return [self]
92
+ def internal_perform
93
+ use_current? ? internal_perform_use_current : internal_perform_new
94
+ end
95
+
96
+ def internal_perform_new
97
+ on_temp_data_file do
98
+ build_temp_data_file
99
+ do_rotate
100
+ move_data_to_target_path
101
+ end
102
+ end
103
+
104
+ def internal_perform_use_current
105
+ infom "Dump \"#{target_path}\" exists and is unexpired"
106
+ end
107
+
108
+ def move_data_to_target_path
109
+ ::FileUtils.mv(temp_data_path, target_path.assert_parent)
110
+ end
111
+
112
+ def on_temp_data_file
113
+ ::EacRubyUtils::Fs::Temp.on_file do |file|
114
+ @temp_data_path = file.to_pathname
115
+ yield
116
+ end
117
+ end
118
+
119
+ # @return [Boolean]
120
+ def overwrite_get_filter(value)
121
+ value.nil? ? DEFAULT_OVERWRITE : value
122
+ end
123
+
124
+ def rotate_get_filter(value)
125
+ value.nil? ? DEFAULT_ROTATE : value
126
+ end
127
+
128
+ # @return [Pathname]
129
+ def target_path_get_filter(value)
130
+ (value || default_dump_path).to_pathname
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
140
+ end
141
+ end
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,109 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/data/package/base_performer'
3
4
  require 'avm/data/package/build_directory'
4
- require 'avm/data/rotate'
5
5
  require 'eac_ruby_utils/core_ext'
6
6
  require 'minitar'
7
7
 
8
8
  module Avm
9
9
  module Data
10
10
  class Package
11
- class Dump
12
- enable_speaker
13
- enable_listable
11
+ class Dump < ::Avm::Data::Package::BasePerformer
12
+ enable_method_class
14
13
  include ::Avm::Data::Package::BuildDirectory
15
14
 
16
- DEFAULT_EXPIRE_TIME = 1.day
15
+ attr_reader :target_path
17
16
 
18
- attr_reader :package, :data_file_path, :existing
19
-
20
- lists.add_string :existing, :denied, :overwrite, :rotate, :rotate_expired
21
-
22
- def initialize(package, data_file_path, options = {})
23
- @package = package
24
- @data_file_path = data_file_path
25
- options = options.to_options_consumer
26
- @existing, @expire_time = options.consume(:existing, :expire_time)
27
- options.validate
28
- self.class.lists.existing.value_validate!(@existing)
29
- end
30
-
31
- def runnable?
32
- cannot_run_reason.blank?
33
- end
34
-
35
- def cannot_run_reason
36
- return nil if !data_file_exist? ||
37
- [EXISTING_OVERWRITE, EXISTING_ROTATE].include?(existing)
38
-
39
- if existing == EXISTING_DENIED
40
- 'Data exist and overwriting is denied'
41
- elsif existing == EXISTING_ROTATE_EXPIRED && !data_file_expired?
42
- 'Data exist and yet is not expired'
43
- end
17
+ def initialize(package, target_path, options = {})
18
+ super(package, options)
19
+ @target_path = target_path.to_pathname
44
20
  end
45
21
 
46
- def run
47
- raise "Cannot run: #{cannot_run_reason}" unless runnable?
48
-
49
- package_file = on_build_directory do
22
+ # @return [void]
23
+ def result
24
+ on_build_directory do
50
25
  dump_units_to_build_directory
51
26
  create_package_file
52
27
  end
53
- rotate
54
- move_download_to_final_dest(package_file)
55
- end
56
-
57
- def data_file_exist?
58
- ::File.exist?(data_file_path)
59
- end
60
-
61
- def data_file_time
62
- data_file_exist? ? ::Time.now - ::File.mtime(data_file_path) : nil
63
- end
64
-
65
- def data_file_expired?
66
- data_file_time.if_present(false) { |v| v >= expire_time }
67
- end
68
-
69
- def expire_time
70
- @expire_time || DEFAULT_EXPIRE_TIME
71
- end
72
-
73
- private
74
-
75
- def move_download_to_final_dest(download_path)
76
- ::FileUtils.mkdir_p(::File.dirname(data_file_path))
77
- ::FileUtils.mv(download_path, data_file_path)
78
- end
79
-
80
- def rotate
81
- return unless data_file_exist?
82
- return unless existing == EXISTING_ROTATE
83
-
84
- infom "Rotating \"#{data_file_path}\"..."
85
- ::Avm::Data::Rotate.new(data_file_path).run
86
28
  end
87
29
 
88
- def new_build_path
89
- f = ::Tempfile.new(self.class.name.parameterize + '-download')
90
- path = f.path
91
- f.close
92
- f.unlink
93
- path
94
- end
30
+ protected
95
31
 
96
32
  def dump_units_to_build_directory
97
- package.dump_units_to_directory(build_directory)
33
+ package.dump_units_to_directory(build_directory, selected_units)
98
34
  end
99
35
 
100
36
  def create_package_file
101
- package_path = new_build_path
102
- infom "Creating package \"#{package_path}\" from \"#{build_directory}\"..."
37
+ infom "Creating package \"#{target_path}\" from \"#{build_directory}\"..."
103
38
  ::Dir.chdir(build_directory.to_path) do
104
- ::Minitar.pack('.', File.open(::File.expand_path(package_path), 'wb'))
39
+ ::Minitar.pack('.', ::File.open(target_path, 'wb'))
105
40
  end
106
- package_path
107
41
  end
108
42
  end
109
43
  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,23 +32,19 @@ module Avm
32
32
  DATA_FILE_EXTENSION
33
33
  end
34
34
 
35
- def dump(data_path, options = {})
36
- ::Avm::Data::Package::Dump.new(self, data_path, options)
37
- end
38
-
39
- def load(data_path)
40
- ::Avm::Data::Package::Load.new(self, data_path)
41
- end
42
-
43
- def dump_units_to_directory(directory)
35
+ def dump_units_to_directory(directory, selected_units = nil)
44
36
  run_callbacks :dump do
45
- units.each { |identifier, unit| unit.dump_to_directory(directory, identifier) }
37
+ (selected_units || units).each do |identifier, unit|
38
+ unit.dump_to_directory(directory, identifier)
39
+ end
46
40
  end
47
41
  end
48
42
 
49
- def load_units_from_directory(directory)
43
+ def load_units_from_directory(directory, selected_units = nil)
50
44
  run_callbacks :load do
51
- 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
52
48
  end
53
49
  end
54
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
 
@@ -12,6 +12,11 @@ module Avm
12
12
  @instance = instance
13
13
  super options
14
14
  end
15
+
16
+ # @return [Pathname]
17
+ def data_default_dump_path
18
+ instance.data_default_dump_path.to_pathname
19
+ end
15
20
  end
16
21
  end
17
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.73.1'
4
+ VERSION = '0.75.0'
5
5
  end
@@ -14,12 +14,12 @@ Gem::Specification.new do |s|
14
14
  s.bindir = 'exe'
15
15
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
16
 
17
- s.add_dependency 'aranha-parsers', '~> 0.18'
18
- s.add_dependency 'avm', '~> 0.73'
17
+ s.add_dependency 'aranha-parsers', '~> 0.19'
18
+ s.add_dependency 'avm', '~> 0.75'
19
19
  s.add_dependency 'avm-eac_ruby_base1', '~> 0.30', '>= 0.30.3'
20
- s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.4', '>= 0.4.2'
20
+ s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.4', '>= 0.4.3'
21
21
  s.add_dependency 'avm-files', '~> 0.6', '>= 0.6.2'
22
- s.add_dependency 'avm-git', '~> 0.13', '>= 0.13.2'
22
+ s.add_dependency 'avm-git', '~> 0.13', '>= 0.13.3'
23
23
  s.add_dependency 'clipboard', '~> 1.3', '>= 1.3.6'
24
24
  s.add_dependency 'curb', '~> 0.9', '>= 0.9.11'
25
25
  s.add_dependency 'eac_git', '~> 0.14', '>= 0.14.1'
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/data/package/dump'
4
3
  require 'avm/instances/runner'
5
4
  require 'eac_cli/core_ext'
6
5
 
@@ -10,53 +9,8 @@ module Avm
10
9
  class Instance < ::Avm::Instances::Runner
11
10
  class Data
12
11
  class Dump
13
- DUMP_EXPIRE_TIME = 1.day
14
- NO_DUMP_MESSAGE = 'Dump "%s" already exist and rewrite options was no setted nor ' \
15
- 'dump was expired.'
16
-
17
- runner_with :help do
18
- desc 'Dump utility for EacRailsBase instance.'
19
- bool_opt '-w', '--rewrite', 'Forces dump overwrite.'
20
- pos_arg :dump_path, optional: true
21
- end
22
-
23
- # @return [String]
24
- def help_extra_text
25
- "Default dump path: \"#{default_dump_path}\""
26
- end
27
-
28
- def run
29
- infov 'Instance to dump', "#{instance} (#{instance.class})"
30
- if package_dump.runnable?
31
- package_dump.run
32
- else
33
- warn(package_dump.cannot_run_reason)
34
- end
35
- success("Dump path: \"#{dump_path}\"")
36
- dump_path
37
- end
38
-
39
- private
40
-
41
- def package_dump_uncached
42
- instance
43
- .data_package.dump(dump_path, existing: package_dump_existing)
44
- end
45
-
46
- def dump_path
47
- parsed.dump_path || default_dump_path
48
- end
49
-
50
- def default_dump_path
51
- instance.data_default_dump_path
52
- end
53
-
54
- def package_dump_existing
55
- if parsed.rewrite?
56
- ::Avm::Data::Package::Dump::EXISTING_ROTATE
57
- else
58
- ::Avm::Data::Package::Dump::EXISTING_ROTATE_EXPIRED
59
- end
12
+ runner_with :help, :include_exclude, :instance_data_dump do
13
+ desc 'Dump utility for instance.'
60
14
  end
61
15
  end
62
16
  end
@@ -9,46 +9,8 @@ module Avm
9
9
  class Instance < ::Avm::Instances::Runner
10
10
  class Data
11
11
  class Load
12
- runner_with :help do
13
- desc 'Load utility for EacRailsBase instance.'
14
- arg_opt '-S', '--source-instance', 'Informa a instância a ser extraída o dump.'
15
- pos_arg :dump_path, optional: true
16
- end
17
-
18
- def run
19
- return fatal_error("Dump \"#{dump_path}\" does not exist") unless
20
- ::File.exist?(dump_path)
21
-
22
- load_dump
23
- success("Dump loaded from \"#{dump_path}\"")
24
- end
25
-
26
- def dump_path_uncached
27
- return parsed.dump_path.to_s if parsed.dump_path.present?
28
- return source_instance_dump_path if parsed.source_instance.present?
29
-
30
- raise "Dump path unknown (Options: #{parsed})"
31
- end
32
-
33
- def source_instance_dump_path
34
- runner_context.call(:instance).class.by_id(parsed.source_instance).run_subcommand(
35
- ::Avm::Tools::Runner::Instance::Data::Dump, []
36
- )
37
- end
38
-
39
- def load_dump
40
- info "Loading dump \"#{dump_path}\"..."
41
- package_load.run
42
- end
43
-
44
- def dump_instance_method
45
- :dump_database
46
- end
47
-
48
- private
49
-
50
- def package_load_uncached
51
- runner_context.call(:instance).data_package.load(dump_path)
12
+ runner_with :help, :include_exclude, :instance_data_load do
13
+ desc 'Load utility for instance.'
52
14
  end
53
15
  end
54
16
  end
@@ -10,28 +10,7 @@ module Avm
10
10
  class Data
11
11
  class Unit
12
12
  class Dump
13
- runner_with :help do
14
- pos_arg :dump_path, optional: true
15
- end
16
-
17
- def run
18
- data_owner.dump(dump_path)
19
- end
20
-
21
- # @return [String]
22
- def help_extra_text
23
- "Default dump path: \"#{default_dump_path}\""
24
- end
25
-
26
- # @return [Pathname]
27
- def dump_path
28
- (parsed.dump_path || default_dump_path).to_pathname
29
- end
30
-
31
- # @return [String]
32
- def default_dump_path
33
- data_owner.data_default_dump_path
34
- end
13
+ runner_with :help, :instance_data_dump
35
14
  end
36
15
  end
37
16
  end
@@ -10,18 +10,7 @@ module Avm
10
10
  class Data
11
11
  class Unit
12
12
  class Load
13
- runner_with :help do
14
- pos_arg :dump_path
15
- end
16
-
17
- def run
18
- data_owner.load(dump_path)
19
- end
20
-
21
- # @return [Pathname]
22
- def dump_path
23
- parsed.dump_path.to_pathname
24
- end
13
+ runner_with :help, :instance_data_load
25
14
  end
26
15
  end
27
16
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'avm/data/clearer'
4
4
  require 'eac_cli/core_ext'
5
- require 'eac_cli/runner'
5
+ require 'avm/tools/runner_with/instance_data_performer'
6
6
 
7
7
  module Avm
8
8
  module Tools
@@ -10,19 +10,12 @@ module Avm
10
10
  module InstanceDataClear
11
11
  common_concern do
12
12
  enable_simple_cache
13
- include ::EacCli::Runner
13
+ include ::Avm::Tools::RunnerWith::InstanceDataPerformer
14
14
  end
15
15
 
16
- def run
17
- performer.perform
18
- end
19
-
20
- private
21
-
22
- def performer_uncached
23
- %i[include exclude].inject(::Avm::Data::Clearer.new(data_owner)) do |a1, e1|
24
- if_respond(e1, []).inject(a1) { |a2, e2| a2.send(e1, e2) }
25
- end
16
+ # @return [Class]
17
+ def data_performer_class
18
+ ::Avm::Data::Clearer
26
19
  end
27
20
  end
28
21
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/dumper'
4
+ require 'eac_cli/core_ext'
5
+ require 'avm/tools/runner_with/instance_data_performer'
6
+
7
+ module Avm
8
+ module Tools
9
+ module RunnerWith
10
+ module InstanceDataDump
11
+ common_concern do
12
+ enable_simple_cache
13
+ runner_definition do
14
+ bool_opt '-w', '--rewrite', 'Forces dump overwrite.'
15
+ pos_arg :dump_path, optional: true
16
+ end
17
+
18
+ set_callback :run, :after do
19
+ success("Dump path: \"#{dump_path}\"")
20
+ dump_path
21
+ end
22
+ end
23
+
24
+ include ::Avm::Tools::RunnerWith::InstanceDataPerformer
25
+
26
+ DUMP_EXPIRE_TIME = 1.day
27
+ NO_DUMP_MESSAGE = 'Dump "%s" already exist and rewrite options was no setted nor ' \
28
+ 'dump was expired.'
29
+
30
+ # @return [Class]
31
+ def data_performer_class
32
+ ::Avm::Data::Dumper
33
+ end
34
+
35
+ # @return [String]
36
+ def help_extra_text
37
+ "Default dump path: \"#{default_dump_path}\""
38
+ end
39
+
40
+ private
41
+
42
+ # @return [Avm::Data::Dumper]
43
+ def data_performer_uncached
44
+ r = super.overwrite(parsed.rewrite?)
45
+ parsed.dump_path.if_present(r) { |v| r.target_path(v.to_pathname) }
46
+ end
47
+
48
+ # @return [Pathname]
49
+ def dump_path
50
+ data_performer.target_path
51
+ end
52
+
53
+ def default_dump_path
54
+ data_performer.default_dump_path
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/dumper'
4
+ require 'avm/data/loader'
5
+ require 'eac_cli/core_ext'
6
+ require 'avm/tools/runner_with/instance_data_performer'
7
+
8
+ module Avm
9
+ module Tools
10
+ module RunnerWith
11
+ module InstanceDataLoad
12
+ common_concern do
13
+ enable_simple_cache
14
+
15
+ runner_definition do
16
+ arg_opt '-S', '--source-instance', 'Informa a instância a ser extraída o dump.'
17
+ bool_opt '-w', '--rewrite'
18
+ pos_arg :dump_path, optional: true
19
+ end
20
+
21
+ set_callback :run, :after do
22
+ success("Dump loaded from \"#{dump_path}\"")
23
+ end
24
+ end
25
+
26
+ include ::Avm::Tools::RunnerWith::InstanceDataPerformer
27
+
28
+ # @return [Class]
29
+ def data_performer_class
30
+ ::Avm::Data::Loader
31
+ end
32
+
33
+ private
34
+
35
+ # @return [Avm::Data::Loader]
36
+ def data_performer_uncached
37
+ super.source_path(dump_path)
38
+ end
39
+
40
+ # @return [Pathname]
41
+ def dump_path_uncached
42
+ return parsed.dump_path.to_pathname if parsed.dump_path.present?
43
+ return source_instance_dump_path if parsed.source_instance.present?
44
+
45
+ fatal_error "Dump path not set (Options: #{parsed})"
46
+ end
47
+
48
+ # @return [Avm::Instances::Base]
49
+ def source_instance
50
+ runner_context.call(:instance).class.by_id(parsed.source_instance)
51
+ end
52
+
53
+ # @return [Avm::Data::Dumper]
54
+ def source_instance_dumper
55
+ data_performer_set_includes_excludes(
56
+ ::Avm::Data::Dumper.new(source_instance.data_package).overwrite(parsed.rewrite?)
57
+ )
58
+ end
59
+
60
+ # @return [Pathname]
61
+ def source_instance_dump_path
62
+ r = source_instance_dumper
63
+ r.perform
64
+ r.target_path
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_cli/runner'
5
+
6
+ module Avm
7
+ module Tools
8
+ module RunnerWith
9
+ module InstanceDataPerformer
10
+ acts_as_abstract :data_performer_class
11
+ common_concern do
12
+ enable_simple_cache
13
+ include ::EacCli::Runner
14
+ end
15
+
16
+ def run
17
+ if data_performer.performable?
18
+ data_performer.perform
19
+ else
20
+ fatal_error("Cannot perform: #{data_performer.cannot_perform_reason}")
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ # @return [Avm::Data::Performer]
27
+ def data_performer_uncached
28
+ data_performer_set_includes_excludes(data_performer_class.new(data_owner))
29
+ end
30
+
31
+ # @return [Avm::Data::Performer]
32
+ def data_performer_set_includes_excludes(data_performer)
33
+ %i[include exclude].inject(data_performer) do |a1, e1|
34
+ if_respond(e1, []).inject(a1) { |a2, e2| a2.send(e1, e2) }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.149.0'
5
+ VERSION = '0.151.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.67.1
4
+ version: 0.69.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
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-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.73'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.73.1
19
+ version: '0.75'
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.73'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.73.1
26
+ version: '0.75'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: avm-eac_asciidoctor_base0
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -298,14 +292,14 @@ dependencies:
298
292
  requirements:
299
293
  - - "~>"
300
294
  - !ruby/object:Gem::Version
301
- version: '0.149'
295
+ version: '0.151'
302
296
  type: :runtime
303
297
  prerelease: false
304
298
  version_requirements: !ruby/object:Gem::Requirement
305
299
  requirements:
306
300
  - - "~>"
307
301
  - !ruby/object:Gem::Version
308
- version: '0.149'
302
+ version: '0.151'
309
303
  - !ruby/object:Gem::Dependency
310
304
  name: eac_ruby_utils
311
305
  requirement: !ruby/object:Gem::Requirement
@@ -1103,6 +1097,9 @@ files:
1103
1097
  - sub/avm-tools/lib/avm/tools/runner_with.rb
1104
1098
  - sub/avm-tools/lib/avm/tools/runner_with/include_exclude.rb
1105
1099
  - sub/avm-tools/lib/avm/tools/runner_with/instance_data_clear.rb
1100
+ - sub/avm-tools/lib/avm/tools/runner_with/instance_data_dump.rb
1101
+ - sub/avm-tools/lib/avm/tools/runner_with/instance_data_load.rb
1102
+ - sub/avm-tools/lib/avm/tools/runner_with/instance_data_performer.rb
1106
1103
  - sub/avm-tools/lib/avm/tools/self.rb
1107
1104
  - sub/avm-tools/lib/avm/tools/version.rb
1108
1105
  - sub/avm-tools/spec/dummy/avm-tools_stub/avm-tools.gemspec
@@ -1142,6 +1139,8 @@ files:
1142
1139
  - sub/avm/lib/avm/applications/base/stereotype.rb
1143
1140
  - sub/avm/lib/avm/data/callbacks.rb
1144
1141
  - sub/avm/lib/avm/data/clearer.rb
1142
+ - sub/avm/lib/avm/data/dumper.rb
1143
+ - sub/avm/lib/avm/data/loader.rb
1145
1144
  - sub/avm/lib/avm/data/package.rb
1146
1145
  - sub/avm/lib/avm/data/package/base_performer.rb
1147
1146
  - sub/avm/lib/avm/data/package/build_directory.rb