You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2009/03/26 19:41:49 UTC

svn commit: r758794 - in /incubator/thrift/trunk/lib/rb: lib/thrift.rb lib/thrift/thrift_native.rb spec/protocol_spec.rb spec/spec_helper.rb

Author: bryanduxbury
Date: Thu Mar 26 18:41:44 2009
New Revision: 758794

URL: http://svn.apache.org/viewvc?rev=758794&view=rev
Log:
THRIFT-372. rb: Ruby lib doesn't rescue properly from lack of native_thrift extension

This patch adds a new thrift/thrift_native.rb which should be the require point for application users. It also removes some unnecessary code from a few files and cleans up requires in some specs.


Added:
    incubator/thrift/trunk/lib/rb/lib/thrift/thrift_native.rb
Modified:
    incubator/thrift/trunk/lib/rb/lib/thrift.rb
    incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb
    incubator/thrift/trunk/lib/rb/spec/spec_helper.rb

Modified: incubator/thrift/trunk/lib/rb/lib/thrift.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift.rb?rev=758794&r1=758793&r2=758794&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift.rb Thu Mar 26 18:41:44 2009
@@ -19,11 +19,6 @@
 
 $:.unshift File.dirname(__FILE__)
 
-module Thrift
-  # prevent the deprecation layer from being loaded if you require 'thrift'
-  DEPRECATION = false unless const_defined? :DEPRECATION
-end
-
 require 'thrift/core_ext'
 require 'thrift/exceptions'
 require 'thrift/types'
@@ -32,6 +27,8 @@
 require 'thrift/struct'
 require 'thrift/protocol'
 require 'thrift/protocol/binaryprotocol'
+require 'thrift/protocol/compact_protocol'
 require 'thrift/transport'
 require 'thrift/transport/socket'
 require 'thrift/server'
+require "thrift/thrift_native"
\ No newline at end of file

Added: incubator/thrift/trunk/lib/rb/lib/thrift/thrift_native.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/thrift_native.rb?rev=758794&view=auto
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/thrift_native.rb (added)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/thrift_native.rb Thu Mar 26 18:41:44 2009
@@ -0,0 +1,5 @@
+begin
+  require "thrift_native"
+rescue LoadError
+  puts "Unable to load thrift_native extension. Defaulting to pure Ruby libraries."
+end
\ No newline at end of file

Modified: incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb?rev=758794&r1=758793&r2=758794&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb Thu Mar 26 18:41:44 2009
@@ -1,5 +1,4 @@
 require File.dirname(__FILE__) + '/spec_helper'
-require "thrift_native"
 
 class ThriftProtocolSpec < Spec::ExampleGroup
   include Thrift

Modified: incubator/thrift/trunk/lib/rb/spec/spec_helper.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/spec_helper.rb?rev=758794&r1=758793&r2=758794&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/spec_helper.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/spec_helper.rb Thu Mar 26 18:41:44 2009
@@ -9,13 +9,6 @@
 # will get screwed up
 # $" << 'fastthread.bundle'
 
-# turn on deprecation so we can test it
-module Thrift
-  # squelch any warnings if we happen to get required twice
-  remove_const(:DEPRECATION) if const_defined? :DEPRECATION
-  DEPRECATION = true
-end
-
 require File.dirname(__FILE__) + '/../lib/thrift'
 
 class Object
@@ -32,9 +25,6 @@
   end
 end
 
-require "thrift/protocol/compact_protocol"
-require "thrift_native"
-
 require File.dirname(__FILE__) + "/../debug_proto_test/gen-rb/Srv"
 
 module Fixtures