dbi-dbrc 1.4.1 → 1.5.0

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: 360d2807dbe54d14d421397476a8f5aa078ae2b6881fb33b9f9e86fd508c2eda
4
- data.tar.gz: c93adb1f0fdc58885e9e18cdb01b656761684a8201ca8aa188af7769e8eda776
3
+ metadata.gz: 0ff5de96e8773faa52022e20fff1d008c360faa548ff65b9aac4a82b2a7e34b5
4
+ data.tar.gz: dc7c04ad5ee358f59fca1a1c6331907a62e94177cdcc0cc2912eef9e204817c1
5
5
  SHA512:
6
- metadata.gz: 6db3ef1daa6494aa793df1ee029b7baa6c777d2185d70ce3c141fcf85f9d4b9f7cb55982828acc8d8111958ca65744534153324542fd53e563460fe73f525d6c
7
- data.tar.gz: 380b6774c0e94754af1843e2b9a5067c814e6065c50a8f9a15053032d30b4d46204b7c984fe84ee9922eddf77499b74b6ac2e80c14424d26f135c3f171c92e29
6
+ metadata.gz: f5ca232636482744e5049a744b629f0fd7b956c511e3024d166ff633c68f3ca16fb089c2d5b126da676d09cc4cdf7ac11bc2b57a46c8b4f01846e4d982c6d9ab
7
+ data.tar.gz: 9296fac30f6fc8a811e5e8cc1468a97d6da9ccb9a8155caecd1e61dc177f1599087191412cdfc294403cb73d6300c0d72e46ed9ba7ecaab15e22bc8c36f65371
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,10 +1,16 @@
1
- == 1.4.1 - 14-Jan-2018
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
2
8
  * Fixed some test warnings.
3
9
  * Added metadata to gemspec.
4
10
  * The VERSION constant is now frozen.
5
11
  * Updated the cert, should be good for about 10 years.
6
12
 
7
- == 1.4.0 - 6-Dec-2015
13
+ ## 1.4.0 - 6-Dec-2015
8
14
  * Use Dir.home to calculate the home directory on Unixy platforms. Therefore
9
15
  Ruby 1.9.3 or later is now required.
10
16
  * The DBI::DBRC::YML class looks for "maximum_reconnects" instead of
@@ -13,37 +19,37 @@
13
19
  * Some gemspec and Rakefile updates.
14
20
  * Added a dbi-dbrc.rb file for convenience.
15
21
 
16
- == 1.3.0 - 3-Oct-2015
22
+ ## 1.3.0 - 3-Oct-2015
17
23
  * License changed to Apache 2.0.
18
24
  * Rakefile gem related tasks now assume Rubygems 2.x.
19
25
  * Added a certs file. This gem is now signed.
20
26
 
21
- == 1.2.0 - 8-Nov-2014
27
+ ## 1.2.0 - 8-Nov-2014
22
28
  * Updated dependency for MS Windows. Now uses win32-file-attributes instead
23
29
  of win32-file.
24
30
  * Minor updates to the Rakefile and gemspec.
25
31
 
26
- == 1.1.9 - 10-Jan-2013
32
+ ## 1.1.9 - 10-Jan-2013
27
33
  * Fixed an unused variable warning.
28
34
  * Changed the way I check for MS Windows.
29
35
 
30
- == 1.1.8 - 7-Oct-2010
36
+ ## 1.1.8 - 7-Oct-2010
31
37
  * Fixed a logic bug in the constructor that primarily affected MS Windows with
32
38
  regards to determining the user's home directory.
33
39
 
34
- == 1.1.7 - 6-Oct-2010
40
+ ## 1.1.7 - 6-Oct-2010
35
41
  * More robust file decryption/encryption for MS Windows.
36
42
  * Better platform checking for MS Windows.
37
43
  * Refactored the Rakefile. Removed the old installation tasks and replaced
38
44
  them with a series of gem tasks.
39
45
  * Updated the win32 library dependencies.
40
46
 
41
- == 1.1.6 - 10-Sep-2009
47
+ ## 1.1.6 - 10-Sep-2009
42
48
  * Fixed validation for dbrc_dir argument.
43
49
  * Added a test for bogus dbrc_dir arguments.
44
50
 
45
- == 1.1.5 - 3-Sep-2009
46
- * License changed to Artistic 2.0.
51
+ ## 1.1.5 - 3-Sep-2009
52
+ * License changed to Artistic-2.0.
47
53
  * Some gemspec updates, including the license and description.
48
54
  * Renamed the test files. The ts_all.rb file was removed.
49
55
  * Added win32-process as a dependency on MS Windows.
@@ -53,24 +59,24 @@
53
59
  * Refactored the main test task.
54
60
  * Added explicit copyright and warranty to the README file.
55
61
 
56
- == 1.1.4 - 10-Nov-2008
62
+ ## 1.1.4 - 10-Nov-2008
57
63
  * Added a custom inspect method which filters the password.
58
64
 
59
- == 1.1.3 - 21-Jul-2008
65
+ ## 1.1.3 - 21-Jul-2008
60
66
  * More RUBY_PLATFORM changes that I missed in the last release.
61
67
  * Added inline RDOC for the accessors and updated the documentation
62
68
  for the constructor.
63
69
  * Added the DBI::DBRC#dbrc_dir and DBI::DBRC#dbrc_file methods.
