Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

Monday, February 7, 2011

Ruby on NetBeans: Here Comes the Cavalry

As recently reported, the NetBeans IDE team has decided to drop support for Ruby (and Rails) from NetBeans 7.0.

I have received many good suggestions from readers, with RedCar and RubyMine getting a lot of love.

But wait! What's that? It sounds like trumpets off in the distance... and hoofbeats.

Indeed, Tom Enebo is leading the cavalry to save the day, as he reported in the JRuby forum recently:

I have been talking to Netbeans team about us adopting the project and this is a done deal. Putting together some details and you should see a blog post about this in the next few days. So, if you like using Netbeans dont worry, it will still be an available option in the plugins catalog (not sure about the full Ruby product as an independent download from netbeans site yet).
Good news for all those that would like to continue to use NetBeans with Ruby.

Thanks, Tom!

Thursday, January 27, 2011

NetBeans Drops Support for Ruby and Rails

The NetBeans team has, unfortunately, decided to remove Ruby and Rails support from the NetBeans IDE:

After thorough consideration, we have taken the difficult step to discontinue support for Ruby on Rails in the NetBeans IDE.
As of January 27, the Ruby on Rails module will be gone from development builds of NetBeans IDE 7.0.
NetBeans has served me well for larger projects over the years, and NetBeans 6.9.1 retains its existing support for Ruby and Rails. But perhaps it's time to start considering Ruby IDE alternatives, and I'm open to suggestions.

Saturday, August 28, 2010

New Ruby IDE Discussion Group

FYI, Ed Howland has launched a new Ruby IDE discussion group:

