dbi-dbrc 1.1.9 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0ff5de96e8773faa52022e20fff1d008c360faa548ff65b9aac4a82b2a7e34b5
4
+ data.tar.gz: dc7c04ad5ee358f59fca1a1c6331907a62e94177cdcc0cc2912eef9e204817c1
5
+ SHA512:
6
+ metadata.gz: f5ca232636482744e5049a744b629f0fd7b956c511e3024d166ff633c68f3ca16fb089c2d5b126da676d09cc4cdf7ac11bc2b57a46c8b4f01846e4d982c6d9ab
7
+ data.tar.gz: 9296fac30f6fc8a811e5e8cc1468a97d6da9ccb9a8155caecd1e61dc177f1599087191412cdfc294403cb73d6300c0d72e46ed9ba7ecaab15e22bc8c36f65371
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
@@ -1,24 +1,55 @@
1
- == 1.1.9 - 10-Jan-2013
1
+ ## 1.5.0 - 12-Apr-2021
2
+ * Switched from test-unit to rspec, with corresponding changes in the
3
+ gemspec and Rakefile.
4
+ * Switched doc files to markdown format.
5
+ * Added a Gemfile.
6
+
7
+ ## 1.4.1 - 14-Jan-2018
8
+ * Fixed some test warnings.
9
+ * Added metadata to gemspec.
10
+ * The VERSION constant is now frozen.
11
+ * Updated the cert, should be good for about 10 years.
12
+
13
+ ## 1.4.0 - 6-Dec-2015
14
+ * Use Dir.home to calculate the home directory on Unixy platforms. Therefore
15
+ Ruby 1.9.3 or later is now required.
16
+ * The DBI::DBRC::YML class looks for "maximum_reconnects" instead of
17
+ "max_reconn" to be consistent with the other classes.
18
+ * Aliases are now universal for all classes.
19
+ * Some gemspec and Rakefile updates.
20
+ * Added a dbi-dbrc.rb file for convenience.
21
+
22
+ ## 1.3.0 - 3-Oct-2015
23
+ * License changed to Apache 2.0.
24
+ * Rakefile gem related tasks now assume Rubygems 2.x.
25
+ * Added a certs file. This gem is now signed.
26
+
27
+ ## 1.2.0 - 8-Nov-2014
28
+ * Updated dependency for MS Windows. Now uses win32-file-attributes instead
29
+ of win32-file.
30
+ * Minor updates to the Rakefile and gemspec.
31
+
32
+ ## 1.1.9 - 10-Jan-2013
2
33
  * Fixed an unused variable warning.
3
34
  * Changed the way I check for MS Windows.
4
35
 
5
- == 1.1.8 - 7-Oct-2010
36
+ ## 1.1.8 - 7-Oct-2010
6
37
  * Fixed a logic bug in the constructor that primarily affected MS Windows with
7
38
  regards to determining the user's home directory.
8
39
 
9
- == 1.1.7 - 6-Oct-2010
40
+ ## 1.1.7 - 6-Oct-2010
10
41
  * More robust file decryption/encryption for MS Windows.
11
42
  * Better platform checking for MS Windows.
12
43
  * Refactored the Rakefile. Removed the old installation tasks and replaced
13
44
  them with a series of gem tasks.
14
45
  * Updated the win32 library dependencies.
15
46
 
16
- == 1.1.6 - 10-Sep-2009
47
+ ## 1.1.6 - 10-Sep-2009
17
48
  * Fixed validation for dbrc_dir argument.
18
49
  * Added a test for bogus dbrc_dir arguments.
19
50
 
20
- == 1.1.5 - 3-Sep-2009
21
- * License changed to Artistic 2.0.
51
+ ## 1.1.5 - 3-Sep-2009
52
+ * License changed to Artistic-2.0.
22
53
  * Some gemspec updates, including the license and description.
23
54
  * Renamed the test files. The ts_all.rb file was removed.
24
55
  * Added win32-process as a dependency on MS Windows.
@@ -28,24 +59,24 @@
28
59
  * Refactored the main test task.
29
60
  * Added explicit copyright and warranty to the README file.
30
61
 
