pg 0.18.2 → 1.4.5

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.
Files changed (119) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +36 -0
  4. data/.gems +6 -0
  5. data/.github/workflows/binary-gems.yml +86 -0
  6. data/.github/workflows/source-gem.yml +131 -0
  7. data/.gitignore +13 -0
  8. data/.hgsigs +34 -0
  9. data/.hgtags +41 -0
  10. data/.irbrc +23 -0
  11. data/.pryrc +23 -0
  12. data/.tm_properties +21 -0
  13. data/.travis.yml +49 -0
  14. data/BSDL +2 -2
  15. data/Gemfile +14 -0
  16. data/History.rdoc +480 -4
  17. data/Manifest.txt +8 -21
  18. data/README-Windows.rdoc +17 -28
  19. data/README.ja.rdoc +1 -2
  20. data/README.rdoc +92 -20
  21. data/Rakefile +33 -133
  22. data/Rakefile.cross +89 -67
  23. data/certs/ged.pem +24 -0
  24. data/certs/larskanis-2022.pem +26 -0
  25. data/ext/errorcodes.def +113 -0
  26. data/ext/errorcodes.rb +1 -1
  27. data/ext/errorcodes.txt +36 -2
  28. data/ext/extconf.rb +120 -54
  29. data/ext/gvl_wrappers.c +8 -0
  30. data/ext/gvl_wrappers.h +44 -33
  31. data/ext/pg.c +216 -172
  32. data/ext/pg.h +93 -98
  33. data/ext/pg_binary_decoder.c +85 -16
  34. data/ext/pg_binary_encoder.c +25 -22
  35. data/ext/pg_coder.c +176 -40
  36. data/ext/pg_connection.c +1735 -1138
  37. data/ext/pg_copy_coder.c +95 -28
  38. data/ext/pg_errors.c +1 -1
  39. data/ext/pg_record_coder.c +521 -0
  40. data/ext/pg_result.c +642 -221
  41. data/ext/pg_text_decoder.c +609 -41
  42. data/ext/pg_text_encoder.c +254 -100
  43. data/ext/pg_tuple.c +569 -0
  44. data/ext/pg_type_map.c +62 -22
  45. data/ext/pg_type_map_all_strings.c +20 -6
  46. data/ext/pg_type_map_by_class.c +55 -25
  47. data/ext/pg_type_map_by_column.c +81 -42
  48. data/ext/pg_type_map_by_mri_type.c +49 -20
  49. data/ext/pg_type_map_by_oid.c +56 -26
  50. data/ext/pg_type_map_in_ruby.c +52 -21
  51. data/ext/{util.c → pg_util.c} +12 -12
  52. data/ext/{util.h → pg_util.h} +2 -2
  53. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  54. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  55. data/lib/pg/basic_type_map_for_results.rb +81 -0
  56. data/lib/pg/basic_type_registry.rb +301 -0
  57. data/lib/pg/binary_decoder.rb +23 -0
  58. data/lib/pg/coder.rb +24 -3
  59. data/lib/pg/connection.rb +711 -64
  60. data/lib/pg/constants.rb +2 -1
  61. data/lib/pg/exceptions.rb +9 -2
  62. data/lib/pg/result.rb +24 -7
  63. data/lib/pg/text_decoder.rb +27 -23
  64. data/lib/pg/text_encoder.rb +40 -8
  65. data/lib/pg/tuple.rb +30 -0
  66. data/lib/pg/type_map_by_column.rb +3 -2
  67. data/lib/pg/version.rb +4 -0
  68. data/lib/pg.rb +61 -36
  69. data/misc/openssl-pg-segfault.rb +31 -0
  70. data/misc/postgres/History.txt +9 -0
  71. data/misc/postgres/Manifest.txt +5 -0
  72. data/misc/postgres/README.txt +21 -0
  73. data/misc/postgres/Rakefile +21 -0
  74. data/misc/postgres/lib/postgres.rb +16 -0
  75. data/misc/ruby-pg/History.txt +9 -0
  76. data/misc/ruby-pg/Manifest.txt +5 -0
  77. data/misc/ruby-pg/README.txt +21 -0
  78. data/misc/ruby-pg/Rakefile +21 -0
  79. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  80. data/pg.gemspec +32 -0
  81. data/rakelib/task_extension.rb +46 -0
  82. data/sample/array_insert.rb +1 -1
  83. data/sample/async_api.rb +4 -8
  84. data/sample/async_copyto.rb +1 -1
  85. data/sample/async_mixed.rb +1 -1
  86. data/sample/check_conn.rb +1 -1
  87. data/sample/copydata.rb +71 -0
  88. data/sample/copyfrom.rb +1 -1
  89. data/sample/copyto.rb +1 -1
  90. data/sample/cursor.rb +1 -1
  91. data/sample/disk_usage_report.rb +6 -15
  92. data/sample/issue-119.rb +2 -2
  93. data/sample/losample.rb +1 -1
  94. data/sample/minimal-testcase.rb +2 -2
  95. data/sample/notify_wait.rb +1 -1
  96. data/sample/pg_statistics.rb +6 -15
  97. data/sample/replication_monitor.rb +9 -18
  98. data/sample/test_binary_values.rb +1 -1
  99. data/sample/wal_shipper.rb +2 -2
  100. data/sample/warehouse_partitions.rb +8 -17
  101. data.tar.gz.sig +0 -0
  102. metadata +74 -216
  103. metadata.gz.sig +0 -0
  104. data/ChangeLog +0 -5545
  105. data/lib/pg/basic_type_mapping.rb +0 -399
  106. data/spec/data/expected_trace.out +0 -26
  107. data/spec/data/random_binary_data +0 -0
  108. data/spec/helpers.rb +0 -355
  109. data/spec/pg/basic_type_mapping_spec.rb +0 -251
  110. data/spec/pg/connection_spec.rb +0 -1535
  111. data/spec/pg/result_spec.rb +0 -449
  112. data/spec/pg/type_map_by_class_spec.rb +0 -138
  113. data/spec/pg/type_map_by_column_spec.rb +0 -222
  114. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  115. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  116. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  117. data/spec/pg/type_map_spec.rb +0 -22
  118. data/spec/pg/type_spec.rb +0 -688
  119. data/spec/pg_spec.rb +0 -50