I set this group up to focus discussions about a community developed IDE written in Ruby (but not necessarily limited to writing code in just that language. The intent is to take general discussion specific off-line from the main ruby-talk group Hopefully, this will be a high signal-noise ratio discussion.

So if you've got some constructive thoughts on what would be the ideal Ruby IDE, make yourself heard here:

http://groups.google.com/group/ruby-ide

David

Sunday, May 24, 2009

The OCRA Compiler: Tips, Tricks, and Gotchas

I've previously mentioned Lars Christensen's One-Click Ruby Application Builder, a "compiler" for Ruby scripts that shows a lot of potential (and current value). There's not much documentation yet, but folks are installing it, using it, and providing feedback. It works right out of the box for many purposes, but here are a few things to keep in mind as you use it...

"Failed to create directory" Error

One user reported receiving the error "Failed to create directory" when running the compiled executable. As a possible workaround, try running ocra.rb from the directory where your script is located. For example, instead of running...


ocra.rb "C:\code\rubyscripts\application.rbw"

...navigate to the "C:\code\rubyscripts" directory, then run:

ocra.rb application.rbw

Note that while this resolved the problem on my machine, it didn't help the person who originally reported the problem.

Require RubyGems

When you compile your script (which uses one or more gems) with OCRA and then run the executable, you may receive a 'no such file to load' error. Try adding the line...

require 'rubygems'

...to the top of your script, above the other require statements. I've found that a script that runs pre-compiled without this statement may not execute once compiled.

Compile Without Running

I mentioned earlier that it would be nice to have an option to avoid fully running the script, similar to RubyScript2Exe's exit if RUBYSCRIPT2EXE.is_compiling? idiom. A tip of the hat goes to reader "BackOrder", who offered the following solution:

exit if Object.const_defined?(:Ocra)

Put all your require statements at the top of your code, followed by this line.

OCRA and Mechanize: "libxml2.dll not found"

There may be a problem compiling a script that requires the mechanize gem. Running the compiled executable resulted in a "libxml2.dll was not found" error on my machine.

Note that the above observations relate to version 1.0.2 (current as of this writing) of the ocra gem.

More information is available in the OCRA forums and bug tracker.

Thanks again to Lars for creating OCRA, and to the users who have installed it, used it, and provided their feedback.

Thanks for stopping by!

Thursday, May 14, 2009

OCRA: One-Click Ruby Application Builder

I recently mentioned the fact that RubyScript2Exe 0.5.3 doesn't play well with recent versions of RubyGems. At the end of that post I mentioned that there are alternatives emerging for creating executables from your Ruby code, including Lars Christensen's OCRA, the One-Click Ruby Application Builder.

I've had a chance to take OCRA for a short test drive and it looks promising. Like Erik Veenstra's RubyScript2Exe, OCRA lets you "compile" your ruby code into an EXE file that you can distribute to others, without requiring that the users have Ruby installed on their PCs. To quote the OCRA page:

The executable is a self-extracting, self-running executable that contains the Ruby interpreter, your source code and any additionally needed ruby libraries or DLL.

OCRA can be installed via RubyGems: open a console window and type:

gem install ocra

It's also available from the RubyForge page. Version 1.0.2 is the latest as of this writing.

The syntax to compile a script is...

ocra.rb [option] your/script.rb

...where option is one or more of the following:

--dll dllname Include additional DLLs from the Ruby bindir.
--no-lzma Disable LZMA compression of the executable.
--quiet Suppress output.
--help Display this information.
--windows Force Windows application (rubyw.exe)
--console Force console application (ruby.exe)
--no-autoload Don't load/include script.rb's autoloads

Thus far, I have exercised only the --windows and --console options.

To create a non-console application, either use the --windows option or give your script the .rbw filename extension. Compiling a basic non-console script is as simple as opening a console window, navigating to the folder containing your script, and typing:

ocra.rb myscript.rbw

OCRA will then run your script to check for dependencies, gather the necessary files, and create your executable. An option to avoid fully running the script would be nice, similar to RubyScript2Exe's exit if RUBYSCRIPT2EXE.is_compiling? idiom.

OCRA uses LZMA compression, so the resulting executable is relatively small. A simple wxRuby app, for example, resulted in a 2.5 Mb executable. The same app compiled with RubyScript2Exe weighed in at over 9 Mb. Apps that do not require a GUI toolkit will be even smaller, perhaps 500k.

I haven't spent a lot of time with OCRA yet, but I think it shows great potential and I want to thank Lars Christensen for his efforts. If you have a need to distribute Ruby programs to non-technical users, you should check it out and pass your feedback along to Lars.

Thanks for stopping by!

Sunday, May 3, 2009

RubyScript2Exe and RubyGems

I've written here previously about Erik Veenstra's RubyScript2Exe "compiler". I use it frequently to create standalone EXE files on Windows.

If you use RubyScript2Exe, you should note that the current version (0.5.3) doesn't appear to play well with the new version (1.3.2) of Rubygems released a few weeks ago. Attempting to compile a script results in the error:


undefined method `list' for Gem::Specification:Class

Some additional discussion can be found in this Ruby Forum thread.

Perhaps Erik will update RubyScript2Exe to utilize the Gem.loaded_specs method, as suggested by Eric Hodel.

In the meantime, RubyGems 1.3.1 continues to work well for me with RubyScript2Exe. Be aware, however, that Daniel Berger points out in the above thread that version 1.3.2 addresses a couple issues related to the win32-file library.

There are alternatives emerging for creating executables from your Ruby code, including ocra and crate. I haven't had the opportunity to try either of these yet, but plan to in the near future. If you have experience with these or similar tools, feel free to share your comments here. Thanks!

Wednesday, September 26, 2007

Using Rake to Automate Windows Desktop App Builds

We've recently talked about compiling your Ruby app with RubyScript2Exe, and creating an install package with Inno Setup.

I was inspired by RoW reader Luis Lebron, who recently shared with me his Rakefile for automating the running of RubyScript2Exe from within the NetBeans Ruby IDE.

My process for packaging an application for distribution involves, among other things:


  • Compiling the code with RubyScript2Exe
  • Replacing the default EXE icon with my own (using Resource Hacker)
  • Moving the EXE file to my Install folder
  • Updating the ReadMe file with the new version number
  • Updating the Inno Setup script with the new version number
  • Running the Inno Setup script to create a new Setup.exe file

This isn't a particularly time-consuming list of manual tasks. But I spend my workdays developing tools to automate my fellow employees' manual tasks. So it was inevitable that I would seek to do the same for myself.

I had no prior experience with Rake, a DSL created by Jim Weirich to automate project builds. I'm neither a C programmer nor a web developer, so I wasn't really motivated to investigate what Rake might have to offer. But after receiving Luis' email, I looked into using Rake, and then researched the options for running Resource Hacker and the Inno Setup compiler from the command line.

I still know almost nothing about Rake, but I learned enough to create a simple Rakefile to automate all of the above tasks. This could, of course, be done in Ruby without the using Rake, but NetBeans' Rake integration and templates make it handy. Now I can right-click on my project icon in NetBeans, select Run Rake Task => create_setup, and Rake takes care of the rest.

In case you're interested, here's an example of my Rakefile. It can no doubt be improved upon, but should give you an example to start from (Beware of line-wrap):

require 'rake'
require 'fileutils'
include FileUtils

# set constant values:
LIB_FOLDER = File.expand_path('../lib')
INSTALL_FOLDER = File.expand_path('../install')
ISCC = "C:/Program Files/Inno Setup 5/iscc.exe"
RESHACKER = "C:/Program Files/ResHacker/ResHacker.exe"
ISS_FILE = "#{INSTALL_FOLDER}/Setup.iss"
README_FILE = "#{INSTALL_FOLDER}/ReadMe.txt"

# extract values from main.rb file:
main_rb = open('../lib/main.rb').read
APP_TITLE = main_rb.scan(/APP_TITLE = '(.+)'/)[0][0]
EXE_NAME = main_rb.scan(/EXE_NAME = '(.+)'/)[0][0]
EXE_BASENAME = EXE_NAME.gsub('.exe', '')
APP_VERSION = main_rb.scan(/APP_VERSION = '(.+)'/)[0][0]

# rake tasks:
task :default => [:create_setup]

desc "Create setup.exe"
task :create_setup => [:move_exe, :modify_icon, :create_iss_script,
:edit_readme] do
puts "Creating setup.exe"
Dir.chdir(INSTALL_FOLDER)
system(ISCC, ISS_FILE)
end

desc "Create ISS script"
task :create_iss_script => [:move_exe] do
puts "Creating ISS script"
Dir.chdir(INSTALL_FOLDER)
data = ISS_TEXT.gsub('[APP_TITLE]', APP_TITLE)
.gsub('[APP_VERSION]', APP_VERSION)
.gsub('[EXE_NAME]', EXE_NAME)
.gsub('[EXE_BASENAME]', EXE_BASENAME)
File.open(ISS_FILE, 'w') do |f|
f.puts(data)
end
end

desc "Edit ReadMe.txt"
task :edit_readme do
puts "Updating ReadMe.txt file"
Dir.chdir(INSTALL_FOLDER)
txt = nil
open(README_FILE) do |f|
txt = f.read
end
old_version = txt.scan(/Version (\d\d\.\d\d\.\d\d)/)[0][0]
txt = txt.gsub(old_version, APP_VERSION)
File.delete(README_FILE)
open(README_FILE, 'w') do |f|
f.puts(txt)
end
end

desc "Modify EXE icon"
task :modify_icon => [:move_exe] do
puts "Modifying EXE icon"
Dir.chdir (INSTALL_FOLDER)
arg = " -addoverwrite #{EXE_NAME}, #{EXE_NAME}, application.ico,
icongroup, appicon, 0"
system(RESHACKER + arg)
end

desc "Move EXE to install folder"
task :move_exe => [:compile_code] do
puts "Moving EXE to install folder"
mv("#{LIB_FOLDER}/main.exe", "#{INSTALL_FOLDER}/#{EXE_NAME}")
end

desc "Compile code into EXE"
task :compile_code do
puts "Compiling main.rb into EXE"
system("rubyscript2exe.cmd", "#{LIB_FOLDER}/main.rb")
end

# text of Inno Setup script:
ISS_TEXT =<<-END_OF_ISS

[Setup]
AppName=[APP_TITLE]
AppVerName=[APP_TITLE] version [APP_VERSION]
AppPublisher=David L. Mullet
AppPublisherURL=http://davidmulletcom
AppContact= david.mullet@gmail.com
AppVersion=[APP_VERSION]
DefaultDirName=C:\\[APP_TITLE]
DefaultGroupName=[APP_TITLE]
UninstallDisplayIcon={app}\\[EXE_NAME]
Compression=lzma
SolidCompression=yes
OutputDir=.
OutputBaseFilename="[EXE_BASENAME]_Setup"

[Files]
Source: "[EXE_NAME]"; DestDir: "{app}"; Flags: ignoreversion
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme ignoreversion

[Icons]
Name: "{group}\\[APP_TITLE]"; Filename: "{app}\\[EXE_NAME]";
WorkingDir: "{app}"
Name: "{group}\\View ReadMe File"; Filename: "{app}\\ReadMe.txt";
WorkingDir: "{app}"

END_OF_ISS

As always, post a comment here or send me an email with questions, comments, or suggestions.

Thanks for stopping by!

Digg my article

Sunday, September 23, 2007

Installing Your Ruby App with Inno Setup Installer

In my last article, we looked at 'compiling' your Ruby app into a single portable executable file using RubyScript2Exe.

As a reader commented, "For windows it becomes so important to make things 'one click'. I guess the next step would be to also wrap this in some kind of simple installer script to store it in the right place and add the appropriate menu/desktop icons."

Which brings us to the topic of today's discussion: using Inno Setup to create an Install program (ie, setup.exe) for your Ruby applications.

Inno Setup, created, by Jordan Russell, has been around for about a decade, is very well documented, and frequently updated. It's very customizable and extendable, and allows you to create professional installation packages that will allow you to create directories, install files to multiple locations (install folder, Windows system folder, etc.), create Start menu Program groups and icons, and place shortcut icons on the user's Desktop and Quick Launch bar. And it's free of charge.

Inno Setup creates your Setup.exe file based on parameters that you define in a text-based script. Your ISS script file is divided into sections, with parameter=value pairs, much like a Windows INI file. Starting out, you'll probably use the Inno Setup user interface to create and edit your scripts, and then to compile your installation package into a setup.exe and run it.



Section names may include [Setup], [Files], [Icons], and [Code]. Inno Setup includes a comprehensive help file detailing all of the options, and there is an extensive FAQ document on the website.

A typical ISS script might look something like this:


[Setup]
AppName=My Ruby Application
AppVerName=My Ruby Application version 09.23.07
AppPublisher=David Mullet
AppPublisherURL=http://davidmullet.com
AppContact=david@davidmullet.com
AppVersion=09.23.07
DefaultDirName=C:\My Ruby Application
DefaultGroupName=My Ruby Application
UninstallDisplayIcon={app}\MyRubyApp.exe
Compression=lzma
SolidCompression=yes

[Files]
Source: "MyRubyApp.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "ReadMe.txt"; DestDir: "{app}"; Flags: isreadme ignoreversion

[Icons]
Name: "{group}\My Ruby Application"; Filename: "{app}\MyRubyApp.exe"; WorkingDir: "{app}"
Name: "{group}\View ReadMe File"; Filename: "{app}\ReadMe.txt"; WorkingDir: "{app}"

Inno Setup is highly customizable. You can, for example, customize the install wizard, or include a [Code] section with Pascal procedures (see the Help file for details and examples). The scripts are straight text, and the compiler can be called from the command line, so you can create and compile your ISS script all within Ruby, if you like, such as in a Rakefile. I'll include just such an example in an upcoming article.

So, you can now create a single executable file for your Ruby application and use a professional-looking installer to distribute it.

Questions? Comments? Suggestions? Post a comment here or send me an email message.

Thanks for stopping by!

Digg my article

Tuesday, September 18, 2007

Compiling Your Ruby App with RubyScript2Exe

I've mentioned RubyScript2Exe previously. This tool allows you to 'compile' a script/application into a portable executable file (EXE) that you can easily provide to your users without requiring them to install Ruby and the required libraries. RubyScript2Exe traces and gathers all the necessary files, including the Ruby interpreter, and 'compiles' them into a single EXE file. You can easily embed images and icon files, and DLLs such as SQLite.

I put the word 'compile' in quotes above because RubyScript2Exe does not transform your code as a C compiler or .Net compiler would. Rather, it collects all the files necessary to run your application and bundles them into a single EXE file. When the user runs that EXE file, that bundle is quickly extracted to a temporary file and your Ruby code is executed.

Installing RubyScript2Exe is as easy as falling off a log, thanks to RubyGems. Just get to a command prompt and enter:


gem install rubyscript2exe

Include the following require statement at the top of your script:

require 'rubyscript2exe'

Whenever possible, include all your require statements at the top of your script. This ensures that RubyScript2Exe successfully traces and includes all the necessary files your application will need.

If you are compiling a non-console script and therefore want to use the rubyw.exe interpreter, rather than the ruby.exe interpreter, include the following module variable near the top of your script:

RUBYSCRIPT2EXE.rubyw = true

When I use the NetBeans Ruby IDE, which defaults a new project's main script name to "main.rb", I include the above code to avoid renaming the script with a ".rbw" extension or providing command-line parameters to the RubyScript2Exe compiler. More on that later.

A Ruby Forum reader and RubyScript2Exe user recently mentioned "I want to be able to wrap the icon file along with the rest of the application." You can embed additional files such as icons or DLLs in the executable like this:

RUBYSCRIPT2EXE.bin = ["my_icon.ico", "sqlite3.dll"]

When you run your compiled executable, RubyScript2Exe extracts all the files from your executable into a temporary directory. But sometimes you need to know the location of the folder the executable was originally run from. Just call the RUBYSCRIPT2EXE.exedir method:

APPLICATION_PATH = RUBYSCRIPT2EXE.exedir

Enough preparation! Let's compile our application. Go to a command prompt and enter:

rubyscript2exe my_script.rb

...or...

rubyscript2exe my_script.rbw

If your script has a filename extension of .rb, RubyScript2Exe will include the ruby.exe interpreter and a console window. If your script has a filename extension of .rbw, RubyScript2Exe will include the rubyw.exe interpreter and your app will therefore not have a console window; this is the same as if you had included RUBYSCRIPT2EXE.rubyw = true in your code.

The size of your compiled executable can vary widely depending on what files are needed to be included. A simple console app may be 1mb in size, a wxRuby 0.6 GUI app may be 3-4mb, and a wxRuby 2 GUI app may be 6-8mb in size. Part of this size is due to a known 'bug' that may cause some files (the 8mb wxRuby2.so file, for example) to be included twice. This affects the size of the EXE file but not the performance.

There you have it. But this post just scratches the surface. RubyScript2Exe's creator, Erik Veenstra, has done a great job maintaining and documenting this tool, and you should take a few minutes and read the docs here.

Questions? Comments? Suggestions?

Post a comment here or send me an email.

Thanks for stopping by!

Digg my article

Wednesday, September 12, 2007

NetBeans Ruby IDE

If you're looking for a new Ruby editor, I suggest you check out NetBeans. Tor Norbye and the gang have been doing a great job adapting this Java IDE for use with Ruby and Rails.

I usually use SciTE, the Scintilla text editor, for writing my Ruby code. It's fast, flexible, and lightweight, consuming a fraction of the resources of a full-blown IDE. It's still my editor of choice for small scripts. But I've begun using NetBeans for larger projects and am very pleased so far.

NetBeans is now available in a Ruby-only version which, presumably, is a little slimmer than the full Java + Ruby IDE. And you can trim a little more fat by deactivating a few plug-ins. On my Windows XP systems, memory usage is in the 80-120Mb range. That's acceptable, even on my more memory-challenged machine, when you consider the potential productivity gains offered by the IDE features. And the fact that it's free is certainly a plus.

Further details can be found on the NetBeans Ruby Support page, on the NetBeans Ruby wiki, and in numerous in-depth reviews like this one by Daniel Spiewak.

New builds are posted every few hours, and the latest stable build can always be found here. I usually replace my nbrubyide folder every day or two.

So if you're looking for a full-featured Ruby IDE, take NetBeans for a test drive and see if it meets your needs. It may be a dumb name, but it's a good Ruby IDE.

Wednesday, August 22, 2007

Windows Developer Power Tools

While taking a brief respite from tutorialism and browsing the stacks at Barnes & Noble recently, I stumbled across Windows Developer Power Tools, an O'Reilly book by James Avery and Jim Holmes that covers over 170 free tools for Windows developers.

I've only scratched the surface thus far, but have already begun using several of the tools mentioned in the book, including SQLite Administrator, SharpDevelop, and Snippet Compiler. Some tools are .NET-specific, but many more are not.

The companion web site is here.

If you work with SQLite, my personal favorite database, you'll probably find SQLite Administrator quite helpful. It provides a GUI front end that allows you to create, design, and manage SQLite database files. Check out the website for full details and screenshots.

Digg my article

Saturday, March 10, 2007

Developing Desktop Ruby Apps for Windows

It seems that a large portion of the Ruby community is either LINUX or Mac OS-based. And Ruby's 'Killer App' is a web development framework (Ruby on Rails). So you can be forgiven for not realizing that you can use Ruby to develop solid desktop applications for Microsoft Windows, complete with a native Windows look-and-feel GUI.

Every tool has its Pros and Cons, its Fanboys and Detractors. For what it's worth, here's a brief overview of the tools I consider essential...

RUBY: One-Click Ruby Installer
The One-Click Ruby Installer will probably meet your needs for a painless Ruby installation that includes most of the Ruby libraries you'll need starting out. It includes the SciTE Text Editor (my code editor of choice) and the WIN32OLE library, essential for COM automation.

DATABASE: SQLite
SQLite is fast, light, and powerful -- and requires zero-configuration. Download the DLL file, install the sqlite-ruby gem and you're ready to deal with datasets both large and small. You can even embed the small SQLite3.DLL file in your RubyScript2Exe-compiled executable file.

GUI TOOLKIT: wxRuby
I've been using wxRuby (version 0.6) for about a year now, and am pleased with the results. My GUI needs are fairly modest (buttons, list and combo boxes, textboxes, etc.) and my user interfaces are virtually identical to those produced by Microsoft Visual Studio. For best results, be sure to de-couple your GUI code from your back-end code, to ensure optimal GUI responsiveness and the ability to easily replace GUIs in the future. Write your GUI code by hand, or use the (separate but free) wxFormBuilder tool to design your interface and export it to an XML document that wxRuby can load.

COMPILER: RubyScript2Exe
See my earlier post, Distributing Ruby Apps on Windows, for further details on this essential tool.

INSTALLER: Inno Setup
Once you have your application packaged up into an executable, you'll want to provide your users with a simple means for installing it (and perhaps other files) on their PCs, creating Start menu icons, etc. Inno Setup handles all of this, is easily configurable, and gives your Windows application a professional, polished installation package.

I hope you find the information above, and this Ruby on Windows weblog in general, to be helpful.

Thanks for stopping by!

Digg my article

Sunday, February 25, 2007

Distributing Ruby Apps on Windows

So, you've developed a Ruby script or application for Windows. You'd like to compile the application into a portable executable file (EXE) that you can easily provide to your users without requiring them to install Ruby and the required libraries. Reach for RubyScript2Exe, Erik Veenstra's Ruby compiler. RubyScript2Exe traces and gathers all the necessary files, including the Ruby interpreter, and 'compiles' them into a single EXE file. You can easily embed images and icon files, and DLLs such as SQLite. RubyScript2Exe is easy to configure, very reliable, and well-documented and supported by the author. Executable files are 3-4mb in size for a typical wxRuby (0.6) application.

UPDATE: I have posted a new article with further details on using RubyScript2Exe, here.

To make compiling your Ruby apps even easier, install LopeSoft's free File Menu Tools and add a new file menu command for RubyScript2Exe. Then just right-click on your Ruby script in Windows explorer and select 'Compile with RubyScript2Exe'.

Speaking of compiling Ruby apps on Windows, keep an eye on the Gardens Point Ruby.NET Compiler project at Australia's Queensland University of Technology. I haven't done much with it yet but it looks promising.

Thanks for stopping by!

Digg my article