dbi-dbrc 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,14 @@
1
+ == 1.1.5 - 3-Sep-2009
2
+ * License changed to Artistic 2.0.
3
+ * Some gemspec updates, including the license and description.
4
+ * Renamed the test files. The ts_all.rb file was removed.
5
+ * Added win32-process as a dependency on MS Windows.
6
+ * Added test-unit as a development dependency. Some tests were refactored
7
+ to use features from test-unit 2.x.
8
+ * Added the 'test_xml' and 'test_yml' rake tasks.
9
+ * Refactored the main test task.
10
+ * Added explicit copyright and warranty to the README file.
11
+
1
12
  == 1.1.4 - 10-Nov-2008
2
13
  * Added a custom inspect method which filters the password.
3
14
 
data/MANIFEST CHANGED
@@ -10,7 +10,6 @@
10
10
  * examples/xml_examples/test_xml.rb
11
11
  * examples/yml_examples/.dbrc
12
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
13
+ * test/test_dbi_dbrc.rb
14
+ * test/test_dbi_dbrc_xml.rb
15
+ * test/test_dbi_dbrc_yml.rb
data/README CHANGED
@@ -242,11 +242,20 @@ DBRC#dsn=(dsn)
242
242
  Take a look at the XML and YML subclasses in dbrc.rb for two examples that
243
243
  you can work from.
244
244
 
245
+ == Future Plans
246
+ Add DBI::DBRC::JSON.
247
+
245
248
  == Known Bugs
246
249
  I'm not positive about the dsn strings for databases other than Oracle.
247
250
  If it's not correct, please let me know.
248
251
 
252
+ == Copyright
253
+ (C) Copyright 2002-2009, Daniel J. Berger, all rights reserved.
254
+
255
+ = Warranty
256
+ This package is provided "as is" and without any express or
257
+ implied warranties, including, without limitation, the implied
258
+ warranties of merchantability and fitness for a particular purpose
259
+
249
260
  == Author
250
261
  Daniel J. Berger
251
- djberg96 at nospam at gmail dot com
252
- imperator on IRC (irc.freenode.net)
@@ -0,0 +1,33 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ desc "Install the dbi-dbrc package (non-gem)"
5
+ task :install do
6
+ dest = File.join(Config::CONFIG['sitelibdir'], 'dbi')
7
+ Dir.mkdir(dest) unless File.exists? dest
8
+ cp 'lib/dbi/dbrc.rb', dest, :verbose => true
9
+ end
10
+
11
+ desc "Install the dbi-dbrc package as a gem"
12
+ task :install_gem do
13
+ ruby 'dbi-dbrc.gemspec'
14
+ file = Dir["*.gem"].first
15
+ sh "gem install #{file}"
16
+ end
17
+
18
+ Rake::TestTask.new do |t|
19
+ t.warning = true
20
+ t.verbose = true
21
+ end
22
+
23
+ Rake::TestTask.new(:test_xml) do |t|
24
+ t.warning = true
25
+ t.verbose = true
26
+ t.test_files = FileList['test/test_dbi_dbrc_xml.rb']
27
+ end
28
+
29
+ Rake::TestTask.new(:test_yml) do |t|
30
+ t.warning = true
31
+ t.verbose = true
32
+ t.test_files = FileList['test/test_dbi_dbrc_yml.rb']
33
+ end
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'dbi-dbrc'
5
+ s.version = '1.1.5'
6
+ s.author = 'Daniel Berger'
7
+ s.email = 'djberg96@gmail.com'
8
+ s.license = 'Artistic 2.0'
9
+ s.summary = 'A simple way to avoid hard-coding passwords with DBI'
10
+ s.homepage = 'http://www.rubyforge.org/projects/shards'
11
+ s.platform = Gem::Platform::RUBY
12
+ s.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
13
+ s.test_files = Dir['test/test*.rb']
14
+ s.has_rdoc = true
15
+
16
+ s.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
17
+ s.rubyforge_project = 'shards'
18
+
19
+ s.add_dependency('sys-admin', '>= 1.5.2')
20
+ s.add_development_dependency('test-unit')
21
+
22
+ if Config::CONFIG['host_os'] =~ /mswin|win32|dos/i
23
+ s.add_dependency('win32-file', '>= 0.4.2')
24
+ s.add_dependency('win32-dir', '>= 0.3.0')
25
+ s.add_dependency('win32-process', '>= 0.6.1')
26
+ s.platform = Gem::Platform::CURRENT
27
+ end
28
+
29
+ s.description = <<-EOF
30
+ The dbi-dbrc library provides an interface for storing database
31
+ connection information, including passwords, in a locally secure
32
+ file only accessible by you, or root. This allows you to avoid
33
+ hard coding login and password information in your programs
34
+ that require such information.
35
+
36
+ This library can also be used to store login and password information
37
+ for logins on remote hosts, not just databases.
38
+ EOF
39
+ end
40
+
41
+ Gem::Builder.new(spec).build
@@ -1,8 +1,9 @@
1
1
  require 'rbconfig'
