REPL stands for Read-Eval-Print-Loop. See it in live below:
Opal. While it is totally possible to write Opal app as is, its getting harder when the Ruby classes getting interact with native classes -- you
must test it on device/simulator but compile-deploy time is so long and so painful.
While there is a way to connect Safari Web Inspector with JSContext, its not possible for Opal: You have to compile it before it can run on JSContext.
Its build on top of following:
- jqConsole Web based terminal.
- Ace Web based code editor with syntax highlighting.
- CocoaHTTPServer HTTP and WebSocket server for realtime communication
between iOS and desktop.
Opal on iOS, is it practical?
// expose Objective-C code to JSContext @protocol ViewControllerExport <JSExport> -(void) setGreeting:(NSString*)helloText; -(NSString*) getGreeting; @end
# wrapping a Objective-C classes class ViewController include Native alias_native :greeting, :getGreeting alias_native :greeting=, :setGreeting end
# use the wrapper class vc = ViewController.new(`App.viewController`) vc.greeting = "Hi!"
All of those wrapping is boring, but when its done, you can build higher level API or
DSL that dramatically changes how you build apps.
Note you'll not implement the whole app in Ruby with Opal (to do that, use RubyMotion), its best for macro or other dynamic behavior.
If you want to build your own Ruby library for Opal on iOS, check IGHTMLQuery, it wrap everything in Ruby and I think its a pleasure to work with it.
- Implement Ruby standard library that is missing on Opal (due to platform limitation) but critical on native app development.
- Something like BubbleWrap might also needed to wrap native class to allow more interaction between Ruby and Objective-C.
- Build great apps and profit!!