pgtk 0.30.5 → 0.30.7
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/Gemfile +1 -0
- data/Gemfile.lock +17 -13
- data/Rakefile +2 -2
- data/lib/pgtk/impatient.rb +5 -5
- data/lib/pgtk/liquibase_task.rb +83 -93
- data/lib/pgtk/liquicheck_task.rb +59 -62
- data/lib/pgtk/pgsql_task.rb +63 -89
- data/lib/pgtk/pool.rb +12 -12
- data/lib/pgtk/retry.rb +13 -10
- data/lib/pgtk/spy.rb +2 -2
- data/lib/pgtk/stash.rb +217 -202
- data/lib/pgtk/version.rb +1 -2
- data/lib/pgtk/wire.rb +81 -85
- data/lib/pgtk.rb +0 -1
- data/pgtk.gemspec +13 -13
- metadata +1 -1
data/lib/pgtk/wire.rb
CHANGED
|
@@ -13,98 +13,94 @@ require_relative '../pgtk'
|
|
|
13
13
|
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
14
14
|
# License:: MIT
|
|
15
15
|
module Pgtk::Wire
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@password = password
|
|
38
|
-
end
|
|
16
|
+
# Simple wire with details.
|
|
17
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
18
|
+
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
19
|
+
# License:: MIT
|
|
20
|
+
class Direct
|
|
21
|
+
# Constructor.
|
|
22
|
+
#
|
|
23
|
+
# @param [String] host Host name of the PostgreSQL server
|
|
24
|
+
# @param [Integer] port Port number of the PostgreSQL server
|
|
25
|
+
# @param [String] dbname Database name
|
|
26
|
+
# @param [String] user Username
|
|
27
|
+
# @param [String] password Password
|
|
28
|
+
def initialize(host:, port:, dbname:, user:, password:)
|
|
29
|
+
raise(ArgumentError, "The host can't be nil") if host.nil?
|
|
30
|
+
@host = host
|
|
31
|
+
raise(ArgumentError, "The port can't be nil") if port.nil?
|
|
32
|
+
@port = port
|
|
33
|
+
@dbname = dbname
|
|
34
|
+
@user = user
|
|
35
|
+
@password = password
|
|
36
|
+
end
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
user: @user, password: @password
|
|
45
|
-
)
|
|
38
|
+
# Create a new connection to PostgreSQL server.
|
|
39
|
+
def connection
|
|
40
|
+
PG.connect(dbname: @dbname, host: @host, port: @port, user: @user, password: @password)
|
|
41
|
+
end
|
|
46
42
|
end
|
|
47
|
-
end
|
|
48
43
|
|
|
49
|
-
# Using ENV variable.
|
|
50
|
-
#
|
|
51
|
-
# The value of the variable should be in this format:
|
|
52
|
-
#
|
|
53
|
-
# postgres://user:password@host:port/dbname
|
|
54
|
-
#
|
|
55
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
56
|
-
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
57
|
-
# License:: MIT
|
|
58
|
-
class Pgtk::Wire::Env
|
|
59
|
-
# Constructor.
|
|
44
|
+
# Using ENV variable.
|
|
60
45
|
#
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
# The value of the variable should be in this format:
|
|
47
|
+
#
|
|
48
|
+
# postgres://user:password@host:port/dbname
|
|
49
|
+
#
|
|
50
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
51
|
+
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
52
|
+
# License:: MIT
|
|
53
|
+
class Env
|
|
54
|
+
# Constructor.
|
|
55
|
+
#
|
|
56
|
+
# @param [String] var The name of the environment variable with the connection URL
|
|
57
|
+
def initialize(var = 'DATABASE_URL')
|
|
58
|
+
raise(ArgumentError, "The name of the environment variable can't be nil") if var.nil?
|
|
59
|
+
@value = ENV.fetch(var, nil)
|
|
60
|
+
raise(ArgumentError, "The environment variable #{@value.inspect} is not set") if @value.nil?
|
|
61
|
+
end
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
# Create a new connection to PostgreSQL server.
|
|
64
|
+
def connection
|
|
65
|
+
uri = URI(@value)
|
|
66
|
+
Pgtk::Wire::Direct.new(
|
|
67
|
+
host: CGI.unescape(uri.host),
|
|
68
|
+
port: uri.port || 5432,
|
|
69
|
+
dbname: CGI.unescape(uri.path[1..]),
|
|
70
|
+
user: CGI.unescape(uri.userinfo.split(':')[0]),
|
|
71
|
+
password: CGI.unescape(uri.userinfo.split(':')[1])
|
|
72
|
+
).connection
|
|
73
|
+
end
|
|
78
74
|
end
|
|
79
|
-
end
|
|
80
75
|
|
|
81
|
-
# Using configuration from YAML file.
|
|
82
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
83
|
-
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
84
|
-
# License:: MIT
|
|
85
|
-
class
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
76
|
+
# Using configuration from YAML file.
|
|
77
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
78
|
+
# Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
|
|
79
|
+
# License:: MIT
|
|
80
|
+
class Yaml
|
|
81
|
+
# Constructor.
|
|
82
|
+
#
|
|
83
|
+
# @param [String] file Path to the YAML configuration file
|
|
84
|
+
# @param [String] node The root node name in the YAML file containing PostgreSQL configuration
|
|
85
|
+
def initialize(file, node = 'pgsql')
|
|
86
|
+
raise(ArgumentError, "The name of the file can't be nil") if file.nil?
|
|
87
|
+
@file = file
|
|
88
|
+
raise(ArgumentError, "The name of the node in the YAML file can't be nil") if node.nil?
|
|
89
|
+
@node = node
|
|
90
|
+
end
|
|
96
91
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
# Create a new connection to PostgreSQL server.
|
|
93
|
+
def connection
|
|
94
|
+
raise(ArgumentError, "The file #{@file.inspect} not found") unless File.exist?(@file)
|
|
95
|
+
cfg = YAML.load_file(@file)
|
|
96
|
+
raise(ArgumentError, "The node '#{@node}' not found in YAML file #{@file.inspect}") unless cfg[@node]
|
|
97
|
+
Pgtk::Wire::Direct.new(
|
|
98
|
+
host: cfg[@node]['host'],
|
|
99
|
+
port: cfg[@node]['port'],
|
|
100
|
+
dbname: cfg[@node]['dbname'],
|
|
101
|
+
user: cfg[@node]['user'],
|
|
102
|
+
password: cfg[@node]['password']
|
|
103
|
+
).connection
|
|
104
|
+
end
|
|
109
105
|
end
|
|
110
106
|
end
|
data/lib/pgtk.rb
CHANGED
data/pgtk.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ lib = File.expand_path('lib', __dir__)
|
|
|
9
9
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
10
10
|
require_relative 'lib/pgtk/version'
|
|
11
11
|
Gem::Specification.new do |s|
|
|
12
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?
|
|
12
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
|
|
13
13
|
s.required_ruby_version = '>= 3.2'
|
|
14
14
|
s.name = 'pgtk'
|
|
15
15
|
s.version = Pgtk::VERSION
|
|
@@ -26,17 +26,17 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
27
27
|
s.rdoc_options = ['--charset=UTF-8']
|
|
28
28
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
|
29
|
-
s.add_dependency
|
|
30
|
-
s.add_dependency
|
|
31
|
-
s.add_dependency
|
|
32
|
-
s.add_dependency
|
|
33
|
-
s.add_dependency
|
|
34
|
-
s.add_dependency
|
|
35
|
-
s.add_dependency
|
|
36
|
-
s.add_dependency
|
|
37
|
-
s.add_dependency
|
|
38
|
-
s.add_dependency
|
|
39
|
-
s.add_dependency
|
|
40
|
-
s.add_dependency
|
|
29
|
+
s.add_dependency('backtrace', '~>0.4')
|
|
30
|
+
s.add_dependency('concurrent-ruby', '~>1.3')
|
|
31
|
+
s.add_dependency('donce', '~>0.0')
|
|
32
|
+
s.add_dependency('ellipsized', '~>0.3')
|
|
33
|
+
s.add_dependency('joined', '~>0.3')
|
|
34
|
+
s.add_dependency('logger', '~>1.7')
|
|
35
|
+
s.add_dependency('loog', '~>0.6')
|
|
36
|
+
s.add_dependency('pg', '~>1.1')
|
|
37
|
+
s.add_dependency('qbash', '~>0.4')
|
|
38
|
+
s.add_dependency('random-port', '~>0.7')
|
|
39
|
+
s.add_dependency('tago', '~>0.1')
|
|
40
|
+
s.add_dependency('waitutil', '~> 0.2')
|
|
41
41
|
s.metadata['rubygems_mfa_required'] = 'true'
|
|
42
42
|
end
|