dbi-dbrc 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +9 -0
- data/MANIFEST +16 -0
- data/README +39 -42
- data/lib/dbi/dbrc.rb +39 -30
- data/test/tc_dbrc.rb +15 -20
- data/test/tc_dbrc_xml.rb +14 -19
- data/test/tc_dbrc_yml.rb +9 -18
- metadata +34 -27
data/CHANGES
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.1.1 - 2-Aug-2007
|
2
|
+
* DBRCError is now DBRC::Error.
|
3
|
+
* Added a Rakefile with tasks for installation and testing.
|
4
|
+
* Added the win32-dir library as a prerequisite for MS Windows.
|
5
|
+
* Removed the install.rb file. That's now handled by the Rakefile.
|
6
|
+
* Some refactoring in the constructor, including the elimination of
|
7
|
+
warnings that appeared when run with -w.
|
8
|
+
* Some doc and test updates.
|
9
|
+
|
1
10
|
== 1.1.0 - 19-Oct-2005
|
2
11
|
* Bug fix for MS Windows (there's no Win32 namespace for win32/file).
|
3
12
|
* Changed platform detection mechanism.
|
data/MANIFEST
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
* MANIFEST
|
2
|
+
* CHANGES
|
3
|
+
* README
|
4
|
+
* Rakefile
|
5
|
+
* dbi-dbrc.gemspec
|
6
|
+
* lib/dbi/dbrc.rb
|
7
|
+
* examples/plain/.dbrc
|
8
|
+
* examples/plain/test.rb
|
9
|
+
* examples/xml_examples/.dbrc
|
10
|
+
* examples/xml_examples/test_xml.rb
|
11
|
+
* examples/yml_examples/.dbrc
|
12
|
+
* examples/yml_examples/test_yml.rb
|
13
|
+
* test/ts_all.rb
|
14
|
+
* test/tc_dbrc.rb
|
15
|
+
* test/tc_dbrc_xml.rb
|
16
|
+
* test/tc_dbrc_yml.rb
|
data/README
CHANGED
@@ -2,15 +2,21 @@
|
|
2
2
|
This is a supplement to the dbi module, allowing you to avoid hard-coding
|
3
3
|
passwords in your programs that make database connections.
|
4
4
|
|
5
|
+
== Requirements
|
6
|
+
* Ruby 1.8.2 or later
|
7
|
+
* sys-admin
|
8
|
+
* win32-file (MS Windows only)
|
9
|
+
* win32-dir (MS Windows only)
|
10
|
+
|
5
11
|
== Synopsis
|
6
12
|
require 'dbi/dbrc'
|
7
13
|
include DBI
|
8
14
|
|
9
|
-
dbrc = DBRC.new(
|
15
|
+
dbrc = DBRC.new('mydb')
|
10
16
|
|
11
17
|
or
|
12
18
|
|
13
|
-
dbrc = DBRC.new(
|
19
|
+
dbrc = DBRC.new('mydb', 'someUser')
|
14
20
|
|
15
21
|
puts dbrc.db
|
16
22
|
puts dbrc.user
|
@@ -22,18 +28,9 @@
|
|
22
28
|
|
23
29
|
dbh = DBI.connect(dbrc.dsn, dbrc.user, dbrc.password)
|
24
30
|
|
25
|
-
== Requirements
|
26
|
-
* Ruby 1.8.0 or later
|
27
|
-
* sys-admin
|
28
|
-
* win32-file (Win32 only)
|
29
|
-
|
30
31
|
== Installation
|
31
|
-
|
32
|
-
|
33
|
-
* ruby install.rb
|
34
|
-
=== Gem Installation
|
35
|
-
* ruby dbi-dbrc.gemspec
|
36
|
-
* gem install dbi-dbrc-<version>.gem
|
32
|
+
rake test (optional)
|
33
|
+
rake install (non-gem) or rake install_gem (gem)
|
37
34
|
|
38
35
|
== Notes on the .dbrc file
|
39
36
|
This module relies on a file in your home directory called ".dbrc", and it
|
@@ -42,9 +39,9 @@
|
|
42
39
|
module or it will fail:
|
43
40
|
|
44
41
|
* Permissions must be set to 600 (Unix only).
|
45
|
-
* Must be hidden (
|
42
|
+
* Must be hidden (MS Windows only).
|
46
43
|
* Must be owned by the current user.
|
47
|
-
* Must have database, user and password.
|
44
|
+
* Must have database, user and password. Other fields are optional.
|
48
45
|
* Must be in the following space-separated format (in the 'plain' version):
|
49
46
|
|
50
47
|
database user password driver timeout maximum_reconnects interval
|
@@ -52,11 +49,12 @@
|
|
52
49
|
e.g. mydb dan mypass oracle 10 2 30
|
53
50
|
|
54
51
|
You may include comments in the .dbrc file by starting the line with a
|
55
|
-
"#" symbol
|
52
|
+
"#" symbol.
|
56
53
|
|
57
|
-
A failure in any of the rules mentioned above will result in a
|
58
|
-
being raised. In addition, the file may also be encrypted on
|
59
|
-
in which case the file will automatically be (temporarily)
|
54
|
+
A failure in any of the rules mentioned above will result in a DBRC::Error
|
55
|
+
being raised. In addition, the file may also be encrypted on MS Windows
|
56
|
+
systems, in which case the file will automatically be (temporarily)
|
57
|
+
decrypted.
|
60
58
|
|
61
59
|
The format for XML (using the example above) is as follows:
|
62
60
|
|
@@ -87,25 +85,25 @@ VERSION
|
|
87
85
|
|
88
86
|
== Class Methods
|
89
87
|
DBRC.new(db, user=nil, dir=nil)
|
90
|
-
The constructor takes one to three arguments.
|
91
|
-
database name.
|
88
|
+
The constructor takes one to three arguments. The first argument is the
|
89
|
+
database name. This *must* be provided. If only the database name is
|
92
90
|
passed, the module will look for the first database entry in the .dbrc
|
93
91
|
file that matches.
|
94
92
|
|
95
|
-
The second argument, a user name, is optional.
|
93
|
+
The second argument, a user name, is optional. If it is passed, the
|
96
94
|
module will look for the first entry in the .dbrc file where both the
|
97
95
|
database *and* user name match.
|
98
96
|
|
99
97
|
The third argument, also optional, specifies the directory where DBRC will
|
100
|
-
look for the .dbrc file.
|
101
|
-
working user id) home directory.
|
98
|
+
look for the .dbrc file. By default, it looks in the pwuid (present
|
99
|
+
working user id) home directory. The rules for a .dbrc file still apply.
|
102
100
|
|
103
|
-
|
101
|
+
MS Windows users should read the "Notes" section for how your home directory
|
104
102
|
is determined.
|
105
103
|
|
106
104
|
== Instance Methods
|
107
105
|
DBRC#database
|
108
|
-
The name of the database.
|
106
|
+
The name of the database. Note that the same entry can appear more than
|
109
107
|
once, presumably because you have multiple user id's for the same
|
110
108
|
database.
|
111
109
|
|
@@ -183,17 +181,17 @@ DBRC#dsn=(dsn)
|
|
183
181
|
not automatically reset the driver or database.
|
184
182
|
|
185
183
|
== Canonical Example
|
186
|
-
This is a basic template for how I do things:
|
184
|
+
# This is a basic template for how I do things:
|
187
185
|
|
188
|
-
require
|
189
|
-
require
|
186
|
+
require 'dbi/dbrc'
|
187
|
+
require 'timeout'
|
190
188
|
|
191
189
|
db = DBI::DBRC.new("somedb")
|
192
190
|
n = db.max_reconn
|
193
191
|
|
194
192
|
begin
|
195
193
|
timeout(db.time_out){
|
196
|
-
DBI.connect(db.dsn,db.user,db.passwd)
|
194
|
+
DBI.connect(db.dsn, db.user, db.passwd)
|
197
195
|
}
|
198
196
|
rescue DBI::Error
|
199
197
|
n -= 1
|
@@ -203,25 +201,24 @@ DBRC#dsn=(dsn)
|
|
203
201
|
rescue TimeoutError
|
204
202
|
# handle timeout error
|
205
203
|
end
|
206
|
-
|
207
|
-
== Notes for
|
204
|
+
|
205
|
+
== Notes for MS Windows Users
|
208
206
|
The 'home' directory for Win32 users is determined by ENV['USERPROFILE'].
|
209
|
-
If that is not set, ENV['HOME'] is used.
|
210
|
-
'C:\Documents and Settings\'
|
211
|
-
used.
|
207
|
+
If that is not set, ENV['HOME'] is used. If that is not set, then
|
208
|
+
'C:\Documents and Settings\user_name' is used.
|
212
209
|
|
213
210
|
To make your file hidden, right click on the .dbrc file in your Explorer
|
214
211
|
window, select "Properties" and check the "Hidden" checkbox.
|
215
212
|
|
216
|
-
I was going to require that the .dbrc file be encrypted on
|
213
|
+
I was going to require that the .dbrc file be encrypted on MS Windows,
|
217
214
|
but that may require an official "certificate", assigned to you by a third
|
218
|
-
party, which is a bit much to expect.
|
215
|
+
party, which is a bit much to expect. However, if the file is encrypted,
|
219
216
|
DBRC will attempt to decrypt it, parse it, and encrypt it again when done
|
220
217
|
parsing.
|
221
218
|
|
222
219
|
== Notes on running the test suite
|
223
220
|
I cannot guarantee that the .dbrc files under the +examples+
|
224
|
-
subdirectories maintain the appropriate properties.
|
221
|
+
subdirectories maintain the appropriate properties. This can cause
|
225
222
|
failures for the test suite (which uses these files).
|
226
223
|
|
227
224
|
The only solution is to perform a 'chmod 600 .dbrc' (on Unix) or set
|
@@ -229,16 +226,16 @@ DBRC#dsn=(dsn)
|
|
229
226
|
question.
|
230
227
|
|
231
228
|
== Summary
|
232
|
-
These "methods" don't really do anything.
|
229
|
+
These "methods" don't really do anything. They're simply meant as a
|
233
230
|
convenience mechanism for you dbi connections, plus a little bit of
|
234
231
|
obfuscation (for passwords).
|
235
232
|
|
236
233
|
== Adding your own configuration
|
237
234
|
If you want to add your own type of configuration file, you can still use
|
238
|
-
the dbi-dbrc package.
|
235
|
+
the dbi-dbrc package. All you need to do is:
|
239
236
|
|
240
237
|
* subclass DBRC
|
241
|
-
* redefine the +parse_dbrc_config_file+ method
|
238
|
+
* redefine the +parse_dbrc_config_file+ method (a private method).
|
242
239
|
|
243
240
|
Take a look at the XML and YML subclasses in dbrc.rb for two examples that
|
244
241
|
you can work from.
|
@@ -249,5 +246,5 @@ DBRC#dsn=(dsn)
|
|
249
246
|
|
250
247
|
== Author
|
251
248
|
Daniel J. Berger
|
252
|
-
djberg96 at gmail dot com
|
249
|
+
djberg96 at nospam at gmail dot com
|
253
250
|
imperator on IRC (irc.freenode.net)
|
data/lib/dbi/dbrc.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
|
-
if
|
2
|
-
require
|
1
|
+
if RUBY_PLATFORM.match('mswin')
|
2
|
+
require 'win32/file'
|
3
|
+
require 'win32/dir'
|
3
4
|
end
|
4
5
|
|
5
|
-
require
|
6
|
+
require 'sys/admin'
|
6
7
|
include Sys
|
7
8
|
|
9
|
+
# The DBI module serves as a namespace only.
|
8
10
|
module DBI
|
9
11
|
|
10
|
-
# The
|
11
|
-
# the error that is raised. A subclass of StandardError.
|
12
|
-
class DBRCError < StandardError; end
|
13
|
-
|
14
|
-
# The main class.
|
12
|
+
# The DBRC class encapsulates a database resource config file.
|
15
13
|
class DBRC
|
16
|
-
|
14
|
+
|
15
|
+
# This error is raised if anything fails trying to read the config file.
|
16
|
+
# the error that is raised.
|
17
|
+
class Error < StandardError; end
|
18
|
+
|
19
|
+
VERSION = '1.1.1'
|
17
20
|
attr_accessor :database, :user, :password, :driver, :dsn
|
18
21
|
attr_accessor :maximum_reconnects, :timeout, :interval, :dbrc_dir
|
19
22
|
|
@@ -28,38 +31,43 @@ module DBI
|
|
28
31
|
# file.
|
29
32
|
#
|
30
33
|
# If an entry cannot be found for the database, or database plus user
|
31
|
-
# combination, then a
|
34
|
+
# combination, then a Error is raised. If the .dbrc file cannot
|
32
35
|
# be found, or is setup improperly with regards to permissions or
|
33
|
-
# properties, a
|
34
|
-
|
36
|
+
# properties, a Error is raised.
|
37
|
+
#
|
38
|
+
def initialize(database, user=nil, dbrc_dir=nil)
|
35
39
|
if dbrc_dir.nil?
|
36
|
-
if
|
37
|
-
home = ENV[
|
40
|
+
if RUBY_PLATFORM.match('mswin')
|
41
|
+
home = ENV['USERPROFILE'] || ENV['HOME']
|
38
42
|
file = nil
|
39
43
|
|
40
44
|
if home
|
41
|
-
file = home
|
45
|
+
file = File.join(home, '.dbrc')
|
42
46
|
else
|
43
|
-
file =
|
44
|
-
file += Admin.get_user(Admin.get_login).home_dir + "\\.dbrc"
|
47
|
+
file = File.join(File.basename(Dir::APPDATA), '.dbrc')
|
45
48
|
end
|
46
49
|
|
47
50
|
@dbrc_file = file
|
48
51
|
else
|
49
|
-
@dbrc_file = Admin.get_user(Process.uid).dir
|
52
|
+
@dbrc_file = File.join(Admin.get_user(Process.uid).dir, '.dbrc')
|
50
53
|
end
|
51
54
|
else
|
52
|
-
@dbrc_file = dbrc_dir
|
55
|
+
@dbrc_file = File.join(dbrc_dir, '.dbrc')
|
53
56
|
end
|
54
57
|
|
55
58
|
@database = database
|
56
59
|
@user = user
|
57
60
|
encrypted = false # Win32 only
|
58
61
|
|
62
|
+
@driver = nil
|
63
|
+
@interval = nil
|
64
|
+
@timeout = nil
|
65
|
+
@maximum_reconnects = nil
|
66
|
+
|
59
67
|
check_file()
|
60
68
|
|
61
69
|
# If on Win32 and the file is encrypted, decrypt it.
|
62
|
-
if
|
70
|
+
if RUBY_PLATFORM.match("mswin") && File.encrypted?(@dbrc_file)
|
63
71
|
encrypted = true
|
64
72
|
File.decrypt(@dbrc_file)
|
65
73
|
end
|
@@ -70,7 +78,7 @@ module DBI
|
|
70
78
|
create_dsn_string()
|
71
79
|
|
72
80
|
# If on Win32 and the file was encrypted, re-encrypt it
|
73
|
-
if
|
81
|
+
if RUBY_PLATFORM.match("mswin") && encrypted
|
74
82
|
File.encrypt(@dbrc_file)
|
75
83
|
end
|
76
84
|
end
|
@@ -80,11 +88,11 @@ module DBI
|
|
80
88
|
# Ensure that the user/password has been set
|
81
89
|
def validate_data
|
82
90
|
unless @user
|
83
|
-
raise
|
91
|
+
raise Error, "no user found associated with #{@database}"
|
84
92
|
end
|
85
93
|
|
86
94
|
unless @password
|
87
|
-
raise
|
95
|
+
raise Error, "password not defined for #{@user}@#{@database}"
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
@@ -106,19 +114,19 @@ module DBI
|
|
106
114
|
|
107
115
|
# Permissions must be set to 600 or better on Unix systems.
|
108
116
|
# Must be hidden on Win32 systems.
|
109
|
-
if
|
117
|
+
if RUBY_PLATFORM.match("mswin")
|
110
118
|
unless File.hidden?(file)
|
111
|
-
raise
|
119
|
+
raise Error, "The .dbrc file must be hidden"
|
112
120
|
end
|
113
121
|
else
|
114
122
|
unless (f.stat.mode & 077) == 0
|
115
|
-
raise
|
123
|
+
raise Error, "Bad .dbrc file permissions"
|
116
124
|
end
|
117
125
|
end
|
118
126
|
|
119
127
|
# Only the owner may use it
|
120
128
|
unless f.stat.owned?
|
121
|
-
raise
|
129
|
+
raise Error, "Not owner of .dbrc file"
|
122
130
|
end
|
123
131
|
}
|
124
132
|
end
|
@@ -151,7 +159,8 @@ module DBI
|
|
151
159
|
else
|
152
160
|
err = "no record found for #{@database}"
|
153
161
|
end
|
154
|
-
|
162
|
+
|
163
|
+
raise Error, err
|
155
164
|
end
|
156
165
|
|
157
166
|
alias_method(:db,:database)
|
@@ -187,7 +196,7 @@ module DBI
|
|
187
196
|
return
|
188
197
|
}
|
189
198
|
# If we reach here it means the database and/or user wasn't found
|
190
|
-
raise
|
199
|
+
raise Error, "No record found for #{@user}@#{@database}"
|
191
200
|
end
|
192
201
|
end
|
193
202
|
|
@@ -214,7 +223,7 @@ module DBI
|
|
214
223
|
}
|
215
224
|
}
|
216
225
|
# If we reach this point, it means the database wasn't found
|
217
|
-
raise
|
226
|
+
raise Error, "No entry found for #{@user}@#{@database}"
|
218
227
|
end
|
219
228
|
end
|
220
229
|
end
|
data/test/tc_dbrc.rb
CHANGED
@@ -1,24 +1,19 @@
|
|
1
|
-
|
1
|
+
#########################################################################
|
2
2
|
# tc_dbrc.rb
|
3
3
|
#
|
4
|
-
# Test suite for the base class of DBI::DBRC.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Dir.chdir("..") if base == "test"
|
10
|
-
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
11
|
-
Dir.chdir("test") rescue nil
|
12
|
-
end
|
13
|
-
|
14
|
-
require "dbi/dbrc"
|
15
|
-
require "test/unit"
|
4
|
+
# Test suite for the base class of DBI::DBRC. This test case should be
|
5
|
+
# run via the 'rake test' task.
|
6
|
+
#########################################################################
|
7
|
+
require 'dbi/dbrc'
|
8
|
+
require 'test/unit'
|
16
9
|
include DBI
|
17
10
|
|
18
11
|
class TC_DBRC < Test::Unit::TestCase
|
19
12
|
def setup
|
13
|
+
Dir.chdir('test') if File.basename(Dir.pwd) != 'test'
|
14
|
+
|
20
15
|
@dir = "../examples/plain"
|
21
|
-
@file = @dir
|
16
|
+
@file = File.join(@dir, '.dbrc')
|
22
17
|
@db1 = "foo"
|
23
18
|
@db2 = "bar"
|
24
19
|
@user1 = "user1"
|
@@ -27,7 +22,7 @@ class TC_DBRC < Test::Unit::TestCase
|
|
27
22
|
@user_bad = "user8" # Doesn't exist
|
28
23
|
|
29
24
|
if File::ALT_SEPARATOR
|
30
|
-
File.set_attr(@file,File::HIDDEN)
|
25
|
+
File.set_attr(@file, File::HIDDEN)
|
31
26
|
else
|
32
27
|
File.chmod(0600, @file)
|
33
28
|
end
|
@@ -36,16 +31,16 @@ class TC_DBRC < Test::Unit::TestCase
|
|
36
31
|
end
|
37
32
|
|
38
33
|
def test_version
|
39
|
-
assert_equal("1.1.
|
34
|
+
assert_equal("1.1.1", DBRC::VERSION)
|
40
35
|
end
|
41
36
|
|
42
37
|
def test_bad_dbrc_properties
|
43
38
|
if File::ALT_SEPARATOR
|
44
39
|
File.unset_attr(@file, File::HIDDEN)
|
45
|
-
assert_raises(
|
40
|
+
assert_raises(DBRC::Error){ DBRC.new(@db1, @user1, @dir) }
|
46
41
|
else
|
47
42
|
File.chmod(0555,@file)
|
48
|
-
assert_raises(
|
43
|
+
assert_raises(DBRC::Error){ DBRC.new(@db1, @user1, @dir) }
|
49
44
|
end
|
50
45
|
end
|
51
46
|
|
@@ -56,11 +51,11 @@ class TC_DBRC < Test::Unit::TestCase
|
|
56
51
|
end
|
57
52
|
|
58
53
|
def test_bad_database
|
59
|
-
assert_raises(
|
54
|
+
assert_raises(DBRC::Error){ DBRC.new(@db_bad, nil, @dir) }
|
60
55
|
end
|
61
56
|
|
62
57
|
def test_bad_user
|
63
|
-
assert_raises(
|
58
|
+
assert_raises(DBRC::Error){ DBRC.new(@db1, @user_bad, @dir) }
|
64
59
|
end
|
65
60
|
|
66
61
|
def test_database
|
data/test/tc_dbrc_xml.rb
CHANGED
@@ -1,16 +1,9 @@
|
|
1
|
-
|
1
|
+
########################################################################
|
2
2
|
# tc_dbrc_xml.rb
|
3
3
|
#
|
4
|
-
# Test suite for the XML specific version of DBI::DBRC.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
if base == "test" || base =~ /dbi-dbrc/
|
9
|
-
Dir.chdir("..") if base == "test"
|
10
|
-
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
11
|
-
Dir.chdir("test") rescue nil
|
12
|
-
end
|
13
|
-
|
4
|
+
# Test suite for the XML specific version of DBI::DBRC. This test case
|
5
|
+
# should be run via the 'rake test' task.
|
6
|
+
########################################################################
|
14
7
|
require "dbi/dbrc"
|
15
8
|
require "test/unit"
|
16
9
|
require "rexml/document"
|
@@ -19,8 +12,9 @@ include DBI
|
|
19
12
|
|
20
13
|
class TC_DBRC_XML < Test::Unit::TestCase
|
21
14
|
def setup
|
15
|
+
Dir.chdir('test') if File.basename(Dir.pwd) != 'test'
|
22
16
|
@dir = "../examples/xml"
|
23
|
-
@file = @dir
|
17
|
+
@file = File.join(@dir, ".dbrc")
|
24
18
|
@db1 = "foo"
|
25
19
|
@db2 = "bar"
|
26
20
|
@user1 = "user1"
|
@@ -28,12 +22,13 @@ class TC_DBRC_XML < Test::Unit::TestCase
|
|
28
22
|
@db_bad = "blah" # Doesn't exist
|
29
23
|
@user_bad = "user8" # Doesn't exist
|
30
24
|
|
25
|
+
if File::ALT_SEPARATOR
|
26
|
+
File.set_attr(@file, File::HIDDEN)
|
27
|
+
else
|
28
|
+
File.chmod(0600, @file)
|
29
|
+
end
|
30
|
+
|
31
31
|
@dbrc = DBRC::XML.new(@db1, nil, @dir)
|
32
|
-
File.chmod(0600, @file)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_version
|
36
|
-
assert_equal("1.1.0", DBRC::XML::VERSION)
|
37
32
|
end
|
38
33
|
|
39
34
|
def test_constructor
|
@@ -43,11 +38,11 @@ class TC_DBRC_XML < Test::Unit::TestCase
|
|
43
38
|
end
|
44
39
|
|
45
40
|
def test_bad_database
|
46
|
-
assert_raises(
|
41
|
+
assert_raises(DBRC::Error){ DBRC::XML.new(@db_bad, nil, @dir) }
|
47
42
|
end
|
48
43
|
|
49
44
|
def test_bad_user
|
50
|
-
assert_raises(
|
45
|
+
assert_raises(DBRC::Error){ DBRC::XML.new(@db1, @user_bad, @dir) }
|
51
46
|
end
|
52
47
|
|
53
48
|
def test_database
|
data/test/tc_dbrc_yml.rb
CHANGED
@@ -1,24 +1,19 @@
|
|
1
|
-
|
1
|
+
#########################################################################
|
2
2
|
# tc_dbrc_yml.rb
|
3
3
|
#
|
4
|
-
# Test suite for the YAML specific version of DBI::DBRC.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
if base == "test" || base =~ /dbi-dbrc/
|
9
|
-
Dir.chdir("..") if base == "test"
|
10
|
-
$LOAD_PATH.unshift(Dir.pwd + "/lib")
|
11
|
-
Dir.chdir("test") rescue nil
|
12
|
-
end
|
13
|
-
|
4
|
+
# Test suite for the YAML specific version of DBI::DBRC. You should run
|
5
|
+
# this test case via the 'rake test' task.
|
6
|
+
#########################################################################
|
14
7
|
require "dbi/dbrc"
|
15
8
|
require "test/unit"
|
16
9
|
include DBI
|
17
10
|
|
18
11
|
class TC_DBRC_YML < Test::Unit::TestCase
|
19
12
|
def setup
|
13
|
+
Dir.chdir('test') if File.basename(Dir.pwd) != 'test'
|
14
|
+
|
20
15
|
@dir = "../examples/yml"
|
21
|
-
@file = @dir
|
16
|
+
@file = File.join(@dir, '.dbrc')
|
22
17
|
@db1 = "foo"
|
23
18
|
@db2 = "bar"
|
24
19
|
@user1 = "user1"
|
@@ -35,10 +30,6 @@ class TC_DBRC_YML < Test::Unit::TestCase
|
|
35
30
|
@dbrc = DBRC::YML.new(@db1, nil, @dir)
|
36
31
|
end
|
37
32
|
|
38
|
-
def test_version
|
39
|
-
assert_equal("1.1.0", DBRC::YML::VERSION)
|
40
|
-
end
|
41
|
-
|
42
33
|
def test_constructor
|
43
34
|
assert_raises(ArgumentError){ DBRC::YML.new }
|
44
35
|
assert_nothing_raised{ DBRC::YML.new(@db1, @user1, @dir) }
|
@@ -46,11 +37,11 @@ class TC_DBRC_YML < Test::Unit::TestCase
|
|
46
37
|
end
|
47
38
|
|
48
39
|
def test_bad_database
|
49
|
-
assert_raises(
|
40
|
+
assert_raises(DBRC::Error){ DBRC::YML.new(@db_bad, nil, @dir) }
|
50
41
|
end
|
51
42
|
|
52
43
|
def test_bad_user
|
53
|
-
assert_raises(
|
44
|
+
assert_raises(DBRC::Error){ DBRC::YML.new(@db1, @user_bad, @dir) }
|
54
45
|
end
|
55
46
|
|
56
47
|
def test_database
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: dbi-dbrc
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date:
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2007-08-02 00:00:00 -06:00
|
8
8
|
summary: A simple way to avoid hard-coding passwords with DBI
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: djberg96@gmail.com
|
12
12
|
homepage: http://www.rubyforge.org/projects/shards
|
13
13
|
rubyforge_project:
|
@@ -18,38 +18,45 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
27
26
|
signing_key:
|
28
27
|
cert_chain:
|
28
|
+
post_install_message:
|
29
29
|
authors:
|
30
|
-
|
30
|
+
- Daniel Berger
|
31
31
|
files:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
- examples/plain
|
33
|
+
- examples/plain/test.rb
|
34
|
+
- examples/xml
|
35
|
+
- examples/xml/test_xml.rb
|
36
|
+
- examples/yml
|
37
|
+
- examples/yml/test_yml.rb
|
38
|
+
- lib/dbi
|
39
|
+
- lib/dbi/dbrc.rb
|
40
|
+
- test/tc_dbrc.rb
|
41
|
+
- test/tc_dbrc_xml.rb
|
42
|
+
- test/tc_dbrc_yml.rb
|
43
|
+
- test/ts_all.rb
|
44
|
+
- README
|
45
|
+
- CHANGES
|
46
|
+
- MANIFEST
|
46
47
|
test_files:
|
47
|
-
|
48
|
+
- test/ts_all.rb
|
48
49
|
rdoc_options: []
|
50
|
+
|
49
51
|
extra_rdoc_files:
|
50
|
-
|
51
|
-
|
52
|
+
- README
|
53
|
+
- CHANGES
|
54
|
+
- MANIFEST
|
52
55
|
executables: []
|
56
|
+
|
53
57
|
extensions: []
|
58
|
+
|
54
59
|
requirements: []
|
55
|
-
|
60
|
+
|
61
|
+
dependencies: []
|
62
|
+
|