dbi-dbrc 1.2.0 → 1.6.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
- SHA1:
3
- metadata.gz: c06a82f0b5915c76160c669042762b9d997d0b19
4
- data.tar.gz: da10908388b233637d14464a59999f4c8455426d
2
+ SHA256:
3
+ metadata.gz: 4f38085a9c7abb4c8a3e53fb239196135d317f78baa14a33f415fbaeab0b03d6
4
+ data.tar.gz: a591ba6877a994765c4ad4dc5eb540b149c98398fe11bfd93ff04be1dca4e562
5
5
  SHA512:
6
- metadata.gz: c28240c48fc90ece726f41b216b8d9afd23eda6b5f5183118765de25549fbfd1cc570528a9d759d7f27df38ae50c3cc97c7e01bdacc1b687ceaf98967f76e0b3
7
- data.tar.gz: 837b3838c075a30b920c10ccc05ddaf5edd7ff3b94dc39374400c84eb0c261c66bd7cf3b9c01fe1194362968965567188c28837897b256fa9d0bacf60af06822
6
+ metadata.gz: 607d4e9c54ceb5c98cfaa7dc1df75708b151daac57cca77bb244371d43a1950107334081cb65ea112ba46da85aa9b015700ad23df863a09f7cbd628b0627d069
7
+ data.tar.gz: 3712726dcf66e0f4dc19c4dbe46115e1dc9ea5159a59a4e9e31bf250e643dd07f114a6b4b27585a31c7a4c34016bba22c3999592b831feaea3aeeacddb9a57f4
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ �l7n�3h�39پP?9\�7����p��� W �?���^kR_ɛ��-��� ����ɝ\�7}z6Dvզ��&�JS�ӧd%��H" � ����t��� ��Q�27?�2gw\"�|H��/S��%$�]�p_tz lf�G��)uJ��:�����# UR�ц�.+I���h�/h)?���d�U�U�4���l��Y���-�v�alW��u��-��,�@rl�[��g�J��:scVCW� F�i�'��N��Z��&���!�V�.�#��� `��4���̣��
2
+ ��J��1�c1���r�/��������7��)�F,I%��B�r�+���W������B��[���,��
3
+ �s���`uލܫO�ޚ
data.tar.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ D7����s�a�Ԙן Ǯ��eM*t���
2
+ v��)��-���8#�m�'� O�>=�C����՚�{H��cSbD��l���T�������ɕ�itĈ|�q>����c���Җ� �����+M�={h�m�mo��d���P��q����A�Ⱦs�2vƫ�t=��3�g<�����D�2�G�e������"zZ�l�n�f jZ�� �Ɯr�i�G"
3
+ ɡ=�
4
+ 5�}0�V`浍L��Wc>��5|dc.cƒy)ä&+Xh�~C��9�� �EO~L�pwx���| U �kI5 ����H�Z�T6���"��o>T������8����t��c$� ?���|d�N�OS,Dik��?i����kW(ܠ=���B��
@@ -1,29 +1,63 @@
1
- == 1.2.0 - 8-Nov-2014
1
+ ## 1.6.0 - 9-Jun-2021
2
+ * Now supports gpg encrypted files, with a 4th optional parameter where you
3
+ can pass gpg options (usually a password, but whatever gpgme supports).
4
+ * Added gpgme as a dependency.
5
+ * Updated specs for MS Windows.
6
+ * The "home" handling is now a bit simpler, as it was originally written
7
+ before that method existed in core Ruby.
8
+
9
+ ## 1.5.0 - 12-Apr-2021
10
+ * Switched from test-unit to rspec, with corresponding changes in the
11
+ gemspec and Rakefile.
12
+ * Switched doc files to markdown format.
13
+ * Added a Gemfile.
14
+
15
+ ## 1.4.1 - 14-Jan-2018
16
+ * Fixed some test warnings.
17
+ * Added metadata to gemspec.
18
+ * The VERSION constant is now frozen.
19
+ * Updated the cert, should be good for about 10 years.
20
+
21
+ ## 1.4.0 - 6-Dec-2015
22
+ * Use Dir.home to calculate the home directory on Unixy platforms. Therefore
23
+ Ruby 1.9.3 or later is now required.
24
+ * The DBI::DBRC::YML class looks for "maximum_reconnects" instead of
25
+ "max_reconn" to be consistent with the other classes.
26
+ * Aliases are now universal for all classes.
27
+ * Some gemspec and Rakefile updates.
28
+ * Added a dbi-dbrc.rb file for convenience.
29
+
30
+ ## 1.3.0 - 3-Oct-2015
31
+ * License changed to Apache 2.0.
32
+ * Rakefile gem related tasks now assume Rubygems 2.x.
33
+ * Added a certs file. This gem is now signed.
34
+
35
+ ## 1.2.0 - 8-Nov-2014
2
36
  * Updated dependency for MS Windows. Now uses win32-file-attributes instead
