Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/drnic/ruby-tmbundle
Browse files Browse the repository at this point in the history
  • Loading branch information
arya committed Aug 21, 2008
2 parents 1bd2664 + 82651d5 commit 29e7ff1
Show file tree
Hide file tree
Showing 16 changed files with 334 additions and 91 deletions.
64 changes: 64 additions & 0 deletions Commands/Rake:Sake task using file path.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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 -w
unless ENV["TM_FILEPATH"]
puts &lt;&lt;-SIMPLE_SNIPPET
# NOTE: if you save this file first it will create a
# namespaced rake/sake task based on the file's
# path within the project
task ${1::${2:task_name}} do
$0
end
SIMPLE_SNIPPET
exit
end
def indent_str
"\t" * @indent
end
relative_filepath = ENV["TM_FILEPATH"].
gsub(ENV["TM_PROJECT_DIRECTORY"], '').
gsub(/^\/?/,'').
gsub(/\.[sr]ake$/, '')
task_name, *reverse_namespaces = relative_filepath.split(/[\/\\]/).reverse
namespaces = reverse_namespaces.reverse
@indent = 0
namespaces.each do |namespace|
puts "#{indent_str}namespace '#{namespace}' do"
@indent += 1
end
puts &lt;&lt;-TASK_SNIPPET
#{indent_str}${2:desc "${1:This task ...}"
#{indent_str}}task :#{task_name} do
#{indent_str} $0
#{indent_str}end
TASK_SNIPPET
reverse_namespaces.each_with_index do |namespace, index|
@indent -= 1
puts "#{indent_str}end"
end</string>
<key>fallbackInput</key>
<string>none</string>
<key>input</key>
<string>selection</string>
<key>name</key>
<string>Rake/Sake task using file path</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>task</string>
<key>uuid</key>
<string>E07FF68B-C87D-4332-8477-D026929FDADA</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Snippets/File_open(filename, 'r') { |f| f_read }.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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>content</key>
<string>File.open(${1:filename}, '${2:r}') { |${3:f}| $3.read }$0</string>
<key>name</key>
<string>File.open(filename, 'r') { |f| f.read }</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>filer</string>
<key>uuid</key>
<string>005EB926-4BFE-4BFA-93B2-C9030636289C</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Snippets/File_read(filename).tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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>content</key>
<string>File.read(${1:filename})$0</string>
<key>name</key>
<string>File.read(filename)</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>filer</string>
<key>uuid</key>
<string>FAFE9F5C-BF9C-4416-8623-2CB8EBC31B3C</string>
</dict>
</plist>
8 changes: 6 additions & 2 deletions Snippets/class .. < Test;;Unit;;TestCase .. end (tc).plist
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<string>require "test/unit"
require "${1:library_file_name}"
require "${1:`#!/usr/bin/env ruby
require 'rubygems'
require "active_support"
puts (ENV['TM_FILENAME'] || 'test_some_model.rb').gsub(/\.rb$/, '').gsub(/^test_/,'').gsub(/_test$/,'')
`}"
class Test${2:${1/([\w&amp;&amp;[^_]]+)|./\u$1/g}} &lt; Test::Unit::TestCase
def test_${3:case_name}
Expand Down
8 changes: 6 additions & 2 deletions Snippets/class .. end (cla).plist
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<string>class ${1:ClassName}
<string>class ${1:`#!/usr/bin/env ruby
require 'rubygems'
require "active_support"
puts (ENV['TM_FILENAME'] || 'some_model.rb').gsub(/\.rb$/, '').camelize.singularize
`}
$0
end</string>
<key>name</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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>content</key>
<string>require File.dirname(__FILE__) + "/test_helper"
require "${1:`#!/usr/bin/env ruby
require 'rubygems'
require "active_support"
puts (ENV['TM_FILENAME'] || 'test_some_model.rb').gsub(/\.rb$/, '').gsub(/^test_/,'').gsub(/_test$/,'')
`}"
class Test${2:${1/([\w&amp;&amp;[^_]]+)|./\u$1/g}} &lt; Test::Unit::TestCase
def test_${3:case_name}
$0
end
end</string>
<key>name</key>
<string>class .. &lt; Test::Unit::TestCase with test_helper</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>tch</string>
<key>uuid</key>
<string>228CAB3A-E221-4727-B430-31E94F76C9D3</string>
</dict>
</plist>
19 changes: 19 additions & 0 deletions Snippets/desc ___ task :name ___ end.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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>content</key>
<string>desc ${1:"$2"}
task ${3::name} do
$0
end</string>
<key>name</key>
<string>desc ... task :name ... end</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>task</string>
<key>uuid</key>
<string>FE9A8EDA-C243-4068-8F38-A615B82D08C9</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Snippets/desc ___.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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>content</key>
<string>desc ${1:"$2"}$0</string>
<key>name</key>
<string>desc ...</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>desc</string>
<key>uuid</key>
<string>F686E1AD-B03D-45A6-BD51-6E3FD1298FE0</string>
</dict>
</plist>
20 changes: 20 additions & 0 deletions Snippets/namespace :name ___ end.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>content</key>
<string>namespace ${1::name} do
$0
end</string>
<key>name</key>
<string>namespace :name ... end</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>namespace</string>
<key>uuid</key>
<string>A3D89AAA-9156-4077-A026-37BB7358C3BA</string>
</dict>
</plist>
23 changes: 23 additions & 0 deletions Snippets/namespace :name ___ task :default ___ end.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>content</key>
<string>namespace ${1::name} do
desc ${2:"${3:default task for namespace $1}"}
task :default do
$0
end
end</string>
<key>name</key>
<string>namespace :name ... task :default ... end</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>namespace</string>
<key>uuid</key>
<string>2031FC41-CBD3-41CC-B9A9-7F068E607A05</string>
</dict>
</plist>
18 changes: 18 additions & 0 deletions Snippets/task :name ___ end.tmSnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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>content</key>
<string>task ${1::name} do
$0
end</string>
<key>name</key>
<string>task :name ... end</string>
<key>scope</key>
<string>source.ruby</string>
<key>tabTrigger</key>
<string>task</string>
<key>uuid</key>
<string>CB81DA55-F3BC-4BFB-B0C5-29F0EE6F8081</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Support/RubyMate/catch_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
file, line, method = $1, $2, $3

url, display_name = '', 'untitled document';
if file != '-' && File.exists?(file) then
if file != '-' && File.exists?(file) && !ENV['TM_SCRIPT_IS_UNTITLED'] then
file = Pathname.new(file).realpath.to_s
url = '&url=file://' + e_url(file)
display_name = File.basename(file)
Expand Down
Loading

0 comments on commit 29e7ff1

Please sign in to comment.