64
70
  * More tests.
65
71
 
66
- == 1.1.2 - 18-Jul-2008
72
+ ## 1.1.2 - 18-Jul-2008
67
73
  * Changed platform checking from RUBY_PLATFORM to Config::CONFIG['host_os']
68
74
  so that other implementations won't choke.
69
75
  * Updated the gemspec to add the sys-admin dependency.
70
76
  * Added a rubyforge_project to the gemspec.
71
77
  * Now has a separate gem for MS Windows.
72
78
 
73
- == 1.1.1 - 2-Aug-2007
79
+ ## 1.1.1 - 2-Aug-2007
74
80
  * DBRCError is now DBRC::Error.
75
81
  * Added a Rakefile with tasks for installation and testing.
76
82
  * Added the win32-dir library as a prerequisite for MS Windows.
@@ -79,21 +85,21 @@
79
85
  warnings that appeared when run with -w.
80
86
  * Some doc and test updates.
81
87
 
82
- == 1.1.0 - 19-Oct-2005
88
+ ## 1.1.0 - 19-Oct-2005
83
89
  * Bug fix for MS Windows (there's no Win32 namespace for win32/file).
84
90
  * Changed platform detection mechanism.
85
91
 
86
- == 1.0.1 - 7-Oct-2005
92
+ ## 1.0.1 - 7-Oct-2005
87
93
  * Improved the error message when an entry isn't found.
88
94
 
89
- == 1.0.0 - 15-Jun-2005
95
+ ## 1.0.0 - 15-Jun-2005
90
96
  * Ditches the use of 'etc'. Now requires the 'sys-admin' package as its
91
97
  replacement (for all platforms).
92
98
  * Moved project to RubyForge.
93
99
  * Minor updates to tests, README and gemspec.
94
100
  * Now hosted on RubyForge.
95
101
 
96
- == 0.5.1 - 17-Mar-2005
102
+ ## 0.5.1 - 17-Mar-2005
97
103
  * Removed the 'doc' directory completely, and moved the primary
98
104
  documentation into the README file.
99
105
  * Removed the INSTALL file. Moved the installation directions into the
@@ -102,7 +108,7 @@
102
108
  * Made the README and CHANGES files rdoc friendly.
103
109
  * Added a gemspec.
104
110
 
105
- == 0.5.0 - 15-Oct-2004
111
+ ## 0.5.0 - 15-Oct-2004
106
112
  * Added a YAML subclass. Use this if you want to store your information in
107
113
  the .dbrc file in YAML format.
108
114
  * On Win32 systems, the .dbrc file must now be "hidden". Also, it will
@@ -119,19 +125,19 @@
119
125
  using rdtool.
120
126
  * Test suite changes.
121
127
 
122
- == 0.4.0 - 3-Sep-2004
128
+ ## 0.4.0 - 3-Sep-2004
123
129
  * Removed redundant error handling for cases when the database and/or login
124
130
  are not found.
125
131
  * Added an XML subclass. Use this if you want to store your information in
126
132
  the .dbrc file in XML format.
127
133
 
128
- == 0.3.0 - 26-Oct-2003
134
+ ## 0.3.0 - 26-Oct-2003
129
135
  * Win32 support added. Requires the win32-etc package.
130
136
  * rd doc separated from source. Moved to 'doc' directory.
131
137
  * Documentation updates and corrections.
132
138
  * Minor test suite tweaks for Win32 systems.
133
139
 
134
- == 0.2.1 - 28-Aug-2003
140
+ ## 0.2.1 - 28-Aug-2003
135
141
  * Removed VERSION class method. Just use the constant.
136
142
  * Bug fix with regards to split and Ruby 1.8. Thanks Michael Garriss.
137
143
  * Changed 'changelog' to 'CHANGES'.
@@ -140,7 +146,7 @@
140
146
  * Test unit cleanup
141
147
  * Minor internal directory layout and doc changes
142
148
 
143
- == 0.2.0 - 13-Jan-2003
149
+ ## 0.2.0 - 13-Jan-2003
144
150
  * DBRC class now under the DBI module namespace
145
151
  * Changed "timeout" to "time_out" to avoid confusion with the timeout
146
152
  module.
@@ -162,9 +168,9 @@
162
168
  * Install script improved
163
169
  * Documentation additions, including plain text doc
164
170
 
165
- == 0.1.1 - 26-Jul-2002
171
+ ## 0.1.1 - 26-Jul-2002
166
172
  * Added 'dsn()' method
167
173
  * Minor documentation additions
168
174
 
169
- == 0.1.0 - 26-Jul-2002
175
+ ## 0.1.0 - 26-Jul-2002
170
176
  * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org' do
2
+ gemspec
3
+ end
@@ -1,6 +1,6 @@
1
- * MANIFEST
2
- * CHANGES
3
- * README
1
+ * CHANGES.md
2
+ * MANIFEST.md
3
+ * README.md
4
4
  * Rakefile
5
5
  * dbi-dbrc.gemspec
6
6
  * certs/djberg96_pub.pem
@@ -11,6 +11,6 @@
11
11
  * examples/xml_examples/test_xml.rb
12
12
  * examples/yml_examples/.dbrc
13
13
  * examples/yml_examples/test_yml.rb
14
- * test/test_dbi_dbrc.rb
15
- * test/test_dbi_dbrc_xml.rb
16
- * 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