2
2
 
3
- if Config::CONFIG['host_os'].match('mswin')
3
+ if Config::CONFIG['host_os'] =~ /mswin|win32|dos/i
4
4
  require 'win32/file'
5
5
  require 'win32/dir'
6
+ require 'win32/process'
6
7
  end
7
8
 
8
9
  require 'sys/admin'
@@ -14,11 +15,12 @@ module DBI
14
15
  class DBRC
15
16
 
16
17
  # This error is raised if anything fails trying to read the config file.
17
- # the error that is raised.
18
18
  class Error < StandardError; end
19
19
 
20
- # The version of this library
21
- VERSION = '1.1.4'
20
+ # The version of the dbi-dbrc library
21
+ VERSION = '1.1.5'
22
+
23
+ @@windows = Config::CONFIG['host_os'] =~ /mswin|win32|dos/i
22
24
 
23
25
  # The database or host to be connected to.
24
26
  attr_accessor :database
@@ -86,22 +88,25 @@ module DBI
86
88
  #
87
89
  def initialize(database, user=nil, dbrc_dir=nil)
88
90
  if dbrc_dir.nil?
89
- if Config::CONFIG['host_os'].match('mswin')
90
- home = ENV['USERPROFILE'] || ENV['HOME']
91
- file = nil
92
-
93
- if home
94
- file = File.join(home, '.dbrc')
91
+ raise Error, 'bad directory' unless File.directory?(dbrc_dir)
92
+
93
+ uid = Process.uid
94
+ home = ENV['HOME'] || ENV['USERPROFILE']
95
+
96
+ if home.nil?
97
+ if @@windows
98
+ home ||= Sys::Admin.get_user(uid, :localaccount => true).dir
95
99
  else
96
- file = File.join(File.basename(Dir::APPDATA), '.dbrc')
100
+ home ||= Sys::Admin.get_user(uid).dir
97
101
  end
98
-
99
- @dbrc_file = file
102
+ end
103
+
104
+ # Default to the app data directory on Windows if no home dir found
105
+ if @@windows && home.nil?
106
+ @dbrc_file = File.join(File.basename(Dir::APPDATA), '.dbrc')
100
107
  else
101
- @dbrc_file = File.join(
102
- Sys::Admin.get_user(Process.uid).dir,
103
- '.dbrc'
104
- )
108
+ uid = Process.uid
109
+ @dbrc_file = File.join(Sys::Admin.get_user(uid).dir, '.dbrc')
105
110
  end
106
111
  else
107
112
  @dbrc_file = File.join(dbrc_dir, '.dbrc')
@@ -120,7 +125,7 @@ module DBI
120
125
  check_file()
121
126
 
122
127
  # If on Win32 and the file is encrypted, decrypt it.
123
- if Config::CONFIG['host_os'].match("mswin") && File.encrypted?(@dbrc_file)
128
+ if @@windows && File.encrypted?(@dbrc_file)
124
129
  encrypted = true
125
130
  File.decrypt(@dbrc_file)
126
131
  end
@@ -131,7 +136,7 @@ module DBI
131
136
  create_dsn_string()
132
137
 
133
138
  # If on Win32 and the file was encrypted, re-encrypt it
134
- if Config::CONFIG['host_os'].match("mswin") && encrypted
139
+ if @@windows && encrypted
135
140
  File.encrypt(@dbrc_file)
136
141
  end
137
142
  end
@@ -182,7 +187,7 @@ module DBI
182
187
 
183
188
  # Permissions must be set to 600 or better on Unix systems.
184
189
  # Must be hidden on Win32 systems.
185
- if Config::CONFIG['host_os'].match("mswin")
190
+ if @@windows
186
191
  unless File.hidden?(file)
187
192
  raise Error, "The .dbrc file must be hidden"
188
193
  end
@@ -1,27 +1,32 @@
1
1
  #########################################################################
2
- # tc_dbrc.rb
2
+ # test_dbi_dbrc.rb
3
3
  #
4
4
  # Test suite for the base class of DBI::DBRC. This test case should be
5
5
  # run via the 'rake test' task.
6
6
  #########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
7
10
  require 'dbi/dbrc'
8
11
  require 'test/unit'
