mina-data_sync 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 37645f8d3589d9c55c0e6042f047918331c7875f
4
- data.tar.gz: aabc85f46af7f5282784fbec8b14f04407f4c5a9
2
+ SHA256:
3
+ metadata.gz: 73113d75dcc06e2ed520c41c9eec7ead5f81997a9e2cc8cbbc303e7028303edd
4
+ data.tar.gz: 03705d30c25c7fa53e7f0cd86b117e1b26e961197385dc0293000cc2d2f7b8f9
5
5
  SHA512:
6
- metadata.gz: 29fa23eb847731061d236b957ee2b853f276ed9c8f9de1847426fd8afd99541146f8baafae55fb11bf82f66d57620c78894c316e52b711a30955947bdce63fd2
7
- data.tar.gz: d1a76a1b1e152117fea3289d2b2ffa6fc1887346ddf82053438dc8b80fff73039aa078756d1a429202ace6626ff2a08cdeb5552d28c59b710f9590f30df789d2
6
+ metadata.gz: e175c1eee90f8f4130da6bdc702b74ac650cf5d8fbcfca808bd045eb2b5fbf1b2829e290a4a0b3cd230f80bb30ad83aa982da83b89c59c40822da53e0a555d3e
7
+ data.tar.gz: 06d9dac2dcb74fae366872f5a2dd1c7cf2a4c2eb915717791329e3c26c4709038a38bbb7968ecd3e8436e1d53f152c842b38424dcb0157b9f8d4b06a4dd86d27
@@ -1,6 +1,7 @@
1
1
  require 'yaml'
2
2
  require 'erb'
3
3
  require 'tty-prompt'
4
+ require 'date'
4
5
  require 'mina/data_sync/defaults'
5
6
  require 'mina/data_sync/helpers'
6
7
  require 'mina/data_sync/version'
@@ -9,7 +9,7 @@ COMMAND = <<-RUBY
9
9
  port = dc["port"]
10
10
  arguments = ""
11
11
  case adapter.to_s
12
- when "postgresql"
12
+ when "postgresql", "postgis"
13
13
  arguments += "PGPASSWORD=\\"" + password + "\\" " if password
14
14
  arguments += method == "dump" ? "pg_dump" : "psql -q"
15
15
  arguments += " -d " + database if database
@@ -31,18 +31,17 @@ COMMAND = <<-RUBY
31
31
  RUBY
32
32
 
33
33
  DATA_SYNC = <<-BASH
34
- function data_sync {
35
- ruby -rjson -e '#{COMMAND}' "$@"
36
- };
34
+ data_sync() {
35
+ ruby -rjson -e '#{COMMAND}' "$@"
36
+ };
37
37
  BASH
38
38
 
39
39
  def dump_restore(rails_root, backup_path, mode: :dump, backend: :local)
40
- set :rails_env, 'development' if backend == :local
41
40
  comment %{#{mode == :dump ? 'Dumping' : 'Restoring'} database}
42
41
  command %{cd #{rails_root}}
43
42
  command DATA_SYNC.to_s
44
43
  command %{mkdir -p #{backup_path}}
45
- command %{CONFIG=$(#{fetch(:rails)} runner "puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json")}
44
+ command %{CONFIG=$(RAILS_ENV=#{backend == :local ? 'development' : fetch(:rails_env)} bundle exec rails runner "puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json")}
46
45
  comment %{$(data_sync "#{mode}" "#{backup_path}/#{fetch(:backup_file)}" "$CONFIG")}
47
46
  command %{eval $(data_sync "#{mode}" "#{backup_path}/#{fetch(:backup_file)}" "$CONFIG")}
48
47
  end
@@ -53,7 +52,7 @@ def rsync_db(mode: :remote_to_local)
53
52
  comment %{Copying backup}
54
53
  command %{mkdir -p #{fetch(:local_backup_path)}}
55
54
  comment %{Backup: #{fetch(:local_backup_path)}/#{fetch(:backup_file)}}
56
- command %{rsync --progress -e "ssh -p #{fetch(:port)}" #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/#{fetch(:remote_backup_path)}/#{fetch(:backup_file)} #{fetch(:local_backup_path)}/#{fetch(:backup_file)}}
55
+ command %{rsync --progress -e "ssh -p #{fetch(:port, 22)}" #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/#{fetch(:remote_backup_path)}/#{fetch(:backup_file)} #{fetch(:local_backup_path)}/#{fetch(:backup_file)}}
57
56
  end
58
57
  else
59
58
  run :remote do
@@ -62,7 +61,7 @@ def rsync_db(mode: :remote_to_local)
62
61
  run :local do
63
62
  comment %{Copying backup}
64
63
  comment %{Backup: #{fetch(:remote_backup_path)}/#{fetch(:backup_file)}}
65
- command %{rsync --progress -e "ssh -p #{fetch(:port)}" #{fetch(:local_backup_path)}/#{fetch(:backup_file)} #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}}
64
+ command %{rsync --progress -e "ssh -p #{fetch(:port, 22)}" #{fetch(:local_backup_path)}/#{fetch(:backup_file)} #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}}
66
65
  end
67
66
  end
68
67
  end
@@ -20,7 +20,10 @@ namespace :data_sync do
20
20
  end
21
21
 
22
22
  task :restore_remote do
23
- exit unless TTY::Prompt.new.yes?("Are you sure you want to restore #{fetch(:rails_env)} database?")
23
+ exit unless TTY::Prompt.new.yes?("Are you sure you want to restore #{fetch(:rails_env)} database?") do |q|
24
+ q.suffix ('y/N')
25
+ q.default false
26
+ end
24
27
  run :remote do
25
28
  dump_restore(fetch(:current_path), fetch(:remote_backup_path), mode: :restore, backend: :remote)
26
29
  end
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module DataSync
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "pry", "~> 0"
24
24
 
25
- spec.add_dependency 'mina', '~> 1.0.0'
26
- spec.add_dependency 'tty-prompt'
25
+ spec.add_dependency 'mina', '~> 1.0'
26
+ spec.add_dependency 'tty-prompt', '~> 0.4'
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-data_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stjepan Hadjic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2021-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.0
61
+ version: '1.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.0
68
+ version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tty-prompt
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.4'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.4'
83
83
  description: Description
84
84
  email:
85
85
  - d4be4st@gmail.com
@@ -105,7 +105,7 @@ homepage: https://github.com/d4be4st/mina-data_sync
105
105
  licenses:
106
106
  - MIT
107
107
  metadata: {}
108
- post_install_message:
108
+ post_install_message:
109
109
  rdoc_options: []
110
110
  require_paths:
111
111
  - lib
@@ -120,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.5.1
125
- signing_key:
123
+ rubygems_version: 3.0.3
124
+ signing_key:
126
125
  specification_version: 4
127
126
  summary: Summary
128
127
  test_files: []