pg 0.18.3 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) 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 +129 -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 +448 -4
  17. data/Manifest.txt +8 -21
  18. data/README-Windows.rdoc +4 -4
  19. data/README.ja.rdoc +1 -2
  20. data/README.rdoc +69 -17
  21. data/Rakefile +33 -135
  22. data/Rakefile.cross +70 -69
  23. data/certs/ged.pem +24 -0
  24. data/certs/larskanis-2022.pem +26 -0
  25. data/ext/errorcodes.def +109 -0
  26. data/ext/errorcodes.rb +1 -1
  27. data/ext/errorcodes.txt +35 -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 +213 -171
  32. data/ext/pg.h +92 -98
  33. data/ext/pg_binary_decoder.c +84 -15
  34. data/ext/pg_binary_encoder.c +24 -21
  35. data/ext/pg_coder.c +175 -39
  36. data/ext/pg_connection.c +1730 -1135
  37. data/ext/pg_copy_coder.c +94 -27
  38. data/ext/pg_record_coder.c +521 -0
  39. data/ext/pg_result.c +640 -221
  40. data/ext/pg_text_decoder.c +608 -40
  41. data/ext/pg_text_encoder.c +253 -99
  42. data/ext/pg_tuple.c +569 -0
  43. data/ext/pg_type_map.c +61 -21
  44. data/ext/pg_type_map_all_strings.c +19 -5
  45. data/ext/pg_type_map_by_class.c +54 -24
  46. data/ext/pg_type_map_by_column.c +79 -40
  47. data/ext/pg_type_map_by_mri_type.c +48 -19
  48. data/ext/pg_type_map_by_oid.c +55 -25
  49. data/ext/pg_type_map_in_ruby.c +51 -20
  50. data/ext/{util.c → pg_util.c} +12 -12
  51. data/ext/{util.h → pg_util.h} +2 -2
  52. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  53. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  54. data/lib/pg/basic_type_map_for_results.rb +81 -0
  55. data/lib/pg/basic_type_registry.rb +301 -0
  56. data/lib/pg/binary_decoder.rb +23 -0
  57. data/lib/pg/coder.rb +24 -3
  58. data/lib/pg/connection.rb +723 -65
  59. data/lib/pg/constants.rb +2 -1
  60. data/lib/pg/exceptions.rb +9 -2
  61. data/lib/pg/result.rb +24 -7
  62. data/lib/pg/text_decoder.rb +24 -22
  63. data/lib/pg/text_encoder.rb +40 -8
  64. data/lib/pg/tuple.rb +30 -0
  65. data/lib/pg/type_map_by_column.rb +3 -2
  66. data/lib/pg/version.rb +4 -0
  67. data/lib/pg.rb +61 -36
  68. data/misc/openssl-pg-segfault.rb +31 -0
  69. data/misc/postgres/History.txt +9 -0
  70. data/misc/postgres/Manifest.txt +5 -0
  71. data/misc/postgres/README.txt +21 -0
  72. data/misc/postgres/Rakefile +21 -0
  73. data/misc/postgres/lib/postgres.rb +16 -0
  74. data/misc/ruby-pg/History.txt +9 -0
  75. data/misc/ruby-pg/Manifest.txt +5 -0
  76. data/misc/ruby-pg/README.txt +21 -0
  77. data/misc/ruby-pg/Rakefile +21 -0
  78. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  79. data/pg.gemspec +32 -0
  80. data/rakelib/task_extension.rb +46 -0
  81. data/sample/array_insert.rb +1 -1
  82. data/sample/async_api.rb +4 -8
  83. data/sample/async_copyto.rb +1 -1
  84. data/sample/async_mixed.rb +1 -1
  85. data/sample/check_conn.rb +1 -1
  86. data/sample/copydata.rb +71 -0
  87. data/sample/copyfrom.rb +1 -1
  88. data/sample/copyto.rb +1 -1
  89. data/sample/cursor.rb +1 -1
  90. data/sample/disk_usage_report.rb +6 -15
  91. data/sample/issue-119.rb +2 -2
  92. data/sample/losample.rb +1 -1
  93. data/sample/minimal-testcase.rb +2 -2
  94. data/sample/notify_wait.rb +1 -1
  95. data/sample/pg_statistics.rb +6 -15
  96. data/sample/replication_monitor.rb +9 -18
  97. data/sample/test_binary_values.rb +1 -1
  98. data/sample/wal_shipper.rb +2 -2
  99. data/sample/warehouse_partitions.rb +8 -17
  100. data.tar.gz.sig +0 -0
  101. metadata +80 -230
  102. metadata.gz.sig +0 -0
  103. data/ChangeLog +0 -5804
  104. data/lib/pg/basic_type_mapping.rb +0 -399
  105. data/spec/data/expected_trace.out +0 -26
  106. data/spec/data/random_binary_data +0 -0
  107. data/spec/helpers.rb +0 -355
  108. data/spec/pg/basic_type_mapping_spec.rb +0 -251
  109. data/spec/pg/connection_spec.rb +0 -1538
  110. data/spec/pg/result_spec.rb +0 -449
  111. data/spec/pg/type_map_by_class_spec.rb +0 -138
  112. data/spec/pg/type_map_by_column_spec.rb +0 -222
  113. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  114. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  115. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  116. data/spec/pg/type_map_spec.rb +0 -22
  117. data/spec/pg/type_spec.rb +0 -690
  118. data/spec/pg_spec.rb +0 -50