9
12
  include DBI
10
13
 
11
- class TC_DBRC < Test::Unit::TestCase
12
- def setup
13
- Dir.chdir('test') if File.basename(Dir.pwd) != 'test'
14
+ class TC_DBI_DBRC < Test::Unit::TestCase
15
+ def self.startup
16
+ @@windows = File::ALT_SEPARATOR
17
+ end
14
18
 
15
- @dir = "../examples/plain"
19
+ def setup
20
+ @dir = File.join(Dir.pwd, 'examples/plain')
16
21
  @file = File.join(@dir, '.dbrc')
17
- @db1 = "foo"
18
- @db2 = "bar"
19
- @user1 = "user1"
20
- @user2 = "user2"
21
- @db_bad = "blah" # Doesn't exist
22
- @user_bad = "user8" # Doesn't exist
22
+ @db1 = 'foo'
23
+ @db2 = 'bar'
24
+ @user1 = 'user1'
25
+ @user2 = 'user2'
26
+ @db_bad = 'blah' # Doesn't exist
27
+ @user_bad = 'user8' # Doesn't exist
23
28
 
24
- if File::ALT_SEPARATOR
29
+ if @@windows && File.respond_to?(:set_attr)
25
30
  File.set_attr(@file, File::HIDDEN)
26
31
  else
27
32
  File.chmod(0600, @file)
@@ -31,11 +36,11 @@ class TC_DBRC < Test::Unit::TestCase
31
36
  end
32
37
 
33
38
  def test_version
34
- assert_equal("1.1.4", DBRC::VERSION)
39
+ assert_equal('1.1.5', DBRC::VERSION)
35
40
  end
36
41
 
37
42
  def test_bad_dbrc_properties
38
- if File::ALT_SEPARATOR
43
+ if @@windows
39
44
  File.unset_attr(@file, File::HIDDEN)
40
45
  assert_raises(DBRC::Error){ DBRC.new(@db1, @user1, @dir) }
41
46
  else
@@ -184,10 +189,9 @@ class TC_DBRC < Test::Unit::TestCase
184
189
  @db_bad = nil
185
190
  @user_bad = nil
186
191
  @dbrc = nil
187
- if File::ALT_SEPARATOR
188
- File.set_attr(@file, File::HIDDEN)
189
- else
190
- File.chmod(0600, @file)
191
- end
192
+ end
193
+
194
+ def self.shutdown
195
+ @@windows = nil
192
196
  end
193
197
  end
@@ -1,20 +1,22 @@
1
1
  ########################################################################
2
- # tc_dbrc_xml.rb
2
+ # test_dbi_dbrc_xml.rb
3
3
  #
4
4
  # Test suite for the XML specific version of DBI::DBRC. This test case
5
5
  # should be run via the 'rake test' task.
6
6
  ########################################################################
7
- require "dbi/dbrc"
8
- require "test/unit"
9
- require "rexml/document"
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'dbi/dbrc'
11
+ require 'test/unit'
12
+ require 'rexml/document'
10
13
  include REXML
11
14
  include DBI
12
15
 
13
- class TC_DBRC_XML < Test::Unit::TestCase
16
+ class TC_DBI_DBRC_XML < Test::Unit::TestCase
14
17
  def setup
15
- Dir.chdir('test') if File.basename(Dir.pwd) != 'test'
16
- @dir = "../examples/xml"
17
- @file = File.join(@dir, ".dbrc")
18
+ @dir = File.join(Dir.pwd, 'examples/xml')
19
+ @file = File.join(@dir, '.dbrc')
18
20
  @db1 = "foo"
19
21
  @db2 = "bar"
20
22
  @user1 = "user1"
@@ -22,7 +24,7 @@ class TC_DBRC_XML < Test::Unit::TestCase
22
24
  @db_bad = "blah" # Doesn't exist
23
25
  @user_bad = "user8" # Doesn't exist
24
26
 
25
- if File::ALT_SEPARATOR
27
+ if File::ALT_SEPARATOR && File.respond_to?(:set_attr)
26
28
  File.set_attr(@file, File::HIDDEN)
27
29
  else
28
30
  File.chmod(0600, @file)
@@ -1,18 +1,19 @@
1
1
  #########################################################################
2
- # tc_dbrc_yml.rb
2
+ # test_dbi_dbrc_yml.rb
3
3
  #
4
4
  # Test suite for the YAML specific version of DBI::DBRC. You should run
5
5
  # this test case via the 'rake test' task.
6
6
  #########################################################################
7
- require "dbi/dbrc"
8
- require "test/unit"
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'dbi/dbrc'
11
+ require 'test/unit'
9
12
  include DBI
