Created
October 25, 2010 13:52
-
-
Save PaulCampbell/644984 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake' | |
require 'configatron' | |
require 'pp' | |
task :setEnvironmentVariables do | |
$env = ENV['environment'] | |
if $env.nil? | |
puts "Please enter an environment to deploy this build to." | |
fail | |
elsif !File.exist?($env + ".yaml") | |
puts "Cannot find configuration for #{$env} environment." | |
puts "Try one of " + Dir.glob("*.yaml").collect {|f| f[0...f.index('.')]}.to_s | |
fail | |
else | |
configatron.configure_from_yaml($env + ".yaml") | |
puts "Releasing build to #{$env} environment." | |
end | |
end | |
desc 'Config CWS Web application to environment' | |
task :config_all_projects => :setEnvironmentVariables do | |
puts "Config ALL applications to environment" | |
Dir.glob("**/*.configatron") do |filename| | |
str = File.read(filename) | |
str = str.gsub(/#\{(configatron\..*)\}/) do |v| | |
c = eval($1) | |
#puts $1, c | |
if c.nil? | |
puts "The config parameter #{$1} in #{filename} is missing from #{$env}.yaml" | |
puts "Check your configuration files and re-run this task." | |
fail | |
end | |
c | |
end | |
# delete file? | |
filename["configatron"] = "config" | |
File.open(filename, 'w') { |f| f.write(str) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment