pgtk 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59a94cc2db34605f428b7f7828f2a4a1e2cec16cd0ed59903ed5cc2244fb2a07
4
- data.tar.gz: 96aae151d530dea967c1d1cff85a3192399d31bcf932305aca789e649cfe1b36
3
+ metadata.gz: 62a786eefdf5750efb4fc874c1d56cabf81925652323df45cf305f7e7cd6db5f
4
+ data.tar.gz: 9d03860055718f2793aa0805307679240d4bd7765e9ae3310dae849511327134
5
5
  SHA512:
6
- metadata.gz: 03dafc5a8296523fbe2a47bf88e0f39f8ced19c39d638e432e21023d646ef988baa805544f37ab2dd82291bc2d0686c0b397b1c660cf0e565578356af25940ea
7
- data.tar.gz: 5d19a05b050ce1ba15b38405a05ddd61b29d80bef1f9fadbc3e7e5f371d3d6d0ac98b7a47d84a658208b98133218bcdd8f3f3b348f559dc7665c05058e8ce399
6
+ metadata.gz: 4bea1c503932c6a77edb73272aaaaa015abc36d82fb6d96d06e9576237f42430f6871d22bdb096feccb0f91eebc01fa41ff5cf64b025bbd8b23ec254914b6fab
7
+ data.tar.gz: 347c2d8171c8ce34390cad9b66c6753f4f40ff1a6f597cfece1284a690d9063951d6fbf9763307a880296161eeac75c3dcadeb54686711424bd87447747e617e
@@ -6,10 +6,10 @@ on:
6
6
  - master
7
7
  jobs:
8
8
  codecov:
9
- runs-on: ubuntu-20.04
9
+ runs-on: ubuntu-22.04
10
10
  steps:
11
- - uses: actions/checkout@v3
12
- - uses: actions/setup-ruby@v1
11
+ - uses: actions/checkout@v4
12
+ - uses: ruby/setup-ruby@v1
13
13
  with:
14
14
  ruby-version: 2.7
15
15
  - run: |
@@ -21,5 +21,6 @@ jobs:
21
21
  - run: bundle exec rake
22
22
  - uses: codecov/codecov-action@v3
23
23
  with:
24
+ token: ${{ secrets.CODECOV_TOKEN }}
24
25
  file: coverage/.resultset.json
25
26
  fail_ci_if_error: true
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pdd
3
- "on":
3
+ on:
4
4
  push:
5
5
  branches:
6
6
  - master
@@ -9,7 +9,7 @@ name: pdd
9
9
  - master
10
10
  jobs:
11
11
  pdd:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  steps:
14
- - uses: actions/checkout@v3
15
- - uses: g4s8/pdd-action@master
14
+ - uses: actions/checkout@v4
15
+ - uses: volodya-lombrozo/pdd-action@master
@@ -16,7 +16,7 @@ jobs:
16
16
  ruby: [2.6]
17
17
  runs-on: ${{ matrix.os }}
18
18
  steps:
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
20
20
  - run: |
21
21
  sudo apt-get update
22
22
  sudo apt-get install -y postgresql-14
@@ -9,9 +9,9 @@ name: xcop
9
9
  - master
10
10
  jobs:
11
11
  xcop:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  steps:
14
- - uses: actions/checkout@v3
14
+ - uses: actions/checkout@v4
15
15
  - uses: g4s8/xcop-action@master
16
16
  with:
17
17
  files: '**/*.xml'
data/.rultor.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  docker:
2
- image: yegor256/rultor-image:1.19.0
2
+ image: yegor256/rultor-image:1.22.0
3
3
  assets:
4
4
  rubygems.yml: yegor256/home#assets/rubygems.yml
5
5
  install: |
6
+ sudo chown -R "$(whoami)" /usr/local/rvm
6
7
  pdd -f /dev/null
7
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
8
+ bundle install --no-color "--gemfile=$(pwd)/Gemfile"
8
9
  release:
9
10
  script: |-
