pg 0.11.0 → 0.12.0pre258
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Contributors.rdoc +37 -0
- data/History.rdoc +60 -0
- data/Manifest.txt +39 -0
- data/README.OS_X.rdoc +68 -0
- data/README.ja.rdoc +7 -0
- data/{README → README.rdoc} +33 -18
- data/{README.windows → README.windows.rdoc} +20 -26
- data/Rakefile +98 -324
- data/ext/extconf.rb +7 -2
- data/ext/pg.c +173 -35
- data/ext/vc/pg.sln +26 -0
- data/ext/vc/pg_18/pg.vcproj +216 -0
- data/ext/vc/pg_19/pg_19.vcproj +209 -0
- data/lib/pg.rb +5 -7
- data/misc/openssl-pg-segfault.rb +31 -0
- data/sample/async_api.rb +109 -0
- data/sample/copyfrom.rb +81 -0
- data/sample/copyto.rb +23 -0
- data/sample/losample.rb +69 -0
- data/sample/notify_wait.rb +43 -0
- data/sample/psql.rb +1181 -0
- data/sample/psqlHelp.rb +158 -0
- data/sample/test1.rb +60 -0
- data/sample/test2.rb +44 -0
- data/sample/test4.rb +71 -0
- data/sample/test_binary_values.rb +35 -0
- data/spec/m17n_spec.rb +1 -1
- data/spec/pgconn_spec.rb +50 -5
- data/spec/pgresult_spec.rb +1 -1
- metadata +142 -66
- data.tar.gz.sig +0 -2
- data/ChangeLog +0 -693
- data/Contributors +0 -32
- data/README.OS_X +0 -19
- data/README.ja +0 -183
- data/Rakefile.local +0 -312
- data/rake/191_compat.rb +0 -26
- data/rake/dependencies.rb +0 -76
- data/rake/documentation.rb +0 -123
- data/rake/helpers.rb +0 -502
- data/rake/hg.rb +0 -318
- data/rake/manual.rb +0 -787
- data/rake/packaging.rb +0 -129
- data/rake/publishing.rb +0 -341
- data/rake/style.rb +0 -62
- data/rake/svn.rb +0 -668
- data/rake/testing.rb +0 -152
- data/rake/verifytask.rb +0 -64
- metadata.gz.sig +0 -0
data/.gemtest
ADDED
File without changes
|
data/Contributors.rdoc
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
Thanks to all the great people that have contributed code, suggestions, and patches through the years. If you contribute a patch, please include a patch for this file that adds your name to the list.
|
3
|
+
|
4
|
+
* Dennis Vshivkov <walrus@amur.ru>
|
5
|
+
* Gabriel Emerson <gemerson@evalsoft.com>
|
6
|
+
* Noboru Saitou <noborus@netlab.jp>
|
7
|
+
* Akinori MUSHA <knu@iDaemons.org>
|
8
|
+
* Andy Yu <is@gnuchina.org>
|
9
|
+
* Ceri Storey <cez@compsoc.man.ac.uk>
|
10
|
+
* Gavin Kistner <gavin@refinery.com>
|
11
|
+
* Henry T. So Jr. <henryso@panix.com>
|
12
|
+
* Jeremy Henty <jeremy@chaos.org.uk>
|
13
|
+
* <kasa@air.linkclub.or.jp>
|
14
|
+
* Leon Brooks <leon-ruby-postgres@cyberknights.com.au>
|
15
|
+
* Martin Hedenfalk <mahe@kth.se>
|
16
|
+
* Yukihiro Matsumoto <matz@zetabits.com>
|
17
|
+
* Eiji Matsumoto <usagi@ruby.club.or.jp>
|
18
|
+
* MoonWolf <moonwolf@moonwolf.com>
|
19
|
+
* <m_seki@mva.biglobe.ne.jp>
|
20
|
+
* Nate Haggard <nate@wordplace.com>
|
21
|
+
* Neil Conway <nconway@klamath.dyndns.org>
|
22
|
+
* Noboru Matui <silicon@mx1.freemail.ne.jp>
|
23
|
+
* Okada Jun <yun@be-in.org>
|
24
|
+
* Shirai,Kaoru <shirai@p1jp.com>
|
25
|
+
* Riley <wormwood@speakeasy.org>
|
26
|
+
* shibata <kshibata@vesta.ocn.ne.jp>
|
27
|
+
* <greentea@fa2.so-net.ne.jp>
|
28
|
+
* ts <decoux@moulon.inra.fr>
|
29
|
+
* Yuta TSUBOI <yuuta-t@is.aist-nara.ac.jp>
|
30
|
+
* Lugovoi Nikolai <meadow.nnick@gmail.com>
|
31
|
+
* Jeff Davis <ruby@j-davis.com>
|
32
|
+
* Bertram Scharpf <software@bertram-scharpf.de>
|
33
|
+
* Michael Granger <ged@FaerieMUD.org>
|
34
|
+
* Mahlon E. Smith <mahlon@martini.nu>
|
35
|
+
|
36
|
+
Jason Yanowitz <me-bitbucket@jasonyanowitz.com>
|
37
|
+
|
data/History.rdoc
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
== v0.12.0 [2011-10-07] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- PGconn#wait_for_notify
|
4
|
+
* send nil as the payload argument if the NOTIFY didn't have one.
|
5
|
+
* accept a nil argument for no timeout (Sequel support)
|
6
|
+
* Fixed API docs
|
7
|
+
* Taint and encode event name and payload
|
8
|
+
- Handle errors while rb_thread_select()ing in PGconn#block.
|
9
|
+
(Brian Weaver).
|
10
|
+
- Fixes for Win32 async queries (Rafał Bigaj)
|
11
|
+
- Memory leak fixed: Closing opened WSA event. (rafal)
|
12
|
+
- Fixes for #66 Win32 asynchronous queries hang on connection
|
13
|
+
error. (rafal)
|
14
|
+
- Fixed a typo in PGconn#error_message's documentation
|
15
|
+
- fixing unused variable warnings for ruby 1.9.3 (Aaron Patterson)
|
16
|
+
- Build system bugfixes
|
17
|
+
- Converted to Hoe
|
18
|
+
|
19
|
+
|
20
|
+
== v0.11.0 [2011-02-09] Michael Granger <ged@FaerieMUD.org>
|
21
|
+
|
22
|
+
Enhancements:
|
23
|
+
|
24
|
+
* Added a PGresult#values method to fetch all result rows as an Array of
|
25
|
+
Arrays. Thanks to Jason Yanowitz (JYanowitz at enovafinancial dot com) for
|
26
|
+
the patch.
|
27
|
+
|
28
|
+
|
29
|
+
== v0.10.1 [2011-01-19] Michael Granger <ged@FaerieMUD.org>
|
30
|
+
|
31
|
+
Bugfixes:
|
32
|
+
|
33
|
+
* Add an include guard for pg.h
|
34
|
+
* Simplify the common case require of the ext
|
35
|
+
* Include the extconf header
|
36
|
+
* Fix compatibility with versions of PostgreSQL without PQgetCancel. (fixes #36)
|
37
|
+
* Fix require for natively-compiled extension under Windows. (fixes #55)
|
38
|
+
* Change rb_yield_splat() to rb_yield_values() for compatibility with Rubinius. (fixes #54)
|
39
|
+
|
40
|
+
|
41
|
+
== v0.10.0 [2010-12-01] Michael Granger <ged@FaerieMUD.org>
|
42
|
+
|
43
|
+
Enhancements:
|
44
|
+
|
45
|
+
* Added support for the payload of NOTIFY events (w/Mahlon E. Smith)
|
46
|
+
* Updated the build system with Rubygems suggestions from RubyConf 2010
|
47
|
+
|
48
|
+
Bugfixes:
|
49
|
+
|
50
|
+
* Fixed issue with PGconn#wait_for_notify that caused it to miss notifications that happened after
|
51
|
+
the LISTEN but before the wait_for_notify.
|
52
|
+
|
53
|
+
== v0.9.0 [2010-02-28] Michael Granger <ged@FaerieMUD.org>
|
54
|
+
|
55
|
+
Bugfixes.
|
56
|
+
|
57
|
+
== v0.8.0 [2009-03-28] Jeff Davis <davis.jeffrey@gmail.com>
|
58
|
+
|
59
|
+
Bugfixes, better Windows support.
|
60
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
.gemtest
|
2
|
+
BSD
|
3
|
+
Contributors.rdoc
|
4
|
+
GPL
|
5
|
+
History.rdoc
|
6
|
+
LICENSE
|
7
|
+
Manifest.txt
|
8
|
+
README.OS_X.rdoc
|
9
|
+
README.ja.rdoc
|
10
|
+
README.rdoc
|
11
|
+
README.windows.rdoc
|
12
|
+
Rakefile
|
13
|
+
ext/compat.c
|
14
|
+
ext/compat.h
|
15
|
+
ext/extconf.rb
|
16
|
+
ext/pg.c
|
17
|
+
ext/pg.h
|
18
|
+
ext/vc/pg.sln
|
19
|
+
ext/vc/pg_18/pg.vcproj
|
20
|
+
ext/vc/pg_19/pg_19.vcproj
|
21
|
+
lib/pg.rb
|
22
|
+
misc/openssl-pg-segfault.rb
|
23
|
+
sample/async_api.rb
|
24
|
+
sample/copyfrom.rb
|
25
|
+
sample/copyto.rb
|
26
|
+
sample/losample.rb
|
27
|
+
sample/notify_wait.rb
|
28
|
+
sample/psql.rb
|
29
|
+
sample/psqlHelp.rb
|
30
|
+
sample/test1.rb
|
31
|
+
sample/test2.rb
|
32
|
+
sample/test4.rb
|
33
|
+
sample/test_binary_values.rb
|
34
|
+
spec/data/expected_trace.out
|
35
|
+
spec/data/random_binary_data
|
36
|
+
spec/lib/helpers.rb
|
37
|
+
spec/m17n_spec.rb
|
38
|
+
spec/pgconn_spec.rb
|
39
|
+
spec/pgresult_spec.rb
|
data/README.OS_X.rdoc
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
= Compiling on MacOS X
|
2
|
+
|
3
|
+
The EnterpriseDB packages are the recommended PostgreSQL installations to use
|
4
|
+
with MacOS X. They eliminate most or all of the issues with getting 'pg'
|
5
|
+
installed, linked correctly, and running.
|
6
|
+
|
7
|
+
== Segfaults and SSL Support
|
8
|
+
|
9
|
+
If you need a custom installation of PostgreSQL, you should ensure that you
|
10
|
+
either compile it against the same version of OpenSSL as the OpenSSL extension
|
11
|
+
of the Ruby you'll be using, or compile it without SSL support. If you fail to
|
12
|
+
do this, you will likely see segfaults when you use 'pg' and the 'openssl'
|
13
|
+
extension at the same time. You can see what library it's linked against using
|
14
|
+
'otool -L'; for example, on my 10.7 machine I use for 'pg' development:
|
15
|
+
|
16
|
+
$ otool -L /System/Library/Frameworks/Ruby.framework/Versions\
|
17
|
+
/1.8/usr/lib/ruby/1.8/universal-darwin11.0/openssl.bundle
|
18
|
+
|
19
|
+
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/\
|
20
|
+
lib/ruby/1.8/universal-darwin11.0/openssl.bundle:
|
21
|
+
/System/Library/Frameworks/Ruby.framework/Versions/1.8/\
|
22
|
+
usr/lib/libruby.1.dylib (compatibility version 1.8.0, \
|
23
|
+
current version 1.8.7)
|
24
|
+
/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, \
|
25
|
+
current version 0.9.8)
|
26
|
+
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, \
|
27
|
+
current version 0.9.8)
|
28
|
+
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, \
|
29
|
+
current version 159.0.0)
|
30
|
+
|
31
|
+
|
32
|
+
== Dealing with Installation Problems
|
33
|
+
|
34
|
+
If you are building/installing pg on MacOS X, and the installation doesn't
|
35
|
+
work at first, here are a few things you can try.
|
36
|
+
|
37
|
+
=== pg_config
|
38
|
+
|
39
|
+
The first thing you should do is ensure that the 'pg_config' tool that comes
|
40
|
+
with Postgres is in your path. If it isn't, or the one that's first in your
|
41
|
+
path isn't the one that was installed with the Postgres you want to build
|
42
|
+
against, you can specify the path to it with the --with-pg-config option.
|
43
|
+
|
44
|
+
For example, if you're using the Ruby binary that comes with OSX, and
|
45
|
+
PostgreSQL 9.0.x installed from MacPorts, do:
|
46
|
+
|
47
|
+
gem install -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
|
48
|
+
|
49
|
+
=== ARCHFLAGS and Universal Binaries
|
50
|
+
|
51
|
+
OS X supports both architecture-specific binaries (e.g. i386), as well as
|
52
|
+
universal binaries (i.e. i386 & ppc). If Ruby is built as a universal binary
|
53
|
+
and PostgreSQL is not, you need to specify the path to the appropriate
|
54
|
+
pg_config binary or set the environment variable ARCHFLAGS appropriately.
|
55
|
+
|
56
|
+
Alternatively, if the build system can't figure out which architectures it
|
57
|
+
should include, you may need to set the 'ARCHFLAGS' environment variable
|
58
|
+
explicitly:
|
59
|
+
|
60
|
+
sudo env ARCHFLAGS='-arch x86_64' gem install pg
|
61
|
+
|
62
|
+
or, if you're building from source:
|
63
|
+
|
64
|
+
rake compile ARCHFLAGS="-arch x86_64"
|
65
|
+
|
66
|
+
Note that the recommended EnterpriseDB packages are correctly compiled as
|
67
|
+
universal binaries, and don't need any of these workarounds.
|
68
|
+
|
data/README.ja.rdoc
ADDED
data/{README → README.rdoc}
RENAMED
@@ -1,54 +1,69 @@
|
|
1
|
-
=
|
1
|
+
= pg
|
2
|
+
|
3
|
+
* https://bitbucket.org/ged/ruby-pg
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
|
8
|
+
|
9
|
+
It works with PostgreSQL 8.2 and later.
|
2
10
|
|
3
|
-
This is the extension library to access a PostgreSQL database from Ruby. This
|
4
|
-
library works with PostgreSQL 7.4 and later.
|
5
11
|
|
6
12
|
== Requirements
|
7
13
|
|
8
|
-
* Ruby 1.8.7-
|
9
|
-
* PostgreSQL
|
14
|
+
* Ruby 1.8.7-p249 or later.
|
15
|
+
* PostgreSQL 8.2.x or later installed.
|
10
16
|
|
11
17
|
It may work with earlier versions as well, but those are not regularly tested.
|
12
18
|
|
19
|
+
|
13
20
|
== How To Install
|
14
21
|
|
15
22
|
Install via RubyGems:
|
16
23
|
|
17
|
-
|
18
|
-
|
19
|
-
Or install from source:
|
20
|
-
|
21
|
-
rake install
|
24
|
+
gem install pg
|
22
25
|
|
23
26
|
You may need to specify the path to the 'pg_config' program installed with
|
24
27
|
Postgres:
|
25
28
|
|
26
|
-
|
29
|
+
gem install pg -- --with-pg-config=<path to pg_config>
|
30
|
+
|
31
|
+
See README.OS_X.rdoc for more information about installing under MacOS X, and
|
32
|
+
README.windows.rdoc for Windows build/installation instructions.
|
33
|
+
|
27
34
|
|
28
|
-
|
29
|
-
(<tt>port install postgresql84</tt>):
|
35
|
+
== Contributing
|
30
36
|
|
31
|
-
|
37
|
+
To report bugs, suggest features, or check out the source with Mercurial,
|
38
|
+
{check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
|
39
|
+
Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
|
40
|
+
|
41
|
+
After checking out the source, run:
|
42
|
+
|
43
|
+
$ rake newb
|
44
|
+
|
45
|
+
This task will install any missing dependencies, run the tests/specs, and
|
46
|
+
generate the API documentation.
|
32
47
|
|
33
|
-
See README.OS_X for more information about installing under MacOS X, and
|
34
|
-
README.windows for Windows build/installation instructions.
|
35
48
|
|
36
49
|
== Copying
|
37
50
|
|
38
51
|
This library is copyrighted by the authors.
|
39
52
|
|
40
53
|
Authors:
|
54
|
+
|
41
55
|
* Yukihiro Matsumoto <matz@ruby-lang.org> - Author of Ruby.
|
42
56
|
* Eiji Matsumoto <usagi@ruby.club.or.jp> - One of users who loves Ruby.
|
43
57
|
* Jeff Davis <ruby-pg@j-davis.com>
|
44
58
|
|
45
59
|
Thanks to:
|
60
|
+
|
46
61
|
* Noboru Saitou <noborus@netlab.jp> - Past maintainer.
|
47
62
|
* Dave Lee - Past maintainer.
|
48
63
|
* Guy Decoux (ts) <decoux@moulon.inra.fr>
|
49
64
|
|
50
65
|
Maintainers:
|
51
|
-
|
66
|
+
|
52
67
|
* Michael Granger <ged@FaerieMUD.org>
|
53
68
|
|
54
69
|
You may redistribute this software under the terms of the Ruby license,
|
@@ -60,9 +75,9 @@ under the terms of the BSD license, included in the file "BSD".
|
|
60
75
|
|
61
76
|
Portions copyright LAIKA, Inc.
|
62
77
|
|
78
|
+
|
63
79
|
== Acknowledgments
|
64
80
|
|
65
81
|
We are thankful to the people at the ruby-list and ruby-dev mailing lists.
|
66
82
|
And to the people who developed PostgreSQL.
|
67
83
|
|
68
|
-
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
= Compiling on MS Windows
|
1
|
+
= Compiling 'pg' on MS Windows
|
3
2
|
|
4
3
|
In order to build this extension on MS Windows you will need a couple things.
|
5
4
|
|
@@ -24,7 +23,7 @@ In order to build ruby-pg, just run 'rake'. If the pg_config.exe executable
|
|
24
23
|
is not in your PATH, you'll need to explicitly point ruby-pg to where your
|
25
24
|
PostgreSQL headers and libraries are with something like this:
|
26
25
|
|
27
|
-
|
26
|
+
rake --with-pg-dir=c:/progra~1/postgr~1/8.3
|
28
27
|
|
29
28
|
Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
|
30
29
|
try to use a path with spaces in it, the nmake.exe program will choke.
|
@@ -32,44 +31,39 @@ try to use a path with spaces in it, the nmake.exe program will choke.
|
|
32
31
|
|
33
32
|
== Cross compiling for mswin32
|
34
33
|
|
35
|
-
Using rake-compiler a cross compiled pg
|
36
|
-
the win32 platform. The generated gem is statically linked against
|
37
|
-
libssl. OpenSSL and PostgreSQL are downloaded and compiled from the
|
38
|
-
There are no runtime dependencies to any but the standard Windows
|
39
|
-
|
40
|
-
Install mingw32. On a debian based system this should work:
|
41
|
-
|
42
|
-
apt-get install mingw32
|
43
|
-
|
44
|
-
On MacOS X, if you have MacPorts installed:
|
34
|
+
Using rake-compiler a cross compiled pg gem can be build on a Linux or MacOS X
|
35
|
+
host for the win32 platform. The generated gem is statically linked against
|
36
|
+
libpq and libssl. OpenSSL and PostgreSQL are downloaded and compiled from the
|
37
|
+
sources. There are no runtime dependencies to any but the standard Windows
|
38
|
+
DLLs.
|
45
39
|
|
46
|
-
|
40
|
+
Install mingw32 using the instructions rake-compiler's README.
|
47
41
|
|
48
42
|
Install the rake-compiler:
|
49
43
|
|
50
|
-
|
44
|
+
gem install rake-compiler
|
51
45
|
|
52
46
|
Download and cross compile ruby 1.8 and 1.9 for win32:
|
53
47
|
|
54
|
-
|
55
|
-
|
48
|
+
rake-compiler cross-ruby VERSION=1.8.7-p334
|
49
|
+
rake-compiler cross-ruby VERSION=1.9.2-p180
|
56
50
|
|
57
51
|
Download and cross compile pg for win32:
|
58
52
|
|
59
|
-
|
53
|
+
rake cross native gem
|
54
|
+
|
60
55
|
or with custom versions:
|
61
|
-
|
56
|
+
|
57
|
+
rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2 \
|
58
|
+
OPENSSL_VERSION=1.0.0d POSTGRESQL_VERSION=9.0.3
|
62
59
|
|
63
60
|
If everything works, there should be pg-VERSION-x86-mswin32.gem in the pkg
|
64
61
|
directory.
|
65
62
|
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
http://bitbucket.org/ged/ruby-pg/issues/new/
|
70
|
-
|
71
|
-
Or you can join the mailing list:
|
64
|
+
== Reporting Problems
|
72
65
|
|
73
|
-
|
66
|
+
If you have any problems you can submit them via
|
67
|
+
[the project's issue-tracker][bitbucket]. And submit questions, problems, or
|
68
|
+
solutions, so that it can be improved.
|
74
69
|
|
75
|
-
And submit questions, problems, or solutions, so that it can be improved.
|
data/Rakefile
CHANGED
@@ -1,364 +1,138 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
# Copyright (c) 2007-2010 The FaerieMUD Consortium
|
8
|
-
#
|
9
|
-
# Authors:
|
10
|
-
# * Michael Granger <ged@FaerieMUD.org>
|
11
|
-
#
|
12
|
-
|
13
|
-
BEGIN {
|
14
|
-
require 'rbconfig'
|
15
|
-
require 'pathname'
|
16
|
-
basedir = Pathname.new( __FILE__ ).dirname
|
17
|
-
|
18
|
-
libdir = basedir + "lib"
|
19
|
-
extdir = libdir + Config::CONFIG['sitearch']
|
20
|
-
|
21
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
22
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
23
|
-
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
|
24
|
-
}
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'pathname'
|
5
|
+
require 'tmpdir'
|
25
6
|
|
26
7
|
begin
|
27
|
-
require '
|
28
|
-
include Readline
|
8
|
+
require 'rake/extensiontask'
|
29
9
|
rescue LoadError
|
30
|
-
|
31
|
-
def readline( text )
|
32
|
-
$stderr.print( text.chomp )
|
33
|
-
return $stdin.gets
|
34
|
-
end
|
10
|
+
abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
|
35
11
|
end
|
36
12
|
|
37
13
|
begin
|
38
|
-
require '
|
14
|
+
require 'hoe'
|
39
15
|
rescue LoadError
|
40
|
-
|
41
|
-
class Specification; end
|
42
|
-
end
|
16
|
+
abort "This Rakefile requires hoe (gem install hoe)"
|
43
17
|
end
|
44
18
|
|
45
|
-
require 'rbconfig'
|
46
|
-
require 'rake'
|
47
|
-
require 'rake/testtask'
|
48
|
-
require 'rake/packagetask'
|
49
19
|
require 'rake/clean'
|
50
|
-
# require 'rake/191_compat.rb'
|
51
|
-
|
52
|
-
$dryrun = false
|
53
|
-
|
54
|
-
### Config constants
|
55
|
-
BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
|
56
|
-
BINDIR = BASEDIR + 'bin'
|
57
|
-
LIBDIR = BASEDIR + 'lib'
|
58
|
-
EXTDIR = BASEDIR + 'ext'
|
59
|
-
DOCSDIR = BASEDIR + 'docs'
|
60
|
-
PKGDIR = BASEDIR + 'pkg'
|
61
|
-
DATADIR = BASEDIR + 'data'
|
62
|
-
|
63
|
-
MANUALDIR = DOCSDIR + 'manual'
|
64
|
-
|
65
|
-
PROJECT_NAME = 'pg'
|
66
|
-
PKG_NAME = PROJECT_NAME.downcase
|
67
|
-
PKG_SUMMARY = 'A Ruby interface to the PostgreSQL RDBMS'
|
68
|
-
|
69
|
-
# Cruisecontrol stuff
|
70
|
-
CC_BUILD_LABEL = ENV['CC_BUILD_LABEL']
|
71
|
-
CC_BUILD_ARTIFACTS = ENV['CC_BUILD_ARTIFACTS'] || 'artifacts'
|
72
|
-
|
73
|
-
VERSION_FILE = LIBDIR + '../ext/pg.c'
|
74
|
-
if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
|
75
|
-
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
|
76
|
-
elsif VERSION_FILE.exist?
|
77
|
-
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
|
78
|
-
end
|
79
20
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
COMMIT_MSG_FILE = 'commit-msg.txt'
|
88
|
-
FILE_INDENT = " " * 12
|
89
|
-
LOG_INDENT = " " * 3
|
90
|
-
|
91
|
-
EXTCONF = EXTDIR + 'extconf.rb'
|
92
|
-
|
93
|
-
ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
|
94
|
-
|
95
|
-
TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README* LICENSE] )
|
96
|
-
BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" )
|
97
|
-
LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
|
98
|
-
EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
|
99
|
-
DATA_FILES = Rake::FileList.new( "#{DATADIR}/**/*" )
|
100
|
-
|
101
|
-
SPECDIR = BASEDIR + 'spec'
|
102
|
-
SPECLIBDIR = SPECDIR + 'lib'
|
103
|
-
SPEC_FILES = Rake::FileList.new( "#{SPECDIR}/**/*_spec.rb", "#{SPECLIBDIR}/**/*.rb" )
|
104
|
-
|
105
|
-
TESTDIR = BASEDIR + 'tests'
|
106
|
-
TEST_FILES = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" )
|
107
|
-
|
108
|
-
RAKE_TASKDIR = BASEDIR + 'rake'
|
109
|
-
RAKE_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/*.rb" )
|
110
|
-
PKG_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/{191_compat,helpers,packaging,rdoc,testing}.rb" )
|
111
|
-
PKG_TASKLIBS.include( "#{RAKE_TASKDIR}/manual.rb" ) if MANUALDIR.exist?
|
112
|
-
|
113
|
-
RAKE_TASKLIBS_URL = 'http://repo.deveiate.org/rake-tasklibs'
|
114
|
-
|
115
|
-
LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
|
116
|
-
|
117
|
-
EXTRA_PKGFILES = Rake::FileList.new
|
118
|
-
EXTRA_PKGFILES.include( "#{BASEDIR}/README.*" )
|
119
|
-
EXTRA_PKGFILES.include( "#{BASEDIR}/GPL" )
|
120
|
-
EXTRA_PKGFILES.include( "#{BASEDIR}/BSD" )
|
121
|
-
EXTRA_PKGFILES.include( "#{BASEDIR}/Contributors" )
|
122
|
-
|
123
|
-
RELEASE_FILES = TEXT_FILES +
|
124
|
-
SPEC_FILES +
|
125
|
-
TEST_FILES +
|
126
|
-
BIN_FILES +
|
127
|
-
LIB_FILES +
|
128
|
-
EXT_FILES +
|
129
|
-
DATA_FILES +
|
130
|
-
RAKE_TASKLIBS +
|
131
|
-
EXTRA_PKGFILES
|
132
|
-
|
133
|
-
|
134
|
-
RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
|
135
|
-
|
136
|
-
RELEASE_ANNOUNCE_ADDRESSES = [
|
137
|
-
"Ruby-Talk List <ruby-talk@ruby-lang.org>",
|
138
|
-
]
|
139
|
-
|
140
|
-
COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
|
141
|
-
RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
|
142
|
-
RCOV_OPTS = [
|
143
|
-
'--exclude', RCOV_EXCLUDES,
|
144
|
-
'--xrefs',
|
145
|
-
'--save',
|
146
|
-
'--callsites',
|
147
|
-
#'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
|
148
|
-
]
|
149
|
-
|
150
|
-
|
151
|
-
### Load some task libraries that need to be loaded early
|
152
|
-
if !RAKE_TASKDIR.exist?
|
153
|
-
$stderr.puts "It seems you don't have the build task directory. Shall I fetch it "
|
154
|
-
ans = readline( "for you? [y]" )
|
155
|
-
ans = 'y' if !ans.nil? && ans.empty?
|
156
|
-
|
157
|
-
if ans =~ /^y/i
|
158
|
-
$stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
|
159
|
-
system 'hg', 'clone', RAKE_TASKLIBS_URL, "./#{RAKE_TASKDIR}"
|
160
|
-
if ! $?.success?
|
161
|
-
fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
|
162
|
-
end
|
163
|
-
else
|
164
|
-
$stderr.puts "Then I'm afraid I can't continue. Best of luck."
|
165
|
-
fail "Rake tasklibs not present."
|
166
|
-
end
|
21
|
+
# Build directory constants
|
22
|
+
BASEDIR = Pathname( __FILE__ ).dirname
|
23
|
+
SPECDIR = BASEDIR + 'spec'
|
24
|
+
LIBDIR = BASEDIR + 'lib'
|
25
|
+
EXTDIR = BASEDIR + 'ext'
|
26
|
+
PKGDIR = BASEDIR + 'pkg'
|
27
|
+
TMPDIR = BASEDIR + 'tmp'
|
167
28
|
|
168
|
-
|
169
|
-
|
29
|
+
DLEXT = Config::CONFIG['DLEXT']
|
30
|
+
EXT = LIBDIR + "pg_ext.#{DLEXT}"
|
170
31
|
|
171
|
-
|
172
|
-
include RakefileHelpers
|
32
|
+
TESTING_TMPDIRS = Rake::FileList[ "#{Dir.tmpdir}/tmp_test_*" ]
|
173
33
|
|
174
|
-
|
175
|
-
|
176
|
-
id = `#{hg} id -n`.chomp
|
177
|
-
PKG_BUILD = (id.chomp[ /^[[:xdigit:]]+/ ] || '1')
|
178
|
-
else
|
179
|
-
PKG_BUILD = '0'
|
180
|
-
end
|
181
|
-
SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
|
182
|
-
SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
|
183
|
-
|
184
|
-
# Documentation constants
|
185
|
-
API_DOCSDIR = DOCSDIR + 'api'
|
186
|
-
README_FILE = TEXT_FILES.find {|path| path =~ /^README/ } || 'README'
|
187
|
-
RDOC_OPTIONS = [
|
188
|
-
'--tab-width=4',
|
189
|
-
'--show-hash',
|
190
|
-
'--include', BASEDIR.to_s,
|
191
|
-
"--main=#{README_FILE}",
|
192
|
-
"--title=#{PKG_NAME}",
|
193
|
-
]
|
194
|
-
YARD_OPTIONS = [
|
195
|
-
'--use-cache',
|
196
|
-
'--protected',
|
197
|
-
'-r', README_FILE,
|
198
|
-
'--exclude', 'extconf\\.rb',
|
199
|
-
'--files', 'ChangeLog,LICENSE',
|
200
|
-
'--output-dir', API_DOCSDIR.to_s,
|
201
|
-
'--title', "#{PKG_NAME} #{PKG_VERSION}",
|
202
|
-
]
|
203
|
-
|
204
|
-
# Release constants
|
205
|
-
SMTP_HOST = "mail.faeriemud.org"
|
206
|
-
SMTP_PORT = 465 # SMTP + SSL
|
207
|
-
|
208
|
-
# Project constants
|
209
|
-
PROJECT_HOST = 'deveiate.org'
|
210
|
-
PROJECT_PUBDIR = '/usr/local/www/public/code/'
|
211
|
-
PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
|
212
|
-
PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
|
213
|
-
PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
|
214
|
-
|
215
|
-
GEM_PUBHOST = 'rubygems.org'
|
216
|
-
|
217
|
-
# Gem dependencies: gemname => version
|
218
|
-
DEPENDENCIES = {
|
219
|
-
}
|
220
|
-
|
221
|
-
# Developer Gem dependencies: gemname => version
|
222
|
-
DEVELOPMENT_DEPENDENCIES = {
|
223
|
-
'rake' => '~> 0.8.7',
|
224
|
-
'rcodetools' => '~> 0.7.0.0',
|
225
|
-
'rcov' => '~> 0.8.1.2.0',
|
226
|
-
'yard' => '~> 0.6.1',
|
227
|
-
'RedCloth' => '~> 4.2.3',
|
228
|
-
'rspec' => '~> 2.0.1',
|
229
|
-
'ruby-termios' => '~> 0.9.6',
|
230
|
-
'text-format' => '~> 1.0.0',
|
231
|
-
'tmail' => '~> 1.2.3.1',
|
232
|
-
'rake-compiler' => '~>0.7.0',
|
233
|
-
}
|
234
|
-
|
235
|
-
# Non-gem requirements: packagename => version
|
236
|
-
REQUIREMENTS = {
|
237
|
-
'PostgreSQL' => '>=7.4',
|
238
|
-
}
|
239
|
-
|
240
|
-
# RubyGem specification
|
241
|
-
GEMSPEC = Gem::Specification.new do |gem|
|
242
|
-
gem.name = PKG_NAME.downcase
|
243
|
-
gem.version = PKG_VERSION
|
244
|
-
|
245
|
-
gem.summary = PKG_SUMMARY
|
246
|
-
gem.description = [
|
247
|
-
"This is the extension library to access a PostgreSQL database from Ruby.",
|
248
|
-
"This library works with PostgreSQL 7.4 and later.",
|
249
|
-
].join( "\n" )
|
250
|
-
|
251
|
-
gem.authors = ["Jeff Davis", "Michael Granger"]
|
252
|
-
gem.email = ["ruby-pg@j-davis.com", "ged@FaerieMUD.org"]
|
253
|
-
gem.homepage = 'http://bitbucket.org/ged/ruby-pg/'
|
254
|
-
gem.licenses = ["Ruby", "GPL", "BSD"]
|
255
|
-
|
256
|
-
gem.has_rdoc = true
|
257
|
-
gem.rdoc_options = RDOC_OPTIONS
|
258
|
-
gem.extra_rdoc_files = TEXT_FILES - [ 'Rakefile' ]
|
259
|
-
|
260
|
-
gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
|
261
|
-
gem.executables = BIN_FILES.select {|pn| File.executable?(pn) }.
|
262
|
-
collect {|pn| File.basename(pn) }
|
263
|
-
gem.require_paths << EXTDIR.relative_path_from( BASEDIR ).to_s if EXTDIR.exist?
|
264
|
-
|
265
|
-
if EXTCONF.exist?
|
266
|
-
gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
|
267
|
-
end
|
34
|
+
CLOBBER.include( *TESTING_TMPDIRS )
|
35
|
+
CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
268
36
|
|
269
|
-
|
270
|
-
|
37
|
+
# Set up Hoe plugins
|
38
|
+
Hoe.plugin :mercurial
|
39
|
+
Hoe.plugin :signing
|
271
40
|
|
272
|
-
|
273
|
-
|
274
|
-
gem.cert_chain = [File.expand_path('~/.gem/ged-public_gem_cert.pem')]
|
41
|
+
Hoe.plugins.delete :rubyforge
|
42
|
+
Hoe.plugins.delete :compiler
|
275
43
|
|
276
44
|
|
277
|
-
|
45
|
+
# Hoe specification
|
46
|
+
$hoespec = Hoe.spec 'pg' do
|
47
|
+
self.readme_file = 'README.rdoc'
|
48
|
+
self.history_file = 'History.rdoc'
|
49
|
+
self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
|
50
|
+
self.extra_rdoc_files.include( 'BSD', 'GPL', 'LICENSE' )
|
51
|
+
self.extra_rdoc_files.include( 'ext/*.c' )
|
278
52
|
|
279
|
-
|
280
|
-
|
281
|
-
gem.add_runtime_dependency( name, version )
|
282
|
-
end
|
53
|
+
self.developer 'Jeff Davis', 'ruby-pg@j-davis.com'
|
54
|
+
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
283
55
|
|
284
|
-
|
285
|
-
|
286
|
-
end
|
287
|
-
end
|
56
|
+
self.dependency 'rake-compiler', '~> 0.7'
|
57
|
+
self.dependency 'rspec', '~> 2.6', :developer
|
288
58
|
|
289
|
-
|
290
|
-
|
291
|
-
$include_dev_dependencies = false
|
59
|
+
self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
|
60
|
+
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
|
292
61
|
|
293
|
-
|
294
|
-
RAKE_TASKLIBS.each do |tasklib|
|
295
|
-
next if tasklib.to_s =~ %r{/helpers\.rb$}
|
296
|
-
begin
|
297
|
-
trace " loading tasklib %s" % [ tasklib ]
|
298
|
-
import tasklib
|
299
|
-
rescue ScriptError => err
|
300
|
-
fail "Task library '%s' failed to load: %s: %s" %
|
301
|
-
[ tasklib, err.class.name, err.message ]
|
302
|
-
trace "Backtrace: \n " + err.backtrace.join( "\n " )
|
303
|
-
rescue => err
|
304
|
-
log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
|
305
|
-
[ tasklib, err.class.name, err.message ]
|
306
|
-
trace "Backtrace: \n " + err.backtrace.join( "\n " )
|
307
|
-
end
|
308
|
-
end
|
62
|
+
self.require_ruby_version( '>= 1.8.7' )
|
309
63
|
|
310
|
-
|
311
|
-
|
64
|
+
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
65
|
+
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
312
66
|
|
67
|
+
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
68
|
+
end
|
313
69
|
|
314
|
-
|
315
|
-
### T A S K S
|
316
|
-
#####################################################################
|
70
|
+
ENV['VERSION'] ||= $hoespec.spec.version.to_s
|
317
71
|
|
318
|
-
|
319
|
-
task :
|
72
|
+
# Tests should pass before checking in
|
73
|
+
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
|
320
74
|
|
321
|
-
|
322
|
-
task :
|
75
|
+
# Support for 'rvm specs'
|
76
|
+
task :specs => :spec
|
323
77
|
|
324
|
-
|
325
|
-
|
326
|
-
CLOBBER.include 'artifacts', 'coverage.info', 'ChangeLog', PKGDIR
|
78
|
+
# Compile before testing
|
79
|
+
task :spec => :compile
|
327
80
|
|
328
|
-
|
329
|
-
|
330
|
-
|
81
|
+
# gem-testers support
|
82
|
+
task :test do
|
83
|
+
# rake-compiler always wants to copy the compiled extension into lib/, but
|
84
|
+
# we don't want testers to have to re-compile, especially since that
|
85
|
+
# often fails because they can't (and shouldn't have to) write to tmp/ in
|
86
|
+
# the installed gem dir. So we clear the task rake-compiler set up
|
87
|
+
# to break the dependency between :spec and :compile when running under
|
88
|
+
# rubygems-test, and then run :spec.
|
89
|
+
Rake::Task[ EXT.to_s ].clear
|
90
|
+
Rake::Task[ :spec ].execute
|
91
|
+
end
|
331
92
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
end
|
93
|
+
desc "Turn on warnings and debugging in the build."
|
94
|
+
task :maint do
|
95
|
+
ENV['MAINTAINER_MODE'] = 'yes'
|
336
96
|
end
|
337
97
|
|
98
|
+
ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
|
99
|
+
|
100
|
+
# Rake-compiler task
|
101
|
+
Rake::ExtensionTask.new do |ext|
|
102
|
+
ext.name = 'pg_ext'
|
103
|
+
ext.gem_spec = $hoespec.spec
|
104
|
+
ext.ext_dir = 'ext'
|
105
|
+
ext.lib_dir = 'lib'
|
106
|
+
ext.source_pattern = "*.{c,h}"
|
107
|
+
ext.cross_compile = true
|
108
|
+
ext.cross_platform = %w[i386-mswin32 i386-mingw32]
|
109
|
+
end
|
338
110
|
|
339
|
-
### Task: cruise (Cruisecontrol task)
|
340
|
-
desc "Cruisecontrol build"
|
341
|
-
task :cruise => [:clean, 'spec:quiet', :package] do |task|
|
342
|
-
raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
|
343
|
-
artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL || Time.now.strftime('%Y%m%d-%T'))
|
344
|
-
artifact_dir.mkpath
|
345
111
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
112
|
+
# Make the ChangeLog update if the repo has changed since it was last built
|
113
|
+
file '.hg/branch' do
|
114
|
+
abort "You need the Mercurial repo to make packages"
|
115
|
+
end
|
116
|
+
file 'ChangeLog' => '.hg/branch' do |task|
|
117
|
+
$stderr.puts "Updating the changelog..."
|
118
|
+
begin
|
119
|
+
content = make_changelog()
|
120
|
+
rescue NameError
|
121
|
+
abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
|
122
|
+
end
|
123
|
+
File.open( task.name, 'w', 0644 ) do |fh|
|
124
|
+
fh.print( content )
|
350
125
|
end
|
351
|
-
|
352
|
-
$stderr.puts "Copying packages..."
|
353
|
-
FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
|
354
126
|
end
|
355
127
|
|
128
|
+
# Rebuild the ChangeLog immediately before release
|
129
|
+
task :prerelease => 'ChangeLog'
|
130
|
+
|
356
131
|
|
357
|
-
desc "
|
358
|
-
task :
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
|
132
|
+
desc "Stop any Postmaster instances that remain after testing."
|
133
|
+
task :cleanup_testing_dbs do
|
134
|
+
require 'spec/lib/helpers'
|
135
|
+
PgTestingHelpers.stop_existing_postmasters()
|
136
|
+
Rake::Task[:clean].invoke
|
363
137
|
end
|
364
138
|
|