data_objects 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/ChangeLog.markdown +20 -0
  2. data/LICENSE +1 -29
  3. data/README.markdown +16 -2
  4. data/Rakefile +41 -7
  5. data/lib/data_objects.rb +3 -2
  6. data/lib/data_objects/byte_array.rb +6 -0
  7. data/lib/data_objects/connection.rb +21 -9
  8. data/lib/data_objects/logger.rb +15 -15
  9. data/lib/data_objects/pooling.rb +250 -0
  10. data/lib/data_objects/reader.rb +16 -0
  11. data/lib/data_objects/spec/bacon.rb +9 -0
  12. data/lib/data_objects/spec/command_spec.rb +54 -47
  13. data/lib/data_objects/spec/connection_spec.rb +119 -30
  14. data/lib/data_objects/spec/encoding_spec.rb +64 -6
  15. data/lib/data_objects/spec/helpers/immediate_red_green_output.rb +59 -0
  16. data/lib/data_objects/spec/helpers/pending.rb +22 -0
  17. data/lib/data_objects/spec/helpers/ssl.rb +21 -0
  18. data/lib/data_objects/spec/reader_spec.rb +47 -24
  19. data/lib/data_objects/spec/result_spec.rb +10 -19
  20. data/lib/data_objects/spec/typecast/array_spec.rb +16 -20
  21. data/lib/data_objects/spec/typecast/bigdecimal_spec.rb +16 -24
  22. data/lib/data_objects/spec/typecast/boolean_spec.rb +16 -24
  23. data/lib/data_objects/spec/typecast/byte_array_spec.rb +11 -15
  24. data/lib/data_objects/spec/typecast/class_spec.rb +7 -11
  25. data/lib/data_objects/spec/typecast/date_spec.rb +17 -25
  26. data/lib/data_objects/spec/typecast/datetime_spec.rb +18 -26
  27. data/lib/data_objects/spec/typecast/float_spec.rb +19 -27
  28. data/lib/data_objects/spec/typecast/integer_spec.rb +10 -14
  29. data/lib/data_objects/spec/typecast/nil_spec.rb +18 -30
  30. data/lib/data_objects/spec/typecast/other_spec.rb +45 -0
  31. data/lib/data_objects/spec/typecast/range_spec.rb +16 -20
  32. data/lib/data_objects/spec/typecast/string_spec.rb +72 -13
  33. data/lib/data_objects/spec/typecast/time_spec.rb +11 -15
  34. data/lib/data_objects/utilities.rb +18 -0
  35. data/lib/data_objects/version.rb +1 -2
  36. data/spec/command_spec.rb +2 -2
  37. data/spec/connection_spec.rb +7 -5
  38. data/spec/do_mock2.rb +31 -0
  39. data/spec/pooling_spec.rb +162 -0
  40. data/spec/reader_spec.rb +7 -4
  41. data/spec/result_spec.rb +2 -2
  42. data/spec/spec_helper.rb +26 -5
  43. data/spec/transaction_spec.rb +11 -9
  44. data/tasks/metrics.rake +36 -0
  45. data/tasks/release.rake +10 -70
  46. data/tasks/spec.rake +16 -14
  47. data/tasks/yard.rake +9 -0
  48. data/tasks/yardstick.rake +19 -0
  49. metadata +53 -27
  50. data/HISTORY.markdown +0 -7
  51. data/Manifest.txt +0 -44
  52. data/spec/lib/pending_helpers.rb +0 -11
  53. data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -53
  54. data/spec/lib/ssl_helpers.rb +0 -20
  55. data/tasks/gem.rake +0 -8
  56. data/tasks/install.rake +0 -13
data/spec/reader_spec.rb CHANGED
@@ -9,10 +9,13 @@ describe DataObjects::Reader do
9
9
 
10
10
  reader = command.execute_reader
11
11
 
