Avoid using Pathname to compute relative paths and instead rely on a fully expanded path

This will allow this code to work whether it's executing in a jar context or a
.rb file on the filesystem
This commit is contained in:
R. Tyler Croy 2014-10-21 15:50:38 -07:00
parent a56c54ef6b
commit e62fe44a25
2 changed files with 2 additions and 4 deletions

View File

@ -1,7 +1,6 @@
require 'java'
require 'red_storm/configurator'
require 'red_storm/environment'
require 'pathname'
java_import 'backtype.storm.tuple.Fields'
java_import 'backtype.storm.tuple.Values'
@ -140,7 +139,7 @@ module RedStorm
# below non-dry see Spout class
def self.inherited(subclass)
path = (caller.first.to_s =~ /^(.+):\d+.*$/) ? $1 : raise(BoltError, "unable to extract base topology class path from #{caller.first.inspect}")
subclass.base_class_path = Pathname.new(path).relative_path_from(Pathname.new(RedStorm::BASE_PATH)).to_s
subclass.base_class_path = File.expand_path(path)
end
def self.base_class_path=(path)

View File

@ -1,7 +1,6 @@
require 'java'
require 'red_storm/configurator'
require 'red_storm/environment'
require 'pathname'
module RedStorm
module DSL
@ -177,7 +176,7 @@ module RedStorm
# below non-dry see Bolt class
def self.inherited(subclass)
path = (caller.first.to_s =~ /^(.+):\d+.*$/) ? $1 : raise(SpoutError, "unable to extract base topology class path from #{caller.first.inspect}")
subclass.base_class_path = Pathname.new(path).relative_path_from(Pathname.new(RedStorm::BASE_PATH)).to_s
subclass.base_class_path = File.expand_path(path)
end
def self.base_class_path=(path)