10
11
  [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
data/.simplecov CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2019-2023 Yegor Bugayenko
3
+ Copyright (c) 2019-2024 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/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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
@@ -54,7 +54,7 @@ Rake::RDocTask.new do |rdoc|
54
54
  end
55
55
 
56
56
  require 'rubocop/rake_task'
57
- desc 'Run RuboCop on all directories'
57
+ desc 'Run Rubocop on all directories'
58
58
  RuboCop::RakeTask.new(:rubocop) do |task|
59
59
  task.fail_on_error = true
60
60
  task.requires << 'rubocop-rspec'
@@ -69,7 +69,7 @@ Xcop::RakeTask.new :xcop do |task|
69
69
  end
70
70
 
71
71
  task :copyright do
72
- sh "grep -q -r '#{Date.today.strftime('%Y')}' \
72
+ sh "grep -q -r '2019-#{Date.today.strftime('%Y')}' \
73
73
  --include '*.rb' \
74
74
  --include '*.txt' \
75
75
  --include 'Rakefile' \
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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,15 +29,17 @@ require_relative '../pgtk'
29
29
 
30
30
  # Liquibase rake task.
31
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
32
- # Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
32
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
33
33
  # License:: MIT
34
34
  class Pgtk::LiquibaseTask < Rake::TaskLib
35
- attr_accessor :name, :master, :yaml, :quiet
35
+ attr_accessor :name, :master, :yaml, :quiet, :liquibase_version, :postgresql_version
36
36
 
37
37
  def initialize(*args, &task_block)
38
38
  super()
39
39
  @name = args.shift || :liquibase
40
40
  @quite = false
41
+ @liquibase_version = '3.2.2'
42
+ @postgresql_version = '42.7.0'
41
43
  desc 'Deploy Liquibase changes to the running PostgreSQL server' unless ::Rake.application.last_description
42
44
  task(name, *args) do |_, task_args|
43
45
  RakeFileUtils.send(:verbose, true) do
@@ -69,10 +71,15 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
69
71
  'mvn verify',
70
72
  '--errors',
71
73
  '--batch-mode',
74
+ '--fail-fast',
72
75
  @quiet ? '--quiet' : '',
73
76
  '--file',
74
77
  Shellwords.escape(pom),
75
78
  '--define',
79
+ "liquibase.version=#{@liquibase_version}",
80
+ '--define',
81
+ "postgresql.version=#{@postgresql_version}",
82
+ '--define',
76
83
  "liquibase.changeLogFile=#{@master}",
77
84
  '--define',
78
85
  "liquibase.url=#{Shellwords.escape(yml['pgsql']['url'])}",
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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,7 +32,7 @@ require_relative '../pgtk'
32
32
 
33
33
  # Pgsql rake task.
34
34
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
35
- # Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
35
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
36
36
  # License:: MIT
37
37
  class Pgtk::PgsqlTask < Rake::TaskLib
38
38
  attr_accessor :name, :dir, :fresh_start, :user, :password, :dbname, :yaml, :quiet, :port
data/lib/pgtk/pool.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
31
31
  # License:: MIT
32
32
  class Pgtk::Pool
33
33
  # Constructor.
@@ -137,14 +137,19 @@ class Pgtk::Pool
137
137
  def exec(query, args = [], result = 0)
138
138
  start = Time.now
139
139
  sql = query.is_a?(Array) ? query.join(' ') : query
140
- out = @conn.exec_params(sql, args, result) do |res|
141
- if block_given?
142
- yield res
143
- else
144
- rows = []
145
- res.each { |r| rows << r }
146
- rows
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
147
149
  end
150
+ rescue StandardError => e
151
+ @log.error("#{sql}: #{e.message}")
152
+ raise e
148
153
  end
149
154
  lag = Time.now - start
150
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-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
27
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
28
28
  # License:: MIT
29
29
  module Pgtk
30
30
  # Current version of the library.
31
- VERSION = '0.8.0'
31
+ VERSION = '0.9.0'
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-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
37
+ # Copyright:: Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
62
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
63
63
  # License:: MIT
64
64
  class Pgtk::Wire::Env
65
65
  # Constructor.
@@ -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-2023 Yegor Bugayenko
88
+ # Copyright:: Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
25
+ # Copyright:: Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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/resources/pom.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <!--
3
3
  (The MIT License)
4
4
 
5
- Copyright (c) 2019-2023 Yegor Bugayenko
5
+ Copyright (c) 2019-2024 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
@@ -26,13 +26,17 @@ SOFTWARE.
26
26
  <modelVersion>4.0.0</modelVersion>
27
27
  <groupId>pgtk</groupId>
28
28
  <artifactId>pgtk</artifactId>
29
- <version>1.0-SNAPSHOT</version>
29
+ <version>0.0.0</version>
30
30
  <packaging>pom</packaging>
31
+ <properties>
32
+ <postgresql.version>42.7.1</postgresql.version>
33
+ <liquibase.version>4.25.1</liquibase.version>
34
+ </properties>
31
35
  <dependencies>
32
36
  <dependency>
33
37
  <groupId>org.postgresql</groupId>
34
38
  <artifactId>postgresql</artifactId>
35
- <version>42.6.0</version>
39
+ <version>${postgresql.version}</version>
36
40
  <scope>runtime</scope>
37
41
  </dependency>
38
42
  </dependencies>
@@ -41,7 +45,7 @@ SOFTWARE.
41
45
  <plugin>
42
46
  <groupId>org.liquibase</groupId>
43
47
  <artifactId>liquibase-maven-plugin</artifactId>
44
- <version>3.2.2</version>
48
+ <version>${liquibase.version}</version>
45
49
  <configuration>
46
50
  <driver>org.postgresql.Driver</driver>
47
51
  <logging>info</logging>
data/test/test__helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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
@@ -47,6 +47,8 @@ class TestLiquibaseTask < Minitest::Test
47
47
  t.master = File.join(__dir__, '../test-resources/master.xml')
48
48
  t.yaml = ['file-is-absent', File.join(dir, 'cfg.yml'), 'another']
49
49
  t.quiet = true
50
+ t.postgresql_version = '42.7.0'
51
+ t.liquibase_version = '3.2.2'
50
52
  end
51
53
  Rake::Task['liquibase2'].invoke
52
54
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 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|
@@ -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: Loog::VERBOSE
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-2023 Yegor Bugayenko
5
+ Copyright (c) 2019-2024 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
@@ -2,7 +2,7 @@
2
2
  <!--
3
3
  (The MIT License)
4
4
 
5
- Copyright (c) 2019-2023 Yegor Bugayenko
5
+ Copyright (c) 2019-2024 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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-02 00:00:00.000000000 Z
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
245
  requirements: []
246
- rubygems_version: 3.2.15
246
+ rubygems_version: 3.4.10
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: PostgreSQL ToolKit for Ruby apps