Permalink
Browse files

Support IP addresses in env vars.

  • Loading branch information...
1 parent 6caf90f commit c282a3ecb32b6c7505016e10ba621bbbe1d7a968 @spraints committed Aug 7, 2012
Showing with 3 additions and 1 deletion.
  1. +1 −1 lib/static_config/reader/environment.rb
  2. +2 −0 spec/static_config/reader/environment_spec.rb
View
2 lib/static_config/reader/environment.rb
@@ -37,7 +37,7 @@ def convert env_value
case env_value
when /^\d+$/
env_value.to_i
- when /^(\d*\.\d+)|(\d+\.\d*)$/
+ when /^(\d*\.\d+|\d+\.\d*)$/
env_value.to_f
when 'true'
true
View
2 spec/static_config/reader/environment_spec.rb
@@ -39,12 +39,14 @@ def opts ; { :env_prefix => 'MY_CONFIG' } ; end
'MY_CONFIG_FALSE' => 'false',
'MY_CONFIG_FLOAT' => '123.45',
'MY_CONFIG_STRING' => 'string',
+ 'MY_CONFIG_IP' => '10.10.10.10',
})
it { subject['int'].should == 123 }
it { subject['true'].should == true }
it { subject['false'].should == false }
it { subject['float'].should == 123.45 }
it { subject['string'].should == 'string' }
+ it { subject['ip'].should == '10.10.10.10' }
end
end

0 comments on commit c282a3e

Please sign in to comment.