avm-tools 0.81.0 → 0.82.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: a429748d11abc010cc9622597d60e36016b008c88e6e95e8efd52bd03b8318ae
4
- data.tar.gz: f126c1dd4af4370ad13f398d4aaefc9252ae8b1580e87ea08aed0debeaea652e
3
+ metadata.gz: 168c054cba584a1c2d268e08f1c89d38768fab0c72696b69480db37b0392b605
4
+ data.tar.gz: 43eea0c69bbdf91f0cc7e30a9cf631461ae3023028c6b8191b5631ea5f5c562b
5
5
  SHA512:
6
- metadata.gz: 5ee2c425e977acaded7b64f05088817765b523f4459a3dcac1fed0b0be4d85d8b25b34843a824c2cff3c7446a06319835b73fbcaff05b1d36f4ec45b37496bf7
7
- data.tar.gz: 6687e21a992f5bbc6e992ceb4fa74900d16b1a16dba9d71400dd1c61d4e5e9e66e4265706b161bf9b0ae896354b292bf64361c531da3d01034e3b9d4bd2c4f85
6
+ metadata.gz: 95bc36c2b16d6b625d4400a98e89a05f53a478cc2e78378e917de85ef0ba0833216c48104f7ad5aab779ecc462bbd972444580cf4a244b1c700949dcbfd460c6
7
+ data.tar.gz: 884b8fa7d13e6d590b61c71fa512986ba37d22630c55ea7bad36fecb475f9a5a2c2249535e9b28b3366215f32ae117a57ebb30b13a92d2e0526c2b620d90671e
@@ -12,11 +12,12 @@ module Avm
12
12
  enable_console_speaker
13
13
 
14
14
  %w[dump load].each do |action|
15
+ method_name = "#{action}_command"
15
16
  class_eval <<~CODE, __FILE__, __LINE__ + 1
16
17
  # Should be overrided.
17
18
  # @return [EacRubyUtils::Envs::Command]
18
- def #{action}_command
19
- fail "Abstract method. Override in #{singleton_class}."
19
+ def #{method_name}
20
+ fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
20
21
  end
21
22
  CODE
22
23
 
@@ -69,7 +70,7 @@ module Avm
69
70
  def load(data_path)
70
71
  run_callbacks :load do
71
72
  infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
72
- load_command.execute!(input_file: data_path)
73
+ do_load(data_path)
73
74
  end
74
75
  end
75
76
 
@@ -79,6 +80,10 @@ module Avm
79
80
  dump_command.execute!(output_file: data_path)
80
81
  end
81
82
 
83
+ def do_load(data_path)
84
+ load_command.execute!(input_file: data_path)
85
+ end
86
+
82
87
  private
83
88
 
84
89
  def unit_on_directory_path(directory, identifier)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'avm/data/instance/unit'
4
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'curb'
5
6
  require 'open-uri'
6
7
 
7
8
  module Avm
@@ -17,8 +18,35 @@ module Avm
17
18
  end
18
19
  end
19
20
 
21
+ def do_load(data_path)
22
+ do_load_by_web(data_path) || do_load_by_rake(data_path) || raise('Failed to load')
23
+ end
24
+
25
+ def do_load_by_web(data_path)
26
+ c = Curl::Easy.new(import_url)
27
+ c.multipart_form_post = true
28
+ c.http_post(Curl::PostField.file('redmine_with_git_tableless_load[path]', data_path))
29
+ c.perform
30
+ true
31
+ rescue Curl::Err::ConnectionFailedError
32
+ false
33
+ end
34
+
35
+ def do_load_by_rake(data_path)
36
+ instance.bundle('exec', 'rake', "redmine_with_git:load:all[#{data_path}]").system
37
+ true
38
+ end
39
+
20
40
  def export_url
21
- uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + '/backup/export'
41
+ url('/backup/export')
42
+ end
43
+
44
+ def import_url
45
+ url('/backup/import.json')
46
+ end
47
+
48
+ def url(path)
49
+ uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + path
22
50
  uri.query_values = { key: instance.read_entry('admin.api_key') }
23
51
  uri.to_s
24
52
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.81.0'
5
+ VERSION = '0.82.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.81.0
4
+ version: 0.82.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company