31
- == 1.1.4 - 10-Nov-2008
62
+ ## 1.1.4 - 10-Nov-2008
32
63
  * Added a custom inspect method which filters the password.
33
64
 
34
- == 1.1.3 - 21-Jul-2008
65
+ ## 1.1.3 - 21-Jul-2008
35
66
  * More RUBY_PLATFORM changes that I missed in the last release.
36
67
  * Added inline RDOC for the accessors and updated the documentation
37
68
  for the constructor.
38
69
  * Added the DBI::DBRC#dbrc_dir and DBI::DBRC#dbrc_file methods.
39
70
  * More tests.
40
71
 
41
- == 1.1.2 - 18-Jul-2008
72
+ ## 1.1.2 - 18-Jul-2008
42
73
  * Changed platform checking from RUBY_PLATFORM to Config::CONFIG['host_os']
43
74
  so that other implementations won't choke.
44
75
  * Updated the gemspec to add the sys-admin dependency.
45
76
  * Added a rubyforge_project to the gemspec.
46
77
  * Now has a separate gem for MS Windows.
47
78
 
48
- == 1.1.1 - 2-Aug-2007
79
+ ## 1.1.1 - 2-Aug-2007
49
80
  * DBRCError is now DBRC::Error.
50
81
  * Added a Rakefile with tasks for installation and testing.
51
82
  * Added the win32-dir library as a prerequisite for MS Windows.
@@ -54,21 +85,21 @@
54
85
  warnings that appeared when run with -w.
55
86
  * Some doc and test updates.
56
87
 