3
37
  of win32-file.
4
38
  * Minor updates to the Rakefile and gemspec.
5
39
 
6
- == 1.1.9 - 10-Jan-2013
40
+ ## 1.1.9 - 10-Jan-2013
7
41
  * Fixed an unused variable warning.
8
42
  * Changed the way I check for MS Windows.
9
43
 
10
- == 1.1.8 - 7-Oct-2010
44
+ ## 1.1.8 - 7-Oct-2010
11
45
  * Fixed a logic bug in the constructor that primarily affected MS Windows with
12
46
  regards to determining the user's home directory.
13
47
 
14
- == 1.1.7 - 6-Oct-2010
48
+ ## 1.1.7 - 6-Oct-2010
15
49
  * More robust file decryption/encryption for MS Windows.
16
50
  * Better platform checking for MS Windows.
17
51
  * Refactored the Rakefile. Removed the old installation tasks and replaced
18
52
  them with a series of gem tasks.
19
53
  * Updated the win32 library dependencies.
20
54
 
21
- == 1.1.6 - 10-Sep-2009
55
+ ## 1.1.6 - 10-Sep-2009
22
56
  * Fixed validation for dbrc_dir argument.
23
57
  * Added a test for bogus dbrc_dir arguments.
24
58
 
25
- == 1.1.5 - 3-Sep-2009
26
- * License changed to Artistic 2.0.
59
+ ## 1.1.5 - 3-Sep-2009
60
+ * License changed to Artistic-2.0.
27
61
  * Some gemspec updates, including the license and description.
28
62
  * Renamed the test files. The ts_all.rb file was removed.
29
63
  * Added win32-process as a dependency on MS Windows.
@@ -33,24 +67,24 @@
33
67
  * Refactored the main test task.
34
68
  * Added explicit copyright and warranty to the README file.
35
69
 
36
- == 1.1.4 - 10-Nov-2008
70
+ ## 1.1.4 - 10-Nov-2008
37
71
  * Added a custom inspect method which filters the password.
38
72
 
39
- == 1.1.3 - 21-Jul-2008
73
+ ## 1.1.3 - 21-Jul-2008
40
74
  * More RUBY_PLATFORM changes that I missed in the last release.
41
75
  * Added inline RDOC for the accessors and updated the documentation
42
76
  for the constructor.
43
77
  * Added the DBI::DBRC#dbrc_dir and DBI::DBRC#dbrc_file methods.
44
78
  * More tests.
45
79
 
46
- == 1.1.2 - 18-Jul-2008
80
+ ## 1.1.2 - 18-Jul-2008
47
81
  * Changed platform checking from RUBY_PLATFORM to Config::CONFIG['host_os']
48
82
  so that other implementations won't choke.
49
83
  * Updated the gemspec to add the sys-admin dependency.
50
84
  * Added a rubyforge_project to the gemspec.
51
85
  * Now has a separate gem for MS Windows.
52
86
 
53
- == 1.1.1 - 2-Aug-2007
87
+ ## 1.1.1 - 2-Aug-2007
54
88
  * DBRCError is now DBRC::Error.
