envious 0.1.1 → 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.md +10 -0
- data/envious.gemspec +1 -1
- data/lib/envious.rb +9 -5
- data/lib/envious/railtie.rb +4 -0
- data/lib/tasks/heroku.rake +10 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -42,6 +42,16 @@ In the above case, `ENV["API_KEY"]` will produce `"ABCXYZ"` because any values n
|
|
42
42
|
Since Envious configuration is loaded when your Rails app loads, the `ENV` hash is available anywhere in your application where you may need to call upon your configuration.
|
43
43
|
|
44
44
|
|
45
|
+
## Using with Heroku
|
46
|
+
Envious allows easy transfer of local environment variables to heroku using a simple rake task. To copy local settings to Heroku use:
|
47
|
+
|
48
|
+
$ rake envious:heroku:push
|
49
|
+
|
50
|
+
The environment used is dependant on Heroku's `RAILS_ENV` configuration setting. If it is blank, Envious assumes it is using `production`. Changing this setting on Heroku is simple. To change Heroku's `RAILS_ENV` to development, use the following command:
|
51
|
+
|
52
|
+
$ heroku config:add RAILS_ENV=development
|
53
|
+
|
54
|
+
|
45
55
|
## Questions or Problems?
|
46
56
|
|
47
57
|
If you have any questions or issues with Envious, please add an [issue on GitHub](https://github.com/RyanNielson/envious/issues), or send a pull request.
|
data/envious.gemspec
CHANGED
data/lib/envious.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require "envious/railtie"
|
2
|
-
|
2
|
+
require "pp"
|
3
3
|
module Envious
|
4
4
|
extend self
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def vars_for_heroku()
|
7
|
+
env_vars = default_vars.merge(environment_vars)
|
8
|
+
env_vars = env_vars.map { |k, v| "#{k}=#{v}"}.join(' ')
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_env()
|
8
12
|
add_to_environment(default_vars.merge(environment_vars))
|
9
13
|
end
|
10
14
|
|
@@ -17,7 +21,7 @@ module Envious
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def environment
|
20
|
-
Rails.env
|
24
|
+
Rails.env.to_s
|
21
25
|
end
|
22
26
|
|
23
27
|
def default_vars()
|
@@ -29,6 +33,6 @@ module Envious
|
|
29
33
|
end
|
30
34
|
|
31
35
|
def add_to_environment(hash)
|
32
|
-
hash.each { |key, value| ENV[key.to_s] = value.to_s }
|
36
|
+
hash.each { |key, value| ENV[key.to_s] = value.to_s unless ENV.key?(key.to_s) }
|
33
37
|
end
|
34
38
|
end
|
data/lib/envious/railtie.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :envious do
|
2
|
+
namespace :heroku do
|
3
|
+
desc "Push environment variables to heroku."
|
4
|
+
task :push do
|
5
|
+
rails_env = `heroku config:get RAILS_ENV`.strip
|
6
|
+
Rails.env = rails_env.blank? ? 'production' : rails_env
|
7
|
+
Kernel.system("heroku config:add #{Envious.vars_for_heroku}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/envious/railtie.rb
|
62
62
|
- lib/generators/envious/setup_generator.rb
|
63
63
|
- lib/generators/envious/templates/environment_vars.yml
|
64
|
+
- lib/tasks/heroku.rake
|
64
65
|
- spec/spec_helper.rb
|
65
66
|
homepage: http://github.com/ryannielson/envious
|
66
67
|
licenses: []
|