rdbi-dbrc 0.1.0
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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/rdbi-dbrc.rb +31 -0
- data/test/dbrc +6 -0
- data/test/helper.rb +15 -0
- data/test/test_dbrc.rb +22 -0
- metadata +119 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Erik Hollensbe
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= rdbi-dbrc
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Erik Hollensbe. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rdbi-dbrc"
|
8
|
+
gem.summary = %Q{Implementation of dbi-dbrc for RDBI}
|
9
|
+
gem.description = %Q{Implementation of dbi-dbrc for RDBI}
|
10
|
+
gem.email = "erik@hollensbe.org"
|
11
|
+
gem.homepage = "http://github.com/erikh/rdbi-dbrc"
|
12
|
+
gem.authors = ["Erik Hollensbe"]
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
|
15
|
+
gem.add_dependency 'rdbi'
|
16
|
+
gem.add_development_dependency 'rdbi-driver-mock'
|
17
|
+
gem.add_development_dependency 'test-unit'
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
Rake::TestTask.new(:test) do |test|
|
26
|
+
test.libs << 'lib' << 'test'
|
27
|
+
test.pattern = 'test/**/test_*.rb'
|
28
|
+
test.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'rcov/rcovtask'
|
33
|
+
Rcov::RcovTask.new do |test|
|
34
|
+
test.libs << 'test'
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
rescue LoadError
|
39
|
+
task :rcov do
|
40
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
task :test => :check_dependencies
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'hanna'
|
49
|
+
require 'rdoc/task'
|
50
|
+
RDoc::Task.new do |rdoc|
|
51
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
|
+
|
53
|
+
rdoc.options.push '-f', 'hanna'
|
54
|
+
rdoc.main = 'README.rdoc'
|
55
|
+
rdoc.rdoc_dir = 'rdoc'
|
56
|
+
rdoc.title = "rdbi-dbrc #{version}"
|
57
|
+
rdoc.rdoc_files.include('README*')
|
58
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/rdbi-dbrc.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
gem 'rdbi'
|
2
|
+
require 'rdbi'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module RDBI::DBRC
|
6
|
+
def self.connect(role)
|
7
|
+
role_data = self.roles[role.to_sym]
|
8
|
+
|
9
|
+
unless role_data
|
10
|
+
raise ArgumentError, "role '#{role}' does not exist."
|
11
|
+
end
|
12
|
+
|
13
|
+
driver = role_data.delete(:driver)
|
14
|
+
|
15
|
+
RDBI.connect(driver, role_data)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.roles
|
19
|
+
rcfile = ENV["DBRC"] || File.expand_path(File.join(ENV["HOME"], '.dbrc'))
|
20
|
+
|
21
|
+
# XXX the rc file should only be two levels deep, so instead of mentarbating
|
22
|
+
# XXX with recursion, let's just do it the cheap way.
|
23
|
+
|
24
|
+
hash = RDBI::Util.key_hash_as_symbols(YAML.load_file(rcfile))
|
25
|
+
hash.each do |key, value|
|
26
|
+
hash[key] = RDBI::Util.key_hash_as_symbols(hash[key])
|
27
|
+
end
|
28
|
+
|
29
|
+
hash
|
30
|
+
end
|
31
|
+
end
|
data/test/dbrc
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'test-unit'
|
3
|
+
require 'test/unit'
|
4
|
+
gem 'rdbi-driver-mock'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
+
require 'rdbi-dbrc'
|
9
|
+
require 'rdbi/driver/mock'
|
10
|
+
|
11
|
+
class Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
ENV["DBRC"] = File.join(File.dirname(__FILE__), 'dbrc')
|
14
|
+
end
|
15
|
+
end
|
data/test/test_dbrc.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestDBRC < Test::Unit::TestCase
|
4
|
+
def test_01_roles
|
5
|
+
hash = RDBI::DBRC.roles
|
6
|
+
assert(hash)
|
7
|
+
assert(hash.has_key?(:mock1))
|
8
|
+
assert(hash[:mock1].has_key?(:driver))
|
9
|
+
assert_equal(hash[:mock1][:driver], "Mock")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_02_connect
|
13
|
+
dbh = RDBI::DBRC.connect(:mock1)
|
14
|
+
assert(dbh)
|
15
|
+
assert(dbh.connected?)
|
16
|
+
assert_kind_of(RDBI::Driver::Mock, dbh.driver)
|
17
|
+
assert(dbh.connect_args.has_key?(:username))
|
18
|
+
assert_equal(dbh.connect_args[:username], "some_username")
|
19
|
+
assert(dbh.connect_args.has_key?(:password))
|
20
|
+
assert_equal(dbh.connect_args[:password], "some_password")
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdbi-dbrc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Erik Hollensbe
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-21 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rdbi
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rdbi-driver-mock
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: test-unit
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: Implementation of dbi-dbrc for RDBI
|
64
|
+
email: erik@hollensbe.org
|
65
|
+
executables: []
|
66
|
+
|
67
|
+
extensions: []
|
68
|
+
|
69
|
+
extra_rdoc_files:
|
70
|
+
- LICENSE
|
71
|
+
- README.rdoc
|
72
|
+
files:
|
73
|
+
- .document
|
74
|
+
- .gitignore
|
75
|
+
- LICENSE
|
76
|
+
- README.rdoc
|
77
|
+
- Rakefile
|
78
|
+
- VERSION
|
79
|
+
- lib/rdbi-dbrc.rb
|
80
|
+
- test/dbrc
|
81
|
+
- test/helper.rb
|
82
|
+
- test/test_dbrc.rb
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: http://github.com/erikh/rdbi-dbrc
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- --charset=UTF-8
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
requirements: []
|
111
|
+
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.3.7
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Implementation of dbi-dbrc for RDBI
|
117
|
+
test_files:
|
118
|
+
- test/helper.rb
|
119
|
+
- test/test_dbrc.rb
|