env_vars 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/env_vars.rb +10 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 368e36e6240a71436160986bc86c3f5786326ff5
4
- data.tar.gz: 3ae9767e8a829132ac2de6d9a3ac1be24eba7167
3
+ metadata.gz: f8ea2051edc275de193a7cd56396e672fd56f081
4
+ data.tar.gz: eee02ef652b4dcd75f0da09550865bc46bca664f
5
5
  SHA512:
6
- metadata.gz: 38c614ff2ef3fca9d383e48ddb32d66cfcd60ec642ac30dae87814e5bd709fbcb2712a3b98b51b1d3d297625bfed40bc9062ec555b75add65f7c76337d48001d
7
- data.tar.gz: d4c12e33c27915af3849fb7b4eace234e915d4c1e8555ff312fc7ed9881bdb3f179290c7f3c18530896ec3f439b84ccaa12db4e15a1bdce8912e72effcb21f83
6
+ metadata.gz: f6921934a70a78876d5fed00e4230043c22db2172d63b3122aedd4dbc57f9274030b034e12779a2c73f31c87112242447ddd4ae29e4784ca4ed593f4249d862e
7
+ data.tar.gz: efd20f2d3c21cf05d741119d50bea3d998c111f74589697f505032e835b8c22fd6afea20333be1b143ed2b70e7606d848f5486f7b1f29cfcad6aa5efe4e5e741
data/README.md CHANGED
@@ -27,6 +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, 'development', string, aliases: %w[env]
30
31
  end
31
32
 
32
33
  Config.database_url
@@ -1,6 +1,6 @@
1
1
  module Env
2
2
  class Vars
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  BOOL_TRUE = ['yes', 'true', '1', true]
5
5
  BOOL_FALSE = ['no', 'false']
6
6
 
@@ -10,7 +10,7 @@ module Env
10
10
  instance_eval(&block)
11
11
  end
12
12
 
13
- def set(name, type, default = nil, required: false)
13
+ def set(name, type, default = nil, required: false, aliases: [])
14
14
  name = name.to_s
15
15
  env_var = name.upcase
16
16
  name = "#{name}?" if type == bool
@@ -29,18 +29,22 @@ module Env
29
29
  value
30
30
  end
31
31
  end
32
+
33
+ aliases.each do |alias_name|
34
+ define_singleton_method(alias_name, method(name))
35
+ end
32
36
  end
33
37
 
34
38
  def validate!(env_var, required)
35
39
  raise MissingEnvironmentVariable, "#{env_var} is not defined" if required && !ENV.key?(env_var)
36
40
  end
37
41
 
38
- def mandatory(name, type)
39
- set(name, type, required: true)
42
+ def mandatory(name, type, aliases: [])
43
+ set(name, type, required: true, aliases: aliases)
40
44
  end
41
45
 
42
- def optional(name, type, default = nil)
43
- set(name, type, default)
46
+ def optional(name, type, default = nil, aliases: [])
47
+ set(name, type, default, aliases: aliases)
44
48
  end
45
49
 
46
50
  def int
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env_vars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira