jruby/rawr exe bundling headbanging with windows xp.

Since I could find nothing on this online, some notes in case it helps anyone.

On Windows XP SP3
jruby 1.5.5
rawr 1.4.5

I was trying to do this:

jruby -S rake rawr:bundle:exe

I kept getting this error:

** Invoke rawr:bundle:exe (first_time)
** Invoke rawr:jar (first_time)
** Invoke package/jar/sersol_delete_url_check.jar (first_time, not_needed)
** Invoke package/classes/java/org/rubyforge/rawr/Main.class (first_time, not_needed)
** Invoke src/org/rubyforge/rawr/Main.java (first_time, not_needed)
** Invoke package/classes/java (first_time, not_needed)
** Invoke package/classes/META-INF (first_time, not_needed)
** Invoke package/jar (first_time, not_needed)
** Execute rawr:jar
cp lib/java/jruby-complete.jar package/jar/lib/java/jruby-complete.jar
** Invoke package/windows (first_time, not_needed)
** Execute rawr:bundle:exe
Creating Windows application in package/jar/sersol_delete_url_check.exe
rake aborted!
private method `split’ called for nil:NilClass
c:/jruby-1.5.5/lib/ruby/gems/1.8/gems/rawr-1.4.5/lib/exe_bundler.rb:95:in `deploy’
c:/jruby-1.5.5/lib/ruby/gems/1.8/gems/rawr-1.4.5/lib/rawr.rb:225
c:/jruby-1.5.5/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call’

I poked around in exe_bundler.rb and made it put file_dir_name, the part of file_dir_name split out for use in output, and output to the screen:

FILE DIR NAME: c:/jruby-1.5.5/lib/ruby/gems/1.8/gems/rawr-1.4.5/lib
SPLIT NAME: c
OUTPUT: Error: The filename, directory name, or volume label syntax is incorrect.

I’m on my work computer so I don’t have full admin permissions, but I can run this fine in the cmd window myself:
fsutil fsinfo volumeinfo c:

Anyway, all of that is leading up to finding out whether my file system is FAT32 or NTFS, so it can do:


if 'NTFS' == output.split("n")[3].split(':')[1].strip
sh "echo y | cacls "#{file_dir_name}/launch4j/bin-win/windres.exe" /G "#{ENV['USERNAME']}":F"
sh "echo y | cacls "#{file_dir_name}/launch4j/bin-win/ld.exe" /G "#{ENV['USERNAME']}":F"
end

I know it is NTFS, so I just commented out the if block lines:


#if 'NTFS' == output.split("n")[3].split(':')[1].strip
sh "echo y | cacls "#{file_dir_name}/launch4j/bin-win/windres.exe" /G "#{ENV['USERNAME']}":F"
sh "echo y | cacls "#{file_dir_name}/launch4j/bin-win/ld.exe" /G "#{ENV['USERNAME']}":F"
#end

That’s hideous, but hey, the next run of rawr:bundle:exe worked with no errors, successfully creating my exe.

Of course, now that I have an exe, I have found that it appears to do nothing, regardless of how I run it. But figuring that out is for another day, because I must get ready to leave work.

ruby, a teeny bit at a time.

So I’ve learned Ruby and I am in love. And I just learned something that is going to make my life a whole lot easier and my scripts a lot less convoluted. Perhaps this was in one of the several books/tutorials I’ve read on the language, but I don’t remember it, or it was not presented in a way that seemed relevant to my applications.

My question was how do I get back to nameless, label-less objects based on their instance attributes? Here’s a silly example:

Here’s the definition of the Cat class:

class Cat
attr_reader :name, :byear

def initialize(name, byear)
@name = name
@byear = byear
end #def initialize
end #class Cat

My initial array—I’ll call it catdata—looked like this:
[["Be", 1996], ["Cu", 1996], ["Hal", "unknown"], ["Felix", 1919]]

I created an array of Cat objects:
cats = []

catdata.each do |e|
newcat = Cat.new(e[0], e[1])
cats.push(newcat)
end #catdata.each do

Now cats is an array of mysterious objects:
[#<Cat:0x7ff6d324>, #<Cat:0x7ff6d34c>, ...etc]

My Problem: Variable names are not assigned to the Cat objects when they are created. How do I access those Cat objects using their instance attributes? For instance, if I want to pull out all the cats born in 1996, what do I do?

I’d come up with a very ugly workaround (don’t ask), but this is much, much cleaner and I believe it can easily be defined as a method for the Cat class. (And if there is an even better/more direct way to do this, please share!)

_1996cats = cats.find_all do |cat|
cat.instance_variable_get(:@byear) == 1996
end

The result is an array with two elements: the objects for Be and Cu. Hooray!