pvcglue 0.1.12 → 0.1.13
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 +8 -8
- data/README.md +2 -2
- data/lib/pvcglue/db.rb +42 -0
- data/lib/pvcglue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDhhMjcyM2U3OWEzMmQxZTJkZGRmYmYwNjdlNDllNjlkYWIzMTQxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjQ5YzNkYjRhYWZmZTI3OWRlNGY0NDhkMDQ3NmQwOWM1MzQ0ODljZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2E3ODdjYmI3YzQ4NmJiOGVjZDcwYjJlYTc3MzY3OWVkMmFkYzlmNjcwNjhh
|
10
|
+
YjM1Y2ZiMDI2ODZmYzliODk1ZDAwMGYwZjFhMzA4MmRkZjVmYjcwOWQ2NDFi
|
11
|
+
MTVjNTQ1ZTc4YjA3ZDhkMzI0ODJjMzljOWZkYzU5Y2FhNzdiOWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDYyNDJkYzRiOGVmZDZkMThiYzAwZDMxNGQ1ZWFkNjAyMDM2ODZjMzIxMzJk
|
14
|
+
YzY4N2RiYTgzNWY3NzI2ZTc2Nzg3MDJlZmJhNTY3ODdiM2U3MDFmNTlkOTI0
|
15
|
+
MjdjN2JjMmM3MDg0MjBlYTA0NDNiMmVmMmM3N2JmZjhiMTliM2M=
|
data/README.md
CHANGED
@@ -146,7 +146,7 @@ Always do a `pvc manager pull` once before making any changes to ensure you have
|
|
146
146
|
pvc ssl import # import .key or .crt or both if no extension given (.crt must be 'pre...
|
147
147
|
pvc version # show the version of PVC...
|
148
148
|
|
149
|
-
https://github.com/radar/guides/blob/master/gem-development.md
|
149
|
+
https://github.com/radar/guides/blob/master/gem-development.md#releasing-the-gem
|
150
150
|
|
151
151
|
## Installation
|
152
152
|
|
@@ -158,7 +158,7 @@ Add these lines to your application's Gemfile. `dotenv-rails` must be listed fi
|
|
158
158
|
|
159
159
|
Then add these lines to your application's Gemfile, whereever you like (usually at the end):
|
160
160
|
|
161
|
-
gem 'pvcglue', "~> 0.1.
|
161
|
+
gem 'pvcglue', "~> 0.1.12", :group => :development
|
162
162
|
gem 'pvcglue_dbutils', "~> 0.5.3"
|
163
163
|
|
164
164
|
And then execute:
|
data/lib/pvcglue/db.rb
CHANGED
@@ -35,6 +35,13 @@ module Pvcglue
|
|
35
35
|
pg_restore(self.class.local, file_name)
|
36
36
|
end
|
37
37
|
|
38
|
+
desc "destroy_all", "destroy_all"
|
39
|
+
|
40
|
+
def destroy_all
|
41
|
+
raise(Thor::Error, "Stage should not be set for this command.") unless Pvcglue.cloud.stage_name.nil?
|
42
|
+
pg_destroy(self.class.local)
|
43
|
+
end
|
44
|
+
|
38
45
|
desc "info", "info"
|
39
46
|
|
40
47
|
def info
|
@@ -132,6 +139,41 @@ module Pvcglue
|
|
132
139
|
end
|
133
140
|
end
|
134
141
|
|
142
|
+
def pg_destroy(dest)
|
143
|
+
sql = "\"select 'drop database '||datname||';' "\
|
144
|
+
"from pg_database "\
|
145
|
+
"where datistemplate=false and datname <> '#{dest.username}' "\
|
146
|
+
"and datname <> 'postgres'\""
|
147
|
+
# I had to use the double for loop because for whatever reason
|
148
|
+
# calling ${line[0]} throws a bad substitution error
|
149
|
+
# This is also why I escaped the string with a regex
|
150
|
+
bash = "#!/bin/bash\n while read line; do "\
|
151
|
+
"s_esc=\"$(echo \"$line\" | sed 's/[^-A-Za-z0-9_]/\\ /g')\"; "\
|
152
|
+
"for word in $s_esc; do "\
|
153
|
+
"if [ $word = \"drop\" ]; then "\
|
154
|
+
"for word in $s_esc; do "\
|
155
|
+
"if [ $word != \"drop\" ] && [ $word != \"database\" ]; then "\
|
156
|
+
"echo \"$s_esc\"; "\
|
157
|
+
"dropdb \"$word\"\; "\
|
158
|
+
"fi "\
|
159
|
+
"done; "\
|
160
|
+
"break; "\
|
161
|
+
"fi "\
|
162
|
+
"done; "\
|
163
|
+
"done < dd.sql; "
|
164
|
+
|
165
|
+
cmd = "psql #{dest.username} -c "
|
166
|
+
cmd += sql
|
167
|
+
cmd += " > dd.sql;"
|
168
|
+
cmd += bash
|
169
|
+
cmd += "rm dd.sql"
|
170
|
+
puts cmd
|
171
|
+
unless system({"PGPASSWORD" => dest.password}, cmd)
|
172
|
+
puts "ERROR:"
|
173
|
+
puts $?.inspect
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
135
177
|
def pg_restore(dest, file_name)
|
136
178
|
Pvcglue.cloud.stage_name == 'production' && destroy_prod?
|
137
179
|
cmd = "pg_restore --verbose --clean --no-acl --no-owner -h #{dest.host} -p #{dest.port}"
|
data/lib/pvcglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pvcglue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Lyric
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|