开发者

Running a Ruby interpreter on iPad

I'll be taking a trip soon with my iPad, without my laptop. I'd like to continue to tinker with Ruby while I'm on the road. I have an iPhone developer program membership, and I'm not interested in submitting this stuff to the app store.

I found the shinycocos project, which appears to embed a Ruby interpreter in an app. But I can't get it to run, and it seems pretty customized for running cocos2d stuff.

My first goal is to run an interactive command line like Try Ruby!. After that, I'd like to enter small programs in a UITextView and run them. I'd appreciat开发者_高级运维e any clues, tips, or existing projects you might know of.


The Rhodes Framework contains a working Ruby implementation for the iPhone. You could try just writing your own simple IRB clone with Rhodes and see how that goes. You won't be able to get it through the App Store, of course, but you don't care about that, anyway.

As a next step, you could steal their build recipes and compile your own.

In the future, it will probably be possible to use MacRuby, but for the time being, everybody who works on MacRuby either works for Apple or has signed an NDA, so they aren't saying anything. However, the MacRuby lead developer once said that MacRuby's ahead-of-time compiler could in the future be used to "run Ruby on resource-constrained small-size mobile internet devices" without ever mentioning the i-word.

[Note that this will probably not allow you to run an interpreter on the device, rather you would statically compile your code natively and then upload it to the device. And the compiler does not support eval, which is crucial for running something like IRB or even a full IDE on the device.]

At the moment, your best bet for a mobile Ruby IDE is probably Android.


There is an iPhone project which embeds a Ruby interpreter and provides a basic command line at https://github.com/takuma104/iphone-irb. I compiled it and could install in on an iPad without problems. Unfortunately the project seems to be abandoned, but a good starting point.


I would recommend

  • Textastic as code editor (it includes sync features - ftp, webdav... - and a web browser to test your web page)
  • jailbreak + openssh
  • iSSH for remote but also localhost connection. Provides a nice shell directly on the iPad
  • jailbreak + ruby 1.9 from Cydia (not fully working, I would try to build it myself)
  • then you create your application on desktop computer, install all gems that you need
  • rake gem:freeze (if I remenber well) to embbed all rails dependencies in the app folder
  • then put the whole on your iPad and see...

then you are a Rails developer in the wild :-D


You'll probably be best off setting up a little server on your home machine to accept uploads of ruby code, run it on the server and return the results via the browser. I think there are some rails implementations out there that will do this for you.


iSSH to your unix server shell, and use "vim" to code and "ruby " to execute. It's no IDE , but it works as long as you have reliable Internet. CCK, Camera Connector Kit, will allow you to use most keyboards, but test first! Some draw too much power, including Apple's own keyboard! :-P. Apple wireless keyboard works fine though, and is very portable. ;-)


I'm now using mruby-web-irb, which meets the requirements stated.

The project provides a Ruby interpreter in Safari (or Chrome) by compiling mruby into Javascript via emscripten. That sounds like a lot of complexity, but it just works.

If you like this kind of thing, definitely check out the emscripten demos. Especially repl.it, an Online REPL for 15+ languages, including Ruby, Python, Lua, Scheme, Forth, and Basic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