From 2bd3a30b91ef2a4a6c54b4a030a4955a65c96bc8 Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Thu, 26 Jun 2008 17:49:49 +0000 Subject: [PATCH] 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 git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@671963 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_rb_generator.cc | 6 +++--- lib/rb/benchmark/gen-rb/BenchmarkService.rb | 2 +- lib/rb/benchmark/gen-rb/Benchmark_constants.rb | 2 +- lib/rb/spec/gen-rb/NonblockingService.rb | 2 +- lib/rb/spec/gen-rb/ThriftSpec_constants.rb | 2 +- lib/rb/spec/nonblockingserver_spec.rb | 2 +- lib/rb/spec/serializer_spec.rb | 2 +- lib/rb/spec/spec_helper.rb | 1 - lib/rb/spec/struct_spec.rb | 2 +- lib/rb/spec/types_spec.rb | 2 +- 10 files changed, 11 insertions(+), 12 deletions(-) diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc index 786c9cd7..3012ab82 100644 --- a/compiler/cpp/src/generate/t_rb_generator.cc +++ b/compiler/cpp/src/generate/t_rb_generator.cc @@ -205,7 +205,7 @@ void t_rb_generator::init_generator() { 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 @@ string t_rb_generator::render_includes() { const vector& 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 @@ void t_rb_generator::generate_service(t_service* tservice) { } 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 c66f8c0a..42c8aecf 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 a1835311..33cfbe92 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 43273ec6..5893f74c 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 2fc84faa..973501cb 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 ae7fe2ca..0eed1dd9 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 57e20aba..fe5a86af 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 9498d2a9..874ed2d1 100644 --- a/lib/rb/spec/spec_helper.rb +++ b/lib/rb/spec/spec_helper.rb @@ -13,7 +13,6 @@ module Thrift 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 6dd28682..eb0542be 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 15ffe5c2..4c2b4eab 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 -- 2.17.1