env_vars 0.3.0 → 0.4.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 +13 -0
- data/lib/env_vars.rb +6 -1
- 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: edb62ff44a63e4c934b684ce185c368f5c7e033d
|
4
|
+
data.tar.gz: 3ea149485a9c4e3a6de43346e86089344b997eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de7f9410fce327186d147d664630417ddc153338b726ccf81afafd8d3a970762ffccf910ce99e5fc400e00641006c6617194401841781bca1dad748c72adfdce
|
7
|
+
data.tar.gz: b566be6e2e9f4a2479d2def53c9ff68c10dd7e7b5fc478802d896e6c73ae5cf0a02d7e1359e8942bc6d5ebd9582b9180ee1a24d66f8b91406dfcacf3237eb4d7
|
data/README.md
CHANGED
@@ -35,6 +35,19 @@ Config.timeout
|
|
35
35
|
Config.force_ssl?
|
36
36
|
```
|
37
37
|
|
38
|
+
If you're going to use `env_vars` as your main configuration object, you can also set arbitrary properties, like the following:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Config = Env::Vars.new do
|
42
|
+
optional :redis_url, string, "redis://127.0.0.1"
|
43
|
+
property :redis, -> { Redis.new }
|
44
|
+
end
|
45
|
+
|
46
|
+
Config.redis.set("key", "value")
|
47
|
+
Config.redis.get("key")
|
48
|
+
#=> "value"
|
49
|
+
```
|
50
|
+
|
38
51
|
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
52
|
|
40
53
|
```ruby
|
data/lib/env_vars.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Env
|
2
2
|
class Vars
|
3
|
-
VERSION = "0.
|
3
|
+
VERSION = "0.4.0"
|
4
4
|
BOOL_TRUE = ["yes", "true", "1", true]
|
5
5
|
BOOL_FALSE = ["no", "false"]
|
6
6
|
|
@@ -47,6 +47,11 @@ module Env
|
|
47
47
|
set(name, type, default, aliases: aliases)
|
48
48
|
end
|
49
49
|
|
50
|
+
def property(name, func)
|
51
|
+
value = func.call
|
52
|
+
define_singleton_method(name) { value }
|
53
|
+
end
|
54
|
+
|
50
55
|
def int
|
51
56
|
:int
|
52
57
|
end
|
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.4.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:
|
11
|
+
date: 2016-01-12 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.5.
|
107
|
+
rubygems_version: 2.5.1
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Access environment variables. Also includes presence validation, type coercion
|