Skip to content

Commit c991c9f

Browse files
committed
add "Run command from Rake task list"
1 parent e3e0ed5 commit c991c9f

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

Default.sublime-commands

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"caption": "RubyMotionBuilder: Deploy",
2020
"command": "ruby_motion_deploy"
2121
},
22+
{
23+
"caption": "RubyMotionBuilder: Run command from Rake task list",
24+
"command": "ruby_motion_run_command_from_list"
25+
},
2226
{
2327
"caption": "RubyMotionBuilder: Set break point for debugging",
2428
"command": "ruby_motion_set_breakpoint"

Default.sublime-keymap

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{ "keys": ["super+alt+r"], "command": "ruby_motion_run_spec"},
55
{ "keys": ["shift+super+r"], "command": "ruby_motion_run", "args": {"options": "retina=true"} },
66
{ "keys": ["super+alt+b"], "command": "ruby_motion_deploy"},
7+
{ "keys": ["super+alt+l"], "command": "ruby_motion_run_command_from_list"},
78
{ "keys": ["ctrl+alt+b"], "command": "ruby_motion_set_breakpoint"},
89
{ "keys": ["ctrl+alt+d"], "command": "ruby_motion_doc"},
910
{ "keys": ["#"], "command": "insert_snippet", "args": {"contents": "#{${1:$SELECTION}}$0"}, "context":

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Usage
5656
| Run | `command` + `r` |
5757
| Run Spec | `command` + `option` + `r` |
5858
| Deploy | `command` + `option` + `b` |
59+
| Run from list | `command` + `option` + `l` |
5960
| Set Breakpoint | `control` + `option` + `b` |
6061
| Show reference | `control` + `option` + `d` |
6162

@@ -108,6 +109,20 @@ Then, automatically post "quit" to Terminal.app and re-execute "rake spec".
108109
1. Open \*.rb or Rakefile in your RubyMotion project and press [`command` + `option` + `b`].
109110
2. Wait for the console to notify you the message "[Finished]".
110111

112+
### Run command from Rake task list
113+
114+
1. Open \*.rb or Rakefile in your RubyMotion project and press [`command` + `option` + `l`].
115+
2. Select a task from displayed list.
116+
117+
This command need `PATH` environment variable in plugin.
118+
Mountain Lion or later users can set variable via `/etc/launchd.conf` like
119+
120+
```
121+
$ echo "setenv PATH $PATH" | sudo tee -ai /etc/launchd.conf
122+
```
123+
124+
Then, reboot your Mac.
125+
111126
### Set break point for debugging
112127

113128
1. Open \*.rb or Rakefile in your RubyMotion project.

RubyMotionBuilder.py

+25
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,31 @@ def run(self):
103103
RunRubyMotionRunScript(self, "device")
104104

105105

106+
class RubyMotionRunCommandFromList(sublime_plugin.WindowCommand):
107+
def run(self):
108+
view = self.window.active_view()
109+
view_file_name = view.file_name()
110+
dir_name, _ = os.path.split(view_file_name)
111+
dir_name = FindRubyMotionRakefile(dir_name)
112+
cmd = "rake -T"
113+
print(env_path)
114+
if os.path.isfile(os.path.join(dir_name, "Gemfile.lock")):
115+
cmd = "bundle exec rake -T"
116+
p = subprocess.Popen(cmd, shell=True, cwd=dir_name,
117+
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
118+
close_fds=True)
119+
output = p.stdout.read()
120+
self.task_list = output.decode("utf-8").split("\n")
121+
self.task_list.pop() # remove emply last line
122+
self.window.show_quick_panel(self.task_list, self.on_done, sublime.MONOSPACE_FONT)
123+
124+
def on_done(self, picked):
125+
if picked == -1:
126+
return
127+
pickup_task = re.compile('rake (\w+)')
128+
task = pickup_task.match(self.task_list[picked]).group(1)
129+
RunRubyMotionRunScript(self, task)
130+
106131
class RubyMotionSetBreakpoint(sublime_plugin.WindowCommand):
107132
def run(self):
108133
view = self.window.active_view()

0 commit comments

Comments
 (0)