heroku_env 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.textile CHANGED
@@ -19,5 +19,5 @@ without changing herokus or your variables
19
19
  FOO: BAR
20
20
  </code></pre>
21
21
 
22
- Heroku Env will overwrite herokus environment variables with yours in
23
- <code>config/heroku_env.yml</code>
22
+ You can generate a default <code>heroku_env.yml</code> file with a rake task:
23
+ <code>rake heroku_env:config:create</code>
data/lib/heroku_env.rb CHANGED
@@ -1,16 +1,31 @@
1
1
  module HerokuEnv
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
- config.before_configuration do
5
- heroku_config = `heroku config --shell`.split("\n").inject({}) do |config, item|
6
- key, value = item.split("=", 2)
7
- config[key] = value
8
- config
4
+
5
+ rake_tasks do
6
+ namespace :heroku_env do
7
+ namespace :config do
8
+ desc "Create heroku_env.yml from heroku config"
9
+ task :create => :environment do
10
+ heroku_config = `heroku config --shell`.split("\n").inject({}) do |config, item|
11
+ key, value = item.split(/\s+\=\>\s+/, 2)
12
+ config[key] = value
13
+ config
14
+ end
15
+ heroku_env = { :development => heroku_config.clone, :test => heroku_config.clone }
16
+ puts heroku_env.to_yaml
17
+ end
18
+ end
9
19
  end
10
- custom_config = YAML.load_file(File.join(::Rails.root, "config", "heroku_env.yml"))[::Rails.env] rescue {}
11
- config = heroku_config.merge(custom_config)
12
- config.each do |key, value|
13
- ENV[key] = value if !ENV.has_key?(key) && key != "BUNDLE_WITHOUT"
20
+ end
21
+
22
+ unless ENV.include?('HEROKU_UPID')
23
+ config.before_configuration do
24
+ if heroku_config = YAML.load_file(File.join(::Rails.root, "config", "heroku_env.yml"))[::Rails.env] rescue nil || {}
25
+ heroku_config.each do |key, value|
26
+ ENV[key] = value if !ENV.has_key?(key) && !["BUNDLE_WITHOUT", "RACK_ENV"].include?(key)
27
+ end
28
+ end
14
29
  end
15
30
  end
16
31
 
@@ -1,3 +1,3 @@
1
1
  module HerokuEnv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: heroku_env
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Spangenberg
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-16 00:00:00 Z
13
+ date: 2011-04-20 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: heroku