12
- reader.should respond_to(:close)
13
- reader.should respond_to(:next!)
14
- reader.should respond_to(:values)
15
- reader.should respond_to(:fields)
12
+ reader.should.be.kind_of(Enumerable)
13
+
14
+ reader.should.respond_to(:close)
15
+ reader.should.respond_to(:next!)
16
+ reader.should.respond_to(:values)
17
+ reader.should.respond_to(:fields)
18
+ reader.should.respond_to(:each)
16
19
 
17
20
  connection.close
18
21
  end
data/spec/result_spec.rb CHANGED
@@ -10,11 +10,11 @@ describe DataObjects::Result do
10
10
  result = command.execute_non_query
11
11
 
12
12
  # Affected Rows:
13
- result.should respond_to(:to_i)
13
+ result.should.respond_to(:to_i)
14
14
  result.to_i.should == 0
15
15
 
16
16
  # The id of the inserted row.
17
- result.should respond_to(:insert_id)
17
+ result.should.respond_to(:insert_id)
18
18
  connection.close
19
19
  end
20
20
 
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,30 @@
1
1
  require 'rubygems'
2
- require 'spec'
3
-
4
- dir = File.dirname(__FILE__)
5
- lib_path = File.expand_path("#{dir}/../lib")
6
- $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
7
2
  require 'data_objects'
3
+ require 'data_objects/spec/bacon'
4
+ require 'mocha/api'
5
+ require 'mocha/object'
6
+ require 'win32console' if RUBY_PLATFORM =~ /mingw|mswin/
7
+
8
+ module DataObjects::Pooling
9
+ class << self
10
+ remove_method :scavenger_interval if instance_methods(false).any? { |m| m.to_sym == :scavenger_interval }
11
+ def scavenger_interval
12
+ 0.5
13
+ end
14
+ end
15
+ end
16
+
17
+ # see http://gnufied.org/2008/06/12/making-ruby-bacon-play-with-mocha/
18
+ class Bacon::Context
19
+ include Mocha::API
20
+ alias_method :old_it,:it
21
+ def it description,&block
22
+ mocha_setup
23
+ old_it(description,&block)
24
+ mocha_verify
25
+ mocha_teardown
26
+ end
27
+ end
8
28
 
9
29
  require File.expand_path(File.join(File.dirname(__FILE__), 'do_mock'))
30
+ require File.expand_path(File.join(File.dirname(__FILE__), 'do_mock2'))
@@ -2,14 +2,14 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
3
  describe DataObjects::Transaction do
4
4
 
5
- before :each do
5
+ before do
6
6
  @connection = mock("connection")
7
- DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection)
7
+ DataObjects::Connection.expects(:new).with("mock://mock/mock").once.returns(@connection)
8
8
  @transaction = DataObjects::Transaction.new("mock://mock/mock")
9
9
  end
10
10
 
11
11
  it "should have a HOST constant" do
12
- DataObjects::Transaction::HOST.should_not == nil?
12
+ DataObjects::Transaction::HOST.should.not == nil?
13
13
  end
14
14
 
15
15
  describe "#initialize" do
@@ -17,22 +17,24 @@ describe DataObjects::Transaction do
17
17
  @transaction.connection.should == @connection
18
18
  end
19
19
  it "should provide an id" do
20
- @transaction.id.should_not == nil
20
+ @transaction.id.should.not == nil
21
21
  end
22
22
  it "should provide a unique id" do
23
- DataObjects::Connection.should_receive(:new).with("mock://mock/mock2").once.and_return(@connection)
24
- @transaction.id.should_not == DataObjects::Transaction.new("mock://mock/mock2").id
23
+ DataObjects::Connection.expects(:new).with("mock://mock/mock2").once.returns(@connection)
24
+ @transaction.id.should.not == DataObjects::Transaction.new("mock://mock/mock2").id
25
25
  end
26
26
  end
27
+
27
28
  describe "#close" do
28
29
  it "should close its connection" do
29
- @connection.should_receive(:close).once
30
- @transaction.close
30
+ @connection.expects(:close).once
31
+ should.not.raise(DataObjects::TransactionError) { @transaction.close }
31
32
  end
32
33
  end