data/lib/pg/constants.rb CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'pg' unless defined?( PG )
4
5
 
data/lib/pg/exceptions.rb CHANGED
@@ -1,11 +1,18 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'pg' unless defined?( PG )
4
5
 
5
6
 
6
7
  module PG
7
8
 
8
- class Error < StandardError; end
9
+ class Error < StandardError
10
+ def initialize(msg=nil, connection: nil, result: nil)
11
+ @connection = connection
12
+ @result = result
13
+ super(msg)
14
+ end
15
+ end
9
16
 
10
17
  end # module PG
11
18
 
data/lib/pg/result.rb CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'pg' unless defined?( PG )
4
5
 
@@ -9,18 +10,34 @@ class PG::Result
9
10
  #
10
11
  # +type_map+: a PG::TypeMap instance.
11
12
  #
12
- # See PG::BasicTypeMapForResults
13
+ # This method is equal to #type_map= , but returns self, so that calls can be chained.
14
+ #
15
+ # See also PG::BasicTypeMapForResults
13
16
  def map_types!(type_map)
14
17
  self.type_map = type_map
15
- self
18
+ return self
19
+ end
20
+
21
+ # Set the data type for all field name returning methods.
22
+ #
23
+ # +type+: a Symbol defining the field name type.
24
+ #
25
+ # This method is equal to #field_name_type= , but returns self, so that calls can be chained.
26
+ def field_names_as(type)
27
+ self.field_name_type = type
28
+ return self
16
29
  end
17
30
 
31
+ ### Return a String representation of the object suitable for debugging.
18
32
  def inspect
19
33
  str = self.to_s
20
- str[-1,0] = " status=#{res_status(result_status)} ntuples=#{ntuples} nfields=#{nfields} cmd_tuples=#{cmd_tuples}"
21
- str
34
+ str[-1,0] = if cleared?
35
+ " cleared"
36
+ else
37
+ " status=#{res_status(result_status)} ntuples=#{ntuples} nfields=#{nfields} cmd_tuples=#{cmd_tuples}"
38
+ end
39
+ return str
22
40
  end
41
+
23
42
  end # class PG::Result
24
43
 
25
- # Backward-compatible alias
26
- PGresult = PG::Result
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'date'
5
+ require 'json'
4
6
 
5
7
  module PG
6
8
  module TextDecoder
7
9
  class Date < SimpleDecoder
8
- ISO_DATE = /\A(\d{4})-(\d\d)-(\d\d)\z/
9
-
10
10
  def decode(string, tuple=nil, field=nil)
