How to run rake-task in RubyMine using OpenAPI?
Hello.
How can I run rake-task in RubyMine using OpenAPI and capture all output into a string?
How can I specify what RubyOnRails environment (producion/development) to use for this task?
Thanks.
Please sign in to leave a comment.
Hi Basil,
For what do you ned it? You are writing some java plugin for RubyMine which launches Rake tasks and does smth with it output? Currenlty there is no OpenAPI for launching Rake tasks.
Yes. I'm wrinting a plugin which should run some rake task, then analyse output and provide some useful information. You said that OpenAPI does not have this functionality, but how does RubyMine collect available tasks? How does it migrate database? This is rake task and it's executed in some way when I select needed migration in RubyMine dialog. I assume that it can be made not via OpenAPI, but could you please tell what is the proper way to do this?
Thank you.
RubyMine collects tasks and launches them using separate ways. To collect rake tasks RubyMine launches 'rake' script provided by rake gem with necessary options. Actually we lauch it 2 times - for documented (rake --tasks --trace) and undocumented (rake --prereqs --trace) tasks. You can lauch a script provided by gem using:
Where
E.g. documented_tasks_output = GemsRunner.runGemsExecutableScript(sdk, module, "rake", "rake", module_content_root, new ExecutionModes.SameThreadMode(), false, errorTitle, "--tasks","--trace");
Bundler exec emulation will be turen on If module contains dependency on bunlder gem and Gemfile & Gemfile.lock files exists. Output is a pair of dumped stdout and stderr output. I think you can use these way.
RubyMine lauches Rake tasks using fake Rake run configuration. RubyMine automatically generates and configures such run configurations. Main advantage is that user can configure whether use bundler, trace, etc. options; consider test output as tests results or not, etc. But I don't think that you can easily reuse it for your purposes. In such case RubyMine always shows run configuration console and you can only add output listener to it.