34
+
33
35
  [:prepare, :commit_prepared, :rollback_prepared].each do |meth|
34
36
  it "should raise NotImplementedError on #{meth}" do
35
- lambda do @transaction.send(meth) end.should raise_error(NotImplementedError)
37
+ should.raise(NotImplementedError) { @transaction.send(meth) }
36
38
  end
37
39
  end
38
40
 
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'metric_fu'
3
+ rescue LoadError
4
+ namespace :metrics do
5
+ task :all do
6
+ abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
7
+ end
8
+ end
9
+ end
10
+
11
+ begin
12
+ require 'reek/adapters/rake_task'
13
+
14
+ Reek::RakeTask.new do |t|
15
+ t.fail_on_error = true
16
+ t.verbose = false
17
+ t.source_files = 'lib/**/*.rb'
18
+ end
19
+ rescue LoadError
20
+ task :reek do
21
+ abort 'Reek is not available. In order to run reek, you must: gem install reek'
22
+ end
23
+ end
24
+
25
+ begin
26
+ require 'roodi'
27
+ require 'roodi_task'
28
+
29
+ RoodiTask.new do |t|
30
+ t.verbose = false
31
+ end
32
+ rescue LoadError
33
+ task :roodi do
34
+ abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
35
+ end
36
+ end
data/tasks/release.rake CHANGED
@@ -1,74 +1,14 @@
1
- begin
2
- gem 'rubyforge', '~> 1.0.1'
3
- require 'rubyforge'
4
- rescue Exception
5
- nil
1
+ desc 'Builds all gems (native, binaries for JRuby and Windows)'
2
+ task :build_all do
3
+ `rake clean`
4
+ `rake build`
6
5
  end
7
6
 
