parity 2.1.0 → 2.2.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
2
  SHA1:
3
- metadata.gz: ceb019ad2c690a6ba32f87972f1451c3cb045919
4
- data.tar.gz: b4895f2489581e5e38ec09c8b060a53028e6e1fe
3
+ metadata.gz: b2f04e5261a33b79ce3469c1622e031c9e6754ad
4
+ data.tar.gz: ed3aef4363acc66e30d6c39bed3163594a34a583
5
5
  SHA512:
6
- metadata.gz: 5e1ee285bbc6264ab655ae23eed8a96422df8e009dcf1e1fa5ab9fbb34d57d151aeb5fa7bfa895d29028d3001d1342e8e6dae4e6726f9bb026d3a5b9b4167dab
7
- data.tar.gz: e890c170dcae62e81fa4f296f21d7433708d56d06a0e2f16ca908a2374c90d812d14dfc5aa98d7e953a835a2616a95f604dc6786c91947f317709e514413f253
6
+ metadata.gz: b967730a15f8b0cfc8d0c2c8b694560ee0e0da9488efa9aa70420bb743a8cc4a51b8f485bc64c7105c625263aa1e5893452f77260af3c276af3b3e66839ccd00
7
+ data.tar.gz: 27a93789ecf6fb18956c5a0b9357806877df2a72be4fa79eae0861edcb3dbc767abe53bdd922ff2806ca33394735b6be5fb738d3d9135379efa93b66ec9ccf9a
data/README.md CHANGED
@@ -11,6 +11,13 @@ On OS X, this installs everything you need:
11
11
  brew tap thoughtbot/formulae
12
12
  brew install parity
13
13
 
14
+ On Debian:
15
+
16
+ wget -qO - https://apt.thoughtbot.com/thoughtbot.gpg.key | sudo apt-key add -
17
+ echo "deb http://apt.thoughtbot.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/thoughtbot.list
18
+ sudo apt-get update
19
+ sudo apt-get install parity
20
+
14
21
  On other systems you can:
15
22
 
16
23
  1. Download the package for your system from the [releases page][releases]
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH << File.expand_path("..", __FILE__)
2
2
 
3
+ require "parity/heroku_app_name"
3
4
  require "parity/version"
4
5
  require "parity/environment"
5
6
  require "parity/usage"
@@ -22,13 +22,12 @@ module Parity
22
22
  end
23
23
  end
24
24
 
25
- protected
25
+ private
26
26
 
27
27
  attr_reader :additional_args, :from, :to
28
28
 
29
- private
30
-
31
29
  def restore_from_development
30
+ reset_remote_database
32
31
  Kernel.system(
33
32
  "heroku pg:push #{development_db} DATABASE_URL --remote #{to} "\
34
33
  "#{additional_args}",
@@ -46,6 +45,17 @@ module Parity
46
45
  Kernel.system("dropdb #{development_db} && createdb #{development_db}")
47
46
  end
48
47
 
48
+ def reset_remote_database
49
+ Kernel.system(
50
+ "heroku pg:reset --remote #{to} #{additional_args} "\
51
+ "--confirm #{heroku_app_name}",
52
+ )
53
+ end
54
+
55
+ def heroku_app_name
56
+ HerokuAppName.new(to).to_s
57
+ end
58
+
49
59
  def download_remote_backup
50
60
  Kernel.system(
51
61
  "curl -o tmp/latest.backup \"$(heroku pg:backups:url --remote #{from})\"",
@@ -65,6 +75,7 @@ module Parity
65
75
  end
66
76
 
67
77
  def restore_to_remote_environment
78
+ reset_remote_database
68
79
  Kernel.system(
69
80
  "heroku pg:backups:restore #{backup_from} --remote #{to} "\
70
81
  "#{additional_args}",
@@ -86,11 +86,15 @@ module Parity
86
86
  end
87
87
 
88
88
  def restore_confirmation_argument
89
- unless PROTECTED_ENVIRONMENTS.include?(environment)
89
+ unless PROTECTED_ENVIRONMENTS.include?(environment) || from_development?
90
90
  "--confirm #{heroku_app_name}"
91
91
  end
92
92
  end
93
93
 
94
+ def from_development?
95
+ arguments.first == "development"
96
+ end
97
+
94
98
  def console
95
99
  Kernel.system(command_for_remote("run rails console"))
96
100
  end
@@ -129,10 +133,7 @@ module Parity
129
133
  end
130
134
 
131
135
  def heroku_app_name
132
- @heroku_app_name ||= Open3.
133
- capture3(command_for_remote("info"))[0].
134
- split("\n")[0].
135
- gsub(/(\s|=)+/, "")
136
+ HerokuAppName.new(environment).to_s
136
137
  end
137
138
 
138
139
  def command_for_remote(command)
@@ -0,0 +1,18 @@
1
+ module Parity
2
+ class HerokuAppName
3
+ def initialize(environment)
4
+ @environment = environment
5
+ end
6
+
7
+ def to_s
8
+ @heroku_app_name ||= Open3.
9
+ capture3("heroku info --remote #{environment}")[0].
10
+ split("\n")[0].
11
+ gsub(/(\s|=)+/, "")
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :environment
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Parity
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parity
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-24 00:00:00.000000000 Z
12
+ date: 2017-05-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |2
15
15
  Development/staging/production parity makes it easier for
@@ -30,6 +30,7 @@ files:
30
30
  - lib/parity.rb
31
31
  - lib/parity/backup.rb
32
32
  - lib/parity/environment.rb
33
+ - lib/parity/heroku_app_name.rb
33
34
  - lib/parity/usage.rb
34
35
  - lib/parity/version.rb
35
36
  homepage: https://github.com/thoughtbot/parity
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
53
  version: '0'
53
54
  requirements: []
54
55
  rubyforge_project:
55
- rubygems_version: 2.6.8
56
+ rubygems_version: 2.4.5
56
57
  signing_key:
57
58
  specification_version: 4
58
59
  summary: Shell commands for development, staging, and production parity.