require 'rake' namespace :ourkudos do namespace :config do task :generate => :environment do config = {:base_uri => "http://ourkudos.com", :api_key => "your api key" } file_path = File.join(Rails.root,'config', 'ourkudos.yml') puts "Generating config file to #{file_path}. \nPlease update it with correct api key" File.open(file_path, '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 end end end