Sha256: 20f4580a8ea040c372196ee55c90fa158beda577e1062fb0ced347cf7393e5d9

Contents?: true

Size: 962 Bytes

Versions: 34

Compression:

Stored size: 962 Bytes

Contents


say_wizard "Generating config/env.yaml..."

append_file "config/application.rb", <<-RUBY

require 'env_yaml'
RUBY

create_file "lib/env_yaml.rb", <<-RUBY
require 'yaml'
begin
  env_yaml = YAML.load_file(File.dirname(__FILE__) + '/../config/env.yml')
  if env_hash = env_yaml[ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development']
    puts env_hash.inspect
    env_hash.each_pair do |k,v|
      ENV[k] = v.to_s
    end
  end
rescue StandardError => e
end

RUBY

create_file "config/env.yml", <<-YAML
defaults:
  ENV_YAML: true

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults
YAML

def env(k,v,rack_env='development')
  inject_into_file "config/env.yml", :after => "#{rack_env}:\n  <<: *defaults" do
    <<-YAML
#{k}: #{v.inspect}    
YAML
  end
end

__END__

name: EnvYAML
description: "Allows you to set environment variables in a YAML file at config/env.yaml"
author: mbleigh

category: other
tags: [utilities, configuration]

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
rails_apps_composer-1.0.26 recipes/env_yaml.rb
rails_apps_composer-1.0.25 recipes/env_yaml.rb
rails_apps_composer-1.0.24 recipes/env_yaml.rb
rails_apps_composer-1.0.23 recipes/env_yaml.rb
rails_apps_composer-1.0.22 recipes/env_yaml.rb
rails_apps_composer-1.0.21 recipes/env_yaml.rb
rails_apps_composer-1.0.20 recipes/env_yaml.rb
rails_apps_composer-1.0.19 recipes/env_yaml.rb
rails_apps_composer-1.0.18 recipes/env_yaml.rb
rails_apps_composer-1.0.17 recipes/env_yaml.rb
rails_apps_composer-1.0.16 recipes/env_yaml.rb
rails_apps_composer-1.0.15 recipes/env_yaml.rb
rails_apps_composer-1.0.14 recipes/env_yaml.rb
rails_apps_composer-1.0.12 recipes/env_yaml.rb
rails_apps_composer-1.0.11 recipes/env_yaml.rb
rails_apps_composer-1.0.10 recipes/env_yaml.rb
rails_apps_composer-1.0.7 recipes/env_yaml.rb
rails_apps_composer-1.0.6 recipes/env_yaml.rb
rails_apps_composer-1.0.5 recipes/env_yaml.rb
rails_apps_composer-1.0.4 recipes/env_yaml.rb