avm-tools 0.150.0 → 0.151.1

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: 1bab59c8dee4bea0f37e1c0d6e9d5cebff9b299aa8f0381ea9e64c47e3404b80
4
- data.tar.gz: 5479c8cfa3d9da70d5359ca226eb051f7854b30bdb68de2ac3579b6eb95b5f54
3
+ metadata.gz: bfb9ed8f8b1418ecd980d2e3d540bca717ba403dbbf758ba3bfa39375c433db4
4
+ data.tar.gz: 18781412c293f956a786b2f9da16218b8cf6c042273189c806e0a069572c466f
5
5
  SHA512:
6
- metadata.gz: ed6c7a23f72685841427cbd84fe08cac9b92e42d3c4f5bee6794c05d2680a1cdbfbb3e24d9d92ab93524a07e88e46f121dc1b41f8b0f9147a885a82f616a1f3c
7
- data.tar.gz: d45232d1d1ac68ea6f1080ee6a73a22c908ed8c9f530ac0ec2d5a5a0261b6e277080d25a8eb844ef1e1596865a6a522756b7ba7c3c009a5e0b6bf0f9bf79675c
6
+ metadata.gz: 9582c923d0a7eaecf6449c73b00f694080404b6d598a1118c419cf8dd502a1bfc83fcb3153b21b5e5ea10ae309f2e64aff8167b9d34b2495aa3de5945412ebbe
7
+ data.tar.gz: 43843c16118268169b44dd69eda28f77ea2c96e39c0f9f604fcc9d252b29a47158907a645436e62effb703172b2a035ae119fe27d6c5ef5fa729bb54e229a2c9
@@ -9,46 +9,13 @@ 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
12
+ runner_with :help, :include_exclude, :instance_data_load do
13
+ desc 'Load utility for instance.'
16
14
  end
17
15
 
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)
16
+ # @return [Avm::Instances::Data::Package]
17
+ def source_instance_data_owner
18
+ source_instance.data_package
52
19
  end
53
20
  end
54
21
  end
@@ -10,17 +10,11 @@ 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
13
+ runner_with :help, :instance_data_load
20
14
 
21
- # @return [Pathname]
22
- def dump_path
23
- parsed.dump_path.to_pathname
15
+ # @return [Avm::Instances::Data::Unit]
16
+ def source_instance_data_owner
17
+ source_instance.data_package.unit(data_owner.identifier)
24
18
  end
25
19
  end
26
20
  end
@@ -28,14 +28,10 @@ module Avm
28
28
  end
29
29
 
30
30
  def entry_keys_banner
31
- ::Avm::Instances::EntryKeys.all.each do |key|
31
+ instance.entry_keys.each do |key|
32
32
  infov key, instance.read_entry_optional(key)
33
33
  end
34
34
  end
35
-
36
- def instance
37
- runner_context.call(:instance)
38
- end
39
35
  end
40
36
  end
41
37
  end
@@ -10,8 +10,6 @@ module Avm
10
10
  module InstanceDataDump
11
11
  common_concern do
12
12
  enable_simple_cache
13
- include ::Avm::Tools::RunnerWith::InstanceDataPerformer
14
-
15
13
  runner_definition do
16
14
  bool_opt '-w', '--rewrite', 'Forces dump overwrite.'
17
15
  pos_arg :dump_path, optional: true
@@ -23,6 +21,8 @@ module Avm
23
21
  end
24
22
  end
25
23
 
24
+ include ::Avm::Tools::RunnerWith::InstanceDataPerformer
25
+
26
26
  DUMP_EXPIRE_TIME = 1.day
27
27
  NO_DUMP_MESSAGE = 'Dump "%s" already exist and rewrite options was no setted nor ' \
28
28
  'dump was expired.'
@@ -41,25 +41,18 @@ module Avm
41
41
 
42
42
  # @return [Avm::Data::Dumper]
43
43
  def data_performer_uncached
44
- super.existing(dump_existing)
44
+ r = super.overwrite(parsed.rewrite?)
45
+ parsed.dump_path.if_present(r) { |v| r.target_path(v.to_pathname) }
45
46
  end
46
47
 
47
48
  # @return [Pathname]
48
49
  def dump_path
49
- (parsed.dump_path || default_dump_path).to_pathname
50
+ data_performer.target_path
50
51
  end
51
52
 
52
53
  def default_dump_path
53
54
  data_performer.default_dump_path
54
55
  end
55
-
56
- def dump_existing
57
- if parsed.rewrite?
58
- ::Avm::Data::Package::Dump::EXISTING_ROTATE
59
- else
60
- ::Avm::Data::Package::Dump::EXISTING_ROTATE_EXPIRED
61
- end
62
- end
63
56
  end
64
57
  end
65
58
  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_owner).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
@@ -17,7 +17,7 @@ module Avm
17
17
  if data_performer.performable?
18
18
  data_performer.perform
19
19
  else
20
- warn("Cannot perform: #{data_performer.cannot_perform_reason}")
20
+ fatal_error("Cannot perform: #{data_performer.cannot_perform_reason}")
21
21
  end
22
22
  end
23
23
 
@@ -25,7 +25,12 @@ module Avm
25
25
 
26
26
  # @return [Avm::Data::Performer]
27
27
  def data_performer_uncached
28
- %i[include exclude].inject(data_performer_class.new(data_owner)) do |a1, e1|
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|
29
34
  if_respond(e1, []).inject(a1) { |a2, e2| a2.send(e1, e2) }
30
35
  end
31
36
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.150.0'
5
+ VERSION = '0.151.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.150.0
4
+ version: 0.151.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
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,28 +16,28 @@ 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: avm
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.74'
33
+ version: '0.76'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.74'
40
+ version: '0.76'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: avm-eac_ruby_base1
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -312,6 +312,7 @@ files:
312
312
  - lib/avm/tools/runner_with/include_exclude.rb
313
313
  - lib/avm/tools/runner_with/instance_data_clear.rb
314
314
  - lib/avm/tools/runner_with/instance_data_dump.rb
315
+ - lib/avm/tools/runner_with/instance_data_load.rb
315
316
  - lib/avm/tools/runner_with/instance_data_performer.rb
316
317
  - lib/avm/tools/self.rb
317
318
  - lib/avm/tools/version.rb