Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed from Windows to UNIX line endings for consistency.

  • Loading branch information...
commit c6bc31d8e016a46d5faf8bf696234d3626be53b4 1 parent 34c92a5
@rexikan rexikan authored
View
30 Default (OSX).sublime-keymap
@@ -1,15 +1,15 @@
-[
- { "keys": ["super+alt+b"],
- "command": "exec",
- "args": {"cmd": ["rspec", "*"]},
- "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)",
- "working_dir": "${folder}"
- },
-
- { "keys": ["super+alt+period"], "command": "open_rspec_file", "args": {"option": "test_and_source"} },
- { "keys": ["super+period"], "command": "open_rspec_file", "args": {"option": "next"} },
- { "keys": ["super+alt+s"], "command": "open_rspec_file", "args": {"option": "source"} },
- { "keys": ["super+alt+t"], "command": "open_rspec_file", "args": {"option": "test"} },
-
- { "keys": ["super+alt+n"], "command": "rspec_create_module", "args": {} }
-]
+[
+ { "keys": ["super+alt+b"],
+ "command": "exec",
+ "args": {"cmd": ["rspec", "*"]},
+ "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)",
+ "working_dir": "${folder}"
+ },
+
+ { "keys": ["super+alt+period"], "command": "open_rspec_file", "args": {"option": "test_and_source"} },
+ { "keys": ["super+period"], "command": "open_rspec_file", "args": {"option": "next"} },
+ { "keys": ["super+alt+s"], "command": "open_rspec_file", "args": {"option": "source"} },
+ { "keys": ["super+alt+t"], "command": "open_rspec_file", "args": {"option": "test"} },
+
+ { "keys": ["super+alt+n"], "command": "rspec_create_module", "args": {} }
+]
View
30 Default (Windows).sublime-keymap
@@ -1,15 +1,15 @@
-[
- { "keys": ["ctrl+f7"],
- "command": "exec",
- "args": {"cmd": ["rspec.bat", "*"]},
- "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)",
- "working_dir": "${folder}"
- },
-
- { "keys": ["ctrl+alt+period"], "command": "open_rspec_file", "args": {"option": "test_and_source"} },
- { "keys": ["ctrl+period"], "command": "open_rspec_file", "args": {"option": "next"} },
- { "keys": ["ctrl+alt+s"], "command": "open_rspec_file", "args": {"option": "source"} },
- { "keys": ["ctrl+alt+t"], "command": "open_rspec_file", "args": {"option": "test"} },
-
- { "keys": ["ctrl+alt+n"], "command": "rspec_create_module", "args": {} }
-]
+[
+ { "keys": ["ctrl+f7"],
+ "command": "exec",
+ "args": {"cmd": ["rspec.bat", "*"]},
+ "file_regex": "# ([A-Za-z0-9_./ ]+rb):([0-9]+)",
+ "working_dir": "${folder}"
+ },
+
+ { "keys": ["ctrl+alt+period"], "command": "open_rspec_file", "args": {"option": "test_and_source"} },
+ { "keys": ["ctrl+period"], "command": "open_rspec_file", "args": {"option": "next"} },
+ { "keys": ["ctrl+alt+s"], "command": "open_rspec_file", "args": {"option": "source"} },
+ { "keys": ["ctrl+alt+t"], "command": "open_rspec_file", "args": {"option": "test"} },
+
+ { "keys": ["ctrl+alt+n"], "command": "rspec_create_module", "args": {} }
+]
View
122 OpenRSpecFile.py
@@ -1,61 +1,61 @@
-import sublime
-import sublime_plugin
-import re, inspect, os
-
-class OpenRspecFileCommand(sublime_plugin.WindowCommand):
-
- def run(self, option):
- if not self.window.active_view():
- return
-
- self.views = []
- window = self.window
- current_file_path = self.window.active_view().file_name()
-
- if re.search(r"\w+\.rb$", current_file_path):
-
- current_file = re.search(r"([\w\.]+)$", current_file_path).group(1)
- base_name = re.search(r"(\w+)\.(\w+)$", current_file).group(1)
- base_name = re.sub('_spec', '', base_name)
-
- source_matcher = re.compile("[/\\\\]" + base_name + "\.rb$")
- test_matcher = re.compile("[/\\\\]" + base_name + "_spec\.rb$")
-
- if option == 'next':
- print "Current file: " + current_file
- if re.search(re.compile(base_name + "_spec\.rb$"), current_file):
- self.open_project_file(source_matcher, window)
- elif re.search(re.compile(base_name + "\.rb$"), current_file):
- self.open_project_file(test_matcher, window)
- else:
- print "Current file is not valid for RSpec switch file!"
- elif option == 'source':
- self.open_project_file(source_matcher, window)
- elif option == 'test':
- self.open_project_file(test_matcher, window)
- elif option == 'test_and_source':
- window.run_command('set_layout', {
- "cols": [0.0, 0.5, 1.0],
- "rows": [0.0, 1.0],
- "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
- })
- self.open_project_file(test_matcher, window, 0)
- self.open_project_file(source_matcher, window, 1)
-
- for v in self.views:
- window.focus_view(v)
-
- def open_project_file(self, file_matcher, window, auto_set_view=-1):
- for root, dirs, files in os.walk(window.folders()[0]):
- for f in files:
- if re.search(r"\.rb$", f):
- cur_file = os.path.join(root, f)
- # print "Assessing: " + cur_file
- if file_matcher.search(cur_file):
- file_view = window.open_file(os.path.join(root, f))
- if auto_set_view >= 0: # don't set the view unless specified
- window.run_command('move_to_group', {'group': auto_set_view})
- self.views.append(file_view)
- print("Opened: " + f)
- return
- print("No matching files!")
+import sublime
+import sublime_plugin
+import re, inspect, os
+
+class OpenRspecFileCommand(sublime_plugin.WindowCommand):
+
+ def run(self, option):
+ if not self.window.active_view():
+ return
+
+ self.views = []
+ window = self.window
+ current_file_path = self.window.active_view().file_name()
+
+ if re.search(r"\w+\.rb$", current_file_path):
+
+ current_file = re.search(r"([\w\.]+)$", current_file_path).group(1)
+ base_name = re.search(r"(\w+)\.(\w+)$", current_file).group(1)
+ base_name = re.sub('_spec', '', base_name)
+
+ source_matcher = re.compile("[/\\\\]" + base_name + "\.rb$")
+ test_matcher = re.compile("[/\\\\]" + base_name + "_spec\.rb$")
+
+ if option == 'next':
+ print "Current file: " + current_file
+ if re.search(re.compile(base_name + "_spec\.rb$"), current_file):
+ self.open_project_file(source_matcher, window)
+ elif re.search(re.compile(base_name + "\.rb$"), current_file):
+ self.open_project_file(test_matcher, window)
+ else:
+ print "Current file is not valid for RSpec switch file!"
+ elif option == 'source':
+ self.open_project_file(source_matcher, window)
+ elif option == 'test':
+ self.open_project_file(test_matcher, window)
+ elif option == 'test_and_source':
+ window.run_command('set_layout', {
+ "cols": [0.0, 0.5, 1.0],
+ "rows": [0.0, 1.0],
+ "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
+ })
+ self.open_project_file(test_matcher, window, 0)
+ self.open_project_file(source_matcher, window, 1)
+
+ for v in self.views:
+ window.focus_view(v)
+
+ def open_project_file(self, file_matcher, window, auto_set_view=-1):
+ for root, dirs, files in os.walk(window.folders()[0]):
+ for f in files:
+ if re.search(r"\.rb$", f):
+ cur_file = os.path.join(root, f)
+ # print "Assessing: " + cur_file
+ if file_matcher.search(cur_file):
+ file_view = window.open_file(os.path.join(root, f))
+ if auto_set_view >= 0: # don't set the view unless specified
+ window.run_command('move_to_group', {'group': auto_set_view})
+ self.views.append(file_view)
+ print("Opened: " + f)
+ return
+ print("No matching files!")
Please sign in to comment.
Something went wrong with that request. Please try again.