Sha256: de5b3cd5a82da6b622d6ef6fb8857380751277808a076cdb48ca9104f73ddf4a

Contents?: true

Size: 946 Bytes

Versions: 19

Compression:

Stored size: 946 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']
    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: &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

19 entries across 19 versions & 4 rubygems

Version Path
appscrolls-0.11.2 scrolls/env_yaml.rb
appscrolls-0.11.1 scrolls/env_yaml.rb
appscrolls-0.11.0 scrolls/env_yaml.rb
appscrolls-0.10.1 scrolls/env_yaml.rb
appscrolls-0.10.0 scrolls/env_yaml.rb
appscrolls-0.9.0 scrolls/env_yaml.rb
appscrolls-0.8.4 scrolls/env_yaml.rb
appscrolls-0.8.3 scrolls/env_yaml.rb
appscrolls-0.8.2 scrolls/env_yaml.rb
appscrolls-0.8.1 scrolls/env_yaml.rb
appscrolls-0.8.0 scrolls/env_yaml.rb
appscrolls-0.7.1 scrolls/env_yaml.rb
appscrolls-0.7.0 scrolls/env_yaml.rb
eldarscrolls-0.7.0 scrolls/env_yaml.rb
ey_rails_wizard-0.6.0 scrolls/env_yaml.rb
ey_rails_wizard-0.5.0 scrolls/env_yaml.rb
ey_rails_wizard-0.4.0 scrolls/env_yaml.rb
ey_rails_wizard-0.3.1 recipes/env_yaml.rb
rails_wizard-0.1.5 recipes/env_yaml.rb