pgtk 0.11.0 → 0.12.1

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: 5dcffe3ba23b17694740ccad32c11d2813f1606b4dfa9b93c63480ebb0e54299
4
- data.tar.gz: b166a621155d4be6f8e7294d46b7a07ead34a711a17a3119cd34c289313d8f62
3
+ metadata.gz: '0229db9fb7094b463af3fc42c60b90d3175faba8ad08d2d43d5af299ce011b8e'
4
+ data.tar.gz: cede9f139659cdfb9419f846bca9110338be3ee77f5ee791781324951816de85
5
5
  SHA512:
6
- metadata.gz: 522afdb2e8c28af25cffd7a298f7caa6e1d964f8551408b7c9200650013d4b2e17c59363e6826011b175269744fb0436a351a79d5d85c5eafcf97d38c2bd7a5a
7
- data.tar.gz: fa0eae28c330618462229826c735b1802e483ae07db63f6a8cc617cfb41f2a70dcf40ddd1ec86ce33b5ea3ec605b47f6b50335f22d456cde919a7bbe8c852663
6
+ metadata.gz: d8aac510a305077c23d3c1e9247b1276f8a5ca116f7e208bcc3f7877226454ec090938a8e59d84bec32cd3236e288c30f32214dfaab9489ec80a699f185d99cd
7
+ data.tar.gz: e6b9e18fac1f1405ab51364f963288096dd99e5de1ee2676b052b90b8d33cbf11433eefd02ab97ddb4757aabf4c34144f387b34b504937150d8eed3c091f2dde
data/.0pdd.yml CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -43,5 +43,3 @@ jobs:
43
43
  - uses: codecov/codecov-action@v5
44
44
  with:
45
45
  token: ${{ secrets.CODECOV_TOKEN }}
46
- file: coverage/.resultset.json
47
- fail_ci_if_error: true
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -45,6 +45,5 @@ jobs:
45
45
  - uses: ruby/setup-ruby@v1
46
46
  with:
47
47
  ruby-version: ${{ matrix.ruby }}
48
- bundler-cache: true
49
48
  - run: bundle update
50
49
  - run: bundle exec rake
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ coverage/
4
4
  .bundle/
5
5
  .DS_Store
6
6
  rdoc/
7
+ doc/
8
+ .yardoc/
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
data/.rultor.yml CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -23,7 +23,6 @@ docker:
23
23
  assets:
24
24
  rubygems.yml: yegor256/home#assets/rubygems.yml
25
25
  install: |
26
- sudo hostname docker
27
26
  sudo apt-get update
28
27
  sudo apt-get install -y libpq-dev postgresql-client postgresql
29
28
  sudo ln -s "$(realpath /usr/lib/postgresql/*/bin/initdb)" /bin/initdb
data/.simplecov CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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/.yamllint.yml CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # 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-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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
@@ -33,3 +33,4 @@ gem 'rubocop-rspec', '3.3.0', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
34
34
  gem 'simplecov-cobertura', '~>2.1'
35
35
  gem 'xcop', '0.7.1', require: false
36
+ gem 'yard', '0.9.37', require: false
data/Gemfile.lock CHANGED
@@ -175,7 +175,7 @@ GEM
175
175
  thor (1.3.2)
176
176
  tzinfo (2.0.6)
177
177
  concurrent-ruby (~> 1.0)
178
- unicode-display_width (3.1.2)
178
+ unicode-display_width (3.1.3)
179
179
  unicode-emoji (~> 4.0, >= 4.0.4)
180
180
  unicode-emoji (4.0.4)
181
181
  uri (1.0.2)
@@ -185,6 +185,7 @@ GEM
185
185
  nokogiri (~> 1.10)
186
186
  rainbow (~> 3.0)
187
187
  slop (~> 4.4)
188
+ yard (0.9.37)
188
189
  zeitwerk (2.7.1)
189
190
 
190
191
  PLATFORMS
@@ -204,6 +205,7 @@ DEPENDENCIES
204
205
  simplecov (= 0.22.0)
205
206
  simplecov-cobertura (~> 2.1)
206
207
  xcop (= 0.7.1)
208
+ yard (= 0.9.37)
207
209
 
208
210
  BUNDLED WITH
209
211
  2.5.16
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2019-2024 Yegor Bugayenko
3
+ Copyright (c) 2019-2025 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/README.md CHANGED
@@ -50,6 +50,10 @@ Pgtk::PgsqlTask.new :pgsql do |t|
50
50
  t.password = 'test'
51
51
  t.dbname = 'test'
52
52
  t.yaml = 'target/pgsql-config.yml' # YAML file to be created with connection details
