compat_resource 12.7.0 → 12.7.1

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: 154eebdbd187ddd7eee14842727a39f1b447dd21
4
- data.tar.gz: 6ad6654c932db5ae4ad4b2de9801d8d67e81f74e
3
+ metadata.gz: df6888adceb67911ef0f109a36965fd4b90b5893
4
+ data.tar.gz: 142976c791c1aeb52b229d6706ef6dfc348411ed
5
5
  SHA512:
6
- metadata.gz: 04a32ccdc4f1ce060bed2a4e99ea39c394157be4b6a4be0ce25be9f23a91de2132c3f0e0afb13e7734d64469cbb939df8a5ae014c550e01c3cdeaf409b10884f
7
- data.tar.gz: 7bddb0214270ce21dce221755f8dfe2edf7215961fb2ef2725ece9977dc236210b9143d5ce76d8a8cfb17c05c68935ab26fc3bd5c8e94eacf7eec08bd2059326
6
+ metadata.gz: 2bb80a7307a55629f9cfa319fe42cca4564ba5fbb030d927a6fafba254788b520883ca2870512c1bf5c1d4ea6be6b87689f5757db217d97d489a949255f65695
7
+ data.tar.gz: a31e50b0ce19d91b80d9fe2eda606fa867d25ca3ad8df043569c45a1dd100b3bf1a4de6a3ecd855f6090932c453c3dede2aca152967a6723468eb25fcf57d452
@@ -4,7 +4,7 @@ module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #
6
6
  # Author:: John Keiser <jkeiser@chef.io>
7
- # Copyright:: Copyright (c) 2015 Opscode, Inc.
7
+ # Copyright:: Copyright 2015-2016, Chef Software Inc.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -4,7 +4,7 @@ module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #
6
6
  # Author:: John Keiser <jkeiser@chef.io>
7
- # Copyright:: Copyright (c) 2015 Opscode, Inc.
7
+ # Copyright:: Copyright 2015-2016, Chef Software Inc.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -3,9 +3,9 @@ class Chef
3
3
  module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #--
6
- # Author:: Adam Jacob (<adam@opscode.com>)
7
- # Author:: Christopher Walters (<cw@opscode.com>)
8
- # Copyright:: Copyright (c) 2008, 2009-2015 Chef Software, Inc.
6
+ # Author:: Adam Jacob (<adam@chef.io>)
7
+ # Author:: Christopher Walters (<cw@chef.io>)
8
+ # Copyright:: Copyright 2008-2016, 2009-2015 Chef Software, Inc.
9
9
  # License:: Apache License, Version 2.0
10
10
  #
11
11
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -3,8 +3,8 @@ class Chef
3
3
  module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #
6
- # Author:: Adam Jacob (<adam@opscode.com>)
7
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
6
+ # Author:: Adam Jacob (<adam@chef.io>)
7
+ # Copyright:: Copyright 2008-2016, Chef Software Inc.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -406,23 +406,34 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
406
406
  return true if !opts.has_key?(key.to_s) && !opts.has_key?(key.to_sym)
407
407
  value = _pv_opts_lookup(opts, key)
408
408
  to_be = [ to_be ].flatten(1)
409
- to_be.each do |tb|
409
+ errors = []
410
+ passed = to_be.any? do |tb|
410
411
  case tb
411
412
  when Proc
412
413
  raise CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate
413
- return true if instance_exec(value, &tb)
414
+ instance_exec(value, &tb)
414
415
  when Property
415
- validate(opts, { key => tb.validation_options })
416
- return true
416
+ begin
417
+ validate(opts, { key => tb.validation_options })
418
+ true
419
+ rescue Exceptions::ValidationFailed
420
+ # re-raise immediately if there is only one "is" so we get a better stack
421
+ raise if to_be.size == 1
422
+ errors << $!
423
+ false
424
+ end
417
425
  else
418
- return true if tb === value
426
+ tb === value
419
427
  end
420
428
  end
421
-
422
- if raise_error
423
- raise Exceptions::ValidationFailed, "Option #{key} must be one of: #{to_be.join(", ")}! You passed #{value.inspect}."
429
+ if passed
430
+ true
424
431
  else
425
- false
432
+ message = "Property #{key} must be one of: #{to_be.map { |v| v.inspect }.join(", ")}! You passed #{value.inspect}."
433
+ unless errors.empty?
434
+ message << " Errors:\n#{errors.map { |m| "- #{m}" }.join("\n")}"
435
+ end
436
+ raise Exceptions::ValidationFailed, message
426
437
  end
427
438
  end
428
439
 
@@ -4,7 +4,7 @@ module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #
6
6
  # Author:: John Keiser <jkeiser@chef.io>
7
- # Copyright:: Copyright (c) 2015 John Keiser.
7
+ # Copyright:: Copyright 2015-2016, John Keiser.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -131,7 +131,7 @@ super if defined?(::Chef::Property)
131
131
  end
132
132
 
133
133
  def to_s
134
- "#{name}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}"
134
+ "#{name || "<property type>"}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}"
135
135
  end
136
136
 
137
137
  #
@@ -465,7 +465,12 @@ super if defined?(::Chef::Property)
465
465
  def validate(resource, value)
466
466
  # If we have no default value, `nil` is never coerced or validated
467
467
  unless value.nil? && !has_default?
468
- (resource || Chef::Mixin::ParamsValidate).validate({ name => value }, { name => validation_options })
468
+ if resource
469
+ resource.validate({ name => value }, { name => validation_options })
470
+ else
471
+ name = self.name || :property_type
472
+ Chef::Mixin::ParamsValidate.validate({ name => value }, { name => validation_options })
473
+ end
469
474
  end
470
475
  end
471
476
 
@@ -4,7 +4,7 @@ module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #
6
6
  # Author:: John Keiser (<jkeiser@chef.io)
7
- # Copyright:: Copyright (c) 2015 Opscode, Inc.
7
+ # Copyright:: Copyright 2015-2016, Chef Software Inc.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -4,7 +4,7 @@ module ::ChefCompat
4
4
  module CopiedFromChef
5
5
  #
6
6
  # Author:: Lamont Granquist (<lamont@chef.io>)
7
- # Copyright:: Copyright (c) 2015-2015 Chef Software, Inc.
7
+ # Copyright:: Copyright 2015-2016, Chef Software, Inc.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,3 +1,3 @@
1
1
  module CompatResource
2
- VERSION = '12.7.0'
2
+ VERSION = '12.7.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compat_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.7.0
4
+ version: 12.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: files/bin
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake