├── Global.sublime-settings ├── Default (Linux).sublime-keymap ├── Default (Windows).sublime-keymap ├── .gitignore ├── Ruby.sublime-settings ├── Marked.sublime-build ├── expand_tabs_on_save.py ├── close_other_tabs.py ├── Package Control.sublime-settings ├── copy_path_to_clipboard.py ├── DetectSyntax.sublime-settings ├── Default (OSX).sublime-keymap ├── run_command.applescript ├── Preferences.sublime-settings └── rspec.py /Global.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | } 3 | -------------------------------------------------------------------------------- /Default (Linux).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | ] 3 | -------------------------------------------------------------------------------- /Default (Windows).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | ] 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.last-run 4 | -------------------------------------------------------------------------------- /Ruby.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": ["ru", "Gemfile"] 3 | } 4 | -------------------------------------------------------------------------------- /Marked.sublime-build: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["open","-a","/Applications/Marked.app","$file"], 3 | "selector": "text.html.markdown" 4 | } -------------------------------------------------------------------------------- /expand_tabs_on_save.py: -------------------------------------------------------------------------------- 1 | import sublime, sublime_plugin 2 | 3 | class ExpandTabs(sublime_plugin.EventListener): 4 | def on_pre_save(self, view): 5 | view.run_command('expand_tabs') 6 | -------------------------------------------------------------------------------- /close_other_tabs.py: -------------------------------------------------------------------------------- 1 | import sublime, sublime_plugin 2 | 3 | class CloseOtherTabs(sublime_plugin.TextCommand): 4 | def run(self, edit): 5 | window = self.view.window() 6 | group_index, view_index = window.get_view_index(self.view) 7 | window.run_command("close_others_by_index", { "group": group_index, "index": view_index}) 8 | -------------------------------------------------------------------------------- /Package Control.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "auto_upgrade_last_run": 1349405235, 3 | "installed_packages": 4 | [ 5 | "Abacus", 6 | "All Autocomplete", 7 | "CoffeeScript", 8 | "CTags", 9 | "DetectSyntax", 10 | "Git", 11 | "Package Control", 12 | "RSpec", 13 | "Ruby 1.9 Hash Converter", 14 | "Sass", 15 | "SCSS", 16 | "SideBarEnhancements", 17 | "SideBarGit", 18 | "Theme - Soda" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /copy_path_to_clipboard.py: -------------------------------------------------------------------------------- 1 | import sublime, sublime_plugin 2 | import os 3 | 4 | class CopyPathToClipboard(sublime_plugin.TextCommand): 5 | def run(self, edit): 6 | line_number, column = self.view.rowcol(self.view.sel()[0].begin()) 7 | line_number += 1 8 | path = self.view.file_name() + ":" + str(line_number) 9 | sublime.set_clipboard(path) 10 | sublime.status_message("Copied " + path) 11 | 12 | -------------------------------------------------------------------------------- /DetectSyntax.sublime-settings: -------------------------------------------------------------------------------- 1 | 2 | { 3 | // If you want exceptions reraised so you can see them in the console, change this to true. 4 | "reraise_exceptions": false, 5 | 6 | // If you want to have a syntax applied when new files are created, set new_file_syntax to the name of the syntax to use. 7 | // The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use 8 | // JavaScript syntax, set new_file_syntax to 'JavaScript'. 9 | "new_file_syntax": false, 10 | 11 | // Put your custom syntax rules here: 12 | "syntaxes": [ 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /Default (OSX).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "keys": ["super+l"], 4 | "command": "show_overlay", 5 | "args": {"overlay": "goto", "text": ":"} 6 | }, 7 | { 8 | "keys": ["ctrl+super+r"], 9 | "command": "reveal_in_side_bar" 10 | }, 11 | { 12 | "keys": ["ctrl+shift+tab"], 13 | "command": "focus_side_bar" 14 | }, 15 | { 16 | "keys": ["ctrl+tab"], 17 | "command": "focus_group", 18 | "args": {"group": 0} 19 | }, 20 | { 21 | "keys": ["super+alt+w"], 22 | "command": "close_other_tabs" 23 | }, 24 | { 25 | "keys": ["ctrl+]"], 26 | "command": "navigate_to_definition" 27 | }, 28 | { 29 | "keys": ["ctrl+shift+down"], 30 | "command": "open_rspec_file", 31 | "args": {"option": "next"} 32 | }, 33 | { 34 | "keys": ["super+shift+c"], 35 | "command": "copy_path_to_clipboard" 36 | }, 37 | { "keys": ["super+shift+v"], "command": "paste" }, 38 | { "keys": ["super+v"], "command": "paste_and_indent" }, 39 | { 40 | "keys": ["super+alt+]"], 41 | "command": "reindent", 42 | "args": { "single_line": false } 43 | }, 44 | { 45 | "keys": ["super+r"], 46 | "command": "run_tests", 47 | "args": {"single": false} 48 | }, 49 | { 50 | "keys": ["super+shift+r"], 51 | "command": "run_tests", 52 | "args": {"single": true} 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /run_command.applescript: -------------------------------------------------------------------------------- 1 | on execInNewTab(_title, _command) 2 | tell application "Terminal" 3 | activate 4 | set currentTab to do script _command 5 | set custom title of tab 1 of window 1 to _title 6 | end 7 | end execInTerminalTab 8 | 9 | on execInTerminalTab(_command, _window, _tab) 10 | tell application "Terminal" 11 | activate 12 | set frontmost of _window to true 13 | set selected of _tab to true 14 | do script "clear" in tab 1 of window 1 15 | do script _command in tab 1 of window 1 16 | end 17 | end execInTerminalTab 18 | 19 | on run argv 20 | set _command to item 1 of argv 21 | set _foundTab to false 22 | set _expected_title to (item 2 of argv) 23 | 24 | if length of argv is 2 25 | tell application "Terminal" 26 | repeat with w in windows 27 | tell w 28 | repeat with t in tabs 29 | set _title to (custom title of t) 30 | 31 | if _title = _expected_title then 32 | set _foundTab to true 33 | set _window to w 34 | set _tab to t 35 | exit repeat 36 | end if 37 | end repeat 38 | end tell 39 | 40 | if _foundTab then 41 | exit repeat 42 | end if 43 | end repeat 44 | end tell 45 | 46 | if _foundTab then 47 | execInTerminalTab(_command, _window, _tab) 48 | else 49 | execInNewTab(_expected_title, _command) 50 | end if 51 | end if 52 | end run 53 | -------------------------------------------------------------------------------- /Preferences.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "auto_complete_commit_on_tab": true, 3 | "bold_folder_labels": true, 4 | // "color_scheme": "Packages/Color Scheme - Default/Blackboard.tmTheme", 5 | "color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme", 6 | "ensure_newline_at_eof_on_save": true, 7 | "file_exclude_patterns": 8 | [ 9 | ".DS_Store", 10 | ".tags*", 11 | "*.pyc", 12 | "*.pyo", 13 | "*.exe", 14 | "*.dll", 15 | "*.obj", 16 | "*.o", 17 | "*.a", 18 | "*.lib", 19 | "*.log", 20 | "*.so", 21 | "*.dylib", 22 | "*.ncb", 23 | "*.sdf", 24 | "*.suo", 25 | "*.pdb", 26 | "*.idb", 27 | "*.class", 28 | "*.psd", 29 | "*.db", 30 | "*.pdf" 31 | ], 32 | "folder_exclude_patterns": 33 | [ 34 | "data", 35 | ".zeus.sock", 36 | ".git", 37 | ".svn", 38 | ".hg", 39 | "CVS", 40 | ".sass-cache", 41 | ".bundle", 42 | "bundle", 43 | ".rbx", 44 | "bin", 45 | "script", 46 | "tmp" 47 | ], 48 | "font_face": "Inconsolata-dz", 49 | "font_size": 22, 50 | "highlight_line": true, 51 | "highlight_modified_tabs": true, 52 | "ignored_packages": 53 | [ 54 | "Vintage" 55 | ], 56 | "line_padding_bottom": 0.5, 57 | "line_padding_top": 0.5, 58 | "new_window_settings": 59 | { 60 | "show_minimap": false 61 | }, 62 | "rulers": 63 | [ 64 | 80 65 | ], 66 | "save_on_focus_lost": true, 67 | "tab_size": 2, 68 | "theme": "Soda Light.sublime-theme", 69 | "translate_tabs_to_spaces": true, 70 | "trim_trailing_white_space_on_save": true 71 | } 72 | -------------------------------------------------------------------------------- /rspec.py: -------------------------------------------------------------------------------- 1 | import sublime 2 | import sublime_plugin 3 | import os, errno 4 | import re 5 | 6 | def get_twin_path(path): 7 | spec_file = path.find("/spec/") >= 0 8 | 9 | if spec_file: 10 | if path.find("/lib/") > 0: 11 | return path.replace("/spec/lib/","/lib/").replace("_spec.rb", ".rb") 12 | else: 13 | return path.replace("/spec/","/app/").replace("_spec.rb", ".rb") 14 | else: 15 | if path.find("/lib/") > 0: 16 | return path.replace("/lib/", "/spec/lib/").replace(".rb", "_spec.rb") 17 | else: 18 | return path.replace("/app/", "/spec/").replace(".rb", "_spec.rb") 19 | 20 | class OpenRspecFileCommand(sublime_plugin.WindowCommand): 21 | def run(self, option): 22 | self.views = [] 23 | window = self.window 24 | current_file_path = self.window.active_view().file_name() 25 | 26 | spec_file = current_file_path.find("/spec/") > 0 27 | twin_path = get_twin_path(current_file_path) 28 | path_parts = twin_path.split("/") 29 | dirname = "/".join(path_parts[0:-1]) 30 | basename = path_parts[-1] 31 | 32 | if not os.path.exists(twin_path) and sublime.ok_cancel_dialog(basename + " was not found. Create it?"): 33 | self.mkdir_p(dirname) 34 | twin_file = open(twin_path, "w") 35 | 36 | constant_name = self.camelize(basename.replace(".rb", "").replace("_spec", "")) 37 | 38 | if spec_file: 39 | twin_file.write("class " + constant_name + "\nend") 40 | else: 41 | twin_file.write("require \"spec_helper\"\n\ndescribe " + constant_name + " do\nend") 42 | twin_file.close() 43 | 44 | if os.path.exists(twin_path): 45 | view = window.open_file(twin_path) 46 | view.run_command("revert") 47 | else: 48 | sublime.status_message("Not found: " + twin_path) 49 | 50 | 51 | def mkdir_p(self, path): 52 | try: 53 | os.makedirs(path) 54 | except OSError as exc: # Python >2.5 55 | if exc.errno == errno.EEXIST: 56 | pass 57 | else: raise 58 | 59 | def camelize(self, string): 60 | return re.sub(r"(?:^|_)(.)", lambda x: x.group(0)[-1].upper(), string) 61 | 62 | class RunTests(sublime_plugin.TextCommand): 63 | def run(self, edit, single): 64 | path = self.view.file_name() 65 | 66 | if path.find("/spec/") < 0: 67 | twin_path = get_twin_path(path) 68 | if os.path.exists(twin_path): 69 | path = twin_path 70 | else: 71 | return sublime.error_message("You're not in a spec, bro.") 72 | 73 | root_path = re.sub("\/spec\/.*", "", path) 74 | 75 | if single: 76 | line_number, column = self.view.rowcol(self.view.sel()[0].begin()) 77 | line_number += 1 78 | path += ":" + str(line_number) 79 | command = "bundle exec rspec" 80 | else: 81 | command = "bundle exec rspec" 82 | 83 | cmd = 'osascript ' 84 | cmd += '"' + sublime.packages_path() + '/User/run_command.applescript"' 85 | cmd += ' "cd ' + root_path + ' && ' + command + ' ' + path + '"' 86 | cmd += ' "Ruby Tests"' 87 | os.system(cmd) 88 | --------------------------------------------------------------------------------