From aa5ac96f25f6e9217f0cf196396a0cf0d3522e22 Mon Sep 17 00:00:00 2001 From: Grzegorz Smajdor Date: Fri, 8 Mar 2013 14:39:24 +0100 Subject: [PATCH] new functionality : easy create file --- Default (Linux).sublime-keymap | 3 ++- Default (OSX).sublime-keymap | 3 ++- Default (Windows).sublime-keymap | 3 ++- README.md | 3 ++- run_ruby_test.py | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Default (Linux).sublime-keymap b/Default (Linux).sublime-keymap index a38734b..08e5938 100644 --- a/Default (Linux).sublime-keymap +++ b/Default (Linux).sublime-keymap @@ -11,5 +11,6 @@ ]}, // switch between code and test in single view { "keys": ["ctrl+shift+period"], "command": "switch_between_code_and_test", "args": {"split_view": true}, "context" : [ { "key": "selector", "operator": "equal", "operand": "source.ruby", "match_all": true } - ]} // switch between code and test in split view + ]}, // switch between code and test in split view + { "keys": ["ctrl+shift+c"], "command": "generate_file" } // create new file ] \ No newline at end of file diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index 684b280..301d630 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -7,5 +7,6 @@ { "keys": ["alt+shift+v"], "command": "verify_ruby_file" }, // verify ruby syntax { "keys": ["super+period"], "command": "switch_between_code_and_test", "args": {"split_view": false} }, // switch between code and test in single mode - { "keys": ["super+ctrl+period"], "command": "switch_between_code_and_test", "args": {"split_view": true} } // switch between code and test in split view + { "keys": ["super+ctrl+period"], "command": "switch_between_code_and_test", "args": {"split_view": true} }, // switch between code and test in split view + { "keys": ["super+shift+c"], "command": "generate_file" } // create new file ] \ No newline at end of file diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap index 2a55b23..dbe8c5d 100644 --- a/Default (Windows).sublime-keymap +++ b/Default (Windows).sublime-keymap @@ -11,5 +11,6 @@ ]}, // switch between code and test in single view { "keys": ["ctrl+shift+period"], "command": "switch_between_code_and_test", "args": {"split_view": true}, "context" : [ { "key": "selector", "operator": "equal", "operand": "source.ruby", "match_all": true } - ]} // switch between code and test in split view + ]}, // switch between code and test in split view + { "keys": ["ctrl+shift+c"], "command": "generate_file" } // create new file ] \ No newline at end of file diff --git a/README.md b/README.md index 73ea78b..e0ed1eb 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ Usage - Run last ruby test(s): `Command-Shift-E` - Show test panel: `Command-Shift-X` (when test panel visible hit `esc` to hide it) - Check RB, ERB file syntax: `Alt-Shift-V` - - Switching between code and test: + - Switching between code and test (create a file if not found): - Single View: `Command-.` - Split View: `Command-Ctrl-.` + - Easy file creation: `Command-Shift-C` Keys: 'Command' (OSX) 'Ctrl' (Linux / Windows) diff --git a/run_ruby_test.py b/run_ruby_test.py index bcb9068..e460414 100644 --- a/run_ruby_test.py +++ b/run_ruby_test.py @@ -376,6 +376,21 @@ def generate(self, selection, name): finally: self.view.end_edit(edit) +class GenerateFile(BaseRubyTask): + def run(self, args): + GenerateNewFile(self.window()).doIt() + +class GenerateNewFile(GenerateTestFile): + def __init__(self, window): + self.window = window + self.split_view = False + + def is_valid_path(self, path): + return not re.search('\.\w+', path) + + def suggest_file_name(self, path): + return "" + class GenerateTestFile: relative_paths = [] full_torelative_paths = {}