lib/sup.rb in sup-0.4 vs lib/sup.rb in sup-0.5
- old
+ new
@@ -31,11 +31,11 @@
end
end
end
module Redwood
- VERSION = "0.4"
+ VERSION = "0.5"
BASE_DIR = ENV["SUP_BASE"] || File.join(ENV["HOME"], ".sup")
CONFIG_FN = File.join(BASE_DIR, "config.yaml")
SOURCE_FN = File.join(BASE_DIR, "sources.yaml")
LABEL_FN = File.join(BASE_DIR, "labels.txt")
@@ -70,11 +70,11 @@
## one-stop shop for yamliciousness
def save_yaml_obj object, fn, safe=false
if safe
safe_fn = "#{File.dirname fn}/safe_#{File.basename fn}"
- mode = File.stat(fn) if File.exists? fn
+ mode = File.stat(fn).mode if File.exists? fn
File.open(safe_fn, "w", mode) { |f| f.puts object.to_yaml }
FileUtils.mv safe_fn, fn
else
File.open(fn, "w") { |f| f.puts object.to_yaml }
end
@@ -167,10 +167,11 @@
if File.exists? Redwood::CONFIG_FN
$config = Redwood::load_yaml_obj Redwood::CONFIG_FN
else
require 'etc'
require 'socket'
- name = Etc.getpwnam(ENV["USER"]).gecos.split(/,/).first
+ name = Etc.getpwnam(ENV["USER"]).gecos.split(/,/).first rescue nil
+ name ||= ENV["USER"]
email = ENV["USER"] + "@" +
begin
Socket.gethostbyname(Socket.gethostname).first
rescue SocketError
Socket.gethostname