env_vars 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +19 -5
- data/Rakefile +1 -1
- data/env_vars.gemspec +14 -14
- data/lib/env_vars/dotenv.rb +4 -4
- data/lib/env_vars.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca734fa7ce7864c0c4466e9f49386731c1dcec1
|
4
|
+
data.tar.gz: 85a5fe9f76d385ca5a26af5da8be69989b57aa66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a012b983335eeacda67793fb5f9cad7126f229d0f3d9dd43df6b0ef7b2b791130b35ee3bdce28669190bad7e09033f47a77eadc06904ba8c1f36a2e1d4b16cba
|
7
|
+
data.tar.gz: f7c2040a92c635adb5d0ded62bbcba949b7fc48cdf4a41191d238b4a2a1a5409fab11114f662f054201e1905c91ab35b73a41cc11426057ea82c202d702eeccb
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Access environment variables. Also includes presence validation, type coercion a
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem
|
12
|
+
gem "env_vars"
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -27,7 +27,7 @@ Config = Env::Vars.new do
|
|
27
27
|
mandatory :database_url, string
|
28
28
|
optional :timeout, int, 10
|
29
29
|
optional :force_ssl, bool, false
|
30
|
-
optional :rails_env,
|
30
|
+
optional :rails_env, "development", string, aliases: %w[env]
|
31
31
|
end
|
32
32
|
|
33
33
|
Config.database_url
|
@@ -35,10 +35,25 @@ Config.timeout
|
|
35
35
|
Config.force_ssl?
|
36
36
|
```
|
37
37
|
|
38
|
-
If you're using [dotenv](https://rubygems.org/gems/dotenv), you can simply require `env_vars/dotenv`. This will load environment variables from `.env.local`, `.env.%{environment}` and `.env` files. You _must_ add `dotenv` to your `Gemfile`.
|
38
|
+
If you're using [dotenv](https://rubygems.org/gems/dotenv), you can simply require `env_vars/dotenv`. This will load environment variables from `.env.local.%{environment}`, `.env.local`, `.env.%{environment}` and `.env` files, respectively. You _must_ add `dotenv` to your `Gemfile`.
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
require
|
41
|
+
require "env_vars/dotenv"
|
42
|
+
```
|
43
|
+
|
44
|
+
### Configuring Rails
|
45
|
+
|
46
|
+
If you want to use `env_vars` even on your Rails configuration files like `database.yml` and `secrets.yml`, you must load it from `config/boot.rb`, right after setting up Bundler.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
50
|
+
|
51
|
+
# Set up gems listed in the Gemfile.
|
52
|
+
require "bundler/setup"
|
53
|
+
|
54
|
+
# Load configuration.
|
55
|
+
require "env_vars/dotenv"
|
56
|
+
require File.expand_path("../config", __FILE__)
|
42
57
|
```
|
43
58
|
|
44
59
|
## Development
|
@@ -55,4 +70,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/fnando
|
|
55
70
|
## License
|
56
71
|
|
57
72
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
58
|
-
|
data/Rakefile
CHANGED
data/env_vars.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../lib/env_vars", __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
4
|
+
spec.name = "env_vars"
|
5
5
|
spec.version = Env::Vars::VERSION
|
6
|
-
spec.authors = [
|
7
|
-
spec.email = [
|
6
|
+
spec.authors = ["Nando Vieira"]
|
7
|
+
spec.email = ["fnando.vieira@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary =
|
9
|
+
spec.summary = "Access environment variables. Also includes presence validation, type coercion and default values."
|
10
10
|
spec.description = spec.summary
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
11
|
+
spec.homepage = "https://github.com/fnando/env_vars"
|
12
|
+
spec.license = "MIT"
|
13
13
|
|
14
|
-
spec.files = `git ls-files -z`.split("\x0").reject {
|
15
|
-
spec.executables = spec.files.grep(%r{^exe/}) {
|
16
|
-
spec.require_paths = [
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
16
|
+
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
spec.add_development_dependency
|
19
|
-
spec.add_development_dependency
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
19
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
spec.add_development_dependency "minitest"
|
21
|
+
spec.add_development_dependency "minitest-utils"
|
22
22
|
end
|
data/lib/env_vars/dotenv.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "env_vars"
|
2
|
+
require "dotenv"
|
3
3
|
|
4
|
-
env = ENV[
|
5
|
-
Dotenv.load
|
4
|
+
env = ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development"
|
5
|
+
Dotenv.load ".env.local.#{env}", ".env.local", ".env.#{env}", ".env"
|
data/lib/env_vars.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Env
|
2
2
|
class Vars
|
3
|
-
VERSION =
|
4
|
-
BOOL_TRUE = [
|
5
|
-
BOOL_FALSE = [
|
3
|
+
VERSION = "0.3.0"
|
4
|
+
BOOL_TRUE = ["yes", "true", "1", true]
|
5
|
+
BOOL_FALSE = ["no", "false"]
|
6
6
|
|
7
7
|
MissingEnvironmentVariable = Class.new(StandardError)
|
8
8
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: env_vars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.5.0
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Access environment variables. Also includes presence validation, type coercion
|