O
Ohad Lutzky
I have this bit of code in the beginning of an application I'm writing
(in main.rb):
require 'pathname'
p = Pathname.new($0)
if p.basename.to_s == 'main.rb'
Dir.chdir p.parent.to_s
end
require 'gui/main_window'
... # (rest of requires, application itself)
The check whether it's "main.rb" or not is so this doesn't happen for
Rake. Now, it works well, but it's ugly. The reason I don't just go
ahead and use ':' is that I use glade, as well as some other files which
I need to be able to find. This is currently in development, so I'd
prefer to avoid forcing people to install the program in predetermined
locations (/usr/local/bin, /usr/local/share/my_app_files, et cetera).
Any cleaner solution?
(in main.rb):
require 'pathname'
p = Pathname.new($0)
if p.basename.to_s == 'main.rb'
Dir.chdir p.parent.to_s
end
require 'gui/main_window'
... # (rest of requires, application itself)
The check whether it's "main.rb" or not is so this doesn't happen for
Rake. Now, it works well, but it's ugly. The reason I don't just go
ahead and use ':' is that I use glade, as well as some other files which
I need to be able to find. This is currently in development, so I'd
prefer to avoid forcing people to install the program in predetermined
locations (/usr/local/bin, /usr/local/share/my_app_files, et cetera).
Any cleaner solution?