-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.pyc | ||
*.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 0.0.1 | ||
|
||
* Package released |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>fileTypes</key> | ||
<array> | ||
<string>exs</string> | ||
</array> | ||
<key>foldingStartMarker</key> | ||
<string>(?x)^ | ||
(\s*+ | ||
(module|class|def | ||
|background|feature|subscribe | ||
|before|describe|it|scenario | ||
|unless|if | ||
|case | ||
|begin | ||
|for|while|until | ||
|^=begin | ||
|( "(\\.|[^"])*+" # eat a double quoted string | ||
| '(\\.|[^'])*+' # eat a single quoted string | ||
| [^#"'] # eat all but comments and strings | ||
)* | ||
( \s (do|begin|case) | ||
| (?<!\$)[-+=&|*/~%^<>~] \s*+ (if|unless) | ||
) | ||
)\b | ||
(?! [^;]*+ ; .*? \bend\b ) | ||
|( "(\\.|[^"])*+" # eat a double quoted string | ||
| '(\\.|[^'])*+' # eat a single quoted string | ||
| [^#"'] # eat all but comments and strings | ||
)* | ||
( \{ (?! [^}]*+ \} ) | ||
| \[ (?! [^\]]*+ \] ) | ||
) | ||
).*$ | ||
| [#] .*? \(fold\) \s*+ $ # Sune’s special marker | ||
</string> | ||
<key>foldingStopMarker</key> | ||
<string>(?x) | ||
( (^|;) \s*+ end \s*+ ([#].*)? $ | ||
| (^|;) \s*+ end \. .* $ | ||
| ^ \s*+ [}\]] \s*+ ([#].*)? $ | ||
| [#] .*? \(end\) \s*+ $ # Sune’s special marker | ||
| ^=end | ||
)</string> | ||
<key>keyEquivalent</key> | ||
<string>^~R</string> | ||
<key>name</key> | ||
<string>ESpec</string> | ||
<key>patterns</key> | ||
<array> | ||
<dict> | ||
<key>match</key> | ||
<string>(?<!\.)\b(before\b|after\b|subject\b!?|let\b!?)</string> | ||
<key>name</key> | ||
<string>keyword.other.espec</string> | ||
</dict> | ||
<dict> | ||
<key>include</key> | ||
<string>#behaviour</string> | ||
</dict> | ||
<dict> | ||
<key>include</key> | ||
<string>#single-line-example</string> | ||
</dict> | ||
<dict> | ||
<key>include</key> | ||
<string>#pending</string> | ||
</dict> | ||
<dict> | ||
<key>include</key> | ||
<string>#example</string> | ||
</dict> | ||
<dict> | ||
<key>include</key> | ||
<string>source.elixir</string> | ||
</dict> | ||
</array> | ||
<key>repository</key> | ||
<dict> | ||
<key>behaviour</key> | ||
<dict> | ||
<key>begin</key> | ||
<string>^\s*(?:(ESpec)\.)?(describe|context|feature)\b</string> | ||
<key>beginCaptures</key> | ||
<dict> | ||
<key>1</key> | ||
<dict> | ||
<key>name</key> | ||
<string>support.class.elixir</string> | ||
</dict> | ||
<key>2</key> | ||
<dict> | ||
<key>name</key> | ||
<string>keyword.other.espec.behaviour</string> | ||
</dict> | ||
</dict> | ||
<key>end</key> | ||
<string>\b(do(?=\s*$))|{</string> | ||
<key>endCaptures</key> | ||
<dict> | ||
<key>1</key> | ||
<dict> | ||
<key>name</key> | ||
<string>keyword.control.elixir.start-block</string> | ||
</dict> | ||
</dict> | ||
<key>name</key> | ||
<string>meta.espec.behaviour</string> | ||
<key>patterns</key> | ||
<array> | ||
<dict> | ||
<key>include</key> | ||
<string>source.elixir</string> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>example</key> | ||
<dict> | ||
<key>begin</key> | ||
<string>^\s*(it|specify|scenario)\b</string> | ||
<key>beginCaptures</key> | ||
<dict> | ||
<key>1</key> | ||
<dict> | ||
<key>name</key> | ||
<string>keyword.other.espec.example</string> | ||
</dict> | ||
</dict> | ||
<key>end</key> | ||
<string>\b(do(?=\s*$))|{</string> | ||
<key>endCaptures</key> | ||
<dict> | ||
<key>1</key> | ||
<dict> | ||
<key>name</key> | ||
<string>keyword.control.elixir.start-block</string> | ||
</dict> | ||
</dict> | ||
<key>name</key> | ||
<string>meta.espec.example</string> | ||
<key>patterns</key> | ||
<array> | ||
<dict> | ||
<key>include</key> | ||
<string>source.elixir</string> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>pending</key> | ||
<dict> | ||
<key>begin</key> | ||
<string>^\s*(it|specify|scenario)\b(?=((?!do|{).)*$)</string> | ||
<key>end</key> | ||
<string>$</string> | ||
<key>beginCaptures</key> | ||
<dict> | ||
<key>1</key> | ||
<dict> | ||
<key>name</key> | ||
<string>keyword.other.espec.pending</string> | ||
</dict> | ||
</dict> | ||
<key>patterns</key> | ||
<array> | ||
<dict> | ||
<key>include</key> | ||
<string>source.elixir</string> | ||
</dict> | ||
</array> | ||
<key>name</key> | ||
<string>meta.espec.pending</string> | ||
</dict> | ||
<key>single-line-example</key> | ||
<dict> | ||
<key>captures</key> | ||
<dict> | ||
<key>1</key> | ||
<dict> | ||
<key>name</key> | ||
<string>keyword.other.espec.example</string> | ||
</dict> | ||
</dict> | ||
<key>match</key> | ||
<string>^\s*(it|specify|scenario)\s*{</string> | ||
</dict> | ||
</dict> | ||
<key>scopeName</key> | ||
<string>source.elixir.espec</string> | ||
<key>uuid</key> | ||
<string>923F0A10-96B9-4792-99A4-94FEF66E0B8C</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import sublime, sublime_plugin, time | ||
import re | ||
|
||
from textwrap import dedent | ||
from ESpec.shared import other_group_in_pair | ||
|
||
|
||
def snake_case(name): | ||
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) | ||
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | ||
|
||
|
||
class GotoLineCommand(sublime_plugin.TextCommand): | ||
|
||
def run(self, edit, line, column=0): | ||
pt = self.view.text_point(line - 1, column) | ||
|
||
self.view.sel().clear() | ||
self.view.sel().add(sublime.Region(pt)) | ||
|
||
self.view.show(pt) | ||
|
||
|
||
class EspecNewModuleCommand(sublime_plugin.TextCommand): | ||
|
||
def run(self, edit, name, namespace): | ||
class_template = dedent(''' | ||
class {name} | ||
end | ||
'''.lstrip('\n').rstrip(' \n').format(name=name)) | ||
|
||
module_template = dedent(''' | ||
module {module} | ||
{definition} | ||
end | ||
'''.lstrip('\n').rstrip(' \n')) | ||
|
||
template, level = class_template, len(namespace) | ||
|
||
while namespace: | ||
module = namespace.pop() | ||
template = module_template.format(module=module, definition=self.indent(template)) | ||
|
||
self.view.insert(edit, 0, template) | ||
self.view.run_command('goto_line', { 'line': 2 + level, 'column': level * 2 }) | ||
|
||
def indent(self, text, space=2): | ||
return '\n'.join(' ' * space + line for line in text.split('\n')) | ||
|
||
|
||
class EspecNewSpecCommand(sublime_plugin.TextCommand): | ||
|
||
def run(self, edit, name): | ||
template = dedent(''' | ||
require 'spec_helper' | ||
describe {name} do | ||
end | ||
'''.strip('\n').format(name=name)) | ||
|
||
self.view.insert(edit, 0, template) | ||
self.view.run_command('goto_line', { 'line': 4 }) | ||
|
||
|
||
class EspecCreateModuleCommand(sublime_plugin.WindowCommand): | ||
|
||
def run(self): | ||
self.window.show_input_panel("Enter module name:", "", self.on_done, None, None) | ||
|
||
def on_done(self, text): | ||
if not text: return | ||
|
||
*namespace, name = re.split(r'/|::', text.strip(' _/')) | ||
|
||
# create the module | ||
module = self.window.new_file() | ||
module.set_syntax_file('Packages/Ruby/Ruby.tmLanguage') | ||
module.set_name(snake_case(name) + '.rb') | ||
|
||
module.run_command('rspec_new_module', { 'name': name, 'namespace': namespace }) | ||
|
||
# create the spec | ||
spec = self.window.new_file() | ||
self.window.run_command('move_to_group', { 'group': other_group_in_pair(self.window) }) | ||
spec.set_syntax_file('Packages/Ruby/Ruby.tmLanguage') | ||
spec.set_name(snake_case(name) + '_spec.rb') | ||
|
||
spec.run_command('rspec_new_spec', { 'name': '::'.join(namespace + [name]) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sublime, sublime_plugin | ||
import os | ||
|
||
class ESpecDetectFileTypeCommand(sublime_plugin.EventListener): | ||
''' | ||
Detects current file type if the file's extension | ||
''' | ||
|
||
def on_load(self, view): | ||
filename = view.file_name() | ||
|
||
if not filename: return # not saved | ||
|
||
name = os.path.basename(filename.lower()) | ||
if name.endswith("_spec.exs"): | ||
set_syntax(view, "ESpec") | ||
elif name == "factories.exs": | ||
set_syntax(view, "ESpec") | ||
|
||
|
||
def set_syntax(view, syntax, path=None): | ||
if path is None: | ||
path = syntax | ||
|
||
view.settings().set('syntax', 'Packages/'+ path + '/' + syntax + '.tmLanguage') | ||
print("Switched syntax to: " + syntax) |
Oops, something went wrong.