11
- if string =~ ISO_DATE
11
+ if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/
12
12
  ::Date.new $1.to_i, $2.to_i, $3.to_i
13
13
  else
14
14
  string
@@ -16,29 +16,31 @@ module PG
16
16
  end
17
17
  end
18
18
 
19
- class TimestampWithoutTimeZone < SimpleDecoder
20
- ISO_DATETIME_WITHOUT_TIMEZONE = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/
21
-
19
+ class JSON < SimpleDecoder
22
20
  def decode(string, tuple=nil, field=nil)
23
- if string =~ ISO_DATETIME_WITHOUT_TIMEZONE
24
- Time.new $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, "#{$6}#{$7}".to_r
25
- else
26
- string
27
- end
21
+ ::JSON.parse(string, quirks_mode: true)
28
22
  end
29
23
  end
30
24
 
31
- class TimestampWithTimeZone < SimpleDecoder
32
- ISO_DATETIME_WITH_TIMEZONE = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?([-\+]\d\d):?(\d\d)?:?(\d\d)?\z/
33
-
34
- def decode(string, tuple=nil, field=nil)
35
- if string =~ ISO_DATETIME_WITH_TIMEZONE
36
- Time.new $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, "#{$6}#{$7}".to_r, "#{$8}:#{$9 || '00'}:#{$10 || '00'}"
37
- else
38
- string
39
- end
25
+ # Convenience classes for timezone options
26
+ class TimestampUtc < Timestamp
27
+ def initialize(params={})
28
+ super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC))
29
+ end
30
+ end
31
+ class TimestampUtcToLocal < Timestamp
32
+ def initialize(params={})
33
+ super(params.merge(flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL))
40
34
  end
41
35
  end
36
+ class TimestampLocal < Timestamp
37
+ def initialize(params={})
38
+ super(params.merge(flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL))
39
+ end
40
+ end
41
+
42
+ # For backward compatibility:
43
+ TimestampWithoutTimeZone = TimestampLocal
44
+ TimestampWithTimeZone = Timestamp
42
45
  end
43
46
  end # module PG
44
-
@@ -1,27 +1,59 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'json'
5
+ require 'ipaddr'
2
6
 
3
7
  module PG
4
8
  module TextEncoder
5
9
  class Date < SimpleEncoder
6
- STRFTIME_ISO_DATE = "%Y-%m-%d".freeze
7
10
  def encode(value)
8
- value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATE) : value
11
+ value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value
9
12
  end
10
13
  end
11
14
 
12
15
  class TimestampWithoutTimeZone < SimpleEncoder
13
- STRFTIME_ISO_DATETIME_WITHOUT_TIMEZONE = "%Y-%m-%d %H:%M:%S.%N".freeze
14
16
  def encode(value)
15
- value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATETIME_WITHOUT_TIMEZONE) : value
17
+ value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N") : value
18
+ end
19
+ end
20
+
21
+ class TimestampUtc < SimpleEncoder
22
+ def encode(value)
23
+ value.respond_to?(:utc) ? value.utc.strftime("%Y-%m-%d %H:%M:%S.%N") : value
16
24
  end
17
25
  end
18
26
 
19
27
  class TimestampWithTimeZone < SimpleEncoder
20
- STRFTIME_ISO_DATETIME_WITH_TIMEZONE = "%Y-%m-%d %H:%M:%S.%N %:z".freeze
21
28
  def encode(value)
22
- value.respond_to?(:strftime) ? value.strftime(STRFTIME_ISO_DATETIME_WITH_TIMEZONE) : value
29
+ value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N %:z") : value
30
+ end
31
+ end
32
+
33
+ class JSON < SimpleEncoder
34
+ def encode(value)
35
+ ::JSON.generate(value, quirks_mode: true)
36
+ end
37
+ end
38
+
39
+ class Inet < SimpleEncoder
40
+ def encode(value)
41
+ case value
42
+ when IPAddr
43
+ default_prefix = (value.family == Socket::AF_INET ? 32 : 128)
44
+ s = value.to_s
45
+ if value.respond_to?(:prefix)
46
+ prefix = value.prefix
47
+ else
48
+ range = value.to_range
49
+ prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i
50
+ end
51
+ s << "/" << prefix.to_s if prefix != default_prefix
52
+ s
53
+ else
54
+ value
55
+ end
23
56
  end
