conker 0.12.2 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
data/conker.gemspec CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2
2
  s.name = 'conker'
3
3
  s.authors = ['Sam Stokes', 'Conrad Irwin', 'Lee Mallabone', 'Martin Kleppmann']
4
4
  s.email = 'supportive@rapportive.com'
5
- s.version = '0.12.2'
5
+ s.version = '0.13.1'
6
6
  s.summary = %q{Conker will conquer your config.}
7
7
  s.description = "Configuration library."
8
8
  s.homepage = "https://github.com/rapportive/conker"
data/lib/conker.rb CHANGED
@@ -242,6 +242,20 @@ module Conker
242
242
  raise MustBeDefined if value.nil? # there's nothing sensible to default to
243
243
  require 'addressable' unless defined? Addressable
244
244
  Addressable::URI.parse(value.to_s)
245
+ when :ip_address
246
+ raise MustBeDefined if value.nil? # there's nothing sensible to default to
247
+ require 'ipaddr' unless defined? IPAddr
248
+ IPAddr.new(value.to_s)
249
+ when :ip_range
250
+ raise MustBeDefined if value.nil? # there's nothing sensible to default to
251
+ require 'ipaddr' unless defined? IPAddr
252
+
253
+ # Support <from>..<to> for ranges that cannot be specified with CIDR easily.
254
+ if value =~ /\A(.*)\.\.(.*)\z/
255
+ IPAddr.new($1) .. IPAddr.new($2)
256
+ else
257
+ IPAddr.new(value.to_s).to_range
258
+ end
245
259
  when :timestamp
246
260
  raise MustBeDefined if value.nil? # there's nothing sensible to default to.
247
261
  Time.iso8601(value.to_s).utc
@@ -1,5 +1,5 @@
1
1
  require 'active_support/core_ext/hash/indifferent_access'
2
-
2
+ $:.unshift File.expand_path("../../lib", __FILE__)
3
3
  require 'conker'
4
4
 
5
5
  describe Conker do
@@ -15,6 +15,35 @@ describe Conker do
15
15
  end
16
16
  end
17
17
 
18
+ describe 'type: :ip_address' do
19
+ it 'should parse IP addresses' do
20
+ Conker.module_eval do
21
+ setup_config! :development, {"IP_ADDR" => "172.17.16.15"},
22
+ IP_ADDR: optional(type: :ip_address, default: nil)
23
+ end
24
+ ::IP_ADDR.should == IPAddr.new("172.17.16.15")
25
+ end
26
+ end
27
+
28
+ describe 'type: :ip_range' do
29
+ it 'should parse CIDR ranges' do
30
+ Conker.module_eval do
31
+ setup_config! :development, {"IP_RANGE" => "172.17.16.0/24"},
32
+ IP_RANGE: optional(type: :ip_range, default: nil)
33
+
34
+ end
35
+ ::IP_RANGE.should include IPAddr.new("172.17.16.15")
36
+ end
37
+
38
+ it 'should parse <from>..<to>' do
39
+ Conker.module_eval do
40
+ setup_config! :development, {"IP_RANGE" => "172.17.16.116..172.17.16.131"},
41
+ IP_RANGE: optional(type: :ip_range, default: nil)
42
+
43
+ end
44
+ ::IP_RANGE.should include IPAddr.new("172.17.16.128")
45
+ end
46
+ end
18
47
 
19
48
  describe 'reading config from a hash' do
20
49
  describe 'basic usage' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.13.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-02-08 00:00:00.000000000 Z
15
+ date: 2013-05-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 1.8.19
102
+ rubygems_version: 1.8.23
103
103
  signing_key:
104
104
  specification_version: 3
105
105
  summary: Conker will conquer your config.