diff --git a/DragCommands/Require Rails File.tmDragCommand b/DragCommands/Require Rails File.tmDragCommand new file mode 100644 index 0000000..72494dd --- /dev/null +++ b/DragCommands/Require Rails File.tmDragCommand @@ -0,0 +1,41 @@ + + + + + beforeRunningCommand + nop + command + #!/usr/bin/env ruby + +file_path = ENV['TM_DROPPED_FILE'].gsub(/\.rb$/, '') +full_file_path = File.expand_path(file_path) +relative_path = nil +known_load_path = %w[app/controllers app/models app/helpers app config lib] +known_load_path.each do |path| + if full_file_path =~ %r{^#{File.join(ENV['TM_PROJECT_DIRECTORY'], path)}/(.*)} + relative_path = $1 + break + end +end +if relative_path + puts "require '#{relative_path}'" +else + puts "require File.dirname(__FILE__) + '/#{file_path}'" +end + + draggedFileExtensions + + rb + + input + selection + name + Require Rails File + output + insertAsSnippet + scope + source.ruby.rails + uuid + 56151E60-589F-4CE7-8062-3E087732E2F1 + + diff --git a/info.plist b/info.plist index b26e65f..7c698fb 100644 --- a/info.plist +++ b/info.plist @@ -844,6 +844,7 @@ D54FBDED-5481-4CC7-B75F-66465A499882 87EF33FE-E918-11DC-A399-00112475D960 C0FD2646-E924-11DC-A399-00112475D960 + 56151E60-589F-4CE7-8062-3E087732E2F1 uuid 467A60E0-6227-11D9-BFB1-000D93589AF6