conker 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/conker.gemspec +1 -1
  2. data/lib/conker.rb +21 -1
  3. metadata +2 -2
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.14.2'
5
+ s.version = '0.15.0'
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
@@ -181,7 +181,10 @@ module Conker
181
181
 
182
182
  class VariableDeclaration
183
183
  def initialize(declaration_opts)
184
- declaration_opts.assert_valid_keys :required_in, :type, :default, *ENVIRONMENTS.map(&:to_sym)
184
+ declaration_opts.assert_valid_keys :required_in, :type, :default, *ENVIRONMENTS.map(&:to_sym), :delimiter
185
+ if declaration_opts.key?(:delimiter) && declaration_opts[:type] != :array
186
+ raise "Unknown key :delimiter for type :#{declaration_opts[:type] || :string}. Did you mean :type => :array?"
187
+ end
185
188
  @declaration_opts = declaration_opts.with_indifferent_access
186
189
  end
187
190
 
@@ -277,6 +280,23 @@ module Conker
277
280
  raise IncompatibleType, "wanted a Hash, got #{value.class}"
278
281
  end
279
282
  value.with_indifferent_access
283
+ when :array
284
+ if delimiter = @declaration_opts[:delimiter]
285
+ # e.g. ENV['WIDGET'] = 'foo:bar:baz' # yields ['foo', 'bar', 'baz']
286
+ if value.is_a? String
287
+ value.split(delimiter)
288
+ else
289
+ raise IncompatibleType, "wanted a String to parse :array with :delimiter, got #{value.class}"
290
+ end
291
+ else
292
+ # e.g.
293
+ # WIDGET: foo # yields WIDGET = ['foo']
294
+ # WIDGET:
295
+ # - bar
296
+ # - baz
297
+ # # yields WIDGET = ['foo', 'bar']
298
+ Array(value)
299
+ end
280
300
  else
281
301
  raise UnknownType, type.to_s
282
302
  end
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.14.2
4
+ version: 0.15.0
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-10-02 00:00:00.000000000 Z
15
+ date: 2013-10-11 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport