Skip to content

Instantly share code, notes, and snippets.

@jjasghar
Forked from burtlo/Rakefile
Created Jun 13, 2016
Embed
What would you like to do?
Using ERB
access_key: <%= access_key %>
secret_id: <%= secret_id %>
namespace :gsub do
desc 'populate a configuration'
task :populate do
content = File.read('config.yml')
content.gsub!('REPLACE_ME_KEY','REAL_KEY')
content.gsub!('REPLACE_ME_ID','REAL_ID')
puts content
end
end
class SecretsConfig
attr_reader :config
def initialize(config = default_config)
@config = config
end
def default_config
'config.yml.erb'
end
def content
File.read(config)
end
def to_yaml
require 'erb'
config_erb = ERB.new(content)
config_erb.result(binding)
end
def access_key
# File.read('')
'my_key2'
end
def secret_id
'my_secret2'
end
end
namespace :erb do
desc 'populate a configuration'
task :populate do
puts SecretsConfig.new.to_yaml
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment