Deploying Ruby-Tk app on OS X - ruby

I'm looking for a straightforward way to deploy a standalone Ruby-Tk desktop app on OS X. All existing options for deploying desktop Ruby GUI apps on the Mac (e.g. standaloneify.rb) assume that you are using RubyCocoa or MacRuby, and are tightly bound to Xcode/Interface Builder project structure; or, alternatively, that you are wrapping a simple script via Platypus that does not involve deploying the entire Ruby runtime. None of the other existing options that I've found--rubyscript2exe, ocra, crate--support the Mac and/or support Ruby 1.9.
I'm hoping that someone can point me to a shell script or Ruby script that does the following:
Tracks all dependencies/gems in an app.
Copies the Ruby interpreter and dependencies into an application bundle.
Runs install_name_tool on the Ruby interpreter and all dylibs to make them portable.
The application bundle can either be something created by Platypus, use a Cocoa stub launcher, or even a shell script--I know how to handle those. The problem I'm having is getting the Ruby runtime wrapped in a portable way.
There's a rakefile at http://weft-qda.rubyforge.org/svn/trunk/weft-qda/rake/rake_osx.rb that encompasses the tasks that I'm looking to achieve, but this rakefile is part of a larger build structure that I can't get running on my Mac. I'm not familiar enough with rakefile structure to refactor this into a simple script that I can run, either via "ruby rake_osx.rb" or even "rake".
If someone can suggest to me how to modify this rakefile to run independently, or point me to another example project, or even share some code, I would be grateful. The project I am working on is better suited for Ruby than Python (better library support in Ruby), but I am not going to invest time in it if deployment won't work. (Python has a much richer tradition of deployment tools than Ruby, something I'v never quite understood.)

This is a bit late after the fact, but in classic fashion, since I could not find a desktop app deployment tool for Ruby-Tk on the Mac, I wrote my own:
ruby2app
ruby2app is a simple command-line tool, inspired by similar Mac tools like py2app for Python, that bundles a Ruby script with the Ruby runtime into a standalone Mac application. It reads a basic configuration file to find the appropriate Ruby installation, compiles a small C program that embeds the Ruby interpreter, copies the entire Ruby installation into the application bundle, and re-links the relevant libraries with the main executable.
It attempts to provide for the Mac what ocra and exerb provide for Windows. Hopefully this will be of use to others.

Related

How to package and distribute a Ruby CLI program with its dependencies?

