Commit 3c441bbed9f6b706f1b1b88ea5865ad466a33529

go_to_external: works for 'ruby-debug' now

Commit diff

Support/lib/go_to_external.rb

 
11require 'rubygems'
22$:.unshift "#{ENV['TM_BUNDLE_SUPPORT']}/lib"
3require "ruby_tm_helpers"
34require "grep_helpers"
45# DEMO TARGET: require 'hpricot'
6# DEMO TARGET: require 'ruby-debug'
7# DEMO TARGET: require 'map_by_method'
58
6class GoToExternal
9module GoToExternal
10 extend self
711 # Returns the path of the project or file that best
812 # matches the context of where the cursor/caret is currently
9 def self.run
10 target_gem = ENV['TM_CURRENT_WORD']
13 def run
14 target_gem = target_term #ENV['TM_CURRENT_WORD']
1115 if gem_spec = Gem.source_index.find_name(target_gem).last
12 gem_path = gem_spec.full_gem_path
13 %x{open -a TextMate #{gem_path}}
16 gem_path = gem_spec.full_gem_path
17 tm_open gem_path
1418 else
1519 puts "No RubyGem with name '#{target_gem}'"
1620 end
1721 end
22
23 def target_term
24 filepath = tm_expanded_selection(
25 :backward => /[\w\/.-]+/,
26 :forward => /[\w\/.-]+/
27 ).strip
28 end
1829end
toggle raw diff

Support/lib/ruby_tm_helpers.rb

 
4242 file = $1
4343 line = $2
4444 end
45
45
4646 unless /^\//.match(file)
4747 file = File.join((ENV['TM_PROJECT_DIRECTORY'] || Dir.pwd), file)
4848 end
49
49
5050 args = []
5151 args << "-w" if wait
5252 args << e_sh(file)
5858def tm_expanded_selection(options = {})
5959 text=ENV['TM_SELECTED_TEXT'].to_s
6060 return text unless text.empty?
61
61
6262 options = {
6363 :input_type => :doc,
6464 :input => nil,
6767 :line_number => ENV['TM_LINE_NUMBER'].to_i,
6868 :col_number => ENV['TM_COLUMN_NUMBER'].to_i
6969 }.merge(options)
70
70
7171 col_number, line_number = options[:col_number], options[:line_number]
72
72
7373 doc = options[:input] ||= $stdin.read
74
75 line =
74
75 line =
7676 case options[:input_type]
7777 when :doc then doc.split("\n")[line_number - 1].to_s
7878 when :line then doc
79 else
79 else
8080 raise "Can't handle input_type #{options[:input_type]} for tm_expanded_selection"
8181 end
82
82
8383 last_part = line[ (col_number - 1)..-1]
8484 first_part = line[ 0..col_number - 2]
8585
toggle raw diff