10
13
 
11
- class TC_DBRC_YML < Test::Unit::TestCase
14
+ class TC_DBI_DBRC_YML < Test::Unit::TestCase
12
15
  def setup
13
- Dir.chdir('test') if File.basename(Dir.pwd) != 'test'
14
-
15
- @dir = "../examples/yml"
16
+ @dir = File.join(Dir.pwd, 'examples/yml')
16
17
  @file = File.join(@dir, '.dbrc')
17
18
  @db1 = "foo"
18
19
  @db2 = "bar"
@@ -21,7 +22,7 @@ class TC_DBRC_YML < Test::Unit::TestCase
21
22
  @db_bad = "blah" # Doesn't exist
22
23
  @user_bad = "user8" # Doesn't exist
23
24
 
24
- if File::ALT_SEPARATOR
25
+ if File::ALT_SEPARATOR && File.respond_to?(:set_attr)
25
26
  File.set_attr(@file, File::HIDDEN)
26
27
  else
27
28
  File.chmod(0600, @file)
@@ -155,11 +156,5 @@ class TC_DBRC_YML < Test::Unit::TestCase
155
156
  @db_bad = nil
156
157
  @user_bad = nil
157
158
  @dbrc = nil
158
-
159
- if File::ALT_SEPARATOR
160
- File.set_attr(@file, File::HIDDEN)
161
- else
162
- File.chmod(0600, @file)
163
- end
164
159
  end
165
160
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbi-dbrc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
@@ -9,20 +9,30 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-10 00:00:00 -07:00
12
+ date: 2009-09-03 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sys-admin
17
17
  type: :runtime
18
18
  version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.5.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: test-unit
27
+ type: :development
28
+ version_requirement:
19
29
  version_requirements: !ruby/object:Gem::Requirement
20
30
  requirements:
21
31
  - - ">="
22
32
  - !ruby/object:Gem::Version
23
33
  version: "0"
24
34
  version:
25
- description: A simple way to avoid hard-coding passwords with DBI
35
+ description: " The dbi-dbrc library provides an interface for storing database\n connection information, including passwords, in a locally secure\n file only accessible by you, or root. This allows you to avoid\n hard coding login and password information in your programs\n that require such information.\n\n This library can also be used to store login and password information\n for logins on remote hosts, not just databases.\n"
26
36
  email: djberg96@gmail.com
27
37
  executables: []
28
38
 
@@ -33,23 +43,22 @@ extra_rdoc_files:
33
43
  - CHANGES
34
44
  - MANIFEST
35
45
  files:
36
- - examples/plain
37
- - examples/plain/test.rb
38
- - examples/xml
46
+ - lib/dbi/dbrc.rb
39
47
  - examples/xml/test_xml.rb
40
- - examples/yml
48
+ - examples/plain/test.rb
41
49
  - examples/yml/test_yml.rb
42
- - lib/dbi
43
- - lib/dbi/dbrc.rb
44
- - test/tc_dbrc.rb
45
- - test/tc_dbrc_xml.rb
46
- - test/tc_dbrc_yml.rb
47
- - test/ts_all.rb
48
- - README
49
50
  - CHANGES
51
+ - dbi-dbrc.gemspec
52
+ - README
53
+ - test/test_dbi_dbrc_xml.rb
54
+ - test/test_dbi_dbrc.rb
55
+ - test/test_dbi_dbrc_yml.rb
50
56
  - MANIFEST
57
+ - Rakefile
51
58
  has_rdoc: true
52
59
  homepage: http://www.rubyforge.org/projects/shards
60
+ licenses:
61
+ - Artistic 2.0
53
62
  post_install_message:
54
63
  rdoc_options: []
55
64
 
@@ -70,9 +79,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
79
  requirements: []
71
80
 
72
81
  rubyforge_project: shards
73
- rubygems_version: 1.2.0
82
+ rubygems_version: 1.3.5
74
83
  signing_key:
75
- specification_version: 2
84
+ specification_version: 3
76
85
  summary: A simple way to avoid hard-coding passwords with DBI
77
86
  test_files:
78
- - test/ts_all.rb
87
+ - test/test_dbi_dbrc_xml.rb
88
+ - test/test_dbi_dbrc.rb
89
+ - test/test_dbi_dbrc_yml.rb
@@ -1,6 +0,0 @@
1
- $LOAD_PATH.unshift(Dir.pwd)
2
- $LOAD_PATH.unshift(Dir.pwd + "/test")
3
-
4
- require "tc_dbrc"
5
- require "tc_dbrc_yml"
6
- require "tc_dbrc_xml"