55
89
  * Added a Rakefile with tasks for installation and testing.
56
90
  * Added the win32-dir library as a prerequisite for MS Windows.
@@ -59,21 +93,21 @@
59
93
  warnings that appeared when run with -w.
60
94
  * Some doc and test updates.
61
95
 
62
- == 1.1.0 - 19-Oct-2005
96
+ ## 1.1.0 - 19-Oct-2005
63
97
  * Bug fix for MS Windows (there's no Win32 namespace for win32/file).
64
98
  * Changed platform detection mechanism.
65
99
 
66
- == 1.0.1 - 7-Oct-2005
100
+ ## 1.0.1 - 7-Oct-2005
67
101
  * Improved the error message when an entry isn't found.
68
102
 
69
- == 1.0.0 - 15-Jun-2005
103
+ ## 1.0.0 - 15-Jun-2005
70
104
  * Ditches the use of 'etc'. Now requires the 'sys-admin' package as its
71
105
  replacement (for all platforms).
72
106
  * Moved project to RubyForge.
73
107
  * Minor updates to tests, README and gemspec.
74
108
  * Now hosted on RubyForge.
75
109
 
76
- == 0.5.1 - 17-Mar-2005
110
+ ## 0.5.1 - 17-Mar-2005
77
111
  * Removed the 'doc' directory completely, and moved the primary
78
112
  documentation into the README file.
79
113
  * Removed the INSTALL file. Moved the installation directions into the
@@ -82,7 +116,7 @@
82
116
  * Made the README and CHANGES files rdoc friendly.
83
117
  * Added a gemspec.
84
118
 
85
- == 0.5.0 - 15-Oct-2004
119
+ ## 0.5.0 - 15-Oct-2004
86
120
  * Added a YAML subclass. Use this if you want to store your information in
87
121
  the .dbrc file in YAML format.
88
122
  * On Win32 systems, the .dbrc file must now be "hidden". Also, it will
@@ -99,19 +133,19 @@
99
133
  using rdtool.
100
134
  * Test suite changes.
101
135
 
102
- == 0.4.0 - 3-Sep-2004
136
+ ## 0.4.0 - 3-Sep-2004
103
137
  * Removed redundant error handling for cases when the database and/or login
104
138
  are not found.
105
139
  * Added an XML subclass. Use this if you want to store your information in
106
140
  the .dbrc file in XML format.
107
141
 
108
- == 0.3.0 - 26-Oct-2003
142
+ ## 0.3.0 - 26-Oct-2003
109
143
  * Win32 support added. Requires the win32-etc package.
110
144
  * rd doc separated from source. Moved to 'doc' directory.
111
145
  * Documentation updates and corrections.
112
146
  * Minor test suite tweaks for Win32 systems.
113
147
 
114
- == 0.2.1 - 28-Aug-2003
148
+ ## 0.2.1 - 28-Aug-2003
115
149
  * Removed VERSION class method. Just use the constant.
116
150
  * Bug fix with regards to split and Ruby 1.8. Thanks Michael Garriss.
117
151
  * Changed 'changelog' to 'CHANGES'.
@@ -120,7 +154,7 @@
120
154
  * Test unit cleanup
121
155
  * Minor internal directory layout and doc changes
122
156
 
123
- == 0.2.0 - 13-Jan-2003
157
+ ## 0.2.0 - 13-Jan-2003
124
158
  * DBRC class now under the DBI module namespace
125
159
  * Changed "timeout" to "time_out" to avoid confusion with the timeout
126
160
  module.
@@ -142,9 +176,9 @@
142
176
  * Install script improved
143
177
  * Documentation additions, including plain text doc
144
178
 
145
- == 0.1.1 - 26-Jul-2002
179
+ ## 0.1.1 - 26-Jul-2002
146
180
  * Added 'dsn()' method
147
181
  * Minor documentation additions
148
182
 
149
- == 0.1.0 - 26-Jul-2002
183
+ ## 0.1.0 - 26-Jul-2002
150
184
  * 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