24
57
  end
25
58
  end
26
59
  end # module PG
27
-
data/lib/pg/tuple.rb ADDED
@@ -0,0 +1,30 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'pg' unless defined?( PG )
5
+
6
+
7
+ class PG::Tuple
8
+
9
+ ### Return a String representation of the object suitable for debugging.
10
+ def inspect
11
+ "#<#{self.class} #{self.map{|k,v| "#{k}: #{v.inspect}" }.join(", ") }>"
12
+ end
13
+
14
+ def has_key?(key)
15
+ field_map.has_key?(key)
16
+ end
17
+ alias key? has_key?
18
+
19
+ def keys
20
+ field_names || field_map.keys.freeze
21
+ end
22
+
23
+ def each_key(&block)
24
+ if fn=field_names
25
+ fn.each(&block)
26
+ else
27
+ field_map.each_key(&block)
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'pg' unless defined?( PG )
4
5
 
@@ -9,7 +10,7 @@ class PG::TypeMapByColumn
9
10
  end
10
11
 
11
12
  def inspect
12
- type_strings = coders.map{|c| c ? "#{c.name}:#{c.format}" : 'nil' }
13
+ type_strings = coders.map{|c| c ? c.inspect_short : 'nil' }
13
14
  "#<#{self.class} #{type_strings.join(' ')}>"
14
15
  end
15
16
  end
data/lib/pg/version.rb ADDED
@@ -0,0 +1,4 @@
1
+ module PG
2
+ # Library version
3
+ VERSION = '1.4.3'
4
+ end
data/lib/pg.rb CHANGED
@@ -1,64 +1,89 @@
1
- #!/usr/bin/env ruby
2
1
 
3
- begin
4
- require 'pg_ext'
5
- rescue LoadError
6
- # If it's a Windows binary gem, try the <major>.<minor> subdirectory
7
- if RUBY_PLATFORM =~/(mswin|mingw)/i
8
- major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
9
- raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
2
+ # -*- ruby -*-
3
+ # frozen_string_literal: true
10
4
 
11
- # Set the PATH environment variable, so that libpq.dll can be found.
12
- old_path = ENV['PATH']
13
- ENV['PATH'] = "#{File.expand_path("../#{RUBY_PLATFORM}", __FILE__)};#{old_path}"
14
- require "#{major_minor}/pg_ext"
15
- ENV['PATH'] = old_path
5
+ # The top-level PG namespace.
6
+ module PG
7
+
8
+ # Is this file part of a fat binary gem with bundled libpq?
9
+ bundled_libpq_path = File.join(__dir__, RUBY_PLATFORM.gsub(/^i386-/, "x86-"))
10
+ if File.exist?(bundled_libpq_path)
11
+ POSTGRESQL_LIB_PATH = bundled_libpq_path
16
12
  else
17
- raise
13
+ bundled_libpq_path = nil
14
+ # Try to load libpq path as found by extconf.rb
15
+ begin
16
+ require "pg/postgresql_lib_path"
17
+ rescue LoadError
18
+ # rake-compiler doesn't use regular "make install", but uses it's own install tasks.
19
+ # It therefore doesn't copy pg/postgresql_lib_path.rb in case of "rake compile".
20
+ POSTGRESQL_LIB_PATH = false
21
+ end
18
22
  end
19
23
 
