ridley 2.4.2 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/ridley/chef/cookbook/metadata.rb +31 -3
- data/lib/ridley/version.rb +1 -1
- data/spec/fixtures/example_cookbook/metadata.rb +12 -0
- data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +52 -0
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +11 -11
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76add10f7d0cfee05331ae99481f011e868261db
|
4
|
+
data.tar.gz: 571ef4c873bbb8ab9697d87f008b0f6dfea9fdbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e15f5a280702aa0b60f05dfddf10da424c0ab4c0c885cc92fe8e29bb47ba0b115fa015e26f605012c4809fca15af79b4557be197e1c75269f3b350b7d24fc1
|
7
|
+
data.tar.gz: 1b1daa08465102f140943cbc8f4209d15136f6c3006d25f4fb87b85e843ae0f9984cbd56476a19d4ed86bd3097a27261179512f50d390ee6516d2587ec5bdace
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0-p353
|
1
|
+
2.0.0-p353
|
data/CHANGELOG.md
CHANGED
@@ -393,14 +393,14 @@ module Ridley::Chef
|
|
393
393
|
:description => { :kind_of => String },
|
394
394
|
:choice => { :kind_of => [ Array ], :default => [] },
|
395
395
|
:calculated => { :equal_to => [ true, false ], :default => false },
|
396
|
-
:type => { :equal_to => [ "string", "array", "hash", "symbol" ], :default => "string" },
|
396
|
+
:type => { :equal_to => [ "string", "array", "hash", "symbol", "boolean", "numeric" ], :default => "string" },
|
397
397
|
:required => { :equal_to => [ "required", "recommended", "optional", true, false ], :default => "optional" },
|
398
398
|
:recipes => { :kind_of => [ Array ], :default => [] },
|
399
|
-
:default => { :kind_of => [ String, Array, Hash ] }
|
399
|
+
:default => { :kind_of => [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] }
|
400
400
|
}
|
401
401
|
)
|
402
402
|
options[:required] = remap_required_attribute(options[:required]) unless options[:required].nil?
|
403
|
-
|
403
|
+
validate_choice_array(options)
|
404
404
|
validate_calculated_default_rule(options)
|
405
405
|
validate_choice_default_rule(options)
|
406
406
|
|
@@ -488,6 +488,34 @@ module Ridley::Chef
|
|
488
488
|
end
|
489
489
|
end
|
490
490
|
|
491
|
+
# Validate the choice of the options hash
|
492
|
+
#
|
493
|
+
# Raise an exception if the members of the array do not match the defaults
|
494
|
+
# === Parameters
|
495
|
+
# opts<Hash>:: The options hash
|
496
|
+
def validate_choice_array(opts)
|
497
|
+
if opts[:choice].kind_of?(Array)
|
498
|
+
case opts[:type]
|
499
|
+
when "string"
|
500
|
+
validator = [ String ]
|
501
|
+
when "array"
|
502
|
+
validator = [ Array ]
|
503
|
+
when "hash"
|
504
|
+
validator = [ Hash ]
|
505
|
+
when "symbol"
|
506
|
+
validator = [ Symbol ]
|
507
|
+
when "boolean"
|
508
|
+
validator = [ TrueClass, FalseClass ]
|
509
|
+
when "numeric"
|
510
|
+
validator = [ Numeric ]
|
511
|
+
end
|
512
|
+
|
513
|
+
opts[:choice].each do |choice|
|
514
|
+
validate( {:choice => choice}, {:choice => {:kind_of => validator}} )
|
515
|
+
end
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
491
519
|
# For backwards compatibility, remap Boolean values to String
|
492
520
|
# true is mapped to "required"
|
493
521
|
# false is mapped to "optional"
|
data/lib/ridley/version.rb
CHANGED
@@ -5,3 +5,15 @@ license "Apache 2.0"
|
|
5
5
|
description "Installs/Configures example_cookbook"
|
6
6
|
long_description IO.read(File.join(File.dirname(__FILE__), "README.md"))
|
7
7
|
version "0.1.0"
|
8
|
+
|
9
|
+
attribute "example_cookbook/test",
|
10
|
+
:display_name => "Test",
|
11
|
+
:description => "Test Attribute",
|
12
|
+
:choice => [
|
13
|
+
"test1",
|
14
|
+
"test2" ],
|
15
|
+
:type => "string",
|
16
|
+
:required => "recommended",
|
17
|
+
:recipes => [ 'example_cookbook::default' ],
|
18
|
+
:default => "test1"
|
19
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ridley::Chef::Cookbook::Metadata do
|
4
|
+
|
5
|
+
let(:metadata) do
|
6
|
+
described_class.new
|
7
|
+
end
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
subject { metadata }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#validate_choice_array" do
|
14
|
+
it "should limit the types allowed in the choice array." do
|
15
|
+
options = {
|
16
|
+
:type => "string",
|
17
|
+
:choice => [ "test1", "test2" ],
|
18
|
+
:default => "test1"
|
19
|
+
}
|
20
|
+
lambda {
|
21
|
+
subject.attribute("test_cookbook/test", options)
|
22
|
+
}.should_not raise_error
|
23
|
+
|
24
|
+
options = {
|
25
|
+
:type => "boolean",
|
26
|
+
:choice => [ true, false ],
|
27
|
+
:default => true
|
28
|
+
}
|
29
|
+
lambda {
|
30
|
+
subject.attribute("test_cookbook/test", options)
|
31
|
+
}.should_not raise_error
|
32
|
+
|
33
|
+
options = {
|
34
|
+
:type => "numeric",
|
35
|
+
:choice => [ 1337, 420 ],
|
36
|
+
:default => 1337
|
37
|
+
}
|
38
|
+
lambda {
|
39
|
+
subject.attribute("test_cookbook/test", options)
|
40
|
+
}.should_not raise_error
|
41
|
+
|
42
|
+
options = {
|
43
|
+
:type => "numeric",
|
44
|
+
:choice => [ true, "false" ],
|
45
|
+
:default => false
|
46
|
+
}
|
47
|
+
lambda {
|
48
|
+
subject.attribute("test_cookbook/test", options)
|
49
|
+
}.should raise_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -130,17 +130,17 @@ describe Ridley::CookbookResource do
|
|
130
130
|
# the ignored files weren't uploaded, so we just check that the
|
131
131
|
# non-ignored files are the ONLY thing uploaded
|
132
132
|
sandbox_resource.should_receive(:create).with([
|
133
|
-
"211a3a8798d4acd424af15ff8a2e28a5",
|
134
|
-
"
|
135
|
-
"
|
136
|
-
"
|
137
|
-
"
|
138
|
-
"
|
139
|
-
"
|
140
|
-
"
|
141
|
-
"
|
142
|
-
"
|
143
|
-
"e9a2e24281cfbd6be0a6b1af3b6d277e"
|
133
|
+
"211a3a8798d4acd424af15ff8a2e28a5",
|
134
|
+
"4f9051c3ac8031bdaff10300fa92e817",
|
135
|
+
"75077ba33d2887cc1746d1ef716bf8b7",
|
136
|
+
"7b1ebd2ff580ca9dc46fb27ec1653bf2",
|
137
|
+
"84e12365e6f4ebe7db6a0e6a92473b16",
|
138
|
+
"a39eb80def9804f4b118099697cc2cd2",
|
139
|
+
"b70ba735f3af47e5d6fc71b91775b34c",
|
140
|
+
"cafb6869fca13f5c36f24a60de8fb982",
|
141
|
+
"dbf3a6c4ab68a86172be748aced9f46e",
|
142
|
+
"dc6461b5da25775f3ef6a9cc1f6cff9f",
|
143
|
+
"e9a2e24281cfbd6be0a6b1af3b6d277e"
|
144
144
|
]).and_return(sandbox)
|
145
145
|
|
146
146
|
subject.upload(cookbook_path, validate: false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -367,6 +367,7 @@ files:
|
|
367
367
|
- spec/unit/ridley/bootstrap_context/windows_spec.rb
|
368
368
|
- spec/unit/ridley/bootstrap_context_spec.rb
|
369
369
|
- spec/unit/ridley/chef/chefignore_spec.rb
|
370
|
+
- spec/unit/ridley/chef/cookbook/metadata_spec.rb
|
370
371
|
- spec/unit/ridley/chef/cookbook/syntax_check_spec.rb
|
371
372
|
- spec/unit/ridley/chef/cookbook_spec.rb
|
372
373
|
- spec/unit/ridley/chef/digester_spec.rb
|
@@ -466,6 +467,7 @@ test_files:
|
|
466
467
|
- spec/unit/ridley/bootstrap_context/windows_spec.rb
|
467
468
|
- spec/unit/ridley/bootstrap_context_spec.rb
|
468
469
|
- spec/unit/ridley/chef/chefignore_spec.rb
|
470
|
+
- spec/unit/ridley/chef/cookbook/metadata_spec.rb
|
469
471
|
- spec/unit/ridley/chef/cookbook/syntax_check_spec.rb
|
470
472
|
- spec/unit/ridley/chef/cookbook_spec.rb
|
471
473
|
- spec/unit/ridley/chef/digester_spec.rb
|