do_postgres 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/LICENSE +1 -1
  2. data/Manifest.txt +15 -5
  3. data/Rakefile +7 -121
  4. data/ext/do_postgres_ext/do_postgres_ext.c +245 -108
  5. data/ext/do_postgres_ext/extconf.rb +3 -1
  6. data/lib/do_postgres.rb +5 -2
  7. data/lib/do_postgres/version.rb +1 -1
  8. data/spec/command_spec.rb +9 -0
  9. data/spec/connection_spec.rb +19 -0
  10. data/spec/encoding_spec.rb +8 -0
  11. data/spec/lib/rspec_immediate_feedback_formatter.rb +3 -0
  12. data/spec/reader_spec.rb +8 -0
  13. data/spec/result_spec.rb +86 -0
  14. data/spec/spec_helper.rb +90 -57
  15. data/spec/typecast/array_spec.rb +8 -0
  16. data/spec/typecast/bigdecimal_spec.rb +9 -0
  17. data/spec/typecast/boolean_spec.rb +9 -0
  18. data/spec/typecast/byte_array_spec.rb +8 -0
  19. data/spec/typecast/class_spec.rb +8 -0
  20. data/spec/typecast/date_spec.rb +9 -0
  21. data/spec/typecast/datetime_spec.rb +9 -0
  22. data/spec/typecast/float_spec.rb +9 -0
  23. data/spec/typecast/integer_spec.rb +8 -0
  24. data/spec/typecast/nil_spec.rb +10 -0
  25. data/spec/typecast/range_spec.rb +8 -0
  26. data/spec/typecast/string_spec.rb +8 -0
  27. data/spec/typecast/time_spec.rb +8 -0
  28. data/tasks/gem.rake +61 -0
  29. data/tasks/install.rake +15 -0
  30. data/tasks/native.rake +35 -0
  31. data/tasks/release.rake +75 -0
  32. data/tasks/retrieve.rake +79 -0
  33. data/tasks/spec.rake +18 -0
  34. metadata +72 -44
  35. data/.gitignore +0 -0
  36. data/autobuild.rb +0 -90
  37. data/buildfile +0 -27
  38. data/ext-java/src/main/java/DoPostgresExtService.java +0 -23
  39. data/ext-java/src/main/java/do_postgres/PostgresDriverDefinition.java +0 -12
  40. data/script/timezone_spec_runner.rb +0 -28
  41. data/script/timezones.txt +0 -562
  42. data/spec/integration/do_postgres_spec.rb +0 -312
  43. data/spec/integration/logging_spec.rb +0 -53
  44. data/spec/integration/quoting_spec.rb +0 -25
  45. data/spec/integration/timezone_spec.rb +0 -66
  46. data/spec/spec.opts +0 -2
  47. data/spec/unit/transaction_spec.rb +0 -28
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/integer_spec'
5
+
6
+ describe 'DataObjects::Postgres with Integer' do
7
+ it_should_behave_like 'supporting Integer'
8
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/nil_spec'
5
+
6
+ describe 'DataObjects::Postgres with Nil' do
7
+ it_should_behave_like 'supporting Nil'
8
+ # it_should_behave_like 'supporting writing an Nil'
9
+ it_should_behave_like 'supporting Nil autocasting'
10
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/range_spec'
5
+
6
+ describe 'DataObjects::Postgres with Range' do
7
+ it_should_behave_like 'supporting Range'
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/string_spec'
5
+
6
+ describe 'DataObjects::Postgres with String' do
7
+ it_should_behave_like 'supporting String'
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/time_spec'
5
+
6
+ describe 'DataObjects::Postgres with Time' do
7
+ it_should_behave_like 'supporting Time'
8
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems/package_task'
2
+
3
+ GEM_SPEC = Gem::Specification.new do |s|
4
+ # basic information
5
+ s.name = "do_postgres"
6
+ s.version = DataObjects::Postgres::VERSION
7
+
8
+ # description and details
9
+ s.summary = 'DataObjects PostgreSQL Driver'
10
+ s.description = "Implements the DataObjects API for PostgreSQL"
11
+
12
+ # dependencies
13
+ s.add_dependency "addressable", "~>2.0.0"
14
+ s.add_dependency "extlib", "~>0.9.12"
15
+ s.add_dependency "data_objects", DataObjects::Postgres::VERSION
16
+
17
+ if JRUBY
18
+ s.add_dependency "jdbc-postgres", ">=8.2"
19
+ s.add_dependency "do_jdbc", DataObjects::Postgres::VERSION
20
+ s.platform = "java"
21
+ # components, files and paths
22
+ s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
23
+ "LICENSE", "Rakefile", "*.{rdoc,txt,yml}", "lib/*.jar"]
24
+ else
25
+ s.platform = Gem::Platform::RUBY
26
+ s.extensions << 'ext/do_postgres_ext/extconf.rb'
27
+ # components, files and paths
28
+ s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake", "ext/**/*.{rb,c}",
29
+ "LICENSE", "Rakefile", "*.{rdoc,txt,yml}"]
30
+ end
31
+
32
+ # development dependencies
33
+ s.add_development_dependency 'rspec', '~>1.2.0'
34
+
35
+
36
+ s.require_path = 'lib'
37
+
38
+ # documentation
39
+ s.has_rdoc = false
40
+
41
+ # project information
42
+ s.homepage = 'http://github.com/datamapper/do'
43
+ s.rubyforge_project = 'dorb'
44
+
45
+ # author and contributors
46
+ s.author = 'Dirkjan Bussink'
47
+ s.email = 'd.bussink@gmail.com'
48
+ end
49
+
50
+ gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
51
+ pkg.need_tar = false
52
+ pkg.need_zip = false
53
+ end
54
+
55
+ file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
56
+ puts "Generating #{t.name}"
57
+ File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
58
+ end
59
+
60
+ desc "Generate or update the standalone gemspec file for the project"
61
+ task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
@@ -0,0 +1,15 @@
1
+ def sudo_gem(cmd)
2
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
+ end
4
+
5
+ # Installation
6
+
7
+ desc "Install #{GEM_SPEC.name} #{GEM_SPEC.version}"
8
+ task :install => [ :package ] do
9
+ sudo_gem "install pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version} --no-update-sources"
10
+ end
11
+
12
+ desc "Uninstall #{GEM_SPEC.name} #{GEM_SPEC.version}"
13
+ task :uninstall => [ :clean ] do
14
+ sudo_gem "uninstall #{GEM_SPEC.name} -v#{GEM_SPEC.version} -I -x"
15
+ end
data/tasks/native.rake ADDED
@@ -0,0 +1,35 @@
1
+ begin
2
+ gem('rake-compiler')
3
+ require 'rake/extensiontask'
4
+
5
+ Rake::ExtensionTask.new('do_postgres_ext', GEM_SPEC) do |ext|
6
+
7
+ postgres_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'pgsql'))
8
+
9
+ # automatically add build options to avoid need of manual input
10
+ if RUBY_PLATFORM =~ /mswin|mingw/ then
11
+ ext.config_options << "--with-pgsql-server-include=#{postgres_lib}/include/server"
12
+ ext.config_options << "--with-pgsql-client-include=#{postgres_lib}/include"
13
+ ext.config_options << "--with-pgsql-win32-include=#{postgres_lib}/include/server/port/win32"
14
+ ext.config_options << "--with-pgsql-client-lib=#{postgres_lib}/lib"
15
+ else
16
+ ext.cross_compile = true
17
+ ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
18
+ ext.cross_config_options << "--with-pgsql-server-include=#{postgres_lib}/include/server"
19
+ ext.cross_config_options << "--with-pgsql-client-include=#{postgres_lib}/include"
20
+ ext.cross_config_options << "--with-pgsql-win32-include=#{postgres_lib}/include/server/port/win32"
21
+ ext.cross_config_options << "--with-pgsql-client-lib=#{postgres_lib}/lib"
22
+ end
23
+
24
+ end
25
+ rescue LoadError
26
+ warn "To cross-compile, install rake-compiler (gem install rake-compiler)"
27
+
28
+ if (tasks_dir = ROOT.parent + 'tasks').directory?
29
+ require tasks_dir + 'ext_helper'
30
+ require tasks_dir + 'ext_helper_java'
31
+
32
+ setup_c_extension("#{GEM_SPEC.name}_ext", GEM_SPEC)
33
+ setup_java_extension("#{GEM_SPEC.name}_ext", GEM_SPEC)
34
+ end
35
+ end
@@ -0,0 +1,75 @@
1
+ begin
2
+ gem 'rubyforge', '~> 1.0.1'
3
+ require 'rubyforge'
4
+ rescue Exception
5
+ nil
6
+ end
7
+
8
+ if defined?(RubyForge) then
9
+ if defined?(GEM_SPEC) then
10
+ desc 'Package and upload to RubyForge'
11
+ task :release => [: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.rdoc")
30
+ r.split(/^(=+ .*)/)[1..4].join.strip
31
+ rescue
32
+ warn "Missing README.rdoc"
33
+ ''
34
+ end
35
+
36
+ # read changes
37
+ changes = begin
38
+ h = File.read("History.txt")
39
+ h.split(/^(==+ .*)/)[1..2].join.strip
40
+ rescue
41
+ warn "Missing History.txt"
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
+ #Rake::Task['release'].prerequisites.unshift('clean', 'cross', 'native')
70
+ else
71
+ warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
72
+ end
73
+ else
74
+ warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
75
+ end
@@ -0,0 +1,79 @@
1
+ begin
2
+ gem('rake-compiler')
3
+ require 'rake/clean'
4
+ require 'rake/extensioncompiler'
5
+
6
+ # download postgres library and headers
7
+ directory "vendor"
8
+
9
+ # only on Windows or cross platform compilation
10
+ def dlltool(dllname, deffile, libfile)
11
+ # define if we are using GCC or not
12
+ if Rake::ExtensionCompiler.mingw_gcc_executable then
13
+ dir = File.dirname(Rake::ExtensionCompiler.mingw_gcc_executable)
14
+ tool = case RUBY_PLATFORM
15
+ when /mingw/
16
+ File.join(dir, 'dlltool.exe')
17
+ when /linux|darwin/
18
+ File.join(dir, "#{Rake::ExtensionCompiler.mingw_host}-dlltool")
19
+ end
20
+ return "#{tool} --dllname #{dllname} --def #{deffile} --output-lib #{libfile}"
21
+ else
22
+ if RUBY_PLATFORM =~ /mswin/ then
23
+ tool = 'lib.exe'
24
+ else
25
+ fail "Unsupported platform for cross-compilation (please, contribute some patches)."
26
+ end
27
+ return "#{tool} /DEF:#{deffile} /OUT:#{libfile}"
28
+ end
29
+ end
30
+
31
+ def copy(from, to)
32
+ if WINDOWS
33
+ from.gsub!(/\//, '\\')
34
+ to.gsub!(/\//, '\\')
35
+ end
36
+ sh "#{WINDOWS ? 'copy' : 'cp'} #{from} #{to}"
37
+ end
38
+
39
+ version = '8.3.7'
40
+ file "vendor/postgresql-#{version}-1-binaries-no-installer.zip" => ['vendor'] do |t|
41
+ url = "http://wwwmaster.postgresql.org/redir/107/h/binary/v#{version}/win32/#{File.basename(t.name)}"
42
+ when_writing "downloading #{t.name}" do
43
+ cd File.dirname(t.name) do
44
+ sh "wget -c #{url} || curl -C - -O #{url}"
45
+ end
46
+ touch t.name
47
+ end
48
+ end
49
+
50
+ file "vendor/pgsql/include/pg_config.h" => ["vendor/postgresql-#{version}-1-binaries-no-installer.zip"] do |t|
51
+ full_file = File.expand_path(t.prerequisites.last)
52
+ when_writing "creating #{t.name}" do
53
+ cd "vendor" do
54
+ sh "unzip #{full_file} pgsql/bin/** pgsql/include/** pgsql/lib/**"
55
+ end
56
+ copy "ext/do_postgres_ext/pg_config.h", "vendor/pgsql/include/pg_config.h"
57
+ copy "ext/do_postgres_ext/pg_config.h", "vendor/pgsql/include/server/pg_config.h"
58
+
59
+ # update file timestamp to avoid Rake perform this extraction again.
60
+ touch t.name
61
+ end
62
+ end
63
+
64
+ # clobber vendored packages
65
+ CLOBBER.include('vendor')
66
+
67
+ # vendor:postgres
68
+ task 'vendor:postgres' => ["vendor/pgsql/include/pg_config.h"]
69
+
70
+ # hook into cross compilation vendored postgres dependency
71
+ if RUBY_PLATFORM =~ /mingw|mswin/ then
72
+ Rake::Task['compile'].prerequisites.unshift 'vendor:postgres'
73
+ else
74
+ if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
75
+ Rake::Task['cross'].prerequisites.unshift 'vendor:postgres'
76
+ end
77
+ end
78
+ rescue LoadError
79
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,18 @@
1
+ # Specs
2
+ require 'spec/rake/spectask'
3
+
4
+ desc 'Run specifications'
5
+ Spec::Rake::SpecTask.new(:spec => [ :clean, :compile ]) 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
+
9
+ begin
10
+ # RCov is run by default, except on the JRuby platform
11
+ t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
12
+ t.rcov_opts << '--exclude' << 'spec'
13
+ t.rcov_opts << '--text-summary'
14
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
15
+ rescue Exception
16
+ # rcov not installed
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirkjan Bussink
@@ -9,9 +9,29 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-19 00:00:00 +01:00
12
+ date: 2009-05-17 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: addressable
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: extlib
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.12
34
+ version:
15
35
  - !ruby/object:Gem::Dependency
16
36
  name: data_objects
17
37
  type: :runtime
@@ -20,64 +40,72 @@ dependencies:
20
40
  requirements:
21
41
  - - "="
22
42
  - !ruby/object:Gem::Version
23
- version: 0.9.11
43
+ version: 0.9.12
24
44
  version:
25
45
  - !ruby/object:Gem::Dependency
26
- name: hoe
46
+ name: rspec
27
47
  type: :development
28
48
  version_requirement:
29
49
  version_requirements: !ruby/object:Gem::Requirement
30
50
  requirements:
31
- - - ">="
51
+ - - ~>
32
52
  - !ruby/object:Gem::Version
33
- version: 1.8.2
53
+ version: 1.2.0
34
54
  version:
35
- description: A DataObject.rb driver for PostgreSQL
36
- email:
37
- - d.bussink@gmail.com
55
+ description: Implements the DataObjects API for PostgreSQL
56
+ email: d.bussink@gmail.com
38
57
  executables: []
39
58
 
40
59
  extensions:
41
60
  - ext/do_postgres_ext/extconf.rb
42
- extra_rdoc_files:
43
- - History.txt
44
- - Manifest.txt
45
- - README.txt
46
- - script/timezones.txt
61
+ extra_rdoc_files: []
62
+
47
63
  files:
48
- - .gitignore
49
- - History.txt
50
- - LICENSE
51
- - Manifest.txt
52
- - README.txt
53
- - Rakefile
54
- - autobuild.rb
55
- - buildfile
56
- - ext-java/src/main/java/DoPostgresExtService.java
57
- - ext-java/src/main/java/do_postgres/PostgresDriverDefinition.java
58
- - ext/do_postgres_ext/do_postgres_ext.c
59
- - ext/do_postgres_ext/extconf.rb
60
- - lib/do_postgres.rb
61
64
  - lib/do_postgres/transaction.rb
62
65
  - lib/do_postgres/version.rb
63
- - script/timezone_spec_runner.rb
64
- - script/timezones.txt
65
- - spec/integration/do_postgres_spec.rb
66
- - spec/integration/logging_spec.rb
67
- - spec/integration/quoting_spec.rb
68
- - spec/integration/timezone_spec.rb
69
- - spec/spec.opts
66
+ - lib/do_postgres.rb
67
+ - spec/command_spec.rb
68
+ - spec/connection_spec.rb
69
+ - spec/encoding_spec.rb
70
+ - spec/lib/rspec_immediate_feedback_formatter.rb
71
+ - spec/reader_spec.rb
72
+ - spec/result_spec.rb
70
73
  - spec/spec_helper.rb
71
- - spec/unit/transaction_spec.rb
72
- has_rdoc: false
73
- homepage: http://rubyforge.org/projects/dorb
74
- post_install_message:
75
- rdoc_options:
76
- - --main
74
+ - spec/typecast/array_spec.rb
75
+ - spec/typecast/bigdecimal_spec.rb
76
+ - spec/typecast/boolean_spec.rb
77
+ - spec/typecast/byte_array_spec.rb
78
+ - spec/typecast/class_spec.rb
79
+ - spec/typecast/date_spec.rb
80
+ - spec/typecast/datetime_spec.rb
81
+ - spec/typecast/float_spec.rb
82
+ - spec/typecast/integer_spec.rb
83
+ - spec/typecast/nil_spec.rb
84
+ - spec/typecast/range_spec.rb
85
+ - spec/typecast/string_spec.rb
86
+ - spec/typecast/time_spec.rb
87
+ - tasks/gem.rake
88
+ - tasks/install.rake
89
+ - tasks/native.rake
90
+ - tasks/release.rake
91
+ - tasks/retrieve.rake
92
+ - tasks/spec.rake
93
+ - ext/do_postgres_ext/extconf.rb
94
+ - ext/do_postgres_ext/do_postgres_ext.c
95
+ - LICENSE
96
+ - Rakefile
97
+ - History.txt
98
+ - Manifest.txt
77
99
  - README.txt
100
+ has_rdoc: true
101
+ homepage: http://github.com/datamapper/do
102
+ licenses: []
103
+
104
+ post_install_message:
105
+ rdoc_options: []
106
+
78
107
  require_paths:
79
108
  - lib
80
- - ext
81
109
  required_ruby_version: !ruby/object:Gem::Requirement
82
110
  requirements:
83
111
  - - ">="
@@ -93,9 +121,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
121
  requirements: []
94
122
 
95
123
  rubyforge_project: dorb
96
- rubygems_version: 1.3.1
124
+ rubygems_version: 1.3.3
97
125
  signing_key:
98
- specification_version: 2
99
- summary: A DataObject.rb driver for PostgreSQL
126
+ specification_version: 3
127
+ summary: DataObjects PostgreSQL Driver
100
128
  test_files: []
101
129