pgtk 0.29.2 → 0.29.3
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 +4 -4
- data/lib/pgtk/pgsql_task.rb +12 -6
- data/lib/pgtk/version.rb +1 -1
- data/lib/pgtk/wire.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed1f139f521063e30992649b32a67bc125d5cd2ae549e56da21c0e88b600455b
|
|
4
|
+
data.tar.gz: 3994612c8c3856d246e6a28a5656e23033aa4cfe8433ca6d8d75dfaaa7d5d41b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5957d0bb3e4921d457726aaae131ee0356f5aac2cfe8dcd0d2df658742822026fd84f098c6da3d62078d27bf70bc3096b98d7a9c625f5464f1d5efb51ce3874
|
|
7
|
+
data.tar.gz: 9294d02de72588841dac47a066b7833e25bd0532d5c3a92a3f7ac7d1f59acd1b51277f1f127c897cae023b57dceea6e4a210bc2dcedcab416db8518397bd0709
|
data/lib/pgtk/pgsql_task.rb
CHANGED
|
@@ -91,9 +91,14 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
|
91
91
|
private
|
|
92
92
|
|
|
93
93
|
def run
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
pg_out = qbash('postgres -V; initdb -V', accept: nil, both: true)
|
|
95
|
+
local = pg_out[1].zero?
|
|
96
|
+
docker_out = qbash('docker -v', accept: nil, both: true)
|
|
97
|
+
docker = docker_out[1].zero?
|
|
98
|
+
unless local || docker
|
|
99
|
+
raise \
|
|
100
|
+
"Failed to find either PostgreSQL or Docker:\n#{pg_out.first}\n#{docker_out.first}"
|
|
101
|
+
end
|
|
97
102
|
raise 'You cannot force Docker to run, because it is not installed locally' if @force_docker && !docker
|
|
98
103
|
raise "Option 'dir' is mandatory" unless @dir
|
|
99
104
|
raise "Option 'yaml' is mandatory" unless @yaml
|
|
@@ -143,7 +148,6 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
|
143
148
|
[
|
|
144
149
|
'docker',
|
|
145
150
|
'run',
|
|
146
|
-
'--name pgtk',
|
|
147
151
|
"--publish #{port}:5432",
|
|
148
152
|
"-e POSTGRES_USER=#{Shellwords.escape(@user)}",
|
|
149
153
|
"-e POSTGRES_PASSWORD=#{Shellwords.escape(@password)}",
|
|
@@ -158,8 +162,10 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
|
158
162
|
container = out.scan(/[a-f0-9]+\Z/).first
|
|
159
163
|
File.write(File.join(home, 'docker-container'), container)
|
|
160
164
|
at_exit do
|
|
161
|
-
qbash("docker
|
|
162
|
-
|
|
165
|
+
if qbash("docker ps --format '{{.ID}}' --no-trunc | grep '#{container}'", both: true, accept: nil)[1].zero?
|
|
166
|
+
qbash("docker stop #{container}")
|
|
167
|
+
puts "PostgreSQL docker container #{container.inspect} was stopped" unless @quiet
|
|
168
|
+
end
|
|
163
169
|
end
|
|
164
170
|
begin
|
|
165
171
|
WaitUtil.wait_for_service('PG in Docker', 'localhost', port, timeout_sec: 10, delay_sec: 0.1)
|
data/lib/pgtk/version.rb
CHANGED
data/lib/pgtk/wire.rb
CHANGED
|
@@ -70,11 +70,11 @@ class Pgtk::Wire::Env
|
|
|
70
70
|
raise "The environment variable #{@var.inspect} is not set" if v.nil?
|
|
71
71
|
uri = URI(v)
|
|
72
72
|
Pgtk::Wire::Direct.new(
|
|
73
|
-
host: uri.host,
|
|
73
|
+
host: CGI.unescape(uri.host),
|
|
74
74
|
port: uri.port,
|
|
75
|
-
dbname: uri.path[1..],
|
|
76
|
-
user: uri.userinfo.split(':')[0],
|
|
77
|
-
password: uri.userinfo.split(':')[1]
|
|
75
|
+
dbname: CGI.unescape(uri.path[1..]),
|
|
76
|
+
user: CGI.unescape(uri.userinfo.split(':')[0]),
|
|
77
|
+
password: CGI.unescape(uri.userinfo.split(':')[1])
|
|
78
78
|
).connection
|
|
79
79
|
end
|
|
80
80
|
end
|