8
- if defined?(RubyForge) then
9
- if defined?(GEM_SPEC) then
10
- desc 'Package and upload to RubyForge'
11
- task :release => [:clobber, :package] do |t|
12
- ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
13
-
14
- # compare versions to avoid mistakes
15
- unless ver == GEM_SPEC.version.to_s then
16
- fail "Version mismatch (supplied and specification versions differ)."
17
- end
18
-
19
- # no rubyforge project? no release for you!
20
- if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
21
- fail "Must define rubyforge_project in your gem specification."
22
- end
23
-
24
- # instantiate a RubyForge object
25
- rf = RubyForge.new
26
-
27
- # read project info and overview
28
- notes = begin
29
- r = File.read("README.markdown")
30
- r.split(/^(.*\n\-+)/)[1..4].join.strip
31
- rescue
32
- warn "Missing README.markdown"
33
- ''
34
- end
35
-
36
- # read changes
37
- changes = begin
38
- h = File.read("HISTORY.markdown")
39
- h.split(/^(##+ .*)/)[1..2].join.strip
40
- rescue
41
- warn "Missing HISTORY.markdown"
42
- ''
43
- end
44
-
45
- # build the configuration for the release
46
- config = Hash.new
47
- config["release_notes"] = notes
48
- config["release_changes"] = changes
49
- config["preformatted"] = true
50
-
51
- # prepare configuration
52
- rf.configure config
53
-
54
- files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
55
- fail "No files found for the release." if files.empty?
56
-
57
- puts "Logging in RubyForge..."
58
- rf.login
59
-
60
- puts "Files to upload:"
61
- files.each do |f|
62
- puts " * #{f}"
63
- end
64
-
65
- puts "Releasing #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
66
- rf.add_release GEM_SPEC.rubyforge_project, GEM_SPEC.name, GEM_SPEC.version, *files
67
- puts "Done."
68
- end
69
- else
70
- warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
7
+ desc 'Release all gems (native, binaries for JRuby and Windows)'
8
+ task :release_all => :build_all do
9
+ Dir["pkg/data_objects-#{DataObjects::VERSION}*.gem"].each do |gem_path|
10
+ command = "gem push #{gem_path}"
11
+ puts "Executing #{command.inspect}:"
12
+ sh command
71
13
  end
72
- else
73
- warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
74
14
  end
data/tasks/spec.rake CHANGED
@@ -1,19 +1,21 @@
1
1
  # Specs
2
- require 'spec/rake/spectask'
3
2
 
4
- desc 'Run specifications'
5
- Spec::Rake::SpecTask.new(:spec) do |t|
6
- t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
7
- t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
8
- t.libs << 'lib'
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:spec) do |spec|
5
+ spec.libs << 'lib' << 'spec'
6
+ spec.pattern = 'spec/**/*_spec.rb'
7
+ spec.verbose = true
8
+ end
9
9
 
10
- begin
11
- # RCov is run by default, except on the JRuby platform
12
- t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
13
- t.rcov_opts << '--exclude' << 'spec'
14
- t.rcov_opts << '--text-summary'
15
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
16
- rescue Exception
17
- # rcov not installed
10
+ begin
11
+ require 'rcov/rcovtask'
12
+ Rcov::RcovTask.new do |spec|
13
+ spec.libs << 'spec'
14
+ spec.pattern = 'spec/**/*_spec.rb'
15
+ spec.verbose = true
16
+ end
17
+ rescue LoadError
18
+ task :rcov do
19
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
18
20
  end
19
21
  end
data/tasks/yard.rake ADDED
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ YARD::Rake::YardocTask.new
5
+ rescue LoadError
6
+ task :yard do
7
+ abort 'YARD is not available. In order to run yard, you must: gem install yard'
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'pathname'
3
+ require 'yardstick/rake/measurement'
4
+ require 'yardstick/rake/verify'
5
+
6
+ # yardstick_measure task
7
+ Yardstick::Rake::Measurement.new
8
+
9
+ # verify_measurements task
10
+ Yardstick::Rake::Verify.new do |verify|
11
+ verify.threshold = 100
12
+ end
13
+ rescue LoadError
14
+ %w[ yardstick_measure verify_measurements ].each do |name|
15
+ task name.to_s do
16
+ abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
17
+ end
18
+ end
19
+ end
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.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirkjan Bussink
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-16 00:00:00 +02:00
12
+ date: 2010-01-09 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,27 +20,37 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: "2.0"
23
+ version: "2.1"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: extlib
27
- type: :runtime
26
+ name: bacon
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: "1.1"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ type: :development
28
38
  version_requirement:
29
39
  version_requirements: !ruby/object:Gem::Requirement
30
40
  requirements:
31
41
  - - ~>
32
42
  - !ruby/object:Gem::Version
33
- version: 0.9.12
43
+ version: "0.9"
34
44
  version:
35
45
  - !ruby/object:Gem::Dependency
36
- name: rspec
46
+ name: yard
37
47
  type: :development
38
48
  version_requirement:
39
49
  version_requirements: !ruby/object:Gem::Requirement
40
50
  requirements:
41
51
  - - ~>
42
52
  - !ruby/object:Gem::Version
43
- version: 1.2.0
53
+ version: "0.5"
44
54
  version:
45
55
  description: Provide a standard and simplified API for communicating with RDBMS from Ruby
46
56
  email: d.bussink@gmail.com
@@ -48,25 +58,36 @@ executables: []
48
58
 
49
59
  extensions: []
50
60
 
51
- extra_rdoc_files: []
52
-
61
+ extra_rdoc_files:
62
+ - README.markdown
53
63
  files:
64
+ - ChangeLog.markdown
65
+ - LICENSE
66
+ - README.markdown
67
+ - Rakefile
68
+ - lib/data_objects.rb
69
+ - lib/data_objects/byte_array.rb
54
70
  - lib/data_objects/command.rb
55
71
  - lib/data_objects/connection.rb
72
+ - lib/data_objects/error.rb
56
73
  - lib/data_objects/error/connection_error.rb
57
74
  - lib/data_objects/error/data_error.rb
58
75
  - lib/data_objects/error/integrity_error.rb
59
76
  - lib/data_objects/error/sql_error.rb
60
77
  - lib/data_objects/error/syntax_error.rb
61
78
  - lib/data_objects/error/transaction_error.rb
62
- - lib/data_objects/error.rb
63
79
  - lib/data_objects/logger.rb
80
+ - lib/data_objects/pooling.rb
64
81
  - lib/data_objects/quoting.rb
65
82
  - lib/data_objects/reader.rb
66
83
  - lib/data_objects/result.rb
84
+ - lib/data_objects/spec/bacon.rb
67
85
  - lib/data_objects/spec/command_spec.rb
68
86
  - lib/data_objects/spec/connection_spec.rb
69
87
  - lib/data_objects/spec/encoding_spec.rb
88
+ - lib/data_objects/spec/helpers/immediate_red_green_output.rb
89
+ - lib/data_objects/spec/helpers/pending.rb
90
+ - lib/data_objects/spec/helpers/ssl.rb
70
91
  - lib/data_objects/spec/quoting_spec.rb
71
92
  - lib/data_objects/spec/reader_spec.rb
72
93
  - lib/data_objects/spec/result_spec.rb
@@ -81,40 +102,36 @@ files:
81
102
  - lib/data_objects/spec/typecast/integer_spec.rb
82
103
  - lib/data_objects/spec/typecast/ipaddr_spec.rb
83
104
  - lib/data_objects/spec/typecast/nil_spec.rb
105
+ - lib/data_objects/spec/typecast/other_spec.rb
84
106
  - lib/data_objects/spec/typecast/range_spec.rb
85
107
  - lib/data_objects/spec/typecast/string_spec.rb
86
108
  - lib/data_objects/spec/typecast/time_spec.rb
87
109
  - lib/data_objects/transaction.rb
88
110
  - lib/data_objects/uri.rb
111
+ - lib/data_objects/utilities.rb
89
112
  - lib/data_objects/version.rb
90
- - lib/data_objects.rb
91
113
  - spec/command_spec.rb
92
114
  - spec/connection_spec.rb
93
115
  - spec/do_mock.rb
94
- - spec/lib/pending_helpers.rb
95
- - spec/lib/rspec_immediate_feedback_formatter.rb
96
- - spec/lib/ssl_helpers.rb
116
+ - spec/do_mock2.rb
117
+ - spec/pooling_spec.rb
97
118
  - spec/reader_spec.rb
98
119
  - spec/result_spec.rb
99
120
  - spec/spec_helper.rb
100
121
  - spec/transaction_spec.rb
101
122
  - spec/uri_spec.rb
102
- - tasks/gem.rake
103
- - tasks/install.rake
123
+ - tasks/metrics.rake
104
124
  - tasks/release.rake
105
125
  - tasks/spec.rake
106
- - LICENSE
107
- - Rakefile
108
- - HISTORY.markdown
109
- - README.markdown
110
- - Manifest.txt
126
+ - tasks/yard.rake
127
+ - tasks/yardstick.rake
111
128
  has_rdoc: true
112
129
  homepage: http://github.com/datamapper/do
113
130
  licenses: []
114
131
 
115
132
  post_install_message:
116
- rdoc_options: []
117
-
133
+ rdoc_options:
134
+ - --charset=UTF-8
118
135
  require_paths:
119
136
  - lib
120
137
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -132,9 +149,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
149
  requirements: []
133
150
 
134
151
  rubyforge_project: dorb
135
- rubygems_version: 1.3.4
152
+ rubygems_version: 1.3.5
136
153
  signing_key:
137
154
  specification_version: 3
138
155
  summary: DataObjects basic API and shared driver specifications
139
- test_files: []
140
-
156
+ test_files:
157
+ - spec/command_spec.rb
158
+ - spec/connection_spec.rb
159
+ - spec/do_mock.rb
160
+ - spec/do_mock2.rb
161
+ - spec/pooling_spec.rb
162
+ - spec/reader_spec.rb
163
+ - spec/result_spec.rb
164
+ - spec/spec_helper.rb
165
+ - spec/transaction_spec.rb
166
+ - spec/uri_spec.rb