Commit 3f308597d4f1368b986f28f0e6b323504e313e4a

renamed Go to Rubygem; moved code into library

Commit diff

Commands/Go to External File-RubyGem

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/go_to_external.rb"
10
11GoToExternal.run</string>
12 <key>fallbackInput</key>
13 <string>word</string>
14 <key>input</key>
15 <string>document</string>
16 <key>keyEquivalent</key>
17 <string>~G</string>
18 <key>name</key>
19 <string>Go to External File/RubyGem</string>
20 <key>output</key>
21 <string>showAsTooltip</string>
22 <key>uuid</key>
23 <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string>
24</dict>
25</plist>
toggle raw diff

Commands/Go to rubygem.tmCommand

 
0<?xml version="1.0" encoding="UTF-8"?>
1<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2<plist version="1.0">
3<dict>
4 <key>beforeRunningCommand</key>
5 <string>nop</string>
6 <key>command</key>
7 <string>#!/usr/bin/env ruby
8
9require 'rubygems'
10
11target_gem = ENV['TM_CURRENT_WORD']
12if gem_spec = Gem.source_index.find_name(target_gem).last
13 gem_path = gem_spec.full_gem_path
14 %x{open -a TextMate #{gem_path}}
15else
16 puts "No RubyGem with name '#{target_gem}'"
17end</string>
18 <key>fallbackInput</key>
19 <string>word</string>
20 <key>input</key>
21 <string>document</string>
22 <key>keyEquivalent</key>
23 <string>~G</string>
24 <key>name</key>
25 <string>Go to RubyGem</string>
26 <key>output</key>
27 <string>showAsTooltip</string>
28 <key>uuid</key>
29 <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string>
30</dict>
31</plist>
toggle raw diff

Support/lib/go_to_external.rb

 
1require 'rubygems'
2$:.unshift "#{ENV['TM_BUNDLE_SUPPORT']}/lib"
3require "grep_helpers"
4# DEMO TARGET: require 'hpricot'
5
16class GoToExternal
27 # Returns the path of the project or file that best
38 # matches the context of where the cursor/caret is currently
49 def self.run
5
10 target_gem = ENV['TM_CURRENT_WORD']
11 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}}
14 else
15 puts "No RubyGem with name '#{target_gem}'"
16 end
617 end
718end
toggle raw diff