| |   |
| 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 |
| 9 | require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/go_to_external.rb" |
| 10 | |
| 11 | GoToExternal.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 |
--- /dev/null
+++ b/Commands/Go to External File-RubyGem.tmCommand
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env ruby
+require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/go_to_external.rb"
+
+GoToExternal.run</string>
+ <key>fallbackInput</key>
+ <string>word</string>
+ <key>input</key>
+ <string>document</string>
+ <key>keyEquivalent</key>
+ <string>~G</string>
+ <key>name</key>
+ <string>Go to External File/RubyGem</string>
+ <key>output</key>
+ <string>showAsTooltip</string>
+ <key>uuid</key>
+ <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string>
+</dict>
+</plist> |
| |   |
| 1 | require 'rubygems' |
| 2 | require 'rake' |
| 3 | require 'rake/testtask' |
| 4 | |
| 5 | APP_NAME='RubyAMP.tmbundle' |
| 6 | APP_ROOT=File.dirname(__FILE__) |
| 7 | |
| 8 | RUBY_APP='ruby' |
| 9 | |
| 10 | desc "TMBundle Test Task" |
| 11 | task :default => [ :test ] |
| 12 | Rake::TestTask.new { |t| |
| 13 | t.libs << "test" |
| 14 | t.pattern = 'Support/test/test_*.rb' |
| 15 | t.verbose = true |
| 16 | t.warning = false |
| 17 | } |
| 18 | Dir['Support/tasks/**/*.rake'].each { |file| load file } |
| toggle raw diff |
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,18 @@
+require 'rubygems'
+require 'rake'
+require 'rake/testtask'
+
+APP_NAME='RubyAMP.tmbundle'
+APP_ROOT=File.dirname(__FILE__)
+
+RUBY_APP='ruby'
+
+desc "TMBundle Test Task"
+task :default => [ :test ]
+Rake::TestTask.new { |t|
+ t.libs << "test"
+ t.pattern = 'Support/test/test_*.rb'
+ t.verbose = true
+ t.warning = false
+}
+Dir['Support/tasks/**/*.rake'].each { |file| load file } |
| |   |
| 1 | require 'rubygems' |
| 2 | $:.unshift "#{ENV['TM_BUNDLE_SUPPORT']}/lib" |
| 3 | require "ruby_tm_helpers" |
| 4 | require "grep_helpers" |
| 5 | # DEMO TARGET: require 'hpricot' |
| 6 | # DEMO TARGET: require 'ruby-debug' |
| 7 | # DEMO TARGET: require 'map_by_method' |
| 8 | |
| 9 | module GoToExternal |
| 10 | extend self |
| 11 | # Returns the path of the project or file that best |
| 12 | # matches the context of where the cursor/caret is currently |
| 13 | def run |
| 14 | target_gem = target_term #ENV['TM_CURRENT_WORD'] |
| 15 | if gem_spec = Gem.source_index.find_name(target_gem).last |
| 16 | gem_path = gem_spec.full_gem_path |
| 17 | tm_open gem_path |
| 18 | else |
| 19 | puts "No RubyGem with name '#{target_gem}'" |
| 20 | end |
| 21 | end |
| 22 | |
| 23 | def target_term |
| 24 | filepath = tm_expanded_selection( |
| 25 | :backward => /[\w\/.-]+/, |
| 26 | :forward => /[\w\/.-]+/ |
| 27 | ).strip |
| 28 | end |
| 29 | end |
| toggle raw diff |
--- /dev/null
+++ b/Support/lib/go_to_external.rb
@@ -0,0 +1,29 @@
+require 'rubygems'
+$:.unshift "#{ENV['TM_BUNDLE_SUPPORT']}/lib"
+require "ruby_tm_helpers"
+require "grep_helpers"
+# DEMO TARGET: require 'hpricot'
+# DEMO TARGET: require 'ruby-debug'
+# DEMO TARGET: require 'map_by_method'
+
+module GoToExternal
+ extend self
+ # Returns the path of the project or file that best
+ # matches the context of where the cursor/caret is currently
+ def run
+ target_gem = target_term #ENV['TM_CURRENT_WORD']
+ if gem_spec = Gem.source_index.find_name(target_gem).last
+ gem_path = gem_spec.full_gem_path
+ tm_open gem_path
+ else
+ puts "No RubyGem with name '#{target_gem}'"
+ end
+ end
+
+ def target_term
+ filepath = tm_expanded_selection(
+ :backward => /[\w\/.-]+/,
+ :forward => /[\w\/.-]+/
+ ).strip
+ end
+end
\ No newline at end of file |
| |   |
| 42 | 42 | file = $1 |
| 43 | 43 | line = $2 |
| 44 | 44 | end |
| 45 | | |
| 45 | |
| 46 | 46 | unless /^\//.match(file) |
| 47 | 47 | file = File.join((ENV['TM_PROJECT_DIRECTORY'] || Dir.pwd), file) |
| 48 | 48 | end |
| 49 | | |
| 49 | |
| 50 | 50 | args = [] |
| 51 | 51 | args << "-w" if wait |
| 52 | 52 | args << e_sh(file) |
| … | … | |
| 58 | 58 | def tm_expanded_selection(options = {}) |
| 59 | 59 | text=ENV['TM_SELECTED_TEXT'].to_s |
| 60 | 60 | return text unless text.empty? |
| 61 | | |
| 61 | |
| 62 | 62 | options = { |
| 63 | 63 | :input_type => :doc, |
| 64 | 64 | :input => nil, |
| … | … | |
| 67 | 67 | :line_number => ENV['TM_LINE_NUMBER'].to_i, |
| 68 | 68 | :col_number => ENV['TM_COLUMN_NUMBER'].to_i |
| 69 | 69 | }.merge(options) |
| 70 | | |
| 70 | |
| 71 | 71 | col_number, line_number = options[:col_number], options[:line_number] |
| 72 | | |
| 72 | |
| 73 | 73 | doc = options[:input] ||= $stdin.read |
| 74 | | |
| 75 | | line = |
| 74 | |
| 75 | line = |
| 76 | 76 | case options[:input_type] |
| 77 | 77 | when :doc then doc.split("\n")[line_number - 1].to_s |
| 78 | 78 | when :line then doc |
| 79 | | else |
| 79 | else |
| 80 | 80 | raise "Can't handle input_type #{options[:input_type]} for tm_expanded_selection" |
| 81 | 81 | end |
| 82 | | |
| 82 | |
| 83 | 83 | last_part = line[ (col_number - 1)..-1] |
| 84 | 84 | first_part = line[ 0..col_number - 2] |
| 85 | 85 | |
| toggle raw diff |
--- a/Support/lib/ruby_tm_helpers.rb
+++ b/Support/lib/ruby_tm_helpers.rb
@@ -42,11 +42,11 @@ def tm_open(file, options = {})
file = $1
line = $2
end
-
+
unless /^\//.match(file)
file = File.join((ENV['TM_PROJECT_DIRECTORY'] || Dir.pwd), file)
end
-
+
args = []
args << "-w" if wait
args << e_sh(file)
@@ -58,7 +58,7 @@ end
def tm_expanded_selection(options = {})
text=ENV['TM_SELECTED_TEXT'].to_s
return text unless text.empty?
-
+
options = {
:input_type => :doc,
:input => nil,
@@ -67,19 +67,19 @@ def tm_expanded_selection(options = {})
:line_number => ENV['TM_LINE_NUMBER'].to_i,
:col_number => ENV['TM_COLUMN_NUMBER'].to_i
}.merge(options)
-
+
col_number, line_number = options[:col_number], options[:line_number]
-
+
doc = options[:input] ||= $stdin.read
-
- line =
+
+ line =
case options[:input_type]
when :doc then doc.split("\n")[line_number - 1].to_s
when :line then doc
- else
+ else
raise "Can't handle input_type #{options[:input_type]} for tm_expanded_selection"
end
-
+
last_part = line[ (col_number - 1)..-1]
first_part = line[ 0..col_number - 2]
|
| |   |
| 13 | 13 | <string>C2B791CB-A363-4795-8722-B13D1AC082E9</string> |
| 14 | 14 | <string>5A794E77-05F6-4BF9-A2C3-C43D81FA35E6</string> |
| 15 | 15 | <string>110CE952-DD36-476D-BC13-48B3D906334D</string> |
| 16 | | <string>7B7488CD-ACC9-49F9-BE91-B3150326C3D0</string> |
| 17 | 16 | <string>5011F1E1-74CF-4D63-B901-1E2FB7760AFE</string> |
| 18 | 17 | <string>C3447304-B1F3-4500-9F00-B025D9520BB0</string> |
| 19 | 18 | <string>7BEFC54B-D3FD-4B88-916A-2E80304D5CD2</string> |
| 20 | 19 | <string>3E287237-8082-4068-8B31-0F814338710E</string> |
| 20 | <string>90E13791-96CC-4380-8344-48EB84D9E616</string> |
| 21 | <string>6472BE24-D59B-46E3-A2AC-8B6B15621C9D</string> |
| 21 | 22 | </array> |
| 22 | 23 | <key>submenus</key> |
| 23 | 24 | <dict> |
| … | … | |
| 46 | 46 | <string>E2D2F075-81CE-4604-9813-A08145995F96</string> |
| 47 | 47 | <string>23D5F39E-73CA-43FC-90B3-18BDBEDDD56B</string> |
| 48 | 48 | <string>7443155B-3A9B-4B0A-8D3D-0B533B3B9125</string> |
| 49 | <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string> |
| 49 | 50 | </array> |
| 50 | 51 | <key>name</key> |
| 51 | 52 | <string>Quick - Navigate</string> |
| … | … | |
| 99 | 99 | <string>E2D2F075-81CE-4604-9813-A08145995F96</string> |
| 100 | 100 | <string>23D5F39E-73CA-43FC-90B3-18BDBEDDD56B</string> |
| 101 | 101 | <string>7443155B-3A9B-4B0A-8D3D-0B533B3B9125</string> |
| 102 | <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string> |
| 102 | 103 | <string>5011F1E1-74CF-4D63-B901-1E2FB7760AFE</string> |
| 103 | 104 | <string>C3447304-B1F3-4500-9F00-B025D9520BB0</string> |
| 104 | 105 | <string>7BEFC54B-D3FD-4B88-916A-2E80304D5CD2</string> |
| 105 | 106 | <string>3E287237-8082-4068-8B31-0F814338710E</string> |
| 107 | <string>6472BE24-D59B-46E3-A2AC-8B6B15621C9D</string> |
| 106 | 108 | </array> |
| 107 | 109 | <key>uuid</key> |
| 108 | 110 | <string>90A97C0D-E305-4C84-93E4-DCFB2113820E</string> |
| toggle raw diff |
--- a/info.plist
+++ b/info.plist
@@ -13,11 +13,12 @@
<string>C2B791CB-A363-4795-8722-B13D1AC082E9</string>
<string>5A794E77-05F6-4BF9-A2C3-C43D81FA35E6</string>
<string>110CE952-DD36-476D-BC13-48B3D906334D</string>
- <string>7B7488CD-ACC9-49F9-BE91-B3150326C3D0</string>
<string>5011F1E1-74CF-4D63-B901-1E2FB7760AFE</string>
<string>C3447304-B1F3-4500-9F00-B025D9520BB0</string>
<string>7BEFC54B-D3FD-4B88-916A-2E80304D5CD2</string>
<string>3E287237-8082-4068-8B31-0F814338710E</string>
+ <string>90E13791-96CC-4380-8344-48EB84D9E616</string>
+ <string>6472BE24-D59B-46E3-A2AC-8B6B15621C9D</string>
</array>
<key>submenus</key>
<dict>
@@ -45,6 +46,7 @@
<string>E2D2F075-81CE-4604-9813-A08145995F96</string>
<string>23D5F39E-73CA-43FC-90B3-18BDBEDDD56B</string>
<string>7443155B-3A9B-4B0A-8D3D-0B533B3B9125</string>
+ <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string>
</array>
<key>name</key>
<string>Quick - Navigate</string>
@@ -97,10 +99,12 @@
<string>E2D2F075-81CE-4604-9813-A08145995F96</string>
<string>23D5F39E-73CA-43FC-90B3-18BDBEDDD56B</string>
<string>7443155B-3A9B-4B0A-8D3D-0B533B3B9125</string>
+ <string>5DB5FB44-7052-4D3C-8FB8-2B950BEBC6AE</string>
<string>5011F1E1-74CF-4D63-B901-1E2FB7760AFE</string>
<string>C3447304-B1F3-4500-9F00-B025D9520BB0</string>
<string>7BEFC54B-D3FD-4B88-916A-2E80304D5CD2</string>
<string>3E287237-8082-4068-8B31-0F814338710E</string>
+ <string>6472BE24-D59B-46E3-A2AC-8B6B15621C9D</string>
</array>
<key>uuid</key>
<string>90A97C0D-E305-4C84-93E4-DCFB2113820E</string> |