pgtk 0.7.5 → 0.8.1
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/.github/workflows/codecov.yml +25 -0
- data/.github/workflows/pdd.yml +15 -0
- data/.github/workflows/rake.yml +29 -0
- data/.github/workflows/xcop.yml +17 -0
- data/.rubocop.yml +2 -0
- data/.rultor.yml +7 -21
- data/.simplecov +8 -6
- data/Gemfile +1 -2
- data/LICENSE.txt +1 -1
- data/README.md +6 -4
- data/Rakefile +1 -1
- data/lib/pgtk/liquibase_task.rb +5 -9
- data/lib/pgtk/pgsql_task.rb +9 -20
- data/lib/pgtk/pool.rb +17 -14
- data/lib/pgtk/version.rb +3 -3
- data/lib/pgtk/wire.rb +6 -6
- data/lib/pgtk.rb +2 -2
- data/pgtk.gemspec +10 -13
- data/renovate.json +6 -0
- data/resources/pom.xml +2 -2
- data/test/test__helper.rb +2 -6
- data/test/test_liquibase_task.rb +1 -1
- data/test/test_pgsql_task.rb +1 -1
- data/test/test_pool.rb +26 -5
- data/test-resources/2019/01-test.xml +1 -1
- data/test-resources/master.xml +1 -1
- metadata +40 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaf408030fd27aadb70b3b60c9905bacd625edc61a40fefac693c6ff5f009b79
|
4
|
+
data.tar.gz: 7a39f9206dbe25972f513a1585be2501d4316c8ad4ac41a5f066a303001f012c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2547d36ec4b3911c2ff9c27583cff79bf66fab67932a00f3ae98f59c14914ed78638a3daed986c7ed64badc2288ce14a82ecb7326cb7b016e52b2376a89a626
|
7
|
+
data.tar.gz: 3dde21fee249a8714b7f3e8a6c18344457dbd0f601533e99beb8b1de903cc32321c1325b865d5cd11e0ef7b8fc6243551c000b25c6e52a22c60f1fb6154e815c
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
name: codecov
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
jobs:
|
8
|
+
codecov:
|
9
|
+
runs-on: ubuntu-22.04
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
- uses: actions/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.7
|
15
|
+
- run: |
|
16
|
+
sudo apt-get update
|
17
|
+
sudo apt-get install -y postgresql-14
|
18
|
+
sudo ln -s /usr/lib/postgresql/14/bin/initdb /bin/initdb
|
19
|
+
sudo ln -s /usr/lib/postgresql/14/bin/postgres /bin/postgres
|
20
|
+
- run: bundle update
|
21
|
+
- run: bundle exec rake
|
22
|
+
- uses: codecov/codecov-action@v3
|
23
|
+
with:
|
24
|
+
file: coverage/.resultset.json
|
25
|
+
fail_ci_if_error: true
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
name: rake
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
name: test
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
os: [ubuntu-20.04]
|
16
|
+
ruby: [2.6]
|
17
|
+
runs-on: ${{ matrix.os }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v3
|
20
|
+
- run: |
|
21
|
+
sudo apt-get update
|
22
|
+
sudo apt-get install -y postgresql-14
|
23
|
+
sudo ln -s /usr/lib/postgresql/14/bin/initdb /bin/initdb
|
24
|
+
sudo ln -s /usr/lib/postgresql/14/bin/postgres /bin/postgres
|
25
|
+
- uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
- run: bundle update
|
29
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
data/.rultor.yml
CHANGED
@@ -1,35 +1,21 @@
|
|
1
|
+
docker:
|
2
|
+
image: yegor256/rultor-image:1.21.0
|
1
3
|
assets:
|
2
4
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
3
|
-
s3cfg: yegor256/home#assets/s3cfg
|
4
5
|
install: |
|
5
|
-
|
6
|
-
sudo
|
7
|
-
sudo apt-get -y install libpq-dev
|
8
|
-
export GEM_HOME=~/.ruby
|
9
|
-
export GEM_PATH=$GEM_HOME:$GEM_PATH
|
10
|
-
sudo apt-get -y update
|
11
|
-
sudo gem install pdd -v 0.20.5
|
6
|
+
pdd -f /dev/null
|
7
|
+
sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
12
8
|
release:
|
13
9
|
script: |-
|
14
|
-
|
15
|
-
rake
|
10
|
+
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
11
|
+
bundle exec rake
|
16
12
|
rm -rf *.gem
|
17
|
-
sed -i "s/
|
13
|
+
sed -i "s/0\.0\.0/${tag}/g" lib/pgtk/version.rb
|
18
14
|
git add lib/pgtk/version.rb
|
19
15
|
git commit -m "version set to ${tag}"
|
20
16
|
gem build pgtk.gemspec
|
21
17
|
chmod 0600 ../rubygems.yml
|
22
18
|
gem push *.gem --config-file ../rubygems.yml
|
23
|
-
commanders:
|
24
|
-
- yegor256
|
25
|
-
architect:
|
26
|
-
- yegor256
|
27
19
|
merge:
|
28
20
|
script: |-
|
29
|
-
bundle install
|
30
21
|
bundle exec rake
|
31
|
-
pdd -f /dev/null
|
32
|
-
deploy:
|
33
|
-
script: |-
|
34
|
-
echo "There is nothing to deploy"
|
35
|
-
exit -1
|
data/.simplecov
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -18,21 +20,21 @@
|
|
18
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
21
|
# SOFTWARE.
|
20
22
|
|
21
|
-
if Gem.win_platform?
|
23
|
+
if Gem.win_platform?
|
22
24
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
23
25
|
SimpleCov::Formatter::HTMLFormatter
|
24
26
|
]
|
25
27
|
SimpleCov.start do
|
26
|
-
add_filter
|
27
|
-
add_filter
|
28
|
+
add_filter '/test/'
|
29
|
+
add_filter '/features/'
|
28
30
|
end
|
29
31
|
else
|
30
32
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
31
33
|
[SimpleCov::Formatter::HTMLFormatter]
|
32
34
|
)
|
33
35
|
SimpleCov.start do
|
34
|
-
add_filter
|
35
|
-
add_filter
|
36
|
+
add_filter '/test/'
|
37
|
+
add_filter '/features/'
|
36
38
|
minimum_coverage 60
|
37
39
|
end
|
38
40
|
end
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -21,5 +21,4 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
source 'https://rubygems.org'
|
24
|
-
ruby '~>2.3'
|
25
24
|
gemspec
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
<img src="https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg" height="64px"/>
|
2
2
|
|
3
3
|
[](https://www.elegantobjects.org)
|
4
|
-
[](https://www.0crat.com/p/C3RFVLU72)
|
5
4
|
[](http://www.rultor.com/p/yegor256/pgtk)
|
6
5
|
[](https://www.jetbrains.com/ruby/)
|
7
6
|
|
8
|
-
[](https://ci.appveyor.com/project/yegor256/pgtk)
|
7
|
+
[](https://github.com/yegor256/pgtk/actions/workflows/rake.yml)
|
10
8
|
[](http://www.0pdd.com/p?name=yegor256/pgtk)
|
11
9
|
[](http://badge.fury.io/rb/pgtk)
|
12
10
|
[](https://codeclimate.com/github/yegor256/pgtk/maintainability)
|
13
|
-
|
14
11
|
[](https://github.com/yegor256/pgtk/blob/master/LICENSE.txt)
|
15
12
|
[](https://codecov.io/github/yegor256/pgtk?branch=master)
|
16
13
|
[](https://hitsofcode.com/view/github/yegor256/pgtk)
|
@@ -151,3 +148,8 @@ $ bundle exec rake
|
|
151
148
|
|
152
149
|
If it's clean and you don't see any error messages, submit your pull request.
|
153
150
|
|
151
|
+
To run a single test, do this:
|
152
|
+
|
153
|
+
```
|
154
|
+
$ bundle exec ruby test/test_pool.rb -n test_basic
|
155
|
+
```
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/lib/pgtk/liquibase_task.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -29,20 +29,16 @@ require_relative '../pgtk'
|
|
29
29
|
|
30
30
|
# Liquibase rake task.
|
31
31
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
32
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
32
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
33
33
|
# License:: MIT
|
34
34
|
class Pgtk::LiquibaseTask < Rake::TaskLib
|
35
|
-
attr_accessor :name
|
36
|
-
attr_accessor :master
|
37
|
-
attr_accessor :yaml
|
38
|
-
attr_accessor :quiet
|
35
|
+
attr_accessor :name, :master, :yaml, :quiet
|
39
36
|
|
40
37
|
def initialize(*args, &task_block)
|
38
|
+
super()
|
41
39
|
@name = args.shift || :liquibase
|
42
40
|
@quite = false
|
43
|
-
unless ::Rake.application.last_description
|
44
|
-
desc 'Deploy Liquibase changes to the running PostgreSQL server'
|
45
|
-
end
|
41
|
+
desc 'Deploy Liquibase changes to the running PostgreSQL server' unless ::Rake.application.last_description
|
46
42
|
task(name, *args) do |_, task_args|
|
47
43
|
RakeFileUtils.send(:verbose, true) do
|
48
44
|
yield(*[self, task_args].slice(0, task_block.arity)) if block_given?
|
data/lib/pgtk/pgsql_task.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -32,20 +32,13 @@ require_relative '../pgtk'
|
|
32
32
|
|
33
33
|
# Pgsql rake task.
|
34
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
35
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
36
36
|
# License:: MIT
|
37
37
|
class Pgtk::PgsqlTask < Rake::TaskLib
|
38
|
-
attr_accessor :name
|
39
|
-
attr_accessor :dir
|
40
|
-
attr_accessor :fresh_start
|
41
|
-
attr_accessor :user
|
42
|
-
attr_accessor :password
|
43
|
-
attr_accessor :dbname
|
44
|
-
attr_accessor :yaml
|
45
|
-
attr_accessor :quiet
|
46
|
-
attr_accessor :port
|
38
|
+
attr_accessor :name, :dir, :fresh_start, :user, :password, :dbname, :yaml, :quiet, :port
|
47
39
|
|
48
40
|
def initialize(*args, &task_block)
|
41
|
+
super()
|
49
42
|
@name = args.shift || :pgsql
|
50
43
|
@fresh_start = false
|
51
44
|
@quite = false
|
@@ -53,9 +46,7 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
53
46
|
@password = 'test'
|
54
47
|
@dbname = 'test'
|
55
48
|
@port = nil
|
56
|
-
unless ::Rake.application.last_description
|
57
|
-
desc 'Start a local PostgreSQL server'
|
58
|
-
end
|
49
|
+
desc 'Start a local PostgreSQL server' unless ::Rake.application.last_description
|
59
50
|
task(name, *args) do |_, task_args|
|
60
51
|
RakeFileUtils.send(:verbose, true) do
|
61
52
|
yield(*[self, task_args].slice(0, task_block.arity)) if block_given?
|
@@ -71,12 +62,10 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
71
62
|
raise "Option 'yaml' is mandatory" unless @yaml
|
72
63
|
home = File.expand_path(@dir)
|
73
64
|
FileUtils.rm_rf(home) if @fresh_start
|
74
|
-
if File.exist?(home)
|
75
|
-
raise "Directory/file #{home} is present, use fresh_start=true"
|
76
|
-
end
|
65
|
+
raise "Directory/file #{home} is present, use fresh_start=true" if File.exist?(home)
|
77
66
|
out = "2>&1 #{@quiet ? '>/dev/null' : ''}"
|
78
67
|
Tempfile.open do |pwfile|
|
79
|
-
|
68
|
+
File.write(pwfile.path, @password)
|
80
69
|
system(
|
81
70
|
[
|
82
71
|
'initdb --auth=trust',
|
@@ -98,7 +87,7 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
98
87
|
puts "Required TCP port #{port} is used"
|
99
88
|
end
|
100
89
|
pid = Process.spawn('postgres', '-k', home, '-D', home, "--port=#{port}")
|
101
|
-
|
90
|
+
File.write(File.join(@dir, 'pid'), pid)
|
102
91
|
at_exit do
|
103
92
|
`kill -TERM #{pid}`
|
104
93
|
puts "PostgreSQL killed in PID #{pid}"
|
@@ -123,7 +112,7 @@ class Pgtk::PgsqlTask < Rake::TaskLib
|
|
123
112
|
raise if attempt > 10
|
124
113
|
retry
|
125
114
|
end
|
126
|
-
|
115
|
+
File.write(
|
127
116
|
@yaml,
|
128
117
|
{
|
129
118
|
'pgsql' => {
|
data/lib/pgtk/pool.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,7 +27,7 @@ require_relative 'wire'
|
|
27
27
|
|
28
28
|
# Pool.
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
30
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
class Pgtk::Pool
|
33
33
|
# Constructor.
|
@@ -39,7 +39,7 @@ class Pgtk::Pool
|
|
39
39
|
|
40
40
|
# Get the version of PostgreSQL server.
|
41
41
|
def version
|
42
|
-
@version ||= exec('SHOW server_version')[0]['server_version'].split
|
42
|
+
@version ||= exec('SHOW server_version')[0]['server_version'].split[0]
|
43
43
|
end
|
44
44
|
|
45
45
|
# Start it with a fixed number of connections. The amount of connections
|
@@ -101,13 +101,11 @@ class Pgtk::Pool
|
|
101
101
|
#
|
102
102
|
# More details about +exec_params+, which is called here, you can find
|
103
103
|
# here: https://www.rubydoc.info/gems/pg/0.17.1/PG%2FConnection:exec_params
|
104
|
-
def exec(query, args = [], result = 0)
|
104
|
+
def exec(query, args = [], result = 0, &block)
|
105
105
|
connect do |c|
|
106
106
|
t = Txn.new(c, @log)
|
107
107
|
if block_given?
|
108
|
-
t.exec(query, args, result)
|
109
|
-
yield res
|
110
|
-
end
|
108
|
+
t.exec(query, args, result, &block)
|
111
109
|
else
|
112
110
|
t.exec(query, args, result)
|
113
111
|
end
|
@@ -139,14 +137,19 @@ class Pgtk::Pool
|
|
139
137
|
def exec(query, args = [], result = 0)
|
140
138
|
start = Time.now
|
141
139
|
sql = query.is_a?(Array) ? query.join(' ') : query
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
140
|
+
begin
|
141
|
+
out = @conn.exec_params(sql, args, result) do |res|
|
142
|
+
if block_given?
|
143
|
+
yield res
|
144
|
+
else
|
145
|
+
rows = []
|
146
|
+
res.each { |r| rows << r }
|
147
|
+
rows
|
148
|
+
end
|
149
149
|
end
|
150
|
+
rescue StandardError => e
|
151
|
+
@log.error("#{sql}: #{e.message}")
|
152
|
+
raise e
|
150
153
|
end
|
151
154
|
lag = Time.now - start
|
152
155
|
if lag < 1
|
data/lib/pgtk/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,9 +24,9 @@ require_relative '../pgtk'
|
|
24
24
|
|
25
25
|
# Pgtk version.
|
26
26
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
27
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
28
28
|
# License:: MIT
|
29
29
|
module Pgtk
|
30
30
|
# Current version of the library.
|
31
|
-
VERSION = '0.
|
31
|
+
VERSION = '0.8.1'
|
32
32
|
end
|
data/lib/pgtk/wire.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -27,14 +27,14 @@ require_relative '../pgtk'
|
|
27
27
|
|
28
28
|
# Wires.
|
29
29
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
30
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
31
31
|
# License:: MIT
|
32
32
|
module Pgtk::Wire
|
33
33
|
end
|
34
34
|
|
35
35
|
# Simple wire with details.
|
36
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
37
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
38
38
|
# License:: MIT
|
39
39
|
class Pgtk::Wire::Direct
|
40
40
|
# Constructor.
|
@@ -59,7 +59,7 @@ end
|
|
59
59
|
|
60
60
|
# Using ENV variable.
|
61
61
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
62
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
62
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
63
63
|
# License:: MIT
|
64
64
|
class Pgtk::Wire::Env
|
65
65
|
# Constructor.
|
@@ -70,7 +70,7 @@ class Pgtk::Wire::Env
|
|
70
70
|
|
71
71
|
# Create a new connection to PostgreSQL server.
|
72
72
|
def connection
|
73
|
-
v = ENV
|
73
|
+
v = ENV.fetch(@var, nil)
|
74
74
|
raise "The environment variable #{@var.inspect} is not set" if v.nil?
|
75
75
|
uri = URI(v)
|
76
76
|
Pgtk::Wire::Direct.new(
|
@@ -85,7 +85,7 @@ end
|
|
85
85
|
|
86
86
|
# Using configuration from YAML file.
|
87
87
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
88
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
88
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
89
89
|
# License:: MIT
|
90
90
|
class Pgtk::Wire::Yaml
|
91
91
|
# Constructor.
|
data/lib/pgtk.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
# Pgtk main module.
|
24
24
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
25
|
-
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
25
|
+
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
26
26
|
# License:: MIT
|
27
27
|
module Pgtk
|
28
28
|
# Nothing here.
|
data/pgtk.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -26,11 +26,7 @@ lib = File.expand_path('lib', __dir__)
|
|
26
26
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
27
27
|
require_relative 'lib/pgtk/version'
|
28
28
|
Gem::Specification.new do |s|
|
29
|
-
s.
|
30
|
-
if s.respond_to? :required_rubygems_version=
|
31
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
32
|
-
end
|
33
|
-
s.rubygems_version = '2.2'
|
29
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
34
30
|
s.required_ruby_version = '>= 2.3'
|
35
31
|
s.name = 'pgtk'
|
36
32
|
s.version = Pgtk::VERSION
|
@@ -44,18 +40,19 @@ connection pool and query processor, to make SQL manipulation simpler.'
|
|
44
40
|
s.homepage = 'http://github.com/yegor256/pgtk'
|
45
41
|
s.files = `git ls-files`.split($RS)
|
46
42
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
47
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
48
43
|
s.rdoc_options = ['--charset=UTF-8']
|
49
44
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
50
45
|
s.add_runtime_dependency 'backtrace', '~> 0.3'
|
51
46
|
s.add_runtime_dependency 'loog', '~> 0.2'
|
52
47
|
s.add_runtime_dependency 'pg', '~> 1.1'
|
53
48
|
s.add_runtime_dependency 'random-port', '~> 0.3'
|
54
|
-
s.add_development_dependency '
|
55
|
-
s.add_development_dependency '
|
56
|
-
s.add_development_dependency 'rake', '
|
49
|
+
s.add_development_dependency 'minitest', '5.18.0'
|
50
|
+
s.add_development_dependency 'rack', '2.2.7'
|
51
|
+
s.add_development_dependency 'rake', '13.0.6'
|
57
52
|
s.add_development_dependency 'rspec-rails', '3.1.0'
|
58
|
-
s.add_development_dependency 'rubocop', '
|
59
|
-
s.add_development_dependency 'rubocop-rspec', '
|
60
|
-
s.add_development_dependency '
|
53
|
+
s.add_development_dependency 'rubocop', '1.50.2'
|
54
|
+
s.add_development_dependency 'rubocop-rspec', '2.20.0'
|
55
|
+
s.add_development_dependency 'simplecov', '0.22.0'
|
56
|
+
s.add_development_dependency 'xcop', '0.7.1'
|
57
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
61
58
|
end
|
data/renovate.json
ADDED
data/resources/pom.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<!--
|
3
3
|
(The MIT License)
|
4
4
|
|
5
|
-
Copyright (c) 2019 Yegor Bugayenko
|
5
|
+
Copyright (c) 2019-2023 Yegor Bugayenko
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the 'Software'), to deal
|
@@ -32,7 +32,7 @@ SOFTWARE.
|
|
32
32
|
<dependency>
|
33
33
|
<groupId>org.postgresql</groupId>
|
34
34
|
<artifactId>postgresql</artifactId>
|
35
|
-
<version>
|
35
|
+
<version>42.6.0</version>
|
36
36
|
<scope>runtime</scope>
|
37
37
|
</dependency>
|
38
38
|
</dependencies>
|
data/test/test__helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -20,14 +20,10 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
|
23
|
+
$stdout.sync = true
|
24
24
|
|
25
25
|
require 'simplecov'
|
26
26
|
SimpleCov.start
|
27
|
-
if ENV['CI'] == 'true'
|
28
|
-
require 'codecov'
|
29
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
30
|
-
end
|
31
27
|
|
32
28
|
require 'minitest/autorun'
|
33
29
|
require_relative '../lib/pgtk'
|
data/test/test_liquibase_task.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/test_pgsql_task.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
data/test/test_pool.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2019-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -53,6 +53,27 @@ class TestPool < Minitest::Test
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def test_logs_sql
|
57
|
+
log = Loog::Buffer.new
|
58
|
+
bootstrap(log: log) do |pool|
|
59
|
+
pool.exec(
|
60
|
+
'INSERT INTO book (title) VALUES ($1)',
|
61
|
+
['Object Thinking']
|
62
|
+
)
|
63
|
+
assert(log.to_s.include?('INSERT INTO book (title) VALUES ($1)'))
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_logs_errors
|
68
|
+
log = Loog::Buffer.new
|
69
|
+
bootstrap(log: log) do |pool|
|
70
|
+
assert_raises PG::UndefinedTable do
|
71
|
+
pool.exec('INSERT INTO tableDoesNotExist (a) VALUES (42)')
|
72
|
+
end
|
73
|
+
assert(log.to_s.include?('INSERT INTO tableDoesNotExist'))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
56
77
|
def test_transaction
|
57
78
|
bootstrap do |pool|
|
58
79
|
id = pool.transaction do |t|
|
@@ -102,12 +123,12 @@ class TestPool < Minitest::Test
|
|
102
123
|
)
|
103
124
|
pool.start(1)
|
104
125
|
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
105
|
-
pid =
|
126
|
+
pid = File.read(File.join(dir, 'pgsql/pid')).to_i
|
106
127
|
`kill -KILL #{pid}`
|
107
128
|
sleep 1
|
108
129
|
task.reenable
|
109
130
|
task.invoke
|
110
|
-
assert_raises
|
131
|
+
assert_raises(PG::UnableToSend, PG::ConnectionBad) do
|
111
132
|
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
112
133
|
end
|
113
134
|
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
@@ -116,7 +137,7 @@ class TestPool < Minitest::Test
|
|
116
137
|
|
117
138
|
private
|
118
139
|
|
119
|
-
def bootstrap
|
140
|
+
def bootstrap(log: Loog::VERBOSE)
|
120
141
|
Dir.mktmpdir 'test' do |dir|
|
121
142
|
id = rand(100..999)
|
122
143
|
Pgtk::PgsqlTask.new("pgsql#{id}") do |t|
|
@@ -136,7 +157,7 @@ class TestPool < Minitest::Test
|
|
136
157
|
Rake::Task["liquibase#{id}"].invoke
|
137
158
|
pool = Pgtk::Pool.new(
|
138
159
|
Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
|
139
|
-
log:
|
160
|
+
log: log
|
140
161
|
)
|
141
162
|
pool.start(1)
|
142
163
|
yield pool
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<!--
|
3
3
|
(The MIT License)
|
4
4
|
|
5
|
-
Copyright (c) 2019 Yegor Bugayenko
|
5
|
+
Copyright (c) 2019-2023 Yegor Bugayenko
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the 'Software'), to deal
|
data/test-resources/master.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<!--
|
3
3
|
(The MIT License)
|
4
4
|
|
5
|
-
Copyright (c) 2019 Yegor Bugayenko
|
5
|
+
Copyright (c) 2019-2023 Yegor Bugayenko
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the 'Software'), to deal
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -67,47 +67,47 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.18.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.18.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2.2.7
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2.2.7
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 13.0.6
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 13.0.6
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-rails
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,42 +128,56 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 1.50.2
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 1.50.2
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop-rspec
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 2.20.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 2.20.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.22.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.22.0
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: xcop
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - '='
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
173
|
+
version: 0.7.1
|
160
174
|
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - '='
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
180
|
+
version: 0.7.1
|
167
181
|
description: |-
|
168
182
|
This small Ruby gem helps you integrate PostgreSQL \
|
169
183
|
with your Ruby web app, through Liquibase. It also adds a simple \
|
@@ -177,6 +191,10 @@ extra_rdoc_files:
|
|
177
191
|
files:
|
178
192
|
- ".0pdd.yml"
|
179
193
|
- ".gitattributes"
|
194
|
+
- ".github/workflows/codecov.yml"
|
195
|
+
- ".github/workflows/pdd.yml"
|
196
|
+
- ".github/workflows/rake.yml"
|
197
|
+
- ".github/workflows/xcop.yml"
|
180
198
|
- ".gitignore"
|
181
199
|
- ".pdd"
|
182
200
|
- ".rubocop.yml"
|
@@ -196,6 +214,7 @@ files:
|
|
196
214
|
- lib/pgtk/version.rb
|
197
215
|
- lib/pgtk/wire.rb
|
198
216
|
- pgtk.gemspec
|
217
|
+
- renovate.json
|
199
218
|
- resources/pom.xml
|
200
219
|
- test-resources/2019/01-test.xml
|
201
220
|
- test-resources/master.xml
|
@@ -206,7 +225,8 @@ files:
|
|
206
225
|
homepage: http://github.com/yegor256/pgtk
|
207
226
|
licenses:
|
208
227
|
- MIT
|
209
|
-
metadata:
|
228
|
+
metadata:
|
229
|
+
rubygems_mfa_required: 'true'
|
210
230
|
post_install_message:
|
211
231
|
rdoc_options:
|
212
232
|
- "--charset=UTF-8"
|
@@ -223,12 +243,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
243
|
- !ruby/object:Gem::Version
|
224
244
|
version: '0'
|
225
245
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
246
|
+
rubygems_version: 3.2.15
|
227
247
|
signing_key:
|
228
|
-
specification_version:
|
248
|
+
specification_version: 4
|
229
249
|
summary: PostgreSQL ToolKit for Ruby apps
|
230
|
-
test_files:
|
231
|
-
- test/test__helper.rb
|
232
|
-
- test/test_liquibase_task.rb
|
233
|
-
- test/test_pgsql_task.rb
|
234
|
-
- test/test_pool.rb
|
250
|
+
test_files: []
|