53
+ t.config = { # list of PostgreSQL configuration options
54
+ log_min_messages: 'ERROR',
55
+ log_filename: 'target/pg.log'
56
+ }
53
57
  end
54
58
  ```
55
59
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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
@@ -33,7 +33,7 @@ def version
33
33
  Gem::Specification.load(Dir['*.gemspec'].first).version
34
34
  end
35
35
 
36
- task default: %i[clean test rubocop xcop copyright]
36
+ task default: %i[clean test rubocop xcop copyright yard]
37
37
 
38
38
  require 'rake/testtask'
39
39
  desc 'Run all unit tests'
@@ -44,13 +44,10 @@ Rake::TestTask.new(:test) do |test|
44
44
  test.verbose = false
45
45
  end
46
46
 
47
- require 'rdoc/task'
48
- desc 'Build RDoc documentation'
49
- Rake::RDocTask.new do |rdoc|
50
- rdoc.rdoc_dir = 'rdoc'
51
- rdoc.title = "#{name} #{version}"
52
- rdoc.rdoc_files.include('README*')
53
- rdoc.rdoc_files.include('lib/**/*.rb')
47
+ require 'yard'
48
+ desc 'Build Yard documentation'
49
+ YARD::Rake::YardocTask.new do |t|
50
+ t.files = ['lib/**/*.rb']
54
51
  end
55
52
 
56
53
  require 'rubocop/rake_task'
@@ -65,7 +62,7 @@ desc 'Validate all XML/XSL/XSD/HTML files for formatting'
65
62
  Xcop::RakeTask.new :xcop do |task|
66
63
  task.license = 'LICENSE.txt'
67
64
  task.includes = ['**/*.xml', '**/*.xsl', '**/*.xsd', '**/*.html']
68
- task.excludes = ['target/**/*', 'coverage/**/*', 'vendor/**/*']
65
+ task.excludes = ['target/**/*', 'coverage/**/*', 'vendor/**/*', 'doc/**/*']
69
66
  end
70
67
 
71
68
  task :copyright do
data/cucumber.yml CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2024 Yegor Bugayenko
1
+ # Copyright (c) 2019-2025 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # 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-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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
@@ -30,7 +30,7 @@ require_relative '../pgtk'
30
30
 
31
31
  # Liquibase rake task.
32
32
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
33
- # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
33
+ # Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
34
34
  # License:: MIT
35
35
  class Pgtk::LiquibaseTask < Rake::TaskLib
36
36
  attr_accessor :name, :master, :yaml, :quiet, :liquibase_version, :postgresql_version
@@ -82,7 +82,7 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
82
82
  Dir.chdir(File.dirname(@master)) do
83
83
  qbash(
84
84
  [
85
- 'mvn verify',
85
+ 'mvn', 'verify',
86
86
  '--errors',
87
87
  '--batch-mode',
88
88
  '--fail-fast',
@@ -94,14 +94,13 @@ class Pgtk::LiquibaseTask < Rake::TaskLib
94
94
  '--define',
95
95
  "postgresql.version=#{@postgresql_version}",
96
96
  '--define',
97
- "liquibase.searchPath=#{File.dirname(@master)}",
97
+ Shellwords.escape("liquibase.searchPath=#{File.dirname(@master)}"),
98
98
  '--define',
99
- "liquibase.changeLogFile=#{old ? @master : File.basename(@master)}",
99
+ Shellwords.escape("liquibase.changeLogFile=#{old ? @master : File.basename(@master)}"),
100
100
  '--define',
101
- "liquibase.url=#{Shellwords.escape(url)}",
101
+ Shellwords.escape("liquibase.url=#{url}"),
102
102
  '--define',
103
- "liquibase.password=#{Shellwords.escape(password)}",
104
- '2>&1'
103
+ Shellwords.escape("liquibase.password=#{password}")
105
104
  ]
106
105
  )
107
106
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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
@@ -33,10 +33,10 @@ require_relative '../pgtk'
33
33
 
34
34
  # Pgsql rake task.
35
35
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
36
- # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
36
+ # Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
37
37
  # License:: MIT
38
38
  class Pgtk::PgsqlTask < Rake::TaskLib
39
- attr_accessor :name, :dir, :fresh_start, :user, :password, :dbname, :yaml, :quiet, :port
39
+ attr_accessor :name, :dir, :fresh_start, :user, :password, :dbname, :yaml, :quiet, :port, :config
40
40
 
41
41
  def initialize(*args, &task_block)
42
42
  super()
@@ -44,6 +44,7 @@ class Pgtk::PgsqlTask < Rake::TaskLib
44
44
  @fresh_start = false
45
45
  @quiet = false
46
46
  @user = 'test'
47
+ @config = {}
47
48
  @password = 'test'
48
49
  @dbname = 'test'
49
50
  @port = nil
@@ -92,10 +93,7 @@ class Pgtk::PgsqlTask < Rake::TaskLib
92
93
  'postgres',
93
94
  '-k', Shellwords.escape(home),
94
95
  '-D', Shellwords.escape(home),
95
- '-c', Shellwords.escape("log_directory=#{home}"),
96
- '-c', 'logging_collector=on',
97
- '-c', 'log_statement=all',
98
- '-c', 'log_filename=pgsql.log',
96
+ @config.map { |k, v| "-c #{Shellwords.escape("#{k}=#{v}")}" },
99
97
  "--port=#{port}"
100
98
  ].join(' ')
101
99
  pid = Process.spawn(
data/lib/pgtk/pool.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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,10 +27,13 @@ require_relative 'wire'
27
27
 
28
28
  # Pool.
29
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
31
31
  # License:: MIT
32
32
  class Pgtk::Pool
33
33
  # Constructor.
34
+ #
35
+ # @param [Pgtk::Wire] wire The wire
36
+ # @param [Object] log The log
34
37
  def initialize(wire, log: Loog::NULL)
35
38
  @wire = wire
36
39
  @log = log
@@ -38,6 +41,8 @@ class Pgtk::Pool
38
41
  end
39
42
 
40
43
  # Get the version of PostgreSQL server.
44
+ #
45
+ # @return [String] Version of PostgreSQL server
41
46
  def version
42
47
  @version ||= exec('SHOW server_version')[0]['server_version'].split[0]
43
48
  end
@@ -48,6 +53,8 @@ class Pgtk::Pool
48
53
  # keep in mind that not all servers will allow you to have many connections
49
54
  # open at the same time. For example, Heroku free PostgreSQL database
50
55
  # allows only one connection open.
56
+ #
57
+ # @param [Integer] max Total amount of PostgreSQL connections in the pool
51
58
  def start(max = 8)
52
59
  max.times do
53
60
  @pool << @wire.connection
@@ -101,6 +108,11 @@ class Pgtk::Pool
101
108
  #
102
109
  # More details about +exec_params+, which is called here, you can find
103
110
  # here: https://www.rubydoc.info/gems/pg/0.17.1/PG%2FConnection:exec_params
111
+ #
112
+ # @param [String] query The SQL query with params inside (possibly)
113
+ # @param [Array] args List of arguments
114
+ # @param [Integer] result Should be 0 for text results, 1 for binary
115
+ # @yield [Hash] Rows
104
116
  def exec(query, args = [], result = 0, &block)
105
117
  connect do |c|
106
118
  t = Txn.new(c, @log)
@@ -142,17 +154,33 @@ class Pgtk::Pool
142
154
  @log = log
143
155
  end
144
156
 
157
+ # Exec a single parameterized command.
158
+ # @param [String] query The SQL query with params inside (possibly)
159
+ # @param [Array] args List of arguments
160
+ # @param [Integer] result Should be 0 for text results, 1 for binary
161
+ # @yield [Hash] Rows
145
162
  def exec(query, args = [], result = 0)
146
163
  start = Time.now
147
164
  sql = query.is_a?(Array) ? query.join(' ') : query
148
165
  begin
149
- out = @conn.exec_params(sql, args, result) do |res|
150
- if block_given?
151
- yield res
166
+ out =
167
+ if args.empty?
168
+ @conn.exec(sql) do |res|
169
+ if block_given?
170
+ yield res
171
+ else
172
+ res.each.to_a
173
+ end
174
+ end
152
175
  else
153
- res.each.to_a
176
+ @conn.exec_params(sql, args, result) do |res|
177
+ if block_given?
178
+ yield res
179
+ else
180
+ res.each.to_a
181
+ end
182
+ end
154
183
  end
155
- end
156
184
  rescue StandardError => e
157
185
  @log.error("#{sql}: #{e.message}")
158
186
  raise e
data/lib/pgtk/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
27
+ # Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
28
28
  # License:: MIT
29
29
  module Pgtk
30
30
  # Current version of the library.
31
- VERSION = '0.11.0'
31
+ VERSION = '0.12.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-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
37
+ # Copyright:: Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
62
+ # Copyright:: Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
88
+ # Copyright:: Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
25
+ # Copyright:: Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
5
+ Copyright (c) 2019-2025 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/test__helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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
@@ -70,6 +70,7 @@ class TestLiquibaseTask < Minitest::Test
70
70
  t.yaml = File.join(dir, 'xxx.yml')
71
71
  t.postgresql_version = '42.7.1'
72
72
  t.liquibase_version = '4.25.1'
73
+ t.quiet = true
73
74
  end
74
75
  Rake::Task['liquibase'].invoke
75
76
  end
@@ -79,6 +80,7 @@ class TestLiquibaseTask < Minitest::Test
79
80
  Pgtk::LiquibaseTask.new(:lb) do |t|
80
81
  t.master = 'the-file-doesnt-exist.xml'
81
82
  t.yaml = { 'pgsql' => {} }
83
+ t.quiet = true
82
84
  end
83
85
  ex = assert_raises do
84
86
  Rake::Task['lb'].invoke
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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
@@ -40,11 +40,13 @@ class TestPgsqlTask < Minitest::Test
40
40
  t.dbname = 'test'
41
41
  t.yaml = File.join(dir, 'cfg.yml')
42
42
  t.quiet = true
43
+ t.config = {
44
+ log_min_error_statement: 'ERROR'
45
+ }
43
46
  end
44
47
  Rake::Task['p2'].invoke
45
48
  yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
46
49
  assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
47
- assert(File.exist?(File.join(dir, 'pgsql/pgsql.log')))
48
50
  end
49
51
  end
50
52
 
@@ -56,12 +58,18 @@ class TestPgsqlTask < Minitest::Test
56
58
  t.password = 'the password'
57
59
  t.dbname = 'test'
58
60
  t.yaml = File.join(dir, 'cfg.yml')
59
- t.quiet = false
61
+ t.quiet = true
62
+ t.config = {
63
+ log_directory: dir,
64
+ logging_collector: 'on',
65
+ log_statement: 'all',
66
+ log_filename: 'pgsql.log'
67
+ }
60
68
  end
61
69
  Rake::Task['p3'].invoke
62
70
  yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
63
71
  assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
64
- assert(File.exist?(File.join(dir, 'pgsql/pgsql.log')))
72
+ assert(File.exist?(File.join(dir, 'pgsql.log')))
65
73
  end
66
74
  end
67
75
  end
data/test/test_pool.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2024 Yegor Bugayenko
3
+ # Copyright (c) 2019-2025 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,6 +54,17 @@ class TestPool < Minitest::Test
54
54
  end
55
55
  end
56
56
 
57
+ def test_complex_query
58
+ bootstrap do |pool|
59
+ pool.exec(
60
+ "
61
+ INSERT INTO book (title) VALUES ('one');
62
+ INSERT INTO book (title) VALUES ('two');
63
+ "
64
+ )
65
+ end
66
+ end
67
+
57
68
  def test_logs_sql
58
69
  log = Loog::Buffer.new
59
70
  bootstrap(log: log) do |pool|
@@ -128,7 +139,7 @@ class TestPool < Minitest::Test
128
139
  t.password = 'A B C привет ! & | !'
129
140
  t.dbname = 'test'
130
141
  t.yaml = File.join(dir, 'cfg.yml')
131
- t.quiet = false
142
+ t.quiet = true
132
143
  t.fresh_start = true
133
144
  t.port = port
134
145
  end
@@ -136,11 +147,11 @@ class TestPool < Minitest::Test
136
147
  task.invoke
137
148
  pool = Pgtk::Pool.new(
138
149
  Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
139
- log: Loog::VERBOSE
150
+ log: Loog::NULL
140
151
  )
141
152
  pool.start(1)
142
153
  pool.exec('SELECT * FROM pg_catalog.pg_tables')
143
- qbash("pg_ctl -D #{Shellwords.escape(File.join(dir, 'pgsql'))} stop", log: $stdout)
154
+ qbash("pg_ctl -D #{Shellwords.escape(File.join(dir, 'pgsql'))} stop", log: nil)
144
155
  cycle = 0
145
156
  loop do
146
157
  begin
@@ -176,7 +187,7 @@ class TestPool < Minitest::Test
176
187
 
177
188
  private
178
189
 
179
- def bootstrap(log: Loog::VERBOSE)
190
+ def bootstrap(log: Loog::NULL)
180
191
  Dir.mktmpdir 'test' do |dir|
181
192
  id = rand(100..999)
182
193
  Pgtk::PgsqlTask.new("pgsql#{id}") do |t|
@@ -2,7 +2,7 @@
2
2
  <!--
3
3
  (The MIT License)
4
4
 
5
- Copyright (c) 2019-2024 Yegor Bugayenko
5
+ Copyright (c) 2019-2025 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-2024 Yegor Bugayenko
5
+ Copyright (c) 2019-2025 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.11.0
4
+ version: 0.12.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: 2024-12-27 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace