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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b57186fbe7d6265ce530ab6a33f95fca5c05a03
4
- data.tar.gz: 887228621e2fea513d72db59f7f84ceaf59a69c6
3
+ metadata.gz: 3200aedd3b04ed43ad9fd1e75564d81549ba4958
4
+ data.tar.gz: 9c48bca7830540999cfb5ee18e67edba2f411681
5
5
  SHA512:
6
- metadata.gz: 6bd05e5ce62e73555001d214a199135da6732e1ce3b457ca6f58ac7e9dc8c7cdfe0842b9473ae7f5c10af18284f95f6dc739839aec0c71bc4cdf3c5b10b63735
7
- data.tar.gz: 1d52aa03bafa7e316fd94c403181339f98f442764120a567cc7e4a1caccb328472563129b8db12f68e5ec3c40259514e389a66f5012f8204730d3f05a1283e83
6
+ metadata.gz: 86fbe5ab7f712f6aadb458c04ce02e0e6e57bcc3a56315d269224890414524c08858da0b4d00984785fa96616efb209a7a4a173b3bdeec67a76d16c569c6b5a1
7
+ data.tar.gz: dd1db30e4fd41cf05533cd6ee4fe341f07836c2ae002fbdae3703f3a5c1a44532387c80c2ca4c8cbe4baa4768f9588483b900366c40b31a4df03835a395a55fb
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Phil Nash
1
+ Copyright (c) 2016 Phil Nash
2
2
 
3
3
  MIT License
4
4
 
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
- You can create your yaml file anywhere (though why not `config/env.yml`?). Then call `Envyable.load('path/to/yml', environment)` and the yaml file will be loaded into `ENV`.
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
@@ -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
- Envyable.load Rails.root.join('config', 'env.yml'), Rails.env
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
@@ -1,3 +1,3 @@
1
1
  module Envyable
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
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.2.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: 2015-03-16 00:00:00.000000000 Z
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.4.5
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