pgtk 0.7.0 → 0.7.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: f41534dffad429c075e89f8281a87a7e18e8f2367177d5ad01f58cb5d97e1874
4
- data.tar.gz: a9d3c137d5130aa409b628a8645803e8c282b06512a02e38b4e42371f7deedc6
3
+ metadata.gz: 13fb64166a42e15fcc78444b4ea01a3b8fcd9039272d5c7fa98a8dc72b879c57
4
+ data.tar.gz: 80cd807f7fa20fa256ffba82e033673a58dc9cf453bf4cb5387a8d591cd31206
5
5
  SHA512:
6
- metadata.gz: 06b8af281bb9f2823875384e4d1b81eb0561d03946a1b7472ee23641ba0fe0084ac8327101214888b5f452c331181c1e4aaff1f9884173d62adc4eda170a723e
7
- data.tar.gz: c84061bce114c7b79e646cc9851d3b13086629f6c8b0a2dcec6ed548fa128e24bd95b2a00d6ccb71c952dddb25f7216c118977dd1892354121add6e2017ad83f
6
+ metadata.gz: 2ea2debe02d73ad8ac645b40e184fac2f03f575d05dc3bd099a090233d1a380b65f158f909d77bd51281a32a4b280b7ccf7891f259995c0f3c8e67c10188de88
7
+ data.tar.gz: d5d4c3a4d664ac09801f3464f2eefeb6d28a257717f0ee63d88f27b7b3bd6b9348de0a9f35e9daabe203c8428830327961a70690d5eeae6515169a6c24cfe6fe
data/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/pgtk.svg)](https://codecov.io/github/yegor256/pgtk?branch=master)
16
16
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/pgtk)](https://hitsofcode.com/view/github/yegor256/pgtk)
17
17
 
18
- This small Ruby gem helps you integrate PostgreSQL with your Ruby
18
+ This small Ruby gem helps you integrate [PostgreSQL](https://www.postgresql.org/) with your Ruby
19
19
  web app, through [Liquibase](https://www.liquibase.org/). It also adds a simple connection pool
20
20
  and query processor, to make SQL manipulation simpler.
21
21
 
@@ -120,6 +120,13 @@ Should work. Well, it works in [zold-io/wts.zold.io](https://github.com/zold-io/
120
120
  and [yegor256/mailanes](https://github.com/yegor256/mailanes). They both are
121
121
  open source, you can see how they use `pgtk`.
122
122
 
123
+ These open source web apps of mine are using pgtk (check their source code
124
+ to see how it all works):
125
+
126
+ * [wts.zold.io](https://github.com/zold-io/wts.zold.io)
127
+ * [mailanes](https://github.com/yegor256/mailanes)
128
+ * [0rsk](https://github.com/yegor256/0rsk)
129
+
123
130
  ## How to contribute
124
131
 
125
132
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
@@ -148,7 +148,7 @@ class Pgtk::Pool
148
148
  rows
149
149
  end
150
150
  end
151
- @log.debug("#{sql}: #{(start - Time.now).round}ms")
151
+ @log.debug("#{sql}: #{(start - Time.now).round}ms / #{@conn.object_id}")
152
152
  out
153
153
  end
154
154
  end
@@ -159,9 +159,10 @@ class Pgtk::Pool
159
159
  conn = @pool.pop
160
160
  begin
161
161
  yield conn
162
- rescue PG::Error
162
+ rescue StandardError => e
163
163
  conn.close
164
- @pool << @wire.connection
164
+ conn = @wire.connection
165
+ raise e
165
166
  ensure
166
167
  @pool << conn
167
168
  end
@@ -28,5 +28,5 @@ require_relative '../pgtk'
28
28
  # License:: MIT
29
29
  module Pgtk
30
30
  # Current version of the library.
31
- VERSION = '0.7.0'
31
+ VERSION = '0.7.1'
32
32
  end
@@ -61,7 +61,7 @@ end
61
61
  # License:: MIT
62
62
  class Pgtk::Wire::Env
63
63
  # Constructor.
64
- def initialize(var)
64
+ def initialize(var = 'DATABASE_URL')
65
65
  @var = var
66
66
  end
67
67
 
@@ -22,8 +22,10 @@
22
22
 
23
23
  require 'minitest/autorun'
24
24
  require 'tmpdir'
25
+ require 'pg'
25
26
  require 'rake'
26
27
  require 'yaml'
28
+ require 'loog'
27
29
  require_relative '../lib/pgtk/pgsql_task'
28
30
  require_relative '../lib/pgtk/liquibase_task'
29
31
  require_relative '../lib/pgtk/pool'
@@ -67,6 +69,17 @@ class TestPool < Minitest::Test
67
69
  end
68
70
  end
69
71
 
72
+ def test_reconnects_on_pg_error
73
+ bootstrap do |pool|
74
+ assert_raises PG::UndefinedTable do
75
+ pool.exec('SELECT * FROM thisiserror')
76
+ end
77
+ 5.times do
78
+ pool.exec('SELECT * FROM book')
79
+ end
80
+ end
81
+ end
82
+
70
83
  private
71
84
 
72
85
  def bootstrap
@@ -87,7 +100,10 @@ class TestPool < Minitest::Test
87
100
  t.quiet = true
88
101
  end
89
102
  Rake::Task["liquibase#{id}"].invoke
90
- pool = Pgtk::Pool.new(Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')))
103
+ pool = Pgtk::Pool.new(
104
+ Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
105
+ log: Loog::VERBOSE
106
+ )
91
107
  pool.start(1)
92
108
  yield pool
93
109
  end
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.7.0
4
+ version: 0.7.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: 2019-06-25 00:00:00.000000000 Z
11
+ date: 2019-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace