def config(*args, &block)
unless defined?(@config)
require 'yaml' unless defined?(YAML)
if test(?s, config_path)
@config = YAML.load(IO.read(config_path))
else
config = args.last.is_a?(Hash) ? args.last : {}
lines = config.to_yaml.split(/\n/)
dash = lines.shift
open(config_path, 'w') do |fd|
fd.puts '### you may need to edit this config!'
fd.puts
fd.puts lines
end
editor = ENV['EDITOR'] || ENV['EDIT'] || 'vi'
system("#{ editor.inspect } #{ config_path }")
@config = YAML.load(IO.read(config_path))
end
end
@config
end