data_objects 0.10.0 → 0.10.1
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/ChangeLog.markdown +20 -0
- data/LICENSE +1 -29
- data/README.markdown +16 -2
- data/Rakefile +41 -7
- data/lib/data_objects.rb +3 -2
- data/lib/data_objects/byte_array.rb +6 -0
- data/lib/data_objects/connection.rb +21 -9
- data/lib/data_objects/logger.rb +15 -15
- data/lib/data_objects/pooling.rb +250 -0
- data/lib/data_objects/reader.rb +16 -0
- data/lib/data_objects/spec/bacon.rb +9 -0
- data/lib/data_objects/spec/command_spec.rb +54 -47
- data/lib/data_objects/spec/connection_spec.rb +119 -30
- data/lib/data_objects/spec/encoding_spec.rb +64 -6
- data/lib/data_objects/spec/helpers/immediate_red_green_output.rb +59 -0
- data/lib/data_objects/spec/helpers/pending.rb +22 -0
- data/lib/data_objects/spec/helpers/ssl.rb +21 -0
- data/lib/data_objects/spec/reader_spec.rb +47 -24
- data/lib/data_objects/spec/result_spec.rb +10 -19
- data/lib/data_objects/spec/typecast/array_spec.rb +16 -20
- data/lib/data_objects/spec/typecast/bigdecimal_spec.rb +16 -24
- data/lib/data_objects/spec/typecast/boolean_spec.rb +16 -24
- data/lib/data_objects/spec/typecast/byte_array_spec.rb +11 -15
- data/lib/data_objects/spec/typecast/class_spec.rb +7 -11
- data/lib/data_objects/spec/typecast/date_spec.rb +17 -25
- data/lib/data_objects/spec/typecast/datetime_spec.rb +18 -26
- data/lib/data_objects/spec/typecast/float_spec.rb +19 -27
- data/lib/data_objects/spec/typecast/integer_spec.rb +10 -14
- data/lib/data_objects/spec/typecast/nil_spec.rb +18 -30
- data/lib/data_objects/spec/typecast/other_spec.rb +45 -0
- data/lib/data_objects/spec/typecast/range_spec.rb +16 -20
- data/lib/data_objects/spec/typecast/string_spec.rb +72 -13
- data/lib/data_objects/spec/typecast/time_spec.rb +11 -15
- data/lib/data_objects/utilities.rb +18 -0
- data/lib/data_objects/version.rb +1 -2
- data/spec/command_spec.rb +2 -2
- data/spec/connection_spec.rb +7 -5
- data/spec/do_mock2.rb +31 -0
- data/spec/pooling_spec.rb +162 -0
- data/spec/reader_spec.rb +7 -4
- data/spec/result_spec.rb +2 -2
- data/spec/spec_helper.rb +26 -5
- data/spec/transaction_spec.rb +11 -9
- data/tasks/metrics.rake +36 -0
- data/tasks/release.rake +10 -70
- data/tasks/spec.rake +16 -14
- data/tasks/yard.rake +9 -0
- data/tasks/yardstick.rake +19 -0
- metadata +53 -27
- data/HISTORY.markdown +0 -7
- data/Manifest.txt +0 -44
- data/spec/lib/pending_helpers.rb +0 -11
- data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -53
- data/spec/lib/ssl_helpers.rb +0 -20
- data/tasks/gem.rake +0 -8
- data/tasks/install.rake +0 -13
@@ -1,18 +1,14 @@
|
|
1
1
|
JRUBY = RUBY_PLATFORM =~ /java/ unless defined?(JRUBY)
|
2
2
|
|
3
|
-
|
3
|
+
shared 'supporting DateTime' do
|
4
4
|
|
5
|
-
|
5
|
+
setup_test_environment
|
6
6
|
|
7
|
-
before
|
8
|
-
setup_test_environment
|
9
|
-
end
|
10
|
-
|
11
|
-
before :each do
|
7
|
+
before do
|
12
8
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
13
9
|
end
|
14
10
|
|
15
|
-
after
|
11
|
+
after do
|
16
12
|
@connection.close
|
17
13
|
end
|
18
14
|
|
@@ -20,7 +16,7 @@ share_examples_for 'supporting DateTime' do
|
|
20
16
|
|
21
17
|
describe 'with manual typecasting' do
|
22
18
|
|
23
|
-
before
|
19
|
+
before do
|
24
20
|
@command = @connection.create_command("SELECT release_date FROM widgets WHERE ad_description = ?")
|
25
21
|
@command.set_types(DateTime)
|
26
22
|
@reader = @command.execute_reader('Buy this product now!')
|
@@ -33,7 +29,7 @@ share_examples_for 'supporting DateTime' do
|
|
33
29
|
end
|
34
30
|
|
35
31
|
it 'should return the correctly typed result' do
|
36
|
-
@values.first.should
|
32
|
+
@values.first.should.be.kind_of(DateTime)
|
37
33
|
end
|
38
34
|
|
39
35
|
it 'should return the correct result' do
|
@@ -45,7 +41,7 @@ share_examples_for 'supporting DateTime' do
|
|
45
41
|
|
46
42
|
describe 'with manual typecasting a nil value' do
|
47
43
|
|
48
|
-
before
|
44
|
+
before do
|
49
45
|
@command = @connection.create_command("SELECT release_datetime FROM widgets WHERE id = ?")
|
50
46
|
@command.set_types(DateTime)
|
51
47
|
@reader = @command.execute_reader(8)
|
@@ -58,11 +54,11 @@ share_examples_for 'supporting DateTime' do
|
|
58
54
|
end
|
59
55
|
|
60
56
|
it 'should return a nil class' do
|
61
|
-
@values.first.should
|
57
|
+
@values.first.should.be.kind_of(NilClass)
|
62
58
|
end
|
63
59
|
|
64
60
|
it 'should return nil' do
|
65
|
-
@values.first.should
|
61
|
+
@values.first.should.be.nil
|
66
62
|
end
|
67
63
|
|
68
64
|
end
|
@@ -71,7 +67,7 @@ share_examples_for 'supporting DateTime' do
|
|
71
67
|
|
72
68
|
describe 'writing an DateTime' do
|
73
69
|
|
74
|
-
before
|
70
|
+
before do
|
75
71
|
local_offset = Rational(Time.local(2008, 2, 14).utc_offset, 86400)
|
76
72
|
@reader = @connection.create_command("SELECT id FROM widgets WHERE release_datetime = ? ORDER BY id").execute_reader(DateTime.civil(2008, 2, 14, 00, 31, 12, local_offset))
|
77
73
|
@reader.next!
|
@@ -84,26 +80,22 @@ share_examples_for 'supporting DateTime' do
|
|
84
80
|
|
85
81
|
it 'should return the correct entry' do
|
86
82
|
#Some of the drivers starts autoincrementation from 0 not 1
|
87
|
-
@values.first.should
|
83
|
+
@values.first.should.satisfy { |val| val == 0 or val == 1 }
|
88
84
|
end
|
89
85
|
|
90
86
|
end
|
91
87
|
|
92
88
|
end
|
93
89
|
|
94
|
-
|
90
|
+
shared 'supporting DateTime autocasting' do
|
95
91
|
|
96
|
-
|
97
|
-
|
98
|
-
before :all do
|
99
|
-
setup_test_environment
|
100
|
-
end
|
92
|
+
setup_test_environment
|
101
93
|
|
102
|
-
before
|
94
|
+
before do
|
103
95
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
104
96
|
end
|
105
97
|
|
106
|
-
after
|
98
|
+
after do
|
107
99
|
@connection.close
|
108
100
|
end
|
109
101
|
|
@@ -111,7 +103,7 @@ share_examples_for 'supporting DateTime autocasting' do
|
|
111
103
|
|
112
104
|
describe 'with automatic typecasting' do
|
113
105
|
|
114
|
-
before
|
106
|
+
before do
|
115
107
|
@reader = @connection.create_command("SELECT release_datetime FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
|
116
108
|
@reader.next!
|
117
109
|
@values = @reader.values
|
@@ -122,11 +114,11 @@ share_examples_for 'supporting DateTime autocasting' do
|
|
122
114
|
end
|
123
115
|
|
124
116
|
it 'should return the correctly typed result' do
|
125
|
-
@values.first.should
|
117
|
+
@values.first.should.be.kind_of(DateTime)
|
126
118
|
end
|
127
119
|
|
128
120
|
it 'should return the correct result' do
|
129
|
-
pending
|
121
|
+
pending('when this is fixed for DST issues')
|
130
122
|
@values.first.should == Time.local(2008, 2, 14, 00, 31, 12).to_datetime
|
131
123
|
end
|
132
124
|
|
@@ -1,16 +1,12 @@
|
|
1
|
-
|
1
|
+
shared 'supporting Float' do
|
2
2
|
|
3
|
-
|
3
|
+
setup_test_environment
|
4
4
|
|
5
|
-
before
|
6
|
-
setup_test_environment
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
5
|
+
before do
|
10
6
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
11
7
|
end
|
12
8
|
|
13
|
-
after
|
9
|
+
after do
|
14
10
|
@connection.close
|
15
11
|
end
|
16
12
|
|
@@ -18,7 +14,7 @@ share_examples_for 'supporting Float' do
|
|
18
14
|
|
19
15
|
describe 'with manual typecasting' do
|
20
16
|
|
21
|
-
before
|
17
|
+
before do
|
22
18
|
@command = @connection.create_command("SELECT id FROM widgets WHERE ad_description = ?")
|
23
19
|
@command.set_types(Float)
|
24
20
|
@reader = @command.execute_reader('Buy this product now!')
|
@@ -31,19 +27,19 @@ share_examples_for 'supporting Float' do
|
|
31
27
|
end
|
32
28
|
|
33
29
|
it 'should return the correctly typed result' do
|
34
|
-
@values.first.should
|
30
|
+
@values.first.should.be.kind_of(Float)
|
35
31
|
end
|
36
32
|
|
37
33
|
it 'should return the correct result' do
|
38
34
|
#Some of the drivers starts autoincrementation from 0 not 1
|
39
|
-
@values.first.should
|
35
|
+
@values.first.should.satisfy { |val| val == 1.0 or val == 0.0 }
|
40
36
|
end
|
41
37
|
|
42
38
|
end
|
43
39
|
|
44
40
|
describe 'with manual typecasting a nil' do
|
45
41
|
|
46
|
-
before
|
42
|
+
before do
|
47
43
|
@command = @connection.create_command("SELECT cost1 FROM widgets WHERE id = ?")
|
48
44
|
@command.set_types(Float)
|
49
45
|
@reader = @command.execute_reader(5)
|
@@ -56,11 +52,11 @@ share_examples_for 'supporting Float' do
|
|
56
52
|
end
|
57
53
|
|
58
54
|
it 'should return the correctly typed result' do
|
59
|
-
@values.first.should
|
55
|
+
@values.first.should.be.kind_of(NilClass)
|
60
56
|
end
|
61
57
|
|
62
58
|
it 'should return the correct result' do
|
63
|
-
@values.first.should
|
59
|
+
@values.first.should.be.nil
|
64
60
|
end
|
65
61
|
|
66
62
|
end
|
@@ -68,7 +64,7 @@ share_examples_for 'supporting Float' do
|
|
68
64
|
|
69
65
|
describe 'writing an Float' do
|
70
66
|
|
71
|
-
before
|
67
|
+
before do
|
72
68
|
@reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(2.0)
|
73
69
|
@reader.next!
|
74
70
|
@values = @reader.values
|
@@ -80,26 +76,22 @@ share_examples_for 'supporting Float' do
|
|
80
76
|
|
81
77
|
it 'should return the correct entry' do
|
82
78
|
#Some of the drivers starts autoincrementation from 0 not 1
|
83
|
-
@values.first.should
|
79
|
+
@values.first.should.satisfy { |val| val == 1 or val == 2 }
|
84
80
|
end
|
85
81
|
|
86
82
|
end
|
87
83
|
|
88
84
|
end
|
89
85
|
|
90
|
-
|
86
|
+
shared 'supporting Float autocasting' do
|
91
87
|
|
92
|
-
|
93
|
-
|
94
|
-
before :all do
|
95
|
-
setup_test_environment
|
96
|
-
end
|
88
|
+
setup_test_environment
|
97
89
|
|
98
|
-
before
|
90
|
+
before do
|
99
91
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
100
92
|
end
|
101
93
|
|
102
|
-
after
|
94
|
+
after do
|
103
95
|
@connection.close
|
104
96
|
end
|
105
97
|
|
@@ -107,7 +99,7 @@ share_examples_for 'supporting Float autocasting' do
|
|
107
99
|
|
108
100
|
describe 'with automatic typecasting' do
|
109
101
|
|
110
|
-
before
|
102
|
+
before do
|
111
103
|
@reader = @connection.create_command("SELECT weight, cost1 FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
|
112
104
|
@reader.next!
|
113
105
|
@values = @reader.values
|
@@ -118,8 +110,8 @@ share_examples_for 'supporting Float autocasting' do
|
|
118
110
|
end
|
119
111
|
|
120
112
|
it 'should return the correctly typed result' do
|
121
|
-
@values.first.should
|
122
|
-
@values.last.should
|
113
|
+
@values.first.should.be.kind_of(Float)
|
114
|
+
@values.last.should.be.kind_of(Float)
|
123
115
|
end
|
124
116
|
|
125
117
|
it 'should return the correct result' do
|
@@ -1,16 +1,12 @@
|
|
1
|
-
|
1
|
+
shared 'supporting Integer' do
|
2
2
|
|
3
|
-
|
3
|
+
setup_test_environment
|
4
4
|
|
5
|
-
before
|
6
|
-
setup_test_environment
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
5
|
+
before do
|
10
6
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
11
7
|
end
|
12
8
|
|
13
|
-
after
|
9
|
+
after do
|
14
10
|
@connection.close
|
15
11
|
end
|
16
12
|
|
@@ -18,7 +14,7 @@ share_examples_for 'supporting Integer' do
|
|
18
14
|
|
19
15
|
describe 'with automatic typecasting' do
|
20
16
|
|
21
|
-
before
|
17
|
+
before do
|
22
18
|
@reader = @connection.create_command("SELECT id FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
|
23
19
|
@reader.next!
|
24
20
|
@values = @reader.values
|
@@ -29,19 +25,19 @@ share_examples_for 'supporting Integer' do
|
|
29
25
|
end
|
30
26
|
|
31
27
|
it 'should return the correctly typed result' do
|
32
|
-
@values.first.should
|
28
|
+
@values.first.should.be.kind_of(Integer)
|
33
29
|
end
|
34
30
|
|
35
31
|
it 'should return the correct result' do
|
36
32
|
#Some of the drivers starts autoincrementation from 0 not 1
|
37
|
-
@values.first.should
|
33
|
+
@values.first.should.satisfy { |val| val == 1 or val == 0 }
|
38
34
|
end
|
39
35
|
|
40
36
|
end
|
41
37
|
|
42
38
|
describe 'with manual typecasting' do
|
43
39
|
|
44
|
-
before
|
40
|
+
before do
|
45
41
|
@command = @connection.create_command("SELECT weight FROM widgets WHERE ad_description = ?")
|
46
42
|
@command.set_types(Integer)
|
47
43
|
@reader = @command.execute_reader('Buy this product now!')
|
@@ -54,7 +50,7 @@ share_examples_for 'supporting Integer' do
|
|
54
50
|
end
|
55
51
|
|
56
52
|
it 'should return the correctly typed result' do
|
57
|
-
@values.first.should
|
53
|
+
@values.first.should.be.kind_of(Integer)
|
58
54
|
end
|
59
55
|
|
60
56
|
it 'should return the correct result' do
|
@@ -67,7 +63,7 @@ share_examples_for 'supporting Integer' do
|
|
67
63
|
|
68
64
|
describe 'writing an Integer' do
|
69
65
|
|
70
|
-
before
|
66
|
+
before do
|
71
67
|
@reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(2)
|
72
68
|
@reader.next!
|
73
69
|
@values = @reader.values
|
@@ -1,16 +1,12 @@
|
|
1
|
-
|
1
|
+
shared 'supporting Nil' do
|
2
2
|
|
3
|
-
|
3
|
+
setup_test_environment
|
4
4
|
|
5
|
-
before
|
6
|
-
setup_test_environment
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
5
|
+
before do
|
10
6
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
11
7
|
end
|
12
8
|
|
13
|
-
after
|
9
|
+
after do
|
14
10
|
@connection.close
|
15
11
|
end
|
16
12
|
|
@@ -18,7 +14,7 @@ share_examples_for 'supporting Nil' do
|
|
18
14
|
|
19
15
|
describe 'with manual typecasting' do
|
20
16
|
|
21
|
-
before
|
17
|
+
before do
|
22
18
|
@command = @connection.create_command("SELECT flags FROM widgets WHERE ad_description = ?")
|
23
19
|
@command.set_types(NilClass)
|
24
20
|
@reader = @command.execute_reader('Buy this product now!')
|
@@ -31,7 +27,7 @@ share_examples_for 'supporting Nil' do
|
|
31
27
|
end
|
32
28
|
|
33
29
|
it 'should return the correctly typed result' do
|
34
|
-
@values.first.should
|
30
|
+
@values.first.should.be.kind_of(NilClass)
|
35
31
|
end
|
36
32
|
|
37
33
|
it 'should return the correct result' do
|
@@ -44,19 +40,15 @@ share_examples_for 'supporting Nil' do
|
|
44
40
|
|
45
41
|
end
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
include DataObjectsSpecHelpers
|
43
|
+
shared 'supporting writing an Nil' do
|
50
44
|
|
51
|
-
|
52
|
-
setup_test_environment
|
53
|
-
end
|
45
|
+
setup_test_environment
|
54
46
|
|
55
|
-
before
|
47
|
+
before do
|
56
48
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
57
49
|
end
|
58
50
|
|
59
|
-
after
|
51
|
+
after do
|
60
52
|
@connection.close
|
61
53
|
end
|
62
54
|
|
@@ -68,7 +60,7 @@ share_examples_for 'supporting writing an Nil' do
|
|
68
60
|
|
69
61
|
describe 'as a parameter' do
|
70
62
|
|
71
|
-
before
|
63
|
+
before do
|
72
64
|
@reader = @connection.create_command("SELECT id FROM widgets WHERE ad_description IN (?) ORDER BY id").execute_reader(nil)
|
73
65
|
end
|
74
66
|
|
@@ -77,7 +69,7 @@ share_examples_for 'supporting writing an Nil' do
|
|
77
69
|
end
|
78
70
|
|
79
71
|
it 'should return the correct entry' do
|
80
|
-
@reader.next!.should
|
72
|
+
@reader.next!.should.be.false
|
81
73
|
end
|
82
74
|
|
83
75
|
end
|
@@ -86,19 +78,15 @@ share_examples_for 'supporting writing an Nil' do
|
|
86
78
|
|
87
79
|
end
|
88
80
|
|
89
|
-
|
90
|
-
|
91
|
-
include DataObjectsSpecHelpers
|
81
|
+
shared 'supporting Nil autocasting' do
|
92
82
|
|
93
|
-
|
94
|
-
setup_test_environment
|
95
|
-
end
|
83
|
+
setup_test_environment
|
96
84
|
|
97
|
-
before
|
85
|
+
before do
|
98
86
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
99
87
|
end
|
100
88
|
|
101
|
-
after
|
89
|
+
after do
|
102
90
|
@connection.close
|
103
91
|
end
|
104
92
|
|
@@ -106,7 +94,7 @@ share_examples_for 'supporting Nil autocasting' do
|
|
106
94
|
|
107
95
|
describe 'with automatic typecasting' do
|
108
96
|
|
109
|
-
before
|
97
|
+
before do
|
110
98
|
@reader = @connection.create_command("SELECT ad_description FROM widgets WHERE id = ?").execute_reader(3)
|
111
99
|
@reader.next!
|
112
100
|
@values = @reader.values
|
@@ -117,7 +105,7 @@ share_examples_for 'supporting Nil autocasting' do
|
|
117
105
|
end
|
118
106
|
|
119
107
|
it 'should return the correctly typed result' do
|
120
|
-
@values.first.should
|
108
|
+
@values.first.should.be.kind_of(NilClass)
|
121
109
|
end
|
122
110
|
|
123
111
|
it 'should return the correct result' do
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class ::CustomTextType
|
2
|
+
|
3
|
+
def initialize(value)
|
4
|
+
@value = value
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
@value.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
shared 'supporting other (unknown) type' do
|
14
|
+
|
15
|
+
setup_test_environment
|
16
|
+
|
17
|
+
before do
|
18
|
+
@connection = DataObjects::Connection.new(CONFIG.uri)
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
@connection.close
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'writing an object of unknown type' do
|
26
|
+
|
27
|
+
before do
|
28
|
+
@command = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE whitepaper_text = ?")
|
29
|
+
@command.set_types(::CustomTextType)
|
30
|
+
@reader = @command.execute_reader('String')
|
31
|
+
@reader.next!
|
32
|
+
@values = @reader.values
|
33
|
+
end
|
34
|
+
|
35
|
+
after do
|
36
|
+
@reader.close
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return the correct entry' do
|
40
|
+
@values.first.should == 'String'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|