Last active
December 18, 2015 03:39
-
-
Save satococoa/5719808 to your computer and use it in GitHub Desktop.
SublimeText 2 の ApplySyntax プラグイン用 RubyMotion 設定。
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
Show hidden characters
{ | |
// 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"}} | |
] | |
} | |
] | |
} |
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
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