public
Fork of timcharper/rubyamp
Description: TextMate bundle - Amplified Mate Productivity
Homepage: http://code.leadmediapartners.com/tools/rubyamp
Clone URL: git://github.com/drnic/rubyamp.git
go_to_external: works for 'ruby-debug' now
drnic (author)
Thu Apr 17 01:55:31 -0700 2008
commit  23aa93a395409e852e03554b54ef65851668d252
tree    3f64df541b669bb7013de84c743f5dac921b0070
parent  3f308597d4f1368b986f28f0e6b323504e313e4a
...
1
2
 
3
4
 
 
5
6
 
 
7
8
9
10
 
 
11
12
13
 
 
14
15
16
17
 
 
 
 
 
 
 
18
19
...
1
2
3
4
5
6
7
8
 
9
10
11
12
 
 
13
14
15
 
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -1,18 +1,29 @@
0
 require 'rubygems'
0
 $:.unshift "#{ENV['TM_BUNDLE_SUPPORT']}/lib"
0
+require "ruby_tm_helpers"
0
 require "grep_helpers"
0
 # DEMO TARGET: require 'hpricot'
0
+# DEMO TARGET: require 'ruby-debug'
0
+# DEMO TARGET: require 'map_by_method'
0
 
0
-class GoToExternal
0
+module GoToExternal
0
+ extend self
0
   # Returns the path of the project or file that best
0
   # matches the context of where the cursor/caret is currently
0
- def self.run
0
- target_gem = ENV['TM_CURRENT_WORD']
0
+ def run
0
+ target_gem = target_term #ENV['TM_CURRENT_WORD']
0
     if gem_spec = Gem.source_index.find_name(target_gem).last
0
- gem_path = gem_spec.full_gem_path
0
- %x{open -a TextMate #{gem_path}}
0
+ gem_path = gem_spec.full_gem_path
0
+ tm_open gem_path
0
     else
0
       puts "No RubyGem with name '#{target_gem}'"
0
     end
0
   end
0
+
0
+ def target_term
0
+ filepath = tm_expanded_selection(
0
+ :backward => /[\w\/.-]+/,
0
+ :forward => /[\w\/.-]+/
0
+ ).strip
0
+ end
0
 end
0
\ No newline at end of file
...
42
43
44
45
 
46
47
48
49
 
50
51
52
...
58
59
60
61
 
62
63
64
...
67
68
69
70
 
71
72
 
73
74
75
 
 
76
77
78
79
 
80
81
82
 
83
84
85
...
42
43
44
 
45
46
47
48
 
49
50
51
52
...
58
59
60
 
61
62
63
64
...
67
68
69
 
70
71
 
72
73
 
 
74
75
76
77
78
 
79
80
81
 
82
83
84
85
0
@@ -42,11 +42,11 @@ def tm_open(file, options = {})
0
     file = $1
0
     line = $2
0
   end
0
-
0
+
0
   unless /^\//.match(file)
0
     file = File.join((ENV['TM_PROJECT_DIRECTORY'] || Dir.pwd), file)
0
   end
0
-
0
+
0
   args = []
0
   args << "-w" if wait
0
   args << e_sh(file)
0
@@ -58,7 +58,7 @@ end
0
 def tm_expanded_selection(options = {})
0
   text=ENV['TM_SELECTED_TEXT'].to_s
0
   return text unless text.empty?
0
-
0
+
0
   options = {
0
     :input_type => :doc,
0
     :input => nil,
0
@@ -67,19 +67,19 @@ def tm_expanded_selection(options = {})
0
     :line_number => ENV['TM_LINE_NUMBER'].to_i,
0
     :col_number => ENV['TM_COLUMN_NUMBER'].to_i
0
   }.merge(options)
0
-
0
+
0
   col_number, line_number = options[:col_number], options[:line_number]
0
-
0
+
0
   doc = options[:input] ||= $stdin.read
0
-
0
- line =
0
+
0
+ line =
0
     case options[:input_type]
0
     when :doc then doc.split("\n")[line_number - 1]
0
     when :line then doc
0
- else
0
+ else
0
       raise "Can't handle input_type #{options[:input_type]} for tm_expanded_selection"
0
     end
0
-
0
+
0
   last_part = line[ (col_number - 1)..-1]
0
   first_part = line[ 0..col_number - 2]
0
 

Comments

    No one has commented yet.