[ruby-oci8-commit] [521] trunk/ruby-oci8: refactor code which generates the C extention name.

nobody at rubyforge.org nobody at rubyforge.org
Sat May 12 13:03:51 UTC 2012


Revision: 521
Author:   kubo
Date:     2012-05-12 13:03:51 +0000 (Sat, 12 May 2012)
Log Message:
-----------
refactor code which generates the C extention name.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/extconf.rb
    trunk/ruby-oci8/lib/oci8.rb.in

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2012-05-05 09:02:56 UTC (rev 520)
+++ trunk/ruby-oci8/ChangeLog	2012-05-12 13:03:51 UTC (rev 521)
@@ -1,3 +1,7 @@
+2012-05-12  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/extconf.rb, lib/oci8.rb.in: refactor code which generates the
+	    C extention name.
+
 2012-05-05  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/oci8.c, lib/oci8/oci8.rb: delete private methods OCI8#server_handle
 	    and OCI8#session_handle and use @server_handle and @session_handle instead.

Modified: trunk/ruby-oci8/ext/oci8/extconf.rb
===================================================================
--- trunk/ruby-oci8/ext/oci8/extconf.rb	2012-05-05 09:02:56 UTC (rev 520)
+++ trunk/ruby-oci8/ext/oci8/extconf.rb	2012-05-12 13:03:51 UTC (rev 521)
@@ -129,22 +129,22 @@
 # make ruby script before running create_makefile.
 replace_keyword(File.dirname(__FILE__) + '/../../lib/oci8.rb.in', '../../lib/oci8.rb', replace)
 
+ruby_engine = (defined? RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
+
 so_basename = 'oci8lib_'
-if defined? RUBY_ENGINE and RUBY_ENGINE != 'ruby'
-  so_basename += RUBY_ENGINE
+if ruby_engine == 'ruby'
+  # Config::CONFIG["ruby_version"] indicates the ruby API version.
+  #  1.8   - ruby 1.8.x
+  #  1.9.1 - ruby 1.9.1, 1.9.2 and 2.0.0-dev at the present time.
+  so_basename += RbConfig::CONFIG["ruby_version"].gsub(/\W/, '')
+else
+  so_basename += ruby_engine
 end
 
-# Config::CONFIG["ruby_version"] indicates the ruby API version.
-#  1.8   - ruby 1.8.x
-#  1.9.1 - ruby 1.9.1, 1.9.2 and 2.0.0-dev at the present time.
-so_basename += RbConfig::CONFIG["ruby_version"].gsub(/\W/, '')
-
 $defs << "-DInit_oci8lib=Init_#{so_basename}"
 $defs << "-Doci8lib=#{so_basename}"
 $defs << "-DOCI8LIB_VERSION=\\\"#{RUBY_OCI8_VERSION}\\\""
-if defined? RUBY_ENGINE and RUBY_ENGINE == 'rbx'
-  $defs << "-DCHAR_IS_NOT_A_SHORTCUT_TO_ID"
-end
+$defs << "-DCHAR_IS_NOT_A_SHORTCUT_TO_ID" if ruby_engine != 'ruby'
 
 create_header()
 

Modified: trunk/ruby-oci8/lib/oci8.rb.in
===================================================================
--- trunk/ruby-oci8/lib/oci8.rb.in	2012-05-05 09:02:56 UTC (rev 520)
+++ trunk/ruby-oci8/lib/oci8.rb.in	2012-05-12 13:03:51 UTC (rev 521)
@@ -23,22 +23,23 @@
   end
 end
 
+ruby_engine = (defined? RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
+
 so_basename = 'oci8lib_'
-if defined? RUBY_ENGINE and RUBY_ENGINE != 'ruby'
-  so_basename += RUBY_ENGINE
-end
-
-# The suffix number indicates the ruby API version.
-#  18  - ruby 1.8.x
-#  191 - ruby 1.9.1 and 1.9.2
-#  19x - ruby 1.9.x future version which will break the API compatibility
-case RUBY_VERSION
-when /^1\.9/, /^2\.0/
-  so_basename += '191'
-when /^1\.8/
-  so_basename += '18'
+if ruby_engine == 'ruby'
+  # The suffix number indicates the ruby API version.
+  #  18  - ruby 1.8.x
+  #  191 - ruby 1.9.1, 1.9.2 and 2.0.0-dev at the present time.
+  case RUBY_VERSION
+  when /^1\.9/, /^2\.0/
+    so_basename += '191'
+  when /^1\.8/
+    so_basename += '18'
+  else
+    raise 'unsupported ruby version: ' + RUBY_VERSION
+  end
 else
-  raise 'unsupported ruby version: ' + RUBY_VERSION
+  so_basename += ruby_engine
 end
 require so_basename
 



More information about the ruby-oci8-commit mailing list