57
- == 1.1.0 - 19-Oct-2005
88
+ ## 1.1.0 - 19-Oct-2005
58
89
  * Bug fix for MS Windows (there's no Win32 namespace for win32/file).
59
90
  * Changed platform detection mechanism.
60
91
 
61
- == 1.0.1 - 7-Oct-2005
92
+ ## 1.0.1 - 7-Oct-2005
62
93
  * Improved the error message when an entry isn't found.
63
94
 
64
- == 1.0.0 - 15-Jun-2005
95
+ ## 1.0.0 - 15-Jun-2005
65
96
  * Ditches the use of 'etc'. Now requires the 'sys-admin' package as its
66
97
  replacement (for all platforms).
67
98
  * Moved project to RubyForge.
68
99
  * Minor updates to tests, README and gemspec.
69
100
  * Now hosted on RubyForge.
70
101
 
71
- == 0.5.1 - 17-Mar-2005
102
+ ## 0.5.1 - 17-Mar-2005
72
103
  * Removed the 'doc' directory completely, and moved the primary
73
104
  documentation into the README file.
74
105
  * Removed the INSTALL file. Moved the installation directions into the
@@ -77,7 +108,7 @@
77
108
  * Made the README and CHANGES files rdoc friendly.
78
109
  * Added a gemspec.
79
110
 
80
- == 0.5.0 - 15-Oct-2004
111
+ ## 0.5.0 - 15-Oct-2004
81
112
  * Added a YAML subclass. Use this if you want to store your information in
82
113
  the .dbrc file in YAML format.
83
114
  * On Win32 systems, the .dbrc file must now be "hidden". Also, it will
@@ -94,19 +125,19 @@
94
125
  using rdtool.
95
126
  * Test suite changes.
96
127
 
97
- == 0.4.0 - 3-Sep-2004
128
+ ## 0.4.0 - 3-Sep-2004
98
129
  * Removed redundant error handling for cases when the database and/or login
99
130
  are not found.
100
131
  * Added an XML subclass. Use this if you want to store your information in
101
132
  the .dbrc file in XML format.
102
133
 
103
- == 0.3.0 - 26-Oct-2003
134
+ ## 0.3.0 - 26-Oct-2003
104
135
  * Win32 support added. Requires the win32-etc package.
105
136
  * rd doc separated from source. Moved to 'doc' directory.
106
137
  * Documentation updates and corrections.
107
138
  * Minor test suite tweaks for Win32 systems.
108
139
 
109
- == 0.2.1 - 28-Aug-2003
140
+ ## 0.2.1 - 28-Aug-2003
110
141
  * Removed VERSION class method. Just use the constant.
111
142
  * Bug fix with regards to split and Ruby 1.8. Thanks Michael Garriss.
112
143
  * Changed 'changelog' to 'CHANGES'.
@@ -115,7 +146,7 @@
115
146
  * Test unit cleanup
116
147
  * Minor internal directory layout and doc changes
117
148
 
118
- == 0.2.0 - 13-Jan-2003
149
+ ## 0.2.0 - 13-Jan-2003
119
150
  * DBRC class now under the DBI module namespace
120
151
  * Changed "timeout" to "time_out" to avoid confusion with the timeout
121
152
  module.
@@ -137,9 +168,9 @@
137
168
  * Install script improved
138
169
  * Documentation additions, including plain text doc
139
170
 
140
- == 0.1.1 - 26-Jul-2002
171
+ ## 0.1.1 - 26-Jul-2002
141
172
  * Added 'dsn()' method
142
173
  * Minor documentation additions
143
174
 
144
- == 0.1.0 - 26-Jul-2002
175
+ ## 0.1.0 - 26-Jul-2002
145
176
  * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org' do
2
+ gemspec
3
+ end
@@ -1,8 +1,9 @@
1
- * MANIFEST
2
- * CHANGES
3
- * README
1
+ * CHANGES.md
2
+ * MANIFEST.md
3
+ * README.md
4
4
  * Rakefile
5
5
  * dbi-dbrc.gemspec
6
+ * certs/djberg96_pub.pem
6
7
  * lib/dbi/dbrc.rb
7
8
  * examples/plain/.dbrc
8
9
  * examples/plain/test.rb
@@ -10,6 +11,6 @@
10
11
  * examples/xml_examples/test_xml.rb
11
12
  * examples/yml_examples/.dbrc
12
13
  * examples/yml_examples/test_yml.rb
13
- * test/test_dbi_dbrc.rb
14
- * test/test_dbi_dbrc_xml.rb
15
- * test/test_dbi_dbrc_yml.rb
14
+ * spec/dbi_dbrc_spec.rb
15
+ * spec/dbi_dbrc_xml_spec.rb
16
+ * spec/dbi_dbrc_yml_spec.rb
data/README.md ADDED
@@ -0,0 +1,292 @@
1
+ ## Description
2
+ This is a supplement to the dbi library, allowing you to avoid hard-coding
3
+ passwords in your programs that make database connections. It can also
4
+ be used as a general password storage mechanism for other types of
5
+ connections, e.g. ssh, ftp, etc.
6
+
7
+ ## Requirements
8
+ For most platforms there are no additional requirements. However, for MS
9
+ Windows there are these additional requirements:
10
+
11
+ * sys-admin
12
+ * win32-file-attributes
13
+ * win32-dir
14
+ * win32-process
15
+
16
+ ## Installation
17
+ `gem install dbi-dbrc`
18
+
19
+ ## Synopsis
20
+ ```ruby
21
+ require 'dbi/dbrc'
22
+
23
+ dbrc = DBI::DBRC.new('mydb') # or...
24
+ dbrc = DBI::DBRC.new('mydb', 'someUser')
25
+
26
+ puts dbrc.db
27
+ puts dbrc.user
28
+ puts dbrc.driver
29
+ puts dbrc.timeout
30
+ puts dbrc.max_reconn
31
+ puts dbrc.interval
32
+ puts dbrc.dsn
33
+ ```
34
+
35
+ ## Notes on the .dbrc file
36
+ This module relies on a file in your home directory called ".dbrc", and it
37
+ is meant to be analogous to the ".netrc" file used by programs such as
38
+ telnet. The .dbrc file has several conditions that must be met by the
39
+ module or it will fail:
40
+
41
+ * Permissions must be set to 600 (Unix only).
42
+ * Must be hidden (MS Windows only).
43
+ * Must be owned by the current user.
44
+ * Must have database, user and password. Other fields are optional.
45
+ * Must be in the following space-separated format (in the 'plain' version):
46
+
47
+ ```
48
+ database user password driver timeout maximum_reconnects interval
49
+ # e.g. mydb dan mypass oracle 10 2 30
50
+ ```
51
+
52
+ You may include comments in the .dbrc file by starting the line with a
53
+ "#" symbol.
54
+
55
+ A failure in any of the rules mentioned above will result in a `DBRC::Error`
56
+ being raised. In addition, the file may also be encrypted on MS Windows
57
+ systems, in which case the file will automatically be (temporarily)
58
+ decrypted.
59
+
60
+ The format for XML (using the example above) is as follows:
61
+
62
+ ```xml
63
+ <dbrc>
64
+ <database name="mydb">
65
+ <user>dan</user>
66
+ <password>mypass</password>
67
+ <driver>oracle</driver>
68
+ <interval>30</interval>
69
+ <timeout>10</timeout>
70
+ <maximum_reconnects>2</maximum_reconnects>
71
+ </database>
72
+ </dbrc>
73
+ ```
74
+
75
+ The format for YAML is as follows:
76
+
77
+ ```yaml
78
+ - mydb:
79
+ user: dan
80
+ password: mypass
81
+ driver: oracle
82
+ interval: 30
83
+ timeout: 10
84
+ max_reconn: 2
85
+ ```
86
+
87
+ ## Constants
88
+ `VERSION`
89
+
90
+ The current version of this library, returned as a String.
91
+
92
+ ## Class Methods
93
+ `DBRC.new(db, user=nil, dir=nil)`
94
+
95
+ The constructor takes one to three arguments. The first argument is the
96
+ database name. This *must* be provided. If only the database name is
97
+ passed, the module will look for the first database entry in the .dbrc
98
+ file that matches.
99
+
100
+ The second argument, a user name, is optional. If it is passed, the
101
+ module will look for the first entry in the .dbrc file where both the
102
+ database *and* user name match.
103
+
104
+ The third argument, also optional, specifies the directory where DBRC will
105
+ look for the .dbrc file. By default, it looks in the pwuid (present
106
+ working user id) home directory. The rules for a .dbrc file still apply.
107
+
108
+ MS Windows users should read the "Notes" section for how your home directory
109
+ is determined.
110
+
111
+ ## Instance Methods
112
+ `DBRC#database`
113
+
114
+ The name of the database. Note that the same entry can appear more than
115
+ once, presumably because you have multiple user id's for the same database.
116
+
117
+ `DBRC#db`
118
+
119
+ An alias for DBRC#database.
120
+
121
+ `DBRC#database=(database)`
122
+
123
+ Sets the database to +database+. This is generally discouraged because
124
+ it does not automatically reset the dsn.
125
+
126
+ `DBRC#db=(database)`
127
+
128
+ An alias for DBRC#database=.
129
+
130
+ `DBRC#user`
131
+
132
+ A valid user name for that database.
133
+
134
+ `DBRC#user=(user)`
135
+
136
+ Sets the user name to +user+.
137
+
138
+ `DBRC#password`
139
+
140
+ The password for that user.
141
+
142
+ `DBRC#passwd`
143
+
144
+ An alias for DBRC#password.
145
+
146
+ `DBRC#password=(password)`
147
+
148
+ Sets the password to +password+.
149
+
150
+ `DBRC#passwd=(password)`
151
+
152
+ An alias for DBRC#password=.
153
+
154
+ `DBRC#driver`
155
+
156
+ The driver type for that database (Oracle, MySql, etc).
157
+
158
+ `DBRC#driver=(driver)`
159
+
160
+ Sets the driver to +driver+. This use is discouraged because it does not reset the dsn.
161
+
162
+ `DBRC#timeout`
163
+
164
+ The timeout period for a connection before the attempt is dropped.
165
+
166
+ `DBRC#time_out`
167
+
168
+ An alias for DBRC#timeout, provided purely for the sake of backwards compatability.
169
+
170
+ `DBRC#timeout=(int)`
171
+
172
+ Sets the timeout value to +int+.
173
+
174
+ `DBRC#maximum_reconnects`
175
+
176
+ The maximum number of reconnect attempts that should be made for the the
177
+ database. Presumablly, you would use this with a "retry" within a rescue block.
178
+
179
+ `DBRC#max_reconn`
180
+
181
+ An alias for DBRC#maximum_reconnects.
182
+
183
+ `DBRC#maximum_reconnects=(max)`
184
+
185
+ Sets the maximum number of reconnect attempts to +max+.
186
+
187
+ `DBRC#max_reconn=(max)`
188
+
189
+ An alias for DBRC#maximum_reconnects.
190
+
191
+ `DBRC#interval`
192
+
193
+ The number of seconds to wait before attempting to reconnect to the database
194
+ again should a network/database glitch occur.
195
+
196
+ `DBRC#interval=(int)`
197
+
198
+ Sets the interval seconds between connection attempts.
199
+
200
+ `DBRC#dsn`
201
+
202
+ Returns a string in "dbi:<driver>:<database>" format.
203
+
204
+ `DBRC#dsn=(dsn)`
205
+
206
+ Sets the dsn string to +dsn+. This method is discouraged because it does
207
+ not automatically reset the driver or database.
208
+
209
+ ## Canonical Example
210
+ ```ruby
211
+ # This is a basic template for how I do things:
212
+
213
+ require 'dbi/dbrc'
214
+ require 'timeout'
215
+
216
+ db = DBI::DBRC.new("somedb")
217
+ n = db.max_reconn
218
+
219
+ begin
220
+ Timeout.timeout(db.timeout){
221
+ DBI.connect(db.dsn, db.user, db.passwd)
222
+ }
223
+ rescue DBI::Error
224
+ n -= 1
225
+ if n > 0
226
+ sleep db.interval
227
+ retry
228
+ end
229
+ raise
230
+ rescue TimeoutError
231
+ # handle timeout error
232
+ end
233
+ ```
234
+
235
+ ## Notes for MS Windows Users
236
+ The `home` directory for Win32 users is determined by `ENV['USERPROFILE']`.
237
+ If that is not set then `ENV['HOME']` is used. If that is not set, then
238
+ the directory found by the sys-admin library is used.
239
+
240
+ To make your file hidden, right click on the .dbrc file in your Explorer
241
+ window, select "Properties" and check the "Hidden" checkbox.
242
+
243
+ I was going to require that the .dbrc file be encrypted on MS Windows,
244
+ but that may require an official "certificate", assigned to you by a third
245
+ party, which is a bit much to expect. However, if the file is encrypted,
246
+ DBRC will attempt to decrypt it, parse it, and encrypt it again when done
247
+ parsing.
248
+
249
+ ## Notes on running the test suite
250
+ I cannot guarantee that the .dbrc files under the `examples`
251
+ subdirectories maintain the appropriate properties. This can cause
252
+ failures for the test suite (which uses these files).
253
+
254
+ The only solution is to perform a `chmod 600 .dbrc` (on Unix) or set
255
+ the properties to 'hidden' (on MS Windows) manually, for the file in
256
+ question.
257
+
258
+ ## Summary
259
+ These "methods" don't really do anything. They're simply meant as a
260
+ convenience mechanism for you dbi connections, plus a little bit of
261
+ obfuscation (for passwords).
262
+
263
+ ## Adding your own configuration
264
+ If you want to add your own type of configuration file, you can still use
265
+ the dbi-dbrc library. All you need to do is:
266
+
267
+ * subclass DBRC
268
+ * redefine the `parse_dbrc_config_file` method (a private method).
269
+
270
+ Take a look at the XML and YML subclasses in dbrc.rb for two examples that
271
+ you can work from.
272
+
273
+ ## Future Plans
274
+ Add DBI::DBRC::JSON.
275
+
276
+ ## Known Bugs
277
+ I'm not positive about the dsn strings for databases other than Oracle.
278
+ If it's not correct, please let me know.
279
+
280
+ ## Copyright
281
+ (C) Copyright 2002-2021, Daniel J. Berger, all rights reserved.
282
+
283
+ ## License
284
+ Apache-2.0
285
+
286
+ ## Warranty
287
+ This package is provided "as is" and without any express or
288
+ implied warranties, including, without limitation, the implied
289
+ warranties of merchantability and fitness for a particular purpose
290
+
291
+ ## Author
292
+ Daniel J. Berger