data_objects 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/Rakefile +39 -4
- data/lib/data_objects.rb +5 -0
- data/lib/data_objects/connection.rb +1 -2
- data/lib/data_objects/uri.rb +29 -0
- data/lib/data_objects/version.rb +1 -1
- data/spec/command_spec.rb +4 -0
- data/spec/connection_spec.rb +8 -44
- data/spec/reader_spec.rb +2 -0
- data/spec/result_spec.rb +1 -0
- metadata +3 -2
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -38,17 +38,52 @@ end
|
|
38
38
|
|
39
39
|
# Specs
|
40
40
|
|
41
|
-
desc 'Run specifications'
|
42
41
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
43
|
-
t.spec_opts << '--
|
44
|
-
t.
|
42
|
+
t.spec_opts << '--format' << 'specdoc' << '--colour'
|
43
|
+
t.spec_opts << '--loadby' << 'random'
|
44
|
+
t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb')
|
45
|
+
|
46
|
+
begin
|
47
|
+
t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
|
48
|
+
t.rcov_opts << '--exclude' << 'spec'
|
49
|
+
t.rcov_opts << '--text-summary'
|
50
|
+
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
51
|
+
rescue Exception
|
52
|
+
# rcov not installed
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
56
|
# JRuby
|
48
|
-
|
49
57
|
namespace :jruby do
|
50
58
|
desc "Install #{GEM_NAME} #{GEM_VERSION} with JRuby"
|
51
59
|
task :install => [ :package ] do
|
52
60
|
sh %{#{SUDO} jruby -S gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}, :verbose => false
|
53
61
|
end
|
54
62
|
end
|
63
|
+
|
64
|
+
namespace :ci do
|
65
|
+
|
66
|
+
task :prepare do
|
67
|
+
rm_rf ROOT + "ci"
|
68
|
+
mkdir_p ROOT + "ci"
|
69
|
+
mkdir_p ROOT + "ci/doc"
|
70
|
+
mkdir_p ROOT + "ci/cyclomatic"
|
71
|
+
mkdir_p ROOT + "ci/token"
|
72
|
+
end
|
73
|
+
|
74
|
+
task :publish do
|
75
|
+
out = ENV['CC_BUILD_ARTIFACTS'] || "out"
|
76
|
+
mkdir_p out unless File.directory? out
|
77
|
+
|
78
|
+
mv "ci/rspec_report.html", "#{out}/rspec_report.html"
|
79
|
+
mv "ci/coverage", "#{out}/coverage"
|
80
|
+
end
|
81
|
+
|
82
|
+
task :spec => :prepare do
|
83
|
+
Rake::Task[:spec].invoke
|
84
|
+
mv ROOT + "coverage", ROOT + "ci/coverage"
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
task :ci => ["ci:spec"]
|
data/lib/data_objects.rb
CHANGED
@@ -6,6 +6,7 @@ require 'extlib'
|
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'support', 'pooling'))
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'logger'))
|
8
8
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'connection'))
|
9
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'uri'))
|
9
10
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'transaction'))
|
10
11
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'command'))
|
11
12
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'result'))
|
@@ -13,6 +14,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'read
|
|
13
14
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'field'))
|
14
15
|
require File.expand_path(File.join(File.dirname(__FILE__), 'data_objects', 'quoting'))
|
15
16
|
|
17
|
+
if RUBY_PLATFORM =~ /java/
|
18
|
+
require 'do_jdbc'
|
19
|
+
end
|
20
|
+
|
16
21
|
module DataObjects
|
17
22
|
class LengthMismatchError < StandardError; end
|
18
23
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'addressable/uri'
|
2
1
|
require 'set'
|
3
2
|
|
4
3
|
begin
|
@@ -10,7 +9,7 @@ module DataObjects
|
|
10
9
|
class Connection
|
11
10
|
|
12
11
|
def self.new(uri)
|
13
|
-
uri =
|
12
|
+
uri = DataObjects::URI::parse(uri)
|
14
13
|
|
15
14
|
if uri.scheme == 'jdbc'
|
16
15
|
driver_name = uri.path.split(':').first
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
|
3
|
+
module DataObjects
|
4
|
+
URI = Struct.new(:scheme, :user, :password, :host, :port, :specified_port, :path, :query, :fragment)
|
5
|
+
|
6
|
+
class URI
|
7
|
+
def self.parse(uri)
|
8
|
+
return uri if uri.kind_of?(self)
|
9
|
+
uri = Addressable::URI::parse(uri) unless uri.kind_of?(Addressable::URI)
|
10
|
+
self.new(uri.scheme, uri.user, uri.password, uri.host, uri.port, uri.specified_port, uri.path, uri.query, uri.fragment)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
string = ""
|
15
|
+
string << "#{scheme}://" if scheme
|
16
|
+
if user
|
17
|
+
string << "#{user}"
|
18
|
+
string << ":#{password}" if password
|
19
|
+
string << "@"
|
20
|
+
end
|
21
|
+
string << "#{host}" if host
|
22
|
+
string << ":#{specified_port}" if specified_port
|
23
|
+
string << path.to_s
|
24
|
+
string << "?#{query}" if query
|
25
|
+
string << "##{fragment}" if fragment
|
26
|
+
string
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/data_objects/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -6,6 +6,10 @@ describe DataObjects::Command do
|
|
6
6
|
@command = DataObjects::Command.new(@connection, 'SQL STRING')
|
7
7
|
end
|
8
8
|
|
9
|
+
after do
|
10
|
+
@connection.close
|
11
|
+
end
|
12
|
+
|
9
13
|
it "should assign the connection object to @connection" do
|
10
14
|
@command.instance_variable_get("@connection").should == @connection
|
11
15
|
end
|
data/spec/connection_spec.rb
CHANGED
@@ -5,6 +5,10 @@ describe DataObjects::Connection do
|
|
5
5
|
@connection = DataObjects::Connection.new('mock://localhost')
|
6
6
|
end
|
7
7
|
|
8
|
+
after do
|
9
|
+
@connection.release
|
10
|
+
end
|
11
|
+
|
8
12
|
%w{dispose create_command}.each do |meth|
|
9
13
|
it "should respond to ##{meth}" do
|
10
14
|
@connection.should respond_to(meth.intern)
|
@@ -15,35 +19,12 @@ describe DataObjects::Connection do
|
|
15
19
|
@connection.to_s.should == 'mock://localhost'
|
16
20
|
end
|
17
21
|
|
18
|
-
describe "getting inherited" do
|
19
|
-
# HACK: Connections needs to exist under the DataObjects namespace?
|
20
|
-
module DataObjects
|
21
|
-
class MyConnection < DataObjects::Connection; end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should set the @connection_lock ivar to a Mutex" do
|
25
|
-
DataObjects::MyConnection.instance_variable_get("@connection_lock").should_not be_nil
|
26
|
-
DataObjects::MyConnection.instance_variable_get("@connection_lock").should be_kind_of(Mutex)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should set the @available_connections ivar to a Hash" do
|
30
|
-
DataObjects::MyConnection.instance_variable_get("@available_connections").should_not be_nil
|
31
|
-
DataObjects::MyConnection.instance_variable_get("@available_connections").should be_kind_of(Hash)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should set the @reserved_connections ivar to a Set" do
|
35
|
-
DataObjects::MyConnection.instance_variable_get("@reserved_connections").should_not be_nil
|
36
|
-
DataObjects::MyConnection.instance_variable_get("@reserved_connections").should be_kind_of(Set)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
22
|
describe "initialization" do
|
41
23
|
it "should accept a regular connection uri as a String" do
|
42
24
|
c = DataObjects::Connection.new('mock://localhost/database')
|
43
25
|
# relying on the fact that mock connection sets @uri
|
44
26
|
uri = c.instance_variable_get("@uri")
|
45
27
|
|
46
|
-
uri.should be_kind_of(Addressable::URI)
|
47
28
|
uri.scheme.should == 'mock'
|
48
29
|
uri.host.should == 'localhost'
|
49
30
|
uri.path.should == '/database'
|
@@ -52,32 +33,15 @@ describe DataObjects::Connection do
|
|
52
33
|
it "should accept a connection uri as a Addressable::URI" do
|
53
34
|
c = DataObjects::Connection.new(Addressable::URI::parse('mock://localhost/database'))
|
54
35
|
# relying on the fact that mock connection sets @uri
|
55
|
-
|
56
|
-
|
57
|
-
uri.should be_kind_of(Addressable::URI)
|
58
|
-
uri.to_s.should == 'mock://localhost/database'
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should determine which DataObject adapter to use from the uri scheme" do
|
62
|
-
DataObjects::Mock::Connection.should_receive(:__new)
|
63
|
-
DataObjects::Connection.new('mock://localhost/database')
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should determine which DataObject adapter to use from a JDBC URL scheme" do
|
67
|
-
DataObjects::Mock::Connection.should_receive(:__new)
|
68
|
-
DataObjects::Connection.new('jdbc:mock://localhost/database')
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should acquire a connection" do
|
72
|
-
uri = Addressable::URI.parse('mock://localhost/database')
|
73
|
-
DataObjects::Mock::Connection.should_receive(:__new).with(uri)
|
74
|
-
|
75
|
-
DataObjects::Connection.new(uri)
|
36
|
+
c.to_s.should == 'mock://localhost/database'
|
76
37
|
end
|
77
38
|
|
78
39
|
it "should return the Connection specified by the scheme" do
|
79
40
|
c = DataObjects::Connection.new(Addressable::URI.parse('mock://localhost/database'))
|
80
41
|
c.should be_kind_of(DataObjects::Mock::Connection)
|
42
|
+
|
43
|
+
c = DataObjects::Connection.new(Addressable::URI.parse('jdbc:mock://localhost/database'))
|
44
|
+
c.should be_kind_of(DataObjects::Mock::Connection)
|
81
45
|
end
|
82
46
|
end
|
83
47
|
end
|
data/spec/reader_spec.rb
CHANGED
data/spec/result_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-12 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/data_objects/result.rb
|
71
71
|
- lib/data_objects/support/pooling.rb
|
72
72
|
- lib/data_objects/transaction.rb
|
73
|
+
- lib/data_objects/uri.rb
|
73
74
|
- lib/data_objects/version.rb
|
74
75
|
- spec/command_spec.rb
|
75
76
|
- spec/connection_spec.rb
|