From f973c09b565022672ac2d5033031b3776038ddf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Gonza=CC=81lez?= Date: Sat, 27 Oct 2012 16:02:30 -0400 Subject: [PATCH] Initial version --- Main.sublime-menu | 45 +++++++++++++++++++++++++ README.md | 56 +++++++++++++++++++++++++++++++ RubyCheckOnSave.py | 14 ++++++++ RubyCheckOnSave.pyc | Bin 0 -> 1288 bytes RubyCheckOnSave.sublime-settings | 6 ++++ 5 files changed, 121 insertions(+) create mode 100644 Main.sublime-menu create mode 100644 README.md create mode 100644 RubyCheckOnSave.py create mode 100644 RubyCheckOnSave.pyc create mode 100644 RubyCheckOnSave.sublime-settings diff --git a/Main.sublime-menu b/Main.sublime-menu new file mode 100644 index 0000000..96ff71a --- /dev/null +++ b/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" + } + ] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5801790 --- /dev/null +++ b/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" + } + } + diff --git a/RubyCheckOnSave.py b/RubyCheckOnSave.py new file mode 100644 index 0000000..9181b50 --- /dev/null +++ b/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()]}) \ No newline at end of file diff --git a/RubyCheckOnSave.pyc b/RubyCheckOnSave.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d7dfd62914db95250d0d56eb34e38510d018b479 GIT binary patch literal 1288 zcma)6%Wl&^6uo07=>y7Jw5(8f-ZX3~Ruw{xV1)vjbVD{)Vo%bcengo`(n`rHEcrRU zfj?l6;N0sxq#_t5dgu(Vwkr$>f zmjS6lkpg-r;>O$d2iUm~X>;87kMKVR$v9z_aaqI;JU!P$VvAu^L+bYs1~xNs(aWpV znJvxtl1}fxNX6g;c{0(?^b4FCWD literal 0 HcmV?d00001 diff --git a/RubyCheckOnSave.sublime-settings b/RubyCheckOnSave.sublime-settings new file mode 100644 index 0000000..48a98f7 --- /dev/null +++ b/RubyCheckOnSave.sublime-settings @@ -0,0 +1,6 @@ +/* + RubySyntaxCheck default settings +*/ +{ + "ruby_check_on_save_cmd": "/usr/bin/ruby" +} \ No newline at end of file