For predictability, and to avoid messing up the user's system, I want the program's dependent gems isolated from any global gems the user/system has installed. So just distributing the program as a gem won't really work.
I know that Heroku's "toolbelt" CLI package used to be written in Ruby (though it's now Node.js, apparently); how did they do it? Is what they did a best practice?
I expect only developers to use the program (it's a release-management tool), so it's safe to assume/require the existence of a package-management tool like Homebrew on OSes that don't already ship with one.
The program is written to work on mostly any version of Ruby, so I can depend on some non-version-constrained Ruby package provided by the OS / package-manager, if that makes things easier.

Running Sinatra within a MacRuby app

I'm new to MacRuby with Xcode but I have what I think (hope) is a simple question. I have a small Ruby Sinatra web app that I want to package as a Mac OS packaged application (.app). The application (however it is packaged) is used to read a specific plist file that is apart of Mac OS X Server and display the results through a specific web port in a browser. I don't know if MacRuby is the way to go, but all I need is a simple GUI that starts and stops the Sinatra web app so that users don't have to fuss with the command line (and hopefully without having to install gems, etc). I'm starting to figure out some of the basics of MacRuby and Xcode 4 but I'm not sure where to place the Sinatra ruby file within the Xcode project or how to start it.
I do know how to run a bash command start the ruby server within the application path but not sure if that's the best way or where to actually put the ruby file.
Please forgive my lack of knowledge of desktop developmentā€”I really only work in the web world. If I can elaborate on any points, let me know.
Control Tower may be your solution:
https://github.com/MacRuby/ControlTower
Part of the macruby project, it does basically what you wish. It's still very new & needs work, but It does function. I have been able to get it to work with sinatra for some test apps but I have yet to try to get any of my actually apps to run thru it (As I am still learning myself)

Can I switch versions of Ruby dynamically using RVM?

I'm working on building a GUI for my checkers implementation. I'm utilizing a GUI framework that only works with Ruby 1.8, yet my game engine, which I have packaged as a gem, only works with Ruby 1.9.
I can't change the code for the GUI framework and reworking my game engine to make it compatible with 1.8 is undesirable, to say the least.
I'm using RVM though, and it looks like you can write RVM scripts to change Ruby versions on the fly.
Does anyone have any experience with that or what the script might look like?
You could run it in two processes. Give the GUI a 1.8 process and talk to it via a shared db or an API on the other side. That's how I'd do it. The good part about that is you can have on online version of your game as well because other clients will be able to talk to it as well.
You can't run one app with two versions of Ruby. How do you imagine this?
RVM has an ability to automatically change current ruby when you cd into a directory. Just create in that directory a file called .rvmrc with content like
rvm use 1.8.7

MacRuby: How to write an app/script that generates native Mac apps?

So I'm basically trying to recreate what this app: Fluid, already does. I want to write a Ruby script, or MacRuby app that accepts a few parameters and can generate a simple native app.
Since their code is not open-sourced, I can't see how they do it. And I don't know how I would begin to accomplish something like this.
Also, I would like this script to be run on Windows (not that the user could install the generated app, but so the app could be distributed to Mac users).
How could I do something like this?
Solution:
Here is a project that does exactly the same thing that I'm trying to do. It takes an app bundle and does some string replacing on some files in the bundle. I'm going to use it as an example to imitate.
https://github.com/maccman/macgap-rb
MacRuby can already create native app bundles on OS X (it's a compiler as well as an interpreter), so in a sense there's no question to be answered here. If you want to write an app in MacRuby or Objective-C for OS X, the experience is essentially the same (though, of course, MacRuby has different command line flags for generating the final result, in this case the -deploy flag to MacRuby vs some linker invocation for ObjC). That said, nothing you write in MacRuby will run natively in Windows. Depending on the complexity of the app you have in mind, you may have to go to some cross-platform solution (like Unity) for that.
Check out Prism. It's not Ruby, but it does exactly what you describe and is open-source. One thing you'll to do is embed a web browser into a window, so look for libraries that do that. I'm assuming you'll use Cocoa for GUI since you're using MacRuby. In the end, the simplest way would be just have a window with web browser in it.

Package Ruby to a standalone Mac OS X application?

I know Python has py2app. I was wondering if Ruby has anything like that. I know there is OCRA (One-Click Ruby Application builder) for Windows, but what about for Mac OS X?
Take a look at Platypus; it may do what you want.
From its homepage:
Platypus is a developer tool for the
Mac OS X operating system. It can be
used to create native, flawlessly
integrated Mac OS X applications from
interpreted scripts such as shell
scripts or Perl and Python programs.
This is done by wrapping the script in
an application bundle directory
structure along with an executable
binary that runs the script.
Edit per #XtraSimplicity in a comment: Platypus can't handle any input or output from stdin or stdout. That will rule it out in some cases.
MacRuby seems like the most likely candidate without knowing more details about what you're doing. It can make standalone native binaries.
http://www.macruby.org/ for more info.
RubyCocoa includes a script (standaloneify.rb) to package all the Ruby files your project uses into the app wrapper, and MacRuby (recommended if you're targeting 10.5+) compiles to native code and thus it's no more work making a standalone app than with Objective-C.
Compared to Windows, Ruby and Python are prebuilt for Mac OS X, so the easiest way might be using Cocoa with Ruby. You can get good information out of the book Programming Cocoa with Ruby.

Resources