G
Gavri Savio Fernandez
Hi,
I downloaded ruby-google and tried to run the sample code when I noticed that the code was unusable as is, in Windows, because it assumed that the configuration file is named .google_key and Win 2000 Professional atleast does not allow '.' to be the first character of a filename.
KEY = File.open("#{ENV['HOME']}/.google_key") {|kf| kf.readline.chomp}
I made a quick modification just so I could get it working. (Ugly, I know)
KEY =
begin
File.open("#{ENV['HOME']}/.google_key") {|kf| kf.readline.chomp}
rescue
File.open("#{ENV['HOME']}/~google_key") {|kf| kf.readline.chomp}
end
What I'd like to know is what is the ruby idiom for choosing configuration files in an OS-agnostic way? (Emacs does this, choosing ~emacs on Win and .emacs on Linux) . Or is this too simple an issue to require an idiom?
thanks,
gavri
I downloaded ruby-google and tried to run the sample code when I noticed that the code was unusable as is, in Windows, because it assumed that the configuration file is named .google_key and Win 2000 Professional atleast does not allow '.' to be the first character of a filename.
KEY = File.open("#{ENV['HOME']}/.google_key") {|kf| kf.readline.chomp}
I made a quick modification just so I could get it working. (Ugly, I know)
KEY =
begin
File.open("#{ENV['HOME']}/.google_key") {|kf| kf.readline.chomp}
rescue
File.open("#{ENV['HOME']}/~google_key") {|kf| kf.readline.chomp}
end
What I'd like to know is what is the ruby idiom for choosing configuration files in an OS-agnostic way? (Emacs does this, choosing ~emacs on Win and .emacs on Linux) . Or is this too simple an issue to require an idiom?
thanks,
gavri