env-conf 0.0.4 → 0.0.5

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: d65d6c79532e7e63b9cb9d15c21ffd286ece2b45
4
- data.tar.gz: 0cdff989113e9acdc74a8d7da124fc2b5ea97c66
3
+ metadata.gz: 5ce3f0a8c8200a87077f541c755d437b08065973
4
+ data.tar.gz: 68e041d51ce6b9be1a7bf360fa1294429c6c868c
5
5
  SHA512:
6
- metadata.gz: 49577599914ac3a3b92cc7a404ff735a9930b08317ad3425500969b004c107d883687d769b48bdc4dec2ee14fd9436d6867f0e9e2aae7820a581115743a93101
7
- data.tar.gz: ee100f7003c5cfd5bd238c35c9a4bf8259204f36c0c8b6885caa75e6f8b5d979380738359f63b1cb106e909803f4aa1c4e1c70815c200e1ff89cc63aa79f80d6
6
+ metadata.gz: 060e1c6e5f820f590697142bc0a8973f6e48c58f0542d420022ca34497c50c79fe84e9402f8d8a6aa4a9d604cddb074ec54a19a9ce6c1e23d19fcb7825b49318
7
+ data.tar.gz: bed5c0fc4464573b2736b182017e468352342ff534c2a48558bfff36df9bf1ea97ffbfd00bd215689a9f42d44e47d39ca0e5af39ae18756dade5616a0a5a3cb7
@@ -1,5 +1,6 @@
1
1
  require_relative './env-conf/version'
2
2
  require 'uri'
3
+ require 'time'
3
4
 
4
5
  module Config
5
6
  @@defaults = {}
@@ -143,7 +144,7 @@ module Config
143
144
  # @return [Fixnum] The number or nil if the value couldn't be coerced to a
144
145
  # Fixnum.
145
146
  def self.int(name)
146
- self[name] && self[name].to_i
147
+ self[name] && Integer(self[name])
147
148
  end
148
149
 
149
150
  # Comma-separated words converted to an array.
@@ -186,7 +187,7 @@ module Config
186
187
  def self.dotenv!
187
188
  return if Config.production?
188
189
  require 'dotenv'
189
- ['.env','.env.local',".env.#{Config[:rack_env]}"].each do |filename|
190
+ ['.env','.env.local',".env.#{Config[:rack_env]}",".env.#{Config[:rack_env]}.local"].each do |filename|
190
191
  if File.exists?(filename)
191
192
  @@dotenv.update(Dotenv::Parser.call(File.read(filename)))
192
193
  end
@@ -2,5 +2,5 @@
2
2
  Object.send(:remove_const, :Config) if defined?(Config)
3
3
 
4
4
  module Config
5
- VERSION = '0.0.4'
5
+ VERSION = '0.0.5'
6
6
  end
@@ -119,6 +119,12 @@ class ConfigTest < Test
119
119
  set_env 'FOO', "3000"
120
120
  assert_equal(3000, Config.int('FOO'))
121
121
  assert_equal(3000, Config.int(:foo))
122
+ set_env 'FOO', "1.0"
123
+ assert_raises(ArgumentError){ Config.time(:foo) }
124
+ set_env 'FOO', nil
125
+ assert_equal(nil, Config.int(:foo))
126
+ set_env 'FOO', "a"
127
+ assert_raises(ArgumentError){ Config.time(:foo) }
122
128
  end
123
129
 
124
130
  # Config.time returns nil or VAR as time
@@ -135,6 +141,12 @@ class ConfigTest < Test
135
141
 
136
142
  set_env 'T', '2000-2-2T11:11'
137
143
  assert_equal(Time.new(2000,2,2,11,11), Config.time(:t))
144
+
145
+ set_env 'T', nil
146
+ assert_equal(nil, Config.time(:t))
147
+
148
+ set_env 'T', 'derp'
149
+ assert_raises(ArgumentError){ Config.time(:t) }
138
150
  end
139
151
 
140
152
  # Config.time returns nil or VAR as URI
@@ -8,7 +8,7 @@ class DotenvTest < Test
8
8
 
9
9
  def teardown
10
10
  super
11
- %w{.env .env.local .env.test}.each do |f|
11
+ %w{.env .env.local .env.test .env.test.local}.each do |f|
12
12
  File.unlink(f) if File.exists?(f)
13
13
  end
14
14
  FakeFS.deactivate!
@@ -32,7 +32,8 @@ class DotenvTest < Test
32
32
  def test_env_specific
33
33
  File.open(".env",'w') { |f| f << "FOO=bar" }
34
34
  File.open(".env.local",'w') { |f| f << "FOO=zzz" }
35
- File.open(".env.test",'w') { |f| f << "FOO=test" }
35
+ File.open(".env.test",'w') { |f| f << "FOO=foo" }
36
+ File.open(".env.test.local",'w') { |f| f << "FOO=test" }
36
37
  assert_equal(nil, Config[:foo])
37
38
  set_env('RACK_ENV', 'test')
38
39
  Config.dotenv!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env-conf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Continanza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-12 00:00:00.000000000 Z
11
+ date: 2014-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv