redshift-client 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: b658841f49c42bf499c3f22897a4705513570c93
4
- data.tar.gz: 1742bf0ceafb98d437226a4bf4a326560e4b7d76
3
+ metadata.gz: 57e6fbf69de3d525922584318839428a561a0f6b
4
+ data.tar.gz: f66fd482e6d7f9c6edce75a631797e5fd18164b6
5
5
  SHA512:
6
- metadata.gz: 5378dd022002853efb3f3941dba78b10ca841a6f20cd5e0c25b2a6833d0185940feb4662ba106c6dea7005966a11ef8fb5cdbbf12c911ad057e3998d48667f5a
7
- data.tar.gz: dab2d572ee46543f268a830640c66034c83a81516398979a5dc10ff2875d2dbcfac15ddd9d8e8e089203269aad499e949269ae5711c049a47f34e158061dae1d
6
+ metadata.gz: 83b406edb33a22f17bd980c97261aea3b6a7e0a4ee28c48c888f4ca2418b04952e986a11b5874b5cf0fe9fb2259755e4e4cd77c4a03d7be281a799b6a1a0236f
7
+ data.tar.gz: abbe01a0b47e299370ffd150d9fd02c788bfe78a01a1b1ab17769644e80f3c232501a81c0bba784301ca0e190e49e3e3f116736e2432c7dc29c6a99b1a985b77
@@ -1,5 +1,6 @@
1
1
  require 'pg'
2
2
  require 'uri'
3
+ require 'active_support/lazy_load_hooks'
3
4
 
4
5
  module Redshift
5
6
  module Client
@@ -26,7 +27,7 @@ module Redshift
26
27
  end
27
28
 
28
29
  def connection
29
- raise ConnectionNotEstablished.new unless established?
30
+ ActiveSupport.run_load_hooks :redshift_client_connection unless established?
30
31
 
31
32
  if connected?
32
33
  thread[:connection]
@@ -49,6 +50,7 @@ module Redshift
49
50
  end
50
51
 
51
52
  def connect!
53
+ raise ConnectionNotEstablished.new unless established?
52
54
  thread[:connection] = PG.connect(thread[:configurations].to_hash)
53
55
  end
54
56
 
@@ -1,5 +1,5 @@
1
1
  module Redshift
2
2
  module Client
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_runtime_dependency "pg"
23
+ spec.add_runtime_dependency "activesupport", ">= 4"
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.10"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
@@ -53,6 +53,31 @@ describe Redshift::Client do
53
53
  end
54
54
  end
55
55
 
56
+ describe "#connection" do
57
+ context "when already established" do
58
+ before do
59
+ Redshift::Client.establish_connection
60
+ end
61
+
62
+ it "returns PG::Connection" do
63
+ expect(Redshift::Client.connection).to be_instance_of PG::Connection
64
+ end
65
+ end
66
+
67
+ context "when not yet established" do
68
+ before do
69
+ allow(ActiveSupport).to receive :run_load_hooks
70
+ end
71
+
72
+ it "calls ActiveSupport#run_load_hooks and raise error" do
73
+ Thread.new {
74
+ expect { Redshift::Client.connection }.to raise_error(Redshift::Client::ConnectionNotEstablished)
75
+ expect(ActiveSupport).to have_received(:run_load_hooks).with(:redshift_client_connection).once
76
+ }.join
77
+ end
78
+ end
79
+ end
80
+
56
81
  describe "#established?" do
57
82
  context "when already established" do
58
83
  before do
@@ -70,7 +95,7 @@ describe Redshift::Client do
70
95
 
71
96
  context "when not yet established" do
72
97
  it "returns false" do
73
- Thread.new { expect(Redshift::Client).not_to be_established }
98
+ Thread.new { expect(Redshift::Client).not_to be_established }.join
74
99
  end
75
100
  end
76
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redshift-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dai Akatsuka
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement