namespace :environment do

desc 'display current environment'
task :current do
  puts 'Environment: ' + Inf.environment.to_s.green
end

def set_environment_and_save(environment)
  Inf.environment.assign :environment, environment
  Inf.environment.configuration.save_config Inf.path.rails.config_infrastructure_dir + '/environment.yml'
  Rake::Task['environment:current'].invoke
end

%w( test development production ).each do |environment|
  desc "Change to #{environment} environment"
  task(environment.to_sym) { set_environment_and_save environment }
end

end