ruby-oci8 2.1.5.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +17 -0
- data/COPYING +30 -0
- data/COPYING_old +64 -0
- data/ChangeLog +2779 -0
- data/Makefile +92 -0
- data/NEWS +660 -0
- data/README.md +43 -0
- data/VERSION +1 -0
- data/dist-files +91 -0
- data/docs/install-binary-package.md +40 -0
- data/docs/install-full-client.md +116 -0
- data/docs/install-instant-client.md +167 -0
- data/docs/platform-specific-issues.md +197 -0
- data/docs/report-installation-issue.md +50 -0
- data/lib/.document +1 -0
- data/lib/dbd/OCI8.rb +591 -0
- data/lib/oci8.rb +147 -0
- data/lib/oci8.rb.in +147 -0
- data/lib/oci8/.document +8 -0
- data/lib/oci8/bindtype.rb +350 -0
- data/lib/oci8/compat.rb +113 -0
- data/lib/oci8/connection_pool.rb +108 -0
- data/lib/oci8/cursor.rb +564 -0
- data/lib/oci8/datetime.rb +605 -0
- data/lib/oci8/encoding-init.rb +79 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2092 -0
- data/lib/oci8/object.rb +605 -0
- data/lib/oci8/oci8.rb +560 -0
- data/lib/oci8/ocihandle.rb +607 -0
- data/lib/oci8/oracle_version.rb +143 -0
- data/lib/oci8/properties.rb +134 -0
- data/lib/oci8lib_200.so +0 -0
- data/metaconfig +142 -0
- data/pre-distclean.rb +7 -0
- data/ruby-oci8.gemspec +80 -0
- data/setup.rb +1333 -0
- data/test/README +42 -0
- data/test/config.rb +184 -0
- data/test/setup_test_object.sql +171 -0
- data/test/test_all.rb +54 -0
- data/test/test_appinfo.rb +63 -0
- data/test/test_array_dml.rb +333 -0
- data/test/test_bind_raw.rb +46 -0
- data/test/test_bind_string.rb +106 -0
- data/test/test_bind_time.rb +178 -0
- data/test/test_break.rb +124 -0
- data/test/test_clob.rb +98 -0
- data/test/test_connection_pool.rb +125 -0
- data/test/test_connstr.rb +81 -0
- data/test/test_datetime.rb +581 -0
- data/test/test_dbi.rb +366 -0
- data/test/test_dbi_clob.rb +53 -0
- data/test/test_encoding.rb +104 -0
- data/test/test_error.rb +88 -0
- data/test/test_metadata.rb +1485 -0
- data/test/test_object.rb +462 -0
- data/test/test_oci8.rb +489 -0
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +256 -0
- data/test/test_oranumber.rb +787 -0
- data/test/test_rowid.rb +33 -0
- metadata +109 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
# oracle_version.rb implements OCI8::OracleVersion.
|
2
|
+
#
|
3
|
+
# Copyright (C) 2009-2013 Kubo Takehiro <kubo@jiubao.org>
|
4
|
+
|
5
|
+
#
|
6
|
+
class OCI8
|
7
|
+
|
8
|
+
# The data class, representing Oracle version.
|
9
|
+
#
|
10
|
+
# Oracle version is represented by five numbers:
|
11
|
+
# *major*, *minor*, *update*, *patch* and *port_update*.
|
12
|
+
#
|
13
|
+
# @see OCI8.oracle_client_version
|
14
|
+
# @see OCI8#oracle_server_version
|
15
|
+
class OracleVersion
|
16
|
+
include Comparable
|
17
|
+
|
18
|
+
# The first part of the Oracle version.
|
19
|
+
attr_reader :major
|
20
|
+
# The second part of the Oracle version.
|
21
|
+
attr_reader :minor
|
22
|
+
# The third part of the Oracle version.
|
23
|
+
attr_reader :update
|
24
|
+
# The fourth part of the Oracle version.
|
25
|
+
attr_reader :patch
|
26
|
+
# The fifth part of the Oracle version.
|
27
|
+
attr_reader :port_update
|
28
|
+
|
29
|
+
# Creates an OCI8::OracleVersion object.
|
30
|
+
#
|
31
|
+
# If the first argument _arg_ is a String, it is parsed as dotted
|
32
|
+
# version string. If it is bigger than 0x08000000, it is parsed as
|
33
|
+
# a number contains 5-digit Oracle version. Otherwise, it is used
|
34
|
+
# as a major version and the rest arguments are minor, update,
|
35
|
+
# patch and port_update. Unspecified version numbers are zeros by
|
36
|
+
# default.
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# # When the first argument is a String,
|
40
|
+
# oraver = OCI8::OracleVersion.new('11.2.0.3')
|
41
|
+
# oraver.major # => 11
|
42
|
+
# oraver.minor # => 2
|
43
|
+
# oraver.update # => 0
|
44
|
+
# oraver.patch # => 3
|
45
|
+
# oraver.port_update # => 0
|
46
|
+
#
|
47
|
+
# # When the first argument is bigger than 0x08000000,
|
48
|
+
# oraver = OCI8::OracleVersion.new(0x0b200300)
|
49
|
+
# oraver.major # => 11
|
50
|
+
# oraver.minor # => 2
|
51
|
+
# oraver.update # => 0
|
52
|
+
# oraver.patch # => 3
|
53
|
+
# oraver.port_update # => 0
|
54
|
+
#
|
55
|
+
# # Otherwise,
|
56
|
+
# oraver = OCI8::OracleVersion.new(11, 2, 0, 3)
|
57
|
+
# oraver.major # => 11
|
58
|
+
# oraver.minor # => 2
|
59
|
+
# oraver.update # => 0
|
60
|
+
# oraver.patch # => 3
|
61
|
+
# oraver.port_update # => 0
|
62
|
+
#
|
63
|
+
# @return [OCI8::OracleVersion]
|
64
|
+
def initialize(arg, minor = nil, update = nil, patch = nil, port_update = nil)
|
65
|
+
if arg.is_a? String
|
66
|
+
major, minor, update, patch, port_update = arg.split('.').collect do |v|
|
67
|
+
v.to_i
|
68
|
+
end
|
69
|
+
elsif arg >= 0x08000000
|
70
|
+
major = (arg & 0xFF000000) >> 24
|
71
|
+
minor = (arg & 0x00F00000) >> 20
|
72
|
+
update = (arg & 0x000FF000) >> 12
|
73
|
+
patch = (arg & 0x00000F00) >> 8
|
74
|
+
port_update = (arg & 0x000000FF)
|
75
|
+
else
|
76
|
+
major = arg
|
77
|
+
end
|
78
|
+
@major = major
|
79
|
+
@minor = minor || 0
|
80
|
+
@update = update || 0
|
81
|
+
@patch = patch || 0
|
82
|
+
@port_update = port_update || 0
|
83
|
+
@vernum = (@major << 24) | (@minor << 20) | (@update << 12) | (@patch << 8) | @port_update
|
84
|
+
end
|
85
|
+
|
86
|
+
# Compares +self+ and +other+.
|
87
|
+
#
|
88
|
+
# <=> is the basis for the methods <, <=, ==, >, >=, and between?,
|
89
|
+
# included from the Comparable module.
|
90
|
+
#
|
91
|
+
# @return [-1, 0, +1]
|
92
|
+
def <=>(other)
|
93
|
+
@vernum <=> other.to_i
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns an integer number contains 5-digit Oracle version.
|
97
|
+
#
|
98
|
+
# If the hexadecimal notation is 0xAABCCDEE, *major*, *minor*,
|
99
|
+
# *update*, *patch* and *port_update* are 0xAA, 0xB, 0xCC, 0xD and
|
100
|
+
# 0xEE respectively.
|
101
|
+
#
|
102
|
+
# @example
|
103
|
+
# oraver = OCI8::OracleVersion.new('11.2.0.3')
|
104
|
+
# oraver.to_i # => 186647296
|
105
|
+
# '%08x' % oraver.to_i # => "0b200300"
|
106
|
+
#
|
107
|
+
# @return [Integer]
|
108
|
+
def to_i
|
109
|
+
@vernum
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns a dotted version string of the Oracle version.
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
# oraver = OCI8::OracleVersion.new('11.2.0.3')
|
116
|
+
# oraver.to_s # => '11.2.0.3.0'
|
117
|
+
#
|
118
|
+
# @return [String]
|
119
|
+
def to_s
|
120
|
+
format('%d.%d.%d.%d.%d', @major, @minor, @update, @patch, @port_update)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Returns true if +self+ and +other+ are the same type and have
|
124
|
+
# equal values.
|
125
|
+
#
|
126
|
+
# @return [true or false]
|
127
|
+
def eql?(other)
|
128
|
+
other.is_a? OCI8::OracleVersion and (self <=> other) == 0
|
129
|
+
end
|
130
|
+
|
131
|
+
# Returns a hash based on the value of +self+.
|
132
|
+
#
|
133
|
+
# @return [Integer]
|
134
|
+
def hash
|
135
|
+
@vernum
|
136
|
+
end
|
137
|
+
|
138
|
+
# @private
|
139
|
+
def inspect
|
140
|
+
"#<#{self.class.to_s}: #{self.to_s}>"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# properties.rb -- implements OCI8.properties
|
2
|
+
#
|
3
|
+
# Copyright (C) 2010-2013 KUBO Takehiro <kubo@jiubao.org>
|
4
|
+
|
5
|
+
#
|
6
|
+
class OCI8
|
7
|
+
|
8
|
+
# @private
|
9
|
+
@@properties = {
|
10
|
+
:length_semantics => :byte,
|
11
|
+
:bind_string_as_nchar => false,
|
12
|
+
:float_conversion_type => OCI8.__get_prop(1) ? :ruby : :oracle,
|
13
|
+
:statement_cache_size => 0,
|
14
|
+
:events_mode => ((OCI8.__get_prop(2) & 4) != 0) # 4 <- OCI_EVENTS in oci.h
|
15
|
+
}
|
16
|
+
|
17
|
+
if OCI8.oracle_client_version < OCI8::ORAVER_9_2
|
18
|
+
@@properties[:statement_cache_size] = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
# @private
|
22
|
+
def @@properties.[](name)
|
23
|
+
raise IndexError, "No such property name: #{name}" unless @@properties.has_key?(name)
|
24
|
+
super(name)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @private
|
28
|
+
def @@properties.[]=(name, val)
|
29
|
+
raise IndexError, "No such property name: #{name}" unless @@properties.has_key?(name)
|
30
|
+
case name
|
31
|
+
when :length_semantic
|
32
|
+
if val != :byte and val != :char
|
33
|
+
raise ArgumentError, "Invalid property value #{val} for :length_semantics."
|
34
|
+
end
|
35
|
+
when :bind_string_as_nchar
|
36
|
+
val = val ? true : false
|
37
|
+
when :float_conversion_type
|
38
|
+
case val
|
39
|
+
when :ruby
|
40
|
+
OCI8.__set_prop(1, true)
|
41
|
+
when :oracle
|
42
|
+
OCI8.__set_prop(1, false)
|
43
|
+
else
|
44
|
+
raise ArgumentError, "float_conversion_type's value should be either :ruby or :oracle."
|
45
|
+
end
|
46
|
+
when :statement_cache_size
|
47
|
+
if OCI8.oracle_client_version < OCI8::ORAVER_9_2
|
48
|
+
raise RuntimeError, ":statement_cache_size is disabled on Oracle 9iR1 client."
|
49
|
+
end
|
50
|
+
val = val.to_i
|
51
|
+
raise ArgumentError, "The property value for :statement_cache_size must not be negative." if val < 0
|
52
|
+
when :events_mode
|
53
|
+
val = val ? true : false
|
54
|
+
if val
|
55
|
+
OCI8.__set_prop(2, OCI8.__get_prop(2) | 4) # set OCI_EVENTS
|
56
|
+
else
|
57
|
+
OCI8.__set_prop(2, OCI8.__get_prop(2) & ~4) # unset OCI_EVENTS
|
58
|
+
end
|
59
|
+
end
|
60
|
+
super(name, val)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns a Hash which ruby-oci8 global settings.
|
64
|
+
# The hash's setter and getter methods are customized to check
|
65
|
+
# property names and values.
|
66
|
+
#
|
67
|
+
# # get properties
|
68
|
+
# OCI8.properties[:bind_string_as_nchar] # => false
|
69
|
+
# OCI8.properties[:invalid_property_name] # raises an IndexError
|
70
|
+
#
|
71
|
+
# # set properties
|
72
|
+
# OCI8.properties[:bind_string_as_nchar] = true
|
73
|
+
# OCI8.properties[:invalid_property_name] = true # raises an IndexError
|
74
|
+
#
|
75
|
+
# Supported properties are listed below:
|
76
|
+
#
|
77
|
+
# [:length_semantics]
|
78
|
+
#
|
79
|
+
# +:char+ when Oracle character length is counted by the number of characters.
|
80
|
+
# +:byte+ when it is counted by the number of bytes.
|
81
|
+
# The default setting is +:byte+ because +:char+ causes unexpected behaviour on
|
82
|
+
# Oracle 9i.
|
83
|
+
#
|
84
|
+
# *Since:* 2.1.0
|
85
|
+
#
|
86
|
+
# [:bind_string_as_nchar]
|
87
|
+
#
|
88
|
+
# +true+ when string bind variables are bound as NCHAR,
|
89
|
+
# otherwise +false+. The default value is +false+.
|
90
|
+
#
|
91
|
+
# [:float_conversion_type]
|
92
|
+
#
|
93
|
+
# +:ruby+ when Oracle decimal numbers are converted to ruby Float values
|
94
|
+
# same as Float#to_s does. (default)
|
95
|
+
# +:oracle:+ when they are done by Oracle OCI functions.
|
96
|
+
#
|
97
|
+
# From ruby 1.9.2, a float value converted from Oracle number 15.7 by
|
98
|
+
# the Oracle function OCINumberToReal() makes a string representation
|
99
|
+
# 15.700000000000001 by Float#to_s.
|
100
|
+
# See: http://rubyforge.org/forum/forum.php?thread_id=50030&forum_id=1078
|
101
|
+
#
|
102
|
+
# *Since:* 2.1.0
|
103
|
+
#
|
104
|
+
# [:statement_cache_size]
|
105
|
+
#
|
106
|
+
# The statement cache size per each session. The default size is 0, which
|
107
|
+
# means no statement cache, since 2.1.2. It was 20 in 2.1.1.
|
108
|
+
# This feature is available on Oracle 9iR2 or later.
|
109
|
+
# See: http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci09adv.htm#i471377
|
110
|
+
#
|
111
|
+
# *Since:* 2.1.1
|
112
|
+
#
|
113
|
+
# [:events_mode]
|
114
|
+
#
|
115
|
+
# +true+ when Fast Application Notification (FAN) Support is enabled.
|
116
|
+
# +false+ when it is disabled. The default value is +false+.
|
117
|
+
# This corresponds to {http://php.net/manual/en/oci8.configuration.php#ini.oci8.events +oci8.events+ in PHP}.
|
118
|
+
#
|
119
|
+
# This parameter can be changed only when no OCI methods are called.
|
120
|
+
#
|
121
|
+
# require 'oci8'
|
122
|
+
# OCI8.properties[:events_mode] = true # works fine.
|
123
|
+
# ... call some OCI methods ...
|
124
|
+
# OCI8.properties[:events_mode] = true # raises a runtime error.
|
125
|
+
#
|
126
|
+
# *Since:* 2.1.4
|
127
|
+
#
|
128
|
+
# @return [a customized Hash]
|
129
|
+
# @since 2.0.5
|
130
|
+
#
|
131
|
+
def self.properties
|
132
|
+
@@properties
|
133
|
+
end
|
134
|
+
end
|
data/lib/oci8lib_200.so
ADDED
Binary file
|
data/metaconfig
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# --*- ruby -*--
|
2
|
+
|
3
|
+
ToplevelInstaller::TASKS.push ['test', 'run test.']
|
4
|
+
ToplevelInstaller::TASKS.push ['distbin', 'make binary package.']
|
5
|
+
ToplevelInstaller.module_eval {
|
6
|
+
alias parsearg_test parsearg_no_options
|
7
|
+
alias parsearg_distbin parsearg_no_options
|
8
|
+
|
9
|
+
def exec_test
|
10
|
+
old = Dir.pwd
|
11
|
+
@installer.mkdir_p "#{objdir_root}/test"
|
12
|
+
Dir.chdir "#{objdir_root}/test"
|
13
|
+
@installer.ruby("-w -I#{srcdir_root}/ext/oci8 -I#{srcdir_root}/lib -I#{srcdir_root}/support -I#{srcdir_root}/test #{srcdir_root}/test/test_all.rb")
|
14
|
+
Dir.chdir old
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_zcontent(file)
|
18
|
+
require 'base64'
|
19
|
+
require 'zlib'
|
20
|
+
File.open(file, 'rb') do |f|
|
21
|
+
Base64.encode64(Zlib::Deflate::deflate(f.read))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def exec_distbin
|
26
|
+
File.open("ruby-oci8-#{RUBY_PLATFORM}.rb", 'w') do |f|
|
27
|
+
f.write <<-EOT
|
28
|
+
# ruby-oci8 binary installer for #{RUBY_PLATFORM}
|
29
|
+
require 'rbconfig'
|
30
|
+
require 'base64'
|
31
|
+
require 'ftools'
|
32
|
+
require 'zlib'
|
33
|
+
|
34
|
+
def msg_error(msg)
|
35
|
+
puts "ERROR: "
|
36
|
+
puts msg
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
|
40
|
+
def msg_ok(msg)
|
41
|
+
puts msg
|
42
|
+
end
|
43
|
+
|
44
|
+
def msg_ask(msg)
|
45
|
+
puts msg
|
46
|
+
$stdout.print "Enter Yes/No: "
|
47
|
+
$stdout.flush
|
48
|
+
ret = gets().chomp.downcase
|
49
|
+
if ret == 'y' || ret == 'ye' || ret == 'yes'
|
50
|
+
return
|
51
|
+
else
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if '#{RUBY_PLATFORM}' != RUBY_PLATFORM
|
57
|
+
msg_ask "This package is for #{RUBY_PLATFORM}\\ninstall anyway?"
|
58
|
+
end
|
59
|
+
|
60
|
+
class Installer
|
61
|
+
@@log = ""
|
62
|
+
def initialize(install_files)
|
63
|
+
@files = []
|
64
|
+
install_files.each do |file, content|
|
65
|
+
basename = File.basename(file)
|
66
|
+
dirname = File.dirname(file)
|
67
|
+
if dirname == '.'
|
68
|
+
dirname = ''
|
69
|
+
else
|
70
|
+
dirname = '/' + dirname
|
71
|
+
end
|
72
|
+
case basename
|
73
|
+
when /\.so$/
|
74
|
+
dirname = "\#{Config::CONFIG['sitearchdir']}\#{dirname}"
|
75
|
+
else
|
76
|
+
dirname = "\#{Config::CONFIG['sitelibdir']}\#{dirname}"
|
77
|
+
end
|
78
|
+
@files << [basename, dirname, content]
|
79
|
+
end
|
80
|
+
@files.sort! do |x, y| x[0] <=> y[0] end
|
81
|
+
end
|
82
|
+
|
83
|
+
def confirm
|
84
|
+
msg = ""
|
85
|
+
@files.each do |f|
|
86
|
+
basename, dirname, content = f
|
87
|
+
msg << "Copy \#{basename} to \#{dirname}\\n"
|
88
|
+
end
|
89
|
+
msg << "OK?\\n"
|
90
|
+
msg_ask(msg)
|
91
|
+
end
|
92
|
+
|
93
|
+
def install
|
94
|
+
@@log = ""
|
95
|
+
@files.each do |f|
|
96
|
+
basename, dirname, content = f
|
97
|
+
@@log << "Copying \#{basename} to \#{dirname} ... "
|
98
|
+
if not FileTest.directory?(dirname)
|
99
|
+
File.makedirs(dirname)
|
100
|
+
end
|
101
|
+
File.open("\#{dirname}/\#{basename}", "wb") do |f|
|
102
|
+
f.write(Zlib::Inflate::inflate(Base64.decode64(content)))
|
103
|
+
end
|
104
|
+
@@log << "done\\n"
|
105
|
+
end
|
106
|
+
@@log << "OK\\n"
|
107
|
+
msg_ok(@@log)
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.log
|
111
|
+
@@log
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
install_files = {}
|
116
|
+
|
117
|
+
install_files['oci8lib.so'] = <<-EOS
|
118
|
+
#{get_zcontent('ext/oci8/oci8lib.so')}EOS
|
119
|
+
|
120
|
+
install_files['oci8.rb'] = <<-EOS
|
121
|
+
#{get_zcontent('lib/oci8.rb')}EOS
|
122
|
+
|
123
|
+
install_files['DBD/OCI8/OCI8.rb'] = <<-EOS
|
124
|
+
#{get_zcontent('lib/DBD/OCI8/OCI8.rb')}EOS
|
125
|
+
|
126
|
+
begin
|
127
|
+
installer = Installer.new(install_files)
|
128
|
+
installer.confirm
|
129
|
+
installer.install
|
130
|
+
rescue
|
131
|
+
msg_error(Installer.log + "\\n" + $!.to_s)
|
132
|
+
end
|
133
|
+
EOT
|
134
|
+
end
|
135
|
+
end
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
ConfigTable.add_entry('oracle_version', ['',
|
140
|
+
'name',
|
141
|
+
'Oracle version name',
|
142
|
+
'NONE' ])
|
data/pre-distclean.rb
ADDED
data/ruby-oci8.gemspec
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# To make a pure ruby gems package:
|
4
|
+
# gem build ruby-oci8.gemspec
|
5
|
+
#
|
6
|
+
# To make a binary gems package:
|
7
|
+
# gem build ruby-oci8.gemspec -- current
|
8
|
+
#
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
if ARGV.include?("--") and ARGV[(ARGV.index("--") + 1)] == 'current'
|
12
|
+
gem_platform = 'current'
|
13
|
+
else
|
14
|
+
gem_platform = Gem::Platform::RUBY
|
15
|
+
end
|
16
|
+
|
17
|
+
spec = Gem::Specification.new do |s|
|
18
|
+
s.name = 'ruby-oci8'
|
19
|
+
s.version = File.read('VERSION').strip
|
20
|
+
s.summary = 'Ruby interface for Oracle using OCI8 API'
|
21
|
+
s.email = 'kubo@jiubao.org'
|
22
|
+
s.homepage = 'http://ruby-oci8.rubyforge.org'
|
23
|
+
s.rubyforge_project = 'ruby-oci8'
|
24
|
+
s.description = <<EOS
|
25
|
+
ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle8i, Oracle9i, Oracle10g, Oracle11g and Oracle Instant Client.
|
26
|
+
EOS
|
27
|
+
s.has_rdoc = 'yard'
|
28
|
+
s.authors = ['Kubo Takehiro']
|
29
|
+
s.platform = gem_platform
|
30
|
+
s.license = '2-clause BSD-style license'
|
31
|
+
files = File.read('dist-files').split("\n")
|
32
|
+
if gem_platform == Gem::Platform::RUBY
|
33
|
+
s.extensions << 'ext/oci8/extconf.rb'
|
34
|
+
s.required_ruby_version = '>= 1.8.0'
|
35
|
+
else
|
36
|
+
so_files = Dir.glob('ext/oci8/oci8lib_*.so')
|
37
|
+
so_vers = so_files.collect do |file|
|
38
|
+
$1 if /ext\/oci8\/oci8lib_(\S+).so/ =~ file
|
39
|
+
end.sort
|
40
|
+
|
41
|
+
# add map files to analyze a core (minidump) file.
|
42
|
+
so_vers.each do |ver|
|
43
|
+
map_file = 'ext/oci8/oci8lib_#{ver}.map'
|
44
|
+
so_files << map_file if File.exists? map_file
|
45
|
+
end
|
46
|
+
|
47
|
+
# least version in so_vers
|
48
|
+
so_vermin = so_vers.collect do |ver|
|
49
|
+
"#$1.#$2.#{$3||'0'}" if /^(?:rbx)?(\d)(\d)(\d)?/ =~ ver
|
50
|
+
end.sort.first
|
51
|
+
|
52
|
+
case so_vers.length
|
53
|
+
when 0
|
54
|
+
raise "No compiled binary are found. Run make in advance."
|
55
|
+
when 1
|
56
|
+
puts "Binary gem for ruby #{so_vers.first}"
|
57
|
+
if so_vers[0] < '2.0.0'
|
58
|
+
s.required_ruby_version = "~> #{so_vermin}"
|
59
|
+
else
|
60
|
+
s.required_ruby_version = "~> #{so_vermin}.0"
|
61
|
+
end
|
62
|
+
else
|
63
|
+
puts "Binary gem for ruby #{so_vers.join(', ')}"
|
64
|
+
s.required_ruby_version = ">= #{so_vermin}"
|
65
|
+
end
|
66
|
+
|
67
|
+
FileUtils.copy so_files, 'lib', :preserve => true
|
68
|
+
files.reject! do |fname|
|
69
|
+
fname =~ /^ext/
|
70
|
+
end
|
71
|
+
so_files.each do |fname|
|
72
|
+
files << 'lib/' + File.basename(fname)
|
73
|
+
end
|
74
|
+
files << 'lib/oci8.rb'
|
75
|
+
end
|
76
|
+
s.require_paths = ['lib', 'ext/oci8']
|
77
|
+
s.files = files
|
78
|
+
s.test_files = 'test/test_all.rb'
|
79
|
+
s.extra_rdoc_files = ['README.md']
|
80
|
+
end
|