Skip to content

Instantly share code, notes, and snippets.

@satococoa
Last active January 18, 2016 21:21
Show Gist options
  • Select an option

  • Save satococoa/9284256 to your computer and use it in GitHub Desktop.

Select an option

Save satococoa/9284256 to your computer and use it in GitHub Desktop.
Sublime Text 3 RubyMotionBuilder and ApplySyntax settings
// Packages/User/ApplySyntax.sublime-settings
{
// 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": "RubyMotionBuilder/RubyMotion",
"rules": [
{"function": {"name": "is_rubymotion_file", "source": "User/is_rubymotion_file"}}
]
}
]
}
# Packages/User/is_rubymotion_file.py
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
# import sys
# print is_rubymotion_file(sys.argv[1])
@dchersey

Copy link
Copy Markdown

Thanks! This solved a hairy problem for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment