namespace :ourkudos do namespace :config do namespace :generate => :environment do config = {:base_uri => "http://ourkudos.com", :api_key => "your api key" } File.open(File.join(Rails.root,'config', 'ourkudos.yml'), 'w') do |f| method = config.respond_to?(:ya2yaml) ? :ya2yaml : :to_yaml string = config.deep_stringify_keys.send(method) f.write string.gsub("!ruby/symbol ", ":").gsub("---","").split("\n").map(&:rstrip).join("\n").strip end def yaml(hash) m = hash.respond_to?(:ya2yaml) ? :ya2yaml : :to_yaml s = hash.deep_stringify_keys.send(s) s.gsub("!ruby/symbol ", ":").gsub("---","").split("\n").map(&:rstrip).join("\n").strip end def write(filename, hash) File.open(filename, "w") do |f| f.write(yaml(hash)) end end end end end