I have extended my old C/C++ headers opener to Ruby. I have associate it to Shift-Cmd-D as in the classic MPW ;)
The scope: source.ruby,text.html.ruby, source.ruby.rails.embedded.html, meta.rails.helper, meta.rails.unit_test, source.js, source.css, source.yaml, meta.rails.controller, meta.rails.functional_test, text.haml
and
#!/usr/bin/env perl
$cmd = 'ruby -e 'p $LOAD_PATH.join(":")''; $paths = `$cmd` . $ENV{'RUBYPATH'} . $ENV{'RUBY'};
$line=$ENV{'TM_CURRENT_LINE'}; $header=$ENV{'TM_SELECTED_TEXT'};
if ($header =~ /^\s*$/) { $line =~ /\s*(require|require_gem)\s*["'](.*?)["']/; $header = $2; }
# local? $t = $ENV{'TM_DIRECTORY'}; if (-f "$t/$header.rb" ) { print "$t/$header"; system("mate", "-r", "$t/$header"); exit 0; }
@incs = split(/:/, $paths);
foreach $t (@incs) { if (-f "$t/$header.rb") { print "$t/$header.rb"; system("mate", "-r", "$t/$header.rb"); exit 0; } } print "$header.rb HEADER NOT FOUND"; exit 1;
Hope this serve someone.
- jf