From: Bryan Duxbury Date: Thu, 26 Mar 2009 18:41:44 +0000 (+0000) Subject: THRIFT-372. rb: Ruby lib doesn't rescue properly from lack of native_thrift extension X-Git-Tag: 0.2.0~205 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=8852720e70e77669fa5ffff494dd641f6fff06f2;p=common%2Fthrift.git 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758794 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/lib/thrift.rb b/lib/rb/lib/thrift.rb index d3fe7abe..ec15adc4 100644 --- a/lib/rb/lib/thrift.rb +++ b/lib/rb/lib/thrift.rb @@ -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/client' 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 diff --git a/lib/rb/lib/thrift/thrift_native.rb b/lib/rb/lib/thrift/thrift_native.rb new file mode 100644 index 00000000..c7fd2524 --- /dev/null +++ b/lib/rb/lib/thrift/thrift_native.rb @@ -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 diff --git a/lib/rb/spec/protocol_spec.rb b/lib/rb/spec/protocol_spec.rb index 1db4e19f..443c8f09 100644 --- a/lib/rb/spec/protocol_spec.rb +++ b/lib/rb/spec/protocol_spec.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/spec_helper' -require "thrift_native" class ThriftProtocolSpec < Spec::ExampleGroup include Thrift diff --git a/lib/rb/spec/spec_helper.rb b/lib/rb/spec/spec_helper.rb index 30b9da70..3fbd673f 100644 --- a/lib/rb/spec/spec_helper.rb +++ b/lib/rb/spec/spec_helper.rb @@ -9,13 +9,6 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. ext]) # 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 @@ Spec::Runner.configure do |configuration| end end -require "thrift/protocol/compact_protocol" -require "thrift_native" - require File.dirname(__FILE__) + "/../debug_proto_test/gen-rb/Srv" module Fixtures