20
- end
21
-
22
-
23
- # The top-level PG namespace.
24
- module PG
24
+ add_dll_path = proc do |path, &block|
25
+ if RUBY_PLATFORM =~/(mswin|mingw)/i && path && File.exist?(path)
26
+ begin
27
+ require 'ruby_installer/runtime'
28
+ RubyInstaller::Runtime.add_dll_directory(path, &block)
29
+ rescue LoadError
30
+ old_path = ENV['PATH']
31
+ ENV['PATH'] = "#{path};#{old_path}"
32
+ block.call
33
+ ENV['PATH'] = old_path
34
+ end
35
+ else
36
+ # No need to set a load path manually - it's set as library rpath.
37
+ block.call
38
+ end
39
+ end
25
40
 
26
- # Library version
27
- VERSION = '0.18.3'
41
+ # Add a load path to the one retrieved from pg_config
42
+ add_dll_path.call(POSTGRESQL_LIB_PATH) do
43
+ if bundled_libpq_path
44
+ # It's a Windows binary gem, try the <major>.<minor> subdirectory
45
+ major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
46
+ raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
47
+ require "#{major_minor}/pg_ext"
48
+ else
49
+ require 'pg_ext'
50
+ end
51
+ end
28
52
 
29
- # VCS revision
30
- REVISION = %q$Revision: 3b49541c9f12 $
31
53
 
32
54
  class NotAllCopyDataRetrieved < PG::Error
33
55
  end
56
+ class NotInBlockingMode < PG::Error
57
+ end
34
58
 
35
- ### Get the PG library version. If +include_buildnum+ is +true+, include the build ID.
36
- def self::version_string( include_buildnum=false )
37
- vstring = "%s %s" % [ self.name, VERSION ]
38
- vstring << " (build %s)" % [ REVISION[/: ([[:xdigit:]]+)/, 1] || '0' ] if include_buildnum
39
- return vstring
59
+ # Get the PG library version.
60
+ #
61
+ # +include_buildnum+ is no longer used and any value passed will be ignored.
62
+ def self.version_string( include_buildnum=nil )
63
+ "%s %s" % [ self.name, VERSION ]
40
64
  end
41
65
 
42
66
 
43
67
  ### Convenience alias for PG::Connection.new.
44
- def self::connect( *args )
45
- return PG::Connection.new( *args )
68
+ def self.connect( *args, &block )
69
+ Connection.new( *args, &block )
46
70
  end
47
71
 
48
72
 
49
73
  require 'pg/exceptions'
50
74
  require 'pg/constants'
51
75
  require 'pg/coder'
76
+ require 'pg/binary_decoder'
52
77
  require 'pg/text_encoder'
53
78
  require 'pg/text_decoder'
54
- require 'pg/basic_type_mapping'
79
+ require 'pg/basic_type_registry'
80
+ require 'pg/basic_type_map_based_on_result'
81
+ require 'pg/basic_type_map_for_queries'
82
+ require 'pg/basic_type_map_for_results'
55
83
  require 'pg/type_map_by_column'
56
84
  require 'pg/connection'
57
85
  require 'pg/result'
86
+ require 'pg/tuple'
87
+ require 'pg/version'
58
88
 
59
89
  end # module PG
