Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
edgar committed Oct 27, 2012
0 parents commit f973c09
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Main.sublime-menu
@@ -0,0 +1,45 @@
[
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "RubyCheckOnSave",
"children":
[
{
"command": "open_file",
"args": {"file": "${packages}/RubyCheckOnSave/README.md"},
"caption": "README"
},
{
"command": "open_file",
"args": {"file": "${packages}/RubyCheckOnSave/changelog.txt"},
"caption": "Change Log"
},
{ "caption": "-" },
{
"command": "open_file",
"args": {"file": "${packages}/RubyCheckOnSave/RubyCheckOnSave.sublime-settings"},
"caption": "Settings – Default"
},
{
"command": "open_file",
"args": {"file": "${packages}/User/RubyCheckOnSave.sublime-settings"},
"caption": "Settings – User"
}
]
}
]
}
]
}
]
56 changes: 56 additions & 0 deletions README.md
@@ -0,0 +1,56 @@
RubyCheckOnSave Sublime Text 2 Plugin
=========++==========================

This simple plugin checks the syntax of ruby files when they're saved.

Installation
------------

**Without Git:** Download the latest source from [GitHub](https://github.com/edgar/RubyCheckOnSave) and copy the RubyCheckOnSave folder to your Sublime Text 2 "Packages" directory.

**With Git:** Clone the repository in your Sublime Text 2 "Packages" directory:

git clone git://github.com/edgar/RubyCheckOnSave.git


The "Packages" directory is located at:

* OS X:

~/Library/Application Support/Sublime Text 2/Packages/

* Linux:

~/.config/sublime-text-2/Packages/

* Windows:

%APPDATA%/Sublime Text 2/Packages/


Configuration
-------------

There are a number of configuration options available to customize the behavior of RubyCheckOnSave. For the latest information on what options are available, select the menu item `Preferences->Package Settings->RubyCheckOnSave->Settings - Default`.

Do **NOT** edit the default RubyCheckOnSave settings. Your changes will be lost when RubyCheckOnSave is updated. ALWAYS edit the user RubyCheckOnSave settings by selecting `Preferences->Package Settings->SublimeLinter->Settings - User`.

If you are using rvm or rbenv, you will probably have to specify the full path to the ruby you are using in the `ruby_check_on_save_cmd` setting.

### Per project

SublimeLinter supports per-project settings. This is useful if you work with several projects that requires different ruby interpreters. To edit your project settings, select the menu item `Project->Edit Project`. If there is no `settings` object at the top level, add one and then add the `ruby_check_on_save_cmd` setting, like this:

{
"folders":
[
{
"path": "/Users/edgar/sandboxes/repo"
}
],
"settings":
{
"ruby_check_on_save_cmd": "/Users/edgar/.rvm/rubies/ruby-1.9.3-p194/bin/ruby"
}
}

14 changes: 14 additions & 0 deletions RubyCheckOnSave.py
@@ -0,0 +1,14 @@
import sublime, sublime_plugin

class RubyCheckOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
if view.file_name()[-3:] == '.rb':
view.window().run_command("ruby_check_on_save", {"saving": True})

class RubyCheckOnSaveCommand(sublime_plugin.TextCommand):
def run(self, edit, saving=False):
view = self.view
global_settings = sublime.load_settings(__name__ + '.sublime-settings')
cmd_setting = 'ruby_check_on_save_cmd'
ruby = view.settings().get(cmd_setting, global_settings.get(cmd_setting))
view.window().run_command("exec", {"cmd": [ruby, "-cw", view.file_name()]})
Binary file added RubyCheckOnSave.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions RubyCheckOnSave.sublime-settings
@@ -0,0 +1,6 @@
/*
RubySyntaxCheck default settings
*/
{
"ruby_check_on_save_cmd": "/usr/bin/ruby"
}

0 comments on commit f973c09

Please sign in to comment.