envyable 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +18 -1
- data/lib/envyable/rails-now.rb +9 -0
- data/lib/envyable/railtie.rb +18 -1
- data/lib/envyable/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3200aedd3b04ed43ad9fd1e75564d81549ba4958
|
4
|
+
data.tar.gz: 9c48bca7830540999cfb5ee18e67edba2f411681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86fbe5ab7f712f6aadb458c04ce02e0e6e57bcc3a56315d269224890414524c08858da0b4d00984785fa96616efb209a7a4a173b3bdeec67a76d16c569c6b5a1
|
7
|
+
data.tar.gz: dd1db30e4fd41cf05533cd6ee4fe341f07836c2ae002fbdae3703f3a5c1a44532387c80c2ca4c8cbe4baa4768f9588483b900366c40b31a4df03835a395a55fb
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -34,9 +34,26 @@ test:
|
|
34
34
|
|
35
35
|
Once installed in a Rails app, add your yaml file at `config/env.yml`. The gem will load the correct environment on initialization of the application.
|
36
36
|
|
37
|
+
### Load Immediately
|
38
|
+
|
39
|
+
If you have gems that require variables to be set earlier, then place `envyable` in the `Gemfile` before those gems and require `envyable/rails-now`:
|
40
|
+
```
|
41
|
+
gem 'envyable', require: 'envyable/rails-now'
|
42
|
+
gem 'other-gem-that-requires-env-variables'
|
43
|
+
```
|
44
|
+
|
37
45
|
### Other applications
|
38
46
|
|
39
|
-
|
47
|
+
With the exception of loading Envyable immediately via the Gemfile, you can create your yaml file anywhere (though why not `config/env.yml`?). To load your yaml file into `ENV`, call:
|
48
|
+
```
|
49
|
+
Envyable.load('path/to/yml', environment)
|
50
|
+
```
|
51
|
+
|
52
|
+
The default environment is development if you leave that argument blank. For example, if your variables are in a config folder in a file called env.yml, and you want to load development only, include in your script:
|
53
|
+
```
|
54
|
+
require 'envyable'
|
55
|
+
Envyable.load('config/env.yml')
|
56
|
+
```
|
40
57
|
|
41
58
|
### Version control
|
42
59
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# For gems that require environment variables to be set before application is
|
2
|
+
# loaded, then place `envyable` in the `Gemfile` before those gems and
|
3
|
+
# require `envyable/rails-now`, e.g.
|
4
|
+
#
|
5
|
+
# gem 'envyable', require: 'envyable/rails-now'
|
6
|
+
# gem 'gem-that-requires-env-variables'
|
7
|
+
|
8
|
+
require 'envyable/railtie'
|
9
|
+
Envyable::Railtie.load
|
data/lib/envyable/railtie.rb
CHANGED
@@ -1,7 +1,24 @@
|
|
1
|
+
require 'envyable'
|
2
|
+
|
1
3
|
module Envyable
|
2
4
|
class Railtie < Rails::Railtie
|
3
5
|
initializer "envyable.load", :before => :load_environment_config do
|
4
|
-
|
6
|
+
load
|
7
|
+
end
|
8
|
+
|
9
|
+
def load
|
10
|
+
Envyable.load root.join('config', 'env.yml'), Rails.env
|
11
|
+
end
|
12
|
+
|
13
|
+
# Fallback of ENV variable or current directory because
|
14
|
+
# Rails 4.1+ returns nil for Rails.root prior to app initialization
|
15
|
+
def root
|
16
|
+
Rails.root || Pathname.new(ENV["RAILS_ROOT"] || Dir.pwd)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Avoid Rails calling `Kernel#load` via #method_mising
|
20
|
+
def self.load
|
21
|
+
instance.load
|
5
22
|
end
|
6
23
|
end
|
7
24
|
end
|
data/lib/envyable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envyable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- envyable.gemspec
|
70
70
|
- lib/envyable.rb
|
71
71
|
- lib/envyable/loader.rb
|
72
|
+
- lib/envyable/rails-now.rb
|
72
73
|
- lib/envyable/railtie.rb
|
73
74
|
- lib/envyable/version.rb
|
74
75
|
- spec/envyable/loader_spec.rb
|
@@ -96,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
version: '0'
|
97
98
|
requirements: []
|
98
99
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.5.1
|
100
101
|
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: The simplest yaml to ENV config loader
|