60
-
61
-
62
- # Backward-compatible aliase
63
- PGError = PG::Error
64
-
@@ -0,0 +1,31 @@
1
+ # -*- ruby -*-
2
+
3
+ PGHOST = 'localhost'
4
+ PGDB = 'test'
5
+ #SOCKHOST = 'github.com'
6
+ SOCKHOST = 'it-trac.laika.com'
7
+
8
+ # Load pg first, so the libssl.so that libpq is linked against is loaded.
9
+ require 'pg'
10
+ $stderr.puts "connecting to postgres://#{PGHOST}/#{PGDB}"
11
+ conn = PG.connect( PGHOST, :dbname => PGDB )
12
+
13
+ # Now load OpenSSL, which might be linked against a different libssl.
14
+ require 'socket'
15
+ require 'openssl'
16
+ $stderr.puts "Connecting to #{SOCKHOST}"
17
+ sock = TCPSocket.open( SOCKHOST, 443 )
18
+ ctx = OpenSSL::SSL::SSLContext.new
19
+ sock = OpenSSL::SSL::SSLSocket.new( sock, ctx )
20
+ sock.sync_close = true
21
+
22
+ # The moment of truth...
23
+ $stderr.puts "Attempting to connect..."
24
+ begin
25
+ sock.connect
26
+ rescue Errno
27
+ $stderr.puts "Got an error connecting, but no segfault."
28
+ else
29
+ $stderr.puts "Nope, no segfault!"
30
+ end
31
+
@@ -0,0 +1,9 @@
1
+ == v0.8.0 [2012-02-09] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ This placeholder version.
4
+
5
+
6
+ == v0.7.9.2008.01.28 [2008-01-28] Jeff Davis <<ruby-pg@j-davis.com>>
7
+
8
+ The last actual version.
9
+
@@ -0,0 +1,5 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/postgres.rb
@@ -0,0 +1,21 @@
1
+ = postgres
2
+
3
+ * https://github.com/ged/ruby-pg
4
+
5
+ == Description
6
+
7
+ This is an old, deprecated version of the Ruby PostgreSQL driver that hasn't
8
+ been maintained or supported since early 2008.
9
+
10
+ You should install/require 'pg' instead.
11
+
12
+ If you need the 'postgres' gem for legacy code that can't be converted, you can
13
+ still install it using an explicit version, like so:
14
+
15
+ gem install postgres -v '0.7.9.2008.01.28'
16
+ gem uninstall postgres -v '>0.7.9.2008.01.28'
17
+
18
+ If you have any questions, the nice folks in the Google group can help:
19
+
20
+ http://goo.gl/OjOPP / ruby-pg@googlegroups.com
21
+
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'date'
4
+ require 'rubygems'
5
+ require 'hoe'
6
+ require 'pp'
7
+
8
+ Hoe.spec 'postgres' do
9
+ self.developer 'Michael Granger', 'ged@FaerieMUD.org'
10
+ self.dependency 'pg', '~> 0'
11
+ self.spec_extras[:date] = Date.parse( '2008/01/30' )
12
+
13
+ line = '-' * 75
14
+ msg = paragraphs_of( 'README.txt', 3..-1 )
15
+ msg.unshift( line )
16
+ msg.push( line )
17
+
18
+ self.spec_extras[:post_install_message] = msg.join( "\n\n" ) + "\n"
19
+ end
20
+
21
+ # vim: syntax=ruby
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'pathname'
4
+
5
+ module Postgres
6
+
7
+ VERSION = '0.8.1'
8
+
9
+ gemdir = Pathname( __FILE__ ).dirname.parent
10
+ readme = gemdir + 'README.txt'
11
+
12
+ header, message = readme.read.split( /^== Description/m )
13
+ abort( message.strip )
14
+
15
+ end
16
+
@@ -0,0 +1,9 @@
1
+ == v0.8.0 [2012-02-09] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ This placeholder version.
4
+
5
+
6
+ == v0.7.9.2008.01.28 [2008-01-28] Jeff Davis <<ruby-pg@j-davis.com>>
7
+
8
+ The last actual version.
9
+
@@ -0,0 +1,5 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/ruby/pg.rb
@@ -0,0 +1,21 @@
1
+ = ruby-pg
2
+
3
+ * https://github.com/ged/ruby-pg
4
+
5
+ == Description
6
+
7
+ This is an old, deprecated version of the 'pg' gem that hasn't been
8
+ maintained or supported since early 2008.
9
+
10
+ You should install/require 'pg' instead.
11
+
12
+ If you need ruby-pg for legacy code that can't be converted, you can still
13
+ install it using an explicit version, like so:
14
+
15
+ gem install ruby-pg -v '0.7.9.2008.01.28'
16
+ gem uninstall ruby-pg -v '>0.7.9.2008.01.28'
17
+
18
+ If you have any questions, the nice folks in the Google group can help:
19
+
20
+ http://goo.gl/OjOPP / ruby-pg@googlegroups.com
21
+
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'date'
4
+ require 'rubygems'
5
+ require 'hoe'
6
+ require 'pp'
7
+
8
+ Hoe.spec 'ruby-pg' do
9
+ self.developer 'Michael Granger', 'ged@FaerieMUD.org'
10
+ self.dependency 'pg', '~> 0'
11
+ self.spec_extras[:date] = Date.parse( '2008/01/30' )
12
+
13
+ line = '-' * 75
14
+ msg = paragraphs_of( 'README.txt', 3..-1 )
15
+ msg.unshift( line )
16
+ msg.push( line )
17
+
18
+ self.spec_extras[:post_install_message] = msg.join( "\n\n" ) + "\n"
19
+ end
20
+
21
+ # vim: syntax=ruby
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'pathname'
4
+
5
+ module Pg
6
+
7
+ VERSION = '0.8.0'
8
+
9
+ gemdir = Pathname( __FILE__ ).dirname.parent.parent
10
+ readme = gemdir + 'README.txt'
11
+
12
+ header, message = readme.read.split( /^== Description/m )
13
+ abort( message.strip )
14
+
15
+ end
16
+
data/pg.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ require_relative 'lib/pg/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pg"
8
+ spec.version = PG::VERSION
9
+ spec.authors = ["Michael Granger", "Lars Kanis"]
10
+ spec.email = ["ged@FaerieMUD.org", "lars@greiz-reinsdorf.de"]
11
+
12
+ spec.summary = "Pg is the Ruby interface to the PostgreSQL RDBMS"
13
+ spec.description = "Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL 9.3 and later."
14
+ spec.homepage = "https://github.com/ged/ruby-pg"
15
+ spec.license = "BSD-2-Clause"
16
+ spec.required_ruby_version = ">= 2.5"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/ged/ruby-pg"
20
+ spec.metadata["changelog_uri"] = "https://github.com/ged/ruby-pg/blob/master/History.rdoc"
21
+ spec.metadata["documentation_uri"] = "http://deveiate.org/code/pg"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.extensions = ["ext/extconf.rb"]
29
+ spec.require_paths = ["lib"]
30
+ spec.cert_chain = ["certs/ged.pem"]
31
+ spec.rdoc_options = ["--main", "README.rdoc"]
32
+ end
@@ -0,0 +1,46 @@
1
+ # This source code is borrowed from:
2
+ # https://github.com/oneclick/rubyinstaller2/blob/b3dcbf69f131e44c78ea3a1c5e0041c223f266ce/lib/ruby_installer/build/utils.rb#L104-L144
3
+
4
+ module TaskExtension
5
+ # Extend rake's file task to be defined only once and to check the expected file is indeed generated
6
+ #
7
+ # The same as #task, but for #file.
8
+ # In addition this file task raises an error, if the file that is expected to be generated is not present after the block was executed.
9
+ def file(name, *args, &block)
10
+ task_once(name, block) do
11
+ super(name, *args) do |ta|
12
+ block.call(ta).tap do
13
+ raise "file #{ta.name} is missing after task executed" unless File.exist?(ta.name)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ # Extend rake's task definition to be defined only once, even if called several times
20
+ #
21
+ # This allows to define common tasks next to specific tasks.
22
+ # It is expected that any variation of the task's block is reflected in the task name or namespace.
23
+ # If the task name is identical, the task block is executed only once, even if the file task definition is executed twice.
24
+ def task(name, *args, &block)
25
+ task_once(name, block) do
26
+ super
27
+ end
28
+ end
29
+
30
+ private def task_once(name, block)
31
+ name = name.keys.first if name.is_a?(Hash)
32
+ if block &&
33
+ Rake::Task.task_defined?(name) &&
34
+ Rake::Task[name].instance_variable_get('@task_block_location') == block.source_location
35
+ # task is already defined for this target and the same block
36
+ # So skip double definition of the same action
37
+ Rake::Task[name]
38
+ elsif block
39
+ yield.tap do
40
+ Rake::Task[name].instance_variable_set('@task_block_location', block.source_location)
41
+ end
42
+ else
43
+ yield
44
+ end
45
+ end
46
+ end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
2
 
3
3
  require 'pg'
4
4