[ANN] Rushmate
On and off over the last few months I have been using rush. Basically, rush is a replacement for the unix shell (bash, zsh, etc) which uses pure Ruby syntax. It adds a lot of convenience to the commandline for people familiar with ruby.
It brings pure ruby syntax to searching (grep), copying files, killing processes, changing permissions and globbing. You can even do all this remotely and it still feels like you are working locally. Here is a quick example.
rush> myproject => localhost:/Users/schlueter/myproject rush> myproject["**/*.rb"].search(/class Bill/).mate
This will open up all the files that contain the string “class Bill” in TextMate. You could just do a find in project in this instance but, with this you can target certain files quicker.
I recently started writing a Textmate command and really wanted to use a few things in rush.
That us why I am announcing Rushmate, the first gem I have written individually. Rushmate provides a Command object that allows you to seamlessly go back and forth between Textmate and rush. It adds a few accessors for TextMate Environment variables so you can access the project dir, current word, etc.
Here is a quick example:
#!/usr/bin/env ruby
require 'rubygems'
require 'rushmate'
Rushmate::Command.new {
# find ruby files with the current word in textmate
found_files = project_directory[
"**/#{current_word.downcase}.rb"]
if found_files.empty?
# if you can't find any files show a tool tip
exit.show_tool_tip(
"can't find #{current_word.downcase}.rb in project")
else
if found_files.size == 1
# if there is only 1 file go ahead and switch to that file
found_files.mate
else
# if there are multiple files prompt the user for
# which file they want to switch to
# then switch to their selection
menu_files = found_files.collect {
|f| f.full_path.gsub(project_directory.full_path, "")
}
project_directory[
user_input.quick_menu_from_array(menu_files)
].mate
end
end
}
It is pretty well commented, but basically it looks at the current word in TextMate then tries to find a ruby file with that name and switch to it. If it finds multiple files with that name, it puts a little menu up and waits for the user to select.
For more information on Rushmate you can view the rdoc online.


