parity 0.9.2 → 0.9.3.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/lib/parity.rb +3 -0
- data/lib/parity/backup.rb +17 -11
- data/lib/parity/environment.rb +12 -8
- data/lib/parity/usage.rb +1 -1
- data/lib/parity/version.rb +1 -1
- metadata +34 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308a5394f878999734f67e7cf5eeb7292eca9de5
|
4
|
+
data.tar.gz: 0f144357d9ce25752690d2ade17779732194fa01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbcc327fdad16ce467a8e720caec5708fb9adcc1863f2b9195e7c0599fd9c3f9300de2dcc7ea90171cdd7637b3864f6ef7f3a670c7f29af93b965c2ebfd648cc
|
7
|
+
data.tar.gz: 6d395b0d355e7bbde331e5b9fa369f40a968bde44a7e5e9b700f6d072a2bf76150dea765aae1ed278331fa7d90935793887bf481cf41d57969bb5de7f38496aa
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ Backup a database:
|
|
36
36
|
production backup
|
37
37
|
staging backup
|
38
38
|
|
39
|
-
Restore a production or staging database backup into development:
|
39
|
+
Restore a production or staging database backup into development (`restore-from` is an alias for `restore`):
|
40
40
|
|
41
41
|
development restore production
|
42
42
|
development restore staging
|
@@ -49,11 +49,18 @@ Push your local development database backup up to staging:
|
|
49
49
|
|
50
50
|
staging restore development
|
51
51
|
|
52
|
-
Deploy from master
|
52
|
+
Deploy from master to production
|
53
|
+
and migrate and restart the dynos if necessary:
|
53
54
|
|
54
55
|
production deploy
|
56
|
+
|
57
|
+
Deploy the current branch to staging or a feature branch
|
58
|
+
and migrate and restart the dynos if necessary:
|
59
|
+
|
55
60
|
staging deploy
|
56
61
|
|
62
|
+
_Note that deploys to non-production environments use `git push --force`._
|
63
|
+
|
57
64
|
Open a console:
|
58
65
|
|
59
66
|
production console
|
@@ -91,8 +98,6 @@ Parity expects:
|
|
91
98
|
* A `production` remote pointing to the production Heroku app.
|
92
99
|
* There is a `config/database.yml` file that can be parsed as YAML for
|
93
100
|
`['development']['database']`.
|
94
|
-
* The Heroku apps are named like `app-staging` and `app-production`
|
95
|
-
where `app` is equal to `basename $PWD`.
|
96
101
|
|
97
102
|
Customization
|
98
103
|
-------------
|
@@ -139,7 +144,7 @@ See guidelines in [`RELEASING.md`](RELEASING.md) for details
|
|
139
144
|
License
|
140
145
|
-------
|
141
146
|
|
142
|
-
Parity is © 2013-
|
147
|
+
Parity is © 2013-2016 thoughtbot, inc.
|
143
148
|
It is free software,
|
144
149
|
and may be redistributed under the terms specified in the [LICENSE] file.
|
145
150
|
|
data/lib/parity.rb
CHANGED
data/lib/parity/backup.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
module Parity
|
4
2
|
class Backup
|
3
|
+
BLANK_ARGUMENTS = "".freeze
|
4
|
+
DATABASE_YML_RELATIVE_PATH = "config/database.yml".freeze
|
5
|
+
DEVELOPMENT_ENVIRONMENT_KEY_NAME = "development".freeze
|
6
|
+
DATABASE_KEY_NAME = "database".freeze
|
7
|
+
|
5
8
|
def initialize(args)
|
6
9
|
@from, @to = args.values_at(:from, :to)
|
7
|
-
@additional_args = args[:additional_args] ||
|
10
|
+
@additional_args = args[:additional_args] || BLANK_ARGUMENTS
|
8
11
|
end
|
9
12
|
|
10
13
|
def restore
|
11
|
-
if to ==
|
14
|
+
if to == DEVELOPMENT_ENVIRONMENT_KEY_NAME
|
12
15
|
restore_to_development
|
13
|
-
elsif from ==
|
16
|
+
elsif from == DEVELOPMENT_ENVIRONMENT_KEY_NAME
|
14
17
|
restore_from_development
|
15
18
|
else
|
16
19
|
restore_to_remote_environment
|
@@ -46,10 +49,6 @@ module Parity
|
|
46
49
|
)
|
47
50
|
end
|
48
51
|
|
49
|
-
def pg_restore
|
50
|
-
"pg_restore --verbose --clean --no-acl --no-owner -d #{development_db}"
|
51
|
-
end
|
52
|
-
|
53
52
|
def restore_to_remote_environment
|
54
53
|
Kernel.system(
|
55
54
|
"heroku pg:backups restore #{backup_from} --remote #{to} "\
|
@@ -66,8 +65,15 @@ module Parity
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def development_db
|
69
|
-
|
70
|
-
|
68
|
+
YAML.load(parsed_database_yml).
|
69
|
+
fetch(DEVELOPMENT_ENVIRONMENT_KEY_NAME).
|
70
|
+
fetch(DATABASE_KEY_NAME)
|
71
|
+
end
|
72
|
+
|
73
|
+
def parsed_database_yml
|
74
|
+
Dotenv.load
|
75
|
+
yaml_file = IO.read(DATABASE_YML_RELATIVE_PATH)
|
76
|
+
ERB.new(yaml_file).result
|
71
77
|
end
|
72
78
|
end
|
73
79
|
end
|
data/lib/parity/environment.rb
CHANGED
@@ -19,10 +19,8 @@ module Parity
|
|
19
19
|
attr_accessor :environment, :subcommand, :arguments
|
20
20
|
|
21
21
|
def run_command
|
22
|
-
if
|
23
|
-
|
24
|
-
elsif self.class.private_method_defined?(subcommand)
|
25
|
-
send(subcommand)
|
22
|
+
if self.class.private_method_defined?(methodized_subcommand)
|
23
|
+
send(methodized_subcommand)
|
26
24
|
else
|
27
25
|
run_via_cli
|
28
26
|
end
|
@@ -71,6 +69,8 @@ module Parity
|
|
71
69
|
end
|
72
70
|
end
|
73
71
|
|
72
|
+
alias :restore_from :restore
|
73
|
+
|
74
74
|
def production?
|
75
75
|
environment == "production"
|
76
76
|
end
|
@@ -125,12 +125,12 @@ module Parity
|
|
125
125
|
)[0].strip
|
126
126
|
end
|
127
127
|
|
128
|
-
def
|
129
|
-
|
128
|
+
def git_remote
|
129
|
+
Git.init.remote(environment).url
|
130
130
|
end
|
131
131
|
|
132
|
-
def
|
133
|
-
|
132
|
+
def heroku_app_name
|
133
|
+
git_remote.split(":").last.split(".").first
|
134
134
|
end
|
135
135
|
|
136
136
|
def run_migrations?
|
@@ -155,5 +155,9 @@ module Parity
|
|
155
155
|
git diff --quiet #{environment}/master..master -- db/migrate
|
156
156
|
})
|
157
157
|
end
|
158
|
+
|
159
|
+
def methodized_subcommand
|
160
|
+
subcommand.gsub("-", "_").to_sym
|
161
|
+
end
|
158
162
|
end
|
159
163
|
end
|
data/lib/parity/usage.rb
CHANGED
data/lib/parity/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: git
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
13
41
|
description: |2
|
14
42
|
Development/staging/production parity makes it easier for
|
15
43
|
those who write the code to deploy the code.
|
@@ -46,12 +74,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
74
|
version: '0'
|
47
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
76
|
requirements:
|
49
|
-
- - "
|
77
|
+
- - ">"
|
50
78
|
- !ruby/object:Gem::Version
|
51
|
-
version:
|
79
|
+
version: 1.3.1
|
52
80
|
requirements: []
|
53
81
|
rubyforge_project:
|
54
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.5.2
|
55
83
|
signing_key:
|
56
84
|
specification_version: 4
|
57
85
|
summary: Shell commands for development, staging, and production parity.
|