data/README.rdoc CHANGED
@@ -1,15 +1,17 @@
1
1
  = pg
2
2
 
3
- home :: https://bitbucket.org/ged/ruby-pg
4
- mirror :: https://github.com/ged/ruby-pg
3
+ home :: https://github.com/ged/ruby-pg
5
4
  docs :: http://deveiate.org/code/pg
5
+ clog :: link:/History.rdoc
6
+
7
+ {<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/ged/ruby-pg">}[https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
6
8
 
7
9
 
8
10
  == Description
9
11
 
10
12
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
11
13
 
12
- It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
14
+ It works with {PostgreSQL 9.3 and later}[http://www.postgresql.org/support/versioning/].
13
15
 
14
16
  A small example usage:
15
17
 
@@ -21,26 +23,38 @@ A small example usage:
21
23
  conn = PG.connect( dbname: 'sales' )
22
24
  conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
23
25
  puts " PID | User | Query"
24
- result.each do |row|
26
+ result.each do |row|
25
27
  puts " %7d | %-16s | %s " %
26
- row.values_at('procpid', 'usename', 'current_query')
28
+ row.values_at('pid', 'usename', 'query')
27
29
  end
28
30
  end
29
31
 
30
32
  == Build Status
31
33
 
32
- {<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
33
-
34
+ {<img src="https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml/badge.svg?branch=master" alt="Build Status Github Actions" />}[https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml]
35
+ {<img src="https://ci.appveyor.com/api/projects/status/gjx5axouf3b1wicp?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg-9j8l3]
36
+ {<img src="https://app.travis-ci.com/larskanis/ruby-pg.svg?branch=master" alt="Build Status" />}[https://app.travis-ci.com/larskanis/ruby-pg]
34
37
 
35
38
  == Requirements
36
39
 
37
- * Ruby 1.9.3-p392, or 2.0.0-p0.
38
- * PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
40
+ * Ruby 2.4 or newer
41
+ * PostgreSQL 9.3.x or later (with headers, -dev packages, etc).
39
42
 
40
- It may work with earlier versions of Ruby/PostgreSQL as well, but those are
43
+ It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
41
44
  not regularly tested.
42
45
 
43
46
 
47
+ == Versioning
48
+
49
+ We tag and release gems according to the {Semantic Versioning}[http://semver.org/] principle.
50
+
51
+ As a result of this policy, you can (and should) specify a dependency on this gem using the {Pessimistic Version Constraint}[http://guides.rubygems.org/patterns/#pessimistic-version-constraint] with two digits of precision.
52
+
53
+ For example:
54
+
55
+ spec.add_dependency 'pg', '~> 1.0'
56
+
57
+
44
58
  == How To Install
45
59
 
46
60
  Install via RubyGems:
@@ -63,6 +77,10 @@ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
63
77
  {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
64
78
  want to chat about something.
65
79
 
80
+ If you want to install as a signed gem, the public certs of the gem signers
81
+ can be found in {the `certs` directory}[https://github.com/ged/ruby-pg/tree/master/certs]
82
+ of the repository.
83
+
66
84
 
67
85
  == Type Casts
68
86
 
@@ -100,6 +118,30 @@ to build composite types by assigning an element encoder/decoder.
100
118
  PG::Coder objects can be used to set up a PG::TypeMap or alternatively
101
119
  to convert single values to/from their string representation.
102
120
 
121
+ The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
122
+ * Integer: {TE}[rdoc-ref:PG::TextEncoder::Integer], {TD}[rdoc-ref:PG::TextDecoder::Integer], {BD}[rdoc-ref:PG::BinaryDecoder::Integer] 💡 No links? Switch to {here}[https://deveiate.org/code/pg/README_rdoc.html#label-Type+Casts] 💡
123
+ * BE: {Int2}[rdoc-ref:PG::BinaryEncoder::Int2], {Int4}[rdoc-ref:PG::BinaryEncoder::Int4], {Int8}[rdoc-ref:PG::BinaryEncoder::Int8]
124
+ * Float: {TE}[rdoc-ref:PG::TextEncoder::Float], {TD}[rdoc-ref:PG::TextDecoder::Float], {BD}[rdoc-ref:PG::BinaryDecoder::Float]
125
+ * Numeric: {TE}[rdoc-ref:PG::TextEncoder::Numeric], {TD}[rdoc-ref:PG::TextDecoder::Numeric]
126
+ * Boolean: {TE}[rdoc-ref:PG::TextEncoder::Boolean], {TD}[rdoc-ref:PG::TextDecoder::Boolean], {BE}[rdoc-ref:PG::BinaryEncoder::Boolean], {BD}[rdoc-ref:PG::BinaryDecoder::Boolean]
127
+ * String: {TE}[rdoc-ref:PG::TextEncoder::String], {TD}[rdoc-ref:PG::TextDecoder::String], {BE}[rdoc-ref:PG::BinaryEncoder::String], {BD}[rdoc-ref:PG::BinaryDecoder::String]
128
+ * Bytea: {TE}[rdoc-ref:PG::TextEncoder::Bytea], {TD}[rdoc-ref:PG::TextDecoder::Bytea], {BE}[rdoc-ref:PG::BinaryEncoder::Bytea], {BD}[rdoc-ref:PG::BinaryDecoder::Bytea]
129
+ * Base64: {TE}[rdoc-ref:PG::TextEncoder::ToBase64], {TD}[rdoc-ref:PG::TextDecoder::FromBase64], {BE}[rdoc-ref:PG::BinaryEncoder::FromBase64], {BD}[rdoc-ref:PG::BinaryDecoder::ToBase64]
130
+ * Timestamp:
131
+ * TE: {local}[rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone], {UTC}[rdoc-ref:PG::TextEncoder::TimestampUtc], {with-TZ}[rdoc-ref:PG::TextEncoder::TimestampWithTimeZone]
132
+ * TD: {local}[rdoc-ref:PG::TextDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::TextDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::TextDecoder::TimestampUtcToLocal]
133
+ * BD: {local}[rdoc-ref:PG::BinaryDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::BinaryDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal]
134
+ * Date: {TE}[rdoc-ref:PG::TextEncoder::Date], {TD}[rdoc-ref:PG::TextDecoder::Date]
135
+ * JSON and JSONB: {TE}[rdoc-ref:PG::TextEncoder::JSON], {TD}[rdoc-ref:PG::TextDecoder::JSON]
136
+ * Inet: {TE}[rdoc-ref:PG::TextEncoder::Inet], {TD}[rdoc-ref:PG::TextDecoder::Inet]
137
+ * Array: {TE}[rdoc-ref:PG::TextEncoder::Array], {TD}[rdoc-ref:PG::TextDecoder::Array]
138
+ * Composite Type (also called "Row" or "Record"): {TE}[rdoc-ref:PG::TextEncoder::Record], {TD}[rdoc-ref:PG::TextDecoder::Record]
139
+
140
+ The following text formats can also be encoded although they are not used as column type:
141
+ * COPY input and output data: {TE}[rdoc-ref:PG::TextEncoder::CopyRow], {TD}[rdoc-ref:PG::TextDecoder::CopyRow]
142
+ * Literal for insertion into SQL string: {TE}[rdoc-ref:PG::TextEncoder::QuotedLiteral]
143
+ * SQL-Identifier: {TE}[rdoc-ref:PG::TextEncoder::Identifier], {TD}[rdoc-ref:PG::TextDecoder::Identifier]
144
+
103
145
  === PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
104
146
 
105
147
  A TypeMap defines which value will be converted by which encoder/decoder.
@@ -109,20 +151,51 @@ needs for type casting. The default type map is PG::TypeMapAllStrings.
109
151
 
110
152
  A type map can be assigned per connection or per query respectively per
111
153
  result set. Type maps can also be used for COPY in and out data streaming.
154
+ See PG::Connection#copy_data .
155
+
156
+ The following base type maps are available:
157
+ * PG::TypeMapAllStrings - encodes and decodes all values to and from strings (default)
158
+ * PG::TypeMapByClass - selects encoder based on the class of the value to be sent
159
+ * PG::TypeMapByColumn - selects encoder and decoder by column order
160
+ * PG::TypeMapByOid - selects decoder by PostgreSQL type OID
161
+ * PG::TypeMapInRuby - define a custom type map in ruby
162
+
163
+ The following type maps are prefilled with type mappings from the PG::BasicTypeRegistry :
164
+ * PG::BasicTypeMapForResults - a PG::TypeMapByOid prefilled with decoders for common PostgreSQL column types
165
+ * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
166
+ * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
112
167
 
113
168
 
114
169
  == Contributing
115
170
 
116
- To report bugs, suggest features, or check out the source with Mercurial,
117
- {check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
118
- Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
171
+ To report bugs, suggest features, or check out the source with Git,
172
+ {check out the project page}[https://github.com/ged/ruby-pg].
119
173
 
120
- After checking out the source, run:
174
+ After checking out the source, install all dependencies:
121
175
 
122
- $ rake newb
176
+ $ bundle install
123
177
 
124
- This task will install any missing dependencies, run the tests/specs, and
125
- generate the API documentation.
178
+ Cleanup extension files, packaging files, test databases:
179
+
180
+ $ rake clean
181
+
182
+ Compile extension:
183
+
184
+ $ rake compile
185
+
186
+ Run tests/specs with PostgreSQL tools like `initdb` in the path:
187
+
188
+ $ PATH=$PATH:/usr/lib/postgresql/14/bin rake test
189
+
190
+ Or run a specific test with the line number:
191
+
192
+ $ PATH=$PATH:/usr/lib/postgresql/14/bin rspec -Ilib -fd spec/pg/connection_spec.rb:455
193
+
194
+ Generate the API documentation:
195
+
196
+ $ rake docs
197
+
198
+ Make sure, that all bugs and new features are verified by tests.
126
199
 
127
200
  The current maintainers are Michael Granger <ged@FaerieMUD.org> and
128
201
  Lars Kanis <lars@greiz-reinsdorf.de>.
@@ -130,7 +203,7 @@ Lars Kanis <lars@greiz-reinsdorf.de>.
130
203
 
131
204
  == Copying
132
205
 
133
- Copyright (c) 1997-2015 by the authors.
206
+ Copyright (c) 1997-2022 by the authors.
134
207
 
135
208
  * Jeff Davis <ruby-pg@j-davis.com>
136
209
  * Guy Decoux (ts) <decoux@moulon.inra.fr>
@@ -142,7 +215,7 @@ Copyright (c) 1997-2015 by the authors.
142
215
  * Noboru Saitou <noborus@netlab.jp>
143
216
 
144
217
  You may redistribute this software under the same terms as Ruby itself; see
145
- http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
218
+ https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
146
219
  for details.
147
220
 
148
221
  Portions of the code are from the PostgreSQL project, and are distributed
@@ -158,4 +231,3 @@ to this library over the years.
158
231
 
159
232
  We are thankful to the people at the ruby-list and ruby-dev mailing lists.
160
233
  And to the people who developed PostgreSQL.
161
-
data/Rakefile CHANGED
@@ -1,22 +1,13 @@
1
- #!/usr/bin/env rake
1
+ # -*- rake -*-
2
2
 
3
3
  require 'rbconfig'
4
4
  require 'pathname'
5
5
  require 'tmpdir'
6
-
7
- begin
8
- require 'rake/extensiontask'
9
- rescue LoadError
10
- abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
11
- end
12
-
13
- begin
14
- require 'hoe'
15
- rescue LoadError
16
- abort "This Rakefile requires hoe (gem install hoe)"
17
- end
18
-
6
+ require 'rake/extensiontask'
19
7
  require 'rake/clean'
8
+ require 'rspec/core/rake_task'
9
+ require 'bundler'
10
+ require 'bundler/gem_helper'
20
11
 
21
12
  # Build directory constants
22
13
  BASEDIR = Pathname( __FILE__ ).dirname
@@ -25,102 +16,38 @@ LIBDIR = BASEDIR + 'lib'
25
16
  EXTDIR = BASEDIR + 'ext'
26
17
  PKGDIR = BASEDIR + 'pkg'
27
18
  TMPDIR = BASEDIR + 'tmp'
19
+ TESTDIR = BASEDIR + "tmp_test_*"
28
20
 
29
21
  DLEXT = RbConfig::CONFIG['DLEXT']
30
22
  EXT = LIBDIR + "pg_ext.#{DLEXT}"
31
23
 
32
24
  GEMSPEC = 'pg.gemspec'
33
25
 
34
- TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
35
-
36
- CLOBBER.include( TEST_DIRECTORY.to_s )
26
+ CLEAN.include( TESTDIR.to_s )
37
27
  CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
38
-
39
- # Set up Hoe plugins
40
- Hoe.plugin :mercurial
41
- Hoe.plugin :signing
42
- Hoe.plugin :deveiate
43
- Hoe.plugin :bundler
44
-
45
- Hoe.plugins.delete :rubyforge
46
- Hoe.plugins.delete :compiler
28
+ CLEAN.include "lib/*/libpq.dll"
29
+ CLEAN.include "lib/pg_ext.*"
30
+ CLEAN.include "lib/pg/postgresql_lib_path.rb"
47
31
 
48
32
  load 'Rakefile.cross'
49
33
 
50
-
51
- # Hoe specification
52
- $hoespec = Hoe.spec 'pg' do
53
- self.readme_file = 'README.rdoc'
54
- self.history_file = 'History.rdoc'
55
- self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
56
- self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
57
- self.extra_rdoc_files.include( 'ext/*.c' )
58
- self.license :BSD
59
-
60
- self.developer 'Michael Granger', 'ged@FaerieMUD.org'
61
- self.developer 'Lars Kanis', 'lars@greiz-reinsdorf.de'
62
-
63
- self.dependency 'rake-compiler', '~> 0.9', :developer
64
- self.dependency 'hoe', '~> 3.12', :developer
65
- self.dependency 'hoe-deveiate', '~> 0.6', :developer
66
- self.dependency 'hoe-bundler', '~> 1.0', :developer
67
- self.dependency 'rspec', '~> 3.0', :developer
68
-
69
- self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
70
- self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
71
-
72
- self.require_ruby_version( '>= 1.9.3' )
73
-
74
- self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
75
- self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
76
- self.spec_extras[:rdoc_options] = [
77
- '-f', 'fivefish',
78
- '-t', 'pg: The Ruby Interface to PostgreSQL',
79
- '-m', 'README.rdoc',
80
- ]
81
-
82
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
83
- end
84
-
85
- ENV['VERSION'] ||= $hoespec.spec.version.to_s
86
-
87
- # Tests should pass before checking in
88
- task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
89
-
90
- # Support for 'rvm specs'
91
- task :specs => :spec
92
-
93
- # Compile before testing
94
- task :spec => :compile
95
-
96
- # gem-testers support
97
- task :test do
98
- # rake-compiler always wants to copy the compiled extension into lib/, but
99
- # we don't want testers to have to re-compile, especially since that
100
- # often fails because they can't (and shouldn't have to) write to tmp/ in
101
- # the installed gem dir. So we clear the task rake-compiler set up
102
- # to break the dependency between :spec and :compile when running under
103
- # rubygems-test, and then run :spec.
104
- Rake::Task[ EXT.to_s ].clear
105
- Rake::Task[ :spec ].execute
106
- end
34
+ Bundler::GemHelper.install_tasks
35
+ $gem_spec = Bundler.load_gemspec(GEMSPEC)
107
36
 
108
37
  desc "Turn on warnings and debugging in the build."
109
38
  task :maint do
110
39
  ENV['MAINTAINER_MODE'] = 'yes'
111
40
  end
112
41
 
113
- ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
114
-
115
42
  # Rake-compiler task
116
43
  Rake::ExtensionTask.new do |ext|
117
44
  ext.name = 'pg_ext'
118
- ext.gem_spec = $hoespec.spec
45
+ ext.gem_spec = $gem_spec
119
46
  ext.ext_dir = 'ext'
120
47
  ext.lib_dir = 'lib'
121
48
  ext.source_pattern = "*.{c,h}"
122
49
  ext.cross_compile = true
123
- ext.cross_platform = CrossLibraries.map &:for_platform
50
+ ext.cross_platform = CrossLibraries.map(&:for_platform)
124
51
 
125
52
  ext.cross_config_options += CrossLibraries.map do |lib|
126
53
  {
@@ -136,52 +63,40 @@ Rake::ExtensionTask.new do |ext|
136
63
 
137
64
  # Add libpq.dll to windows binary gemspec
138
65
  ext.cross_compiling do |spec|
139
- # mingw32-platform strings differ (RUBY_PLATFORM=i386-mingw32 vs. x86-mingw32 for rubygems)
140
- spec.files << "lib/#{spec.platform.to_s.gsub(/^x86-/, "i386-")}/libpq.dll"
66
+ spec.files << "lib/#{spec.platform}/libpq.dll"
141
67
  end
142
68
  end
143
69
 
70
+ RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
71
+ task :test => :spec
144
72
 
145
- # Make the ChangeLog update if the repo has changed since it was last built
146
- file '.hg/branch' do
147
- warn "WARNING: You need the Mercurial repo to update the ChangeLog"
148
- end
149
- file 'ChangeLog' do |task|
150
- if File.exist?('.hg/branch')
151
- $stderr.puts "Updating the changelog..."
152
- begin
153
- content = make_changelog()
154
- rescue NameError
155
- abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
156
- end
157
- File.open( task.name, 'w', 0644 ) do |fh|
158
- fh.print( content )
159
- end
160
- else
161
- touch 'ChangeLog'
162
- end
163
- end
73
+ # Use the fivefish formatter for docs generated from development checkout
74
+ require 'rdoc/task'
164
75
 
165
- # Rebuild the ChangeLog immediately before release
166
- task :prerelease => 'ChangeLog'
76
+ RDoc::Task.new( 'docs' ) do |rdoc|
77
+ rdoc.main = "README.rdoc"
78
+ rdoc.rdoc_files.include( "*.rdoc", "lib/**/*.rb", 'ext/**/*.{c,h}' )
79
+ rdoc.generator = :fivefish
80
+ rdoc.title = "PG: The Ruby PostgreSQL Driver"
81
+ rdoc.rdoc_dir = 'doc'
82
+ end
167
83
 
84
+ desc "Build the source gem #{$gem_spec.full_name}.gem into the pkg directory"
85
+ task :gem => :build
168
86
 
169
- desc "Stop any Postmaster instances that remain after testing."
170
- task :cleanup_testing_dbs do
171
- require 'spec/lib/helpers'
172
- PgTestingHelpers.stop_existing_postmasters()
173
- Rake::Task[:clean].invoke
87
+ task :clobber do
88
+ puts "Stop any Postmaster instances that remain after testing."
89
+ require_relative 'spec/helpers'
90
+ PG::TestingHelpers.stop_existing_postmasters()
174
91
  end
175
92
 
176
93
  desc "Update list of server error codes"
177
94
  task :update_error_codes do
178
- URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=HEAD"
95
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_15_0"
179
96
 
180
97
  ERRORCODES_TXT = "ext/errorcodes.txt"
181
98
  sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
182
- end
183
99
 
184
- file 'ext/errorcodes.def' => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
185
100
  ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
186
101
  end
187
102
 
@@ -189,18 +104,3 @@ file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
189
104
  # trigger compilation of changed errorcodes.def
190
105
  touch 'ext/pg_errors.c'
191
106
  end
192
-
193
- task :gemspec => GEMSPEC
194
- file GEMSPEC => __FILE__
195
- task GEMSPEC do |task|
196
- spec = $hoespec.spec
197
- spec.files.delete( '.gemtest' )
198
- spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
199
- File.open( task.name, 'w' ) do |fh|
200
- fh.write( spec.to_ruby )
201
- end
202
- end
203
-
204
- CLOBBER.include( GEMSPEC.to_s )
205
- task :default => :gemspec
206
-