This plugin is an alpha implementation of a ruby instarepl for the Light Table IDE. On demand, it can evaluate the contents of a ruby file and print the result of the last statement at the bottom. It can also eval selections of ruby code and print the result next to it.
No extra editing of the file is needed, and the result comes back in the nice Light Table widgets. Like a true repl your state will persist between evals.
There is also a basic Live Mode/Instarepl that will evaluate lines of code as you type (see below).
App: Reload Behaviors or restart LightTablectrl/cmd-enter to eval it. Use ctrl/cmd-shift-enter to eval the whole file.You'll need the eventmachine, json, and method_source gems installed.
Developed on Mac OS X 10.7 with ruby 2.0. Seems to work OK with REE 1.8 and ruby 1.9. I have no clue if it works on other platforms.
ctrl/cmd-shift-enter evals a whole file and prints the result of the last statement.ctrl/cmd-enter evals the selected text and prints results inline. If no text is selected it evals the current line.If the code sent for evaluation is not a complete statement, then the inline result will show … The code will be saved, and any future code sent for evaluation will be concatenated and evaled together.
A basic live evaluation mode has been implemented. To enable it for your editor, type ctrl/cmd-space and choose Ruby Instarepl: Toggle live mode.
When enabled, new lines typed at the end of the file will automatically be sent to the repl process for evaluation.
Watches enable you to see the results of individual expressions that were executed as part of an eval.
alt-w adds a watch for the selectionalt-shift-w removes the watch for the selectionAt present, you have to re-evaluate the whole file with ctrl/cmd-shift enter before your watches will be active. This will be fixed in a future version (see #14)
As of v0.0.4, the plugin is able to load a Rails environment. Just start up a Ruby connection in your project directory and then eval require 'config/environment' (or place that in an init file -- see below)
Basic rspec support is implemented. If the file you are evaling from is named *_spec.rb your code will be run as specs with results displayed inline.
Ruby code in .lighttable in the project root (the same directory as your Gemfile) will be run after establishing a new connection.
Support exists for both RVM and rbenv. To enable RVM add (:lt.objs.langs.ruby/use-rvm) to the :editor vector in your User Behaviors (e.g. :editor [:lt.objs.langs.ruby/use-rvm]. Once that's in place the ruby repl will be run out of whatever RVM environment you've defined for that directory via rvmrc, etc.
By default, the plugin looks for RVM at $HOME/.rvm/scripts/rvm If it's in a different locaton you can specify that via the :lt.objs.langs.ruby/rvm-path user behavior (e.g. :editor [(:lt.objs.langs.ruby/rvm-path "/usr/local/rvm/scripts/rvm")])
To enable rbenv add [(:lt.objs.langs.ruby/use-rbenv)] to the :editor vector.
If you're not using rbenv or rvm you can set the path to ruby manually by adding (:lt.objs.langs.ruby/ruby-exe "/path/to/ruby") to the :editor vector.
It would be nice to add more features for Rails in future versions. Also the live mode could be enhanced to enable automatic watches.
I try to plan out features in the Wish List
The clojurescript / lighttable side started by using the Python plugin as a template. Thank you Chris and everyone else at Kodowa for getting me so inspired about a text editor.
Thanks also to my employer, Green River for supporting development of this plugin.
:editor.ruby [:lt.objs.langs.ruby/client-enable-logging] in User Behaviorsmethod_source gemctrl/cmd-enter evals current line if no selection__FILE__ now gets set correctly:editor.ruby [(:lt.objs.langs.ruby/use-rvm? true)] to :editor.ruby [(:lt.objs.langs.ruby/use-rvm)] to better match style of other boolean behaviors.Copyright (C) 2014 Rafe Rosen
Distributed under the GPLv3, see license.md for the full text.
$ claude mcp add lt-ruby \
-- python -m otcore.mcp_server <graph>