rb: Use File.dirname(__FILE__) in generated requires [THRIFT-57]

This means you no longer have to put the gen-rb folder in $:

Author: Kevin Ballard <kevin@rapleaf.com>


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@671963 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index 786c9cd..3012ab8 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -205,7 +205,7 @@
   f_consts_ <<
     rb_autogen_comment() << endl <<
     rb_imports() << endl <<
-    "require '" << program_name_ << "_types'" << endl <<
+    "require File.dirname(__FILE__) + '/" << program_name_ << "_types'" << endl <<
     endl;
     begin_namespace(f_consts_, ruby_modules(program_));
 
@@ -218,7 +218,7 @@
   const vector<t_program*>& includes = program_->get_includes();
   string result = "";
   for (size_t i = 0; i < includes.size(); ++i) {
-    result += "require '" + includes[i]->get_name() + "_types'\n";
+    result += "require File.dirname(__FILE__) + '/" + includes[i]->get_name() + "_types'\n";
   }
   if (includes.size() > 0) {
     result += "\n";
@@ -590,7 +590,7 @@
   }
 
   f_service_ <<
-    "require '" << program_name_ << "_types'" << endl <<
+    "require File.dirname(__FILE__) + '/" << program_name_ << "_types'" << endl <<
     endl;
 
   begin_namespace(f_service_, ruby_modules(tservice->get_program()));
diff --git a/lib/rb/benchmark/gen-rb/BenchmarkService.rb b/lib/rb/benchmark/gen-rb/BenchmarkService.rb
index c66f8c0..42c8aec 100644
--- a/lib/rb/benchmark/gen-rb/BenchmarkService.rb
+++ b/lib/rb/benchmark/gen-rb/BenchmarkService.rb
@@ -6,7 +6,7 @@
 
 require 'thrift'
 require 'thrift/protocol'
-require 'Benchmark_types'
+require File.dirname(__FILE__) + '/Benchmark_types'
 
     module ThriftBenchmark
       module BenchmarkService
diff --git a/lib/rb/benchmark/gen-rb/Benchmark_constants.rb b/lib/rb/benchmark/gen-rb/Benchmark_constants.rb
index a183531..33cfbe9 100644
--- a/lib/rb/benchmark/gen-rb/Benchmark_constants.rb
+++ b/lib/rb/benchmark/gen-rb/Benchmark_constants.rb
@@ -5,7 +5,7 @@
 #
 
 require 'thrift/protocol'
-require 'Benchmark_types'
+require File.dirname(__FILE__) + '/Benchmark_types'
 
   module ThriftBenchmark
 end
diff --git a/lib/rb/spec/gen-rb/NonblockingService.rb b/lib/rb/spec/gen-rb/NonblockingService.rb
index 43273ec..5893f74 100644
--- a/lib/rb/spec/gen-rb/NonblockingService.rb
+++ b/lib/rb/spec/gen-rb/NonblockingService.rb
@@ -6,7 +6,7 @@
 
 require 'thrift'
 require 'thrift/protocol'
-require 'ThriftSpec_types'
+require File.dirname(__FILE__) + '/ThriftSpec_types'
 
     module SpecNamespace
       module NonblockingService
diff --git a/lib/rb/spec/gen-rb/ThriftSpec_constants.rb b/lib/rb/spec/gen-rb/ThriftSpec_constants.rb
index 2fc84fa..973501c 100644
--- a/lib/rb/spec/gen-rb/ThriftSpec_constants.rb
+++ b/lib/rb/spec/gen-rb/ThriftSpec_constants.rb
@@ -5,7 +5,7 @@
 #
 
 require 'thrift/protocol'
-require 'ThriftSpec_types'
+require File.dirname(__FILE__) + '/ThriftSpec_types'
 
   module SpecNamespace
 end
diff --git a/lib/rb/spec/nonblockingserver_spec.rb b/lib/rb/spec/nonblockingserver_spec.rb
index ae7fe2c..0eed1dd 100644
--- a/lib/rb/spec/nonblockingserver_spec.rb
+++ b/lib/rb/spec/nonblockingserver_spec.rb
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/spec_helper'
 require 'thrift/server/nonblockingserver'
-require 'NonblockingService'
+require File.dirname(__FILE__) + '/gen-rb/NonblockingService'
 
 class ThriftNonblockingServerSpec < Spec::ExampleGroup
   include Thrift
diff --git a/lib/rb/spec/serializer_spec.rb b/lib/rb/spec/serializer_spec.rb
index 57e20ab..fe5a86a 100644
--- a/lib/rb/spec/serializer_spec.rb
+++ b/lib/rb/spec/serializer_spec.rb
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/spec_helper'
 require 'thrift/serializer'
-require 'ThriftSpec_types'
+require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
 
 class ThriftSerializerSpec < Spec::ExampleGroup
   include Thrift
diff --git a/lib/rb/spec/spec_helper.rb b/lib/rb/spec/spec_helper.rb
index 9498d2a..874ed2d 100644
--- a/lib/rb/spec/spec_helper.rb
+++ b/lib/rb/spec/spec_helper.rb
@@ -13,7 +13,6 @@
 end
 
 require File.dirname(__FILE__) + '/../lib/thrift'
-$:.unshift File.dirname(__FILE__) + "/gen-rb"
 
 class Object
   # tee is a useful method, so let's let our tests have it
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index 6dd2868..eb0542b 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -1,5 +1,5 @@
 require File.dirname(__FILE__) + '/spec_helper'
-require "ThriftSpec_types"
+require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
 
 class ThriftStructSpec < Spec::ExampleGroup
   include Thrift
diff --git a/lib/rb/spec/types_spec.rb b/lib/rb/spec/types_spec.rb
index 15ffe5c..4c2b4ea 100644
--- a/lib/rb/spec/types_spec.rb
+++ b/lib/rb/spec/types_spec.rb
@@ -1,5 +1,5 @@
 require File.dirname(__FILE__) + '/spec_helper'
-require 'ThriftSpec_types'
+require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
 
 class ThriftTypesSpec < Spec::ExampleGroup
   include Thrift