yeah, you're correct, I was just posting a correction to myself. You get the path relative to the pwd - which would let us do something like this:
require 'fileutils' module Kernel def boot relpath caller_file = File.join FileUtils.pwd, caller[0].split(/:in/)[0] caller_dir = File.dirname caller_file target = File.expand_path File.join(caller_dir, relpath) require target end def libs *relpaths caller_file = File.join FileUtils.pwd, caller[0].split(/:in/)[0] caller_dir = File.dirname caller_file paths.flatten.each do |path| $:.unshift File.expand_path(File.join(caller_dir, path)) end end end If we could bung this in site_ruby or a gem, it might be something ... On Wed, Dec 23, 2009 at 11:15 AM, Bodaniel Jeanes <m...@bjeanes.com> wrote: > Huh? You do get the full path when you call `caller`. e.g.: > > ["/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/core_ext/instance_exec.rb:48:in > `instance_exec'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/core_ext/instance_exec.rb:48:in > `cucumber_instance_exec'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/core_ext/instance_exec.rb:69:in > `cucumber_run_with_backtrace_filtering'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/core_ext/instance_exec.rb:36:in > `cucumber_instance_exec'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/rb_support/rb_step_definition.rb:55:in > `invoke'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/step_match.rb:24:in > `invoke'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/step_invocation.rb:58:in > `invoke'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/step_invocation.rb:37:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:99:in > `visit_step'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:164:in > `broadcast'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:98:in > `visit_step'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/step_collection.rb:15:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/step_collection.rb:14:in > `each'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/step_collection.rb:14:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:93:in > `visit_steps'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:164:in > `broadcast'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:92:in > `visit_steps'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/scenario.rb:45:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/step_mother.rb:195:in > `before_and_after'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/scenario.rb:43:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/scenario.rb:98:in > `with_visitor'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/scenario.rb:37:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:51:in > `visit_feature_element'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:164:in > `broadcast'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:50:in > `visit_feature_element'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/feature.rb:25:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/feature.rb:24:in > `each'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/feature.rb:24:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:20:in > `visit_feature'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:164:in > `broadcast'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:19:in > `visit_feature'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/features.rb:29:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/features.rb:17:in > `each'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/features.rb:17:in > `each'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/features.rb:28:in > `accept'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:14:in > `visit_features'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:164:in > `broadcast'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/ast/tree_walker.rb:13:in > `visit_features'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/cli/main.rb:55:in > `execute!'", > "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/../lib/cucumber/cli/main.rb:24:in > `execute'", "/Library/Ruby/Gems/1.8/gems/cucumber-0.4.3/bin/cucumber:8", > "/usr/bin/cucumber:19:in `load'", "/usr/bin/cucumber:19"] > > > On Wed, Dec 23, 2009 at 10:01 AM, David Lee > <deathtoallfanat...@gmail.com>wrote: > >> yeah, but you can't get the path, which defeats the purpose. >> >> On a slightly related note, here's a pretty good explanation of autoload, >> which I didn't really know about, and which solves a different problem not >> uncommon outside of rails projects: >> >> http://talklikeaduck.denhaven2.com/2009/04/06/all-that-you-might-require >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby or Rails Oceania" group. >> To post to this group, send email to rails-ocea...@googlegroups.com. >> To unsubscribe from this group, send email to >> rails-oceania+unsubscr...@googlegroups.com<rails-oceania%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/rails-oceania?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to rails-ocea...@googlegroups.com. > To unsubscribe from this group, send email to > rails-oceania+unsubscr...@googlegroups.com<rails-oceania%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > -- cheers, David Lee -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to rails-ocea...@googlegroups.com. To unsubscribe from this group, send email to rails-oceania+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.