ardb 0.28.2 → 0.28.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ardb.rb +21 -6
- data/lib/ardb/version.rb +1 -1
- data/test/support/postgresql/setup_test_db.rb +1 -0
- data/test/unit/ardb_tests.rb +15 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA512:
|
3
|
-
metadata.gz: f4a5484485c36474860b31db1f64cd6c2d50bfa9dbfc885b38ac248a79fe6022f34915085a842b3cbee868ac8bbe7de5bc03b80d84600185a7154be93675a0dd
|
4
|
-
data.tar.gz: c52b82f4e6277afeac490fae8e3c80b4f71f8b0c73b8fa3170a7a42bf1d88894d4ad6b005961177976e6b68cc6533d965400cfe020fcf8378fea84755ad2d14f
|
5
2
|
SHA1:
|
6
|
-
|
7
|
-
|
3
|
+
data.tar.gz: 352c1dc50e3ac2567d5f74cc148ba572d4fa8f3d
|
4
|
+
metadata.gz: 0a5e57adec591aaa7273bade002b3f873caef819
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: c16e759ea474b84490ebb450825b44e11725960d847ff82cfec5e5840dd00b853a4278cc92f49989da04f6f04196b61aa428f4ba7f151f7562cd3d562ead9015
|
7
|
+
metadata.gz: f61b9a4df10d7d2b5b4520d8f601c1e3f9d3e1155a306d9b477cecf63d9021546bf9123adcdfddd9747f1348a905a388d564ef4babbde667c97fd732b355e213
|
data/lib/ardb.rb
CHANGED
@@ -15,14 +15,19 @@ module Ardb
|
|
15
15
|
self.config.tap(&block)
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.adapter
|
18
|
+
def self.adapter
|
19
|
+
@adapter || raise(NotInitializedError.new(caller))
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.reset_adapter; @adapter = nil; end
|
19
23
|
|
20
24
|
def self.init(establish_connection = true)
|
21
25
|
require 'ardb/require_autoloaded_active_record_files'
|
22
26
|
begin
|
23
27
|
require_db_file
|
24
28
|
rescue InvalidDBFileError => exception
|
25
|
-
|
29
|
+
exception.set_backtrace(caller)
|
30
|
+
raise exception
|
26
31
|
end
|
27
32
|
|
28
33
|
self.config.validate!
|
@@ -35,6 +40,9 @@ module Ardb
|
|
35
40
|
|
36
41
|
def self.escape_like_pattern(pattern, escape_char = nil)
|
37
42
|
self.adapter.escape_like_pattern(pattern, escape_char)
|
43
|
+
rescue NotInitializedError => exception
|
44
|
+
exception.set_backtrace(caller)
|
45
|
+
raise exception
|
38
46
|
end
|
39
47
|
|
40
48
|
private
|
@@ -122,10 +130,10 @@ module Ardb
|
|
122
130
|
def ==(other)
|
123
131
|
if other.kind_of?(self.class)
|
124
132
|
self.activerecord_connect_hash == other.activerecord_connect_hash &&
|
125
|
-
self.logger == other.logger
|
126
|
-
self.root_path == other.root_path
|
127
|
-
self.schema_format == other.schema_format
|
128
|
-
self.migrations_path == other.migrations_path
|
133
|
+
self.logger == other.logger &&
|
134
|
+
self.root_path == other.root_path &&
|
135
|
+
self.schema_format == other.schema_format &&
|
136
|
+
self.migrations_path == other.migrations_path &&
|
129
137
|
self.schema_path == other.schema_path
|
130
138
|
else
|
131
139
|
super
|
@@ -179,4 +187,11 @@ module Ardb
|
|
179
187
|
ConfigurationError = Class.new(ArgumentError)
|
180
188
|
InvalidAdapterError = Class.new(RuntimeError)
|
181
189
|
|
190
|
+
class NotInitializedError < RuntimeError
|
191
|
+
def initialize(backtrace)
|
192
|
+
super("ardb hasn't been initialized yet, run `Ardb.init`")
|
193
|
+
set_backtrace(backtrace)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
182
197
|
end
|
data/lib/ardb/version.rb
CHANGED
data/test/unit/ardb_tests.rb
CHANGED
@@ -14,10 +14,13 @@ module Ardb
|
|
14
14
|
setup do
|
15
15
|
@module = Ardb
|
16
16
|
end
|
17
|
+
teardown do
|
18
|
+
@module.reset_adapter
|
19
|
+
end
|
17
20
|
subject{ @module }
|
18
21
|
|
19
|
-
should have_imeths :config, :configure, :adapter, :
|
20
|
-
should have_imeths :escape_like_pattern
|
22
|
+
should have_imeths :config, :configure, :adapter, :reset_adapter
|
23
|
+
should have_imeths :init, :escape_like_pattern
|
21
24
|
|
22
25
|
should "default the db file env var" do
|
23
26
|
assert_equal 'config/db', ENV['ARDB_DB_FILE']
|
@@ -122,6 +125,16 @@ module Ardb
|
|
122
125
|
assert_equal 2, @ardb_adapter.connect_db_called_count
|
123
126
|
end
|
124
127
|
|
128
|
+
should "raise a not initialized error using its adapter before init" do
|
129
|
+
subject.reset_adapter
|
130
|
+
assert_raises(NotInitializedError){ subject.adapter }
|
131
|
+
assert_raises(NotInitializedError){ subject.escape_like_pattern(Factory.string) }
|
132
|
+
|
133
|
+
subject.init
|
134
|
+
assert_nothing_raised{ subject.adapter }
|
135
|
+
assert_nothing_raised{ subject.escape_like_pattern(Factory.string) }
|
136
|
+
end
|
137
|
+
|
125
138
|
end
|
126
139
|
|
127
140
|
class InitTests < InitMethodSetupTests
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ardb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.28.
|
4
|
+
version: 0.28.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-08-18 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: assert
|