Skip to content

Instantly share code, notes, and snippets.

@satococoa
Last active December 18, 2015 03:39
Show Gist options
  • Save satococoa/5719808 to your computer and use it in GitHub Desktop.
Save satococoa/5719808 to your computer and use it in GitHub Desktop.
SublimeText 2 の ApplySyntax プラグイン用 RubyMotion 設定。
{
// If you want exceptions reraised so you can see them in the console, change this to true.
"reraise_exceptions": false,
// 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.
// The format is exactly the same as "name" in the rules below. For example, if you want to have a new file use
// JavaScript syntax, set new_file_syntax to 'JavaScript'.
"new_file_syntax": false,
// Put your custom syntax rules here:
"syntaxes": [
{
"name": "RubyMotion",
"rules": [
{"function": {"name": "is_rubymotion_file"}}
]
}
]
}
import os.path
import re
def is_rubymotion_file(file_name):
path = os.path.dirname(file_name)
file_name = os.path.basename(file_name).lower()
name, extension = os.path.splitext(file_name)
result = False
re_rubymotion = re.compile("Motion::Project::App")
while path != "/":
rakefile = os.path.join(path, "Rakefile")
if os.path.exists(rakefile):
for line in open(rakefile):
if re_rubymotion.search(line):
result = True
break
path = os.path.dirname(path)
return extension == ".rb" and result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment