chef-sugar 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/chef/sugar.rb +1 -0
- data/lib/chef/sugar/constraints.rb +2 -55
- data/lib/chef/sugar/constraints_dsl.rb +83 -0
- data/lib/chef/sugar/platform.rb +14 -0
- data/lib/chef/sugar/version.rb +1 -1
- data/spec/unit/chef/sugar/constraints_spec.rb +4 -2
- data/spec/unit/chef/sugar/platform_spec.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f284c42cb57577613febeaaaad0c92dc7da64a9
|
4
|
+
data.tar.gz: ec1b3ba2496d4fb0bf99bbb0003410e21fb00217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca8d21daa32329740d9e051541993eba4fa9fc76d5d01aa4b6dce6825c9184bc60013d663e03273b5379452ee30d3a8c81304e880e4e9a3e1c5dbf92de3e498e
|
7
|
+
data.tar.gz: 08770b8f178afd0d9838f94bfda7e5cc2ffc3361b8090c4f71d500e3c8384ee8639a6ec09c81d4b3ab84238a105b1b053b1a9c864737b8078062e50aaa575b03
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@ Chef Sugar Changelog
|
|
2
2
|
=========================
|
3
3
|
This file is used to list changes made in each version of the chef-sugar cookbook and gem.
|
4
4
|
|
5
|
+
v3.3.0 (2016-01-11)
|
6
|
+
-------------------
|
7
|
+
### Improvements
|
8
|
+
- Break up `Chef::Sugar::Constraints` into a class and a dsl file
|
9
|
+
- Add `platform_version` method with full constraints comparison support
|
10
|
+
|
5
11
|
v3.2.0 (2015-12-10)
|
6
12
|
-------------------
|
7
13
|
### Improvements
|
data/lib/chef/sugar.rb
CHANGED
@@ -23,6 +23,7 @@ class Chef
|
|
23
23
|
require_relative 'sugar/architecture'
|
24
24
|
require_relative 'sugar/cloud'
|
25
25
|
require_relative 'sugar/constraints'
|
26
|
+
require_relative 'sugar/constraints_dsl'
|
26
27
|
require_relative 'sugar/data_bag'
|
27
28
|
require_relative 'sugar/docker'
|
28
29
|
require_relative 'sugar/filters'
|
@@ -17,34 +17,6 @@
|
|
17
17
|
class Chef
|
18
18
|
module Sugar
|
19
19
|
module Constraints
|
20
|
-
extend self
|
21
|
-
|
22
|
-
#
|
23
|
-
# Shortcut method for creating a new {Version} object.
|
24
|
-
#
|
25
|
-
# @param [String] version
|
26
|
-
# the version (as a string) to create
|
27
|
-
#
|
28
|
-
# @return [Chef::Sugar::Constraints::Version]
|
29
|
-
# the new version object
|
30
|
-
#
|
31
|
-
def version(version)
|
32
|
-
Chef::Sugar::Constraints::Version.new(version)
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# Shortcut method for creating a new {Constraint} object.
|
37
|
-
#
|
38
|
-
# @param [String, Array<String>] constraints
|
39
|
-
# the list of constraints to use
|
40
|
-
#
|
41
|
-
# @return [Chef::Sugar::Constraints::Constraint]
|
42
|
-
# the new constraint object
|
43
|
-
#
|
44
|
-
def constraint(*constraints)
|
45
|
-
Chef::Sugar::Constraints::Constraint.new(*constraints)
|
46
|
-
end
|
47
|
-
|
48
20
|
#
|
49
21
|
# This class is a wrapper around a version requirement that adds a nice
|
50
22
|
# DSL for comparing constraints:
|
@@ -99,7 +71,7 @@ class Chef
|
|
99
71
|
# @example Compare a version with constraints
|
100
72
|
# Chef::Sugar::Version('1.2.3').satisfies?('~> 1.3.4', '< 2.0.5')
|
101
73
|
#
|
102
|
-
class Version
|
74
|
+
class Version < String
|
103
75
|
#
|
104
76
|
# Create a new version object.
|
105
77
|
#
|
@@ -107,6 +79,7 @@ class Chef
|
|
107
79
|
# the version to create
|
108
80
|
#
|
109
81
|
def initialize(version)
|
82
|
+
super
|
110
83
|
@version = Gem::Version.new(version)
|
111
84
|
end
|
112
85
|
|
@@ -131,31 +104,5 @@ class Chef
|
|
131
104
|
end
|
132
105
|
end
|
133
106
|
end
|
134
|
-
|
135
|
-
module DSL
|
136
|
-
# @see Chef::Sugar::Constraints#version
|
137
|
-
def version(version)
|
138
|
-
Chef::Sugar::Constraints::Version.new(version)
|
139
|
-
end
|
140
|
-
|
141
|
-
# @see Chef::Sugar::Constraints#constraint
|
142
|
-
def constraint(*constraints)
|
143
|
-
Chef::Sugar::Constraints.constraint(*constraints)
|
144
|
-
end
|
145
|
-
|
146
|
-
#
|
147
|
-
# This wrapper/convenience method is only available in the recipe DSL. It
|
148
|
-
# creates a new version object from the {Chef::VERSION}.
|
149
|
-
#
|
150
|
-
# @example Check if Chef 11+
|
151
|
-
# chef_version.satisfies?('>= 11.0.0')
|
152
|
-
#
|
153
|
-
# @return [Chef::Sugar::Constraints::Version]
|
154
|
-
# a version object, wrapping the current {Chef::VERSION}
|
155
|
-
#
|
156
|
-
def chef_version
|
157
|
-
version(Chef::VERSION)
|
158
|
-
end
|
159
|
-
end
|
160
107
|
end
|
161
108
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013-2015, Seth Vargo <sethvargo@gmail.com>
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require_relative 'constraints'
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
module Sugar
|
21
|
+
#
|
22
|
+
# The Constraints DSL methods were broken out into this separate
|
23
|
+
# file to allow projects (such as Omnibus) to consume the
|
24
|
+
# Chef::Sugar::Constraints classes without the DSL methods
|
25
|
+
# stepping on existing methods of the same name.
|
26
|
+
#
|
27
|
+
module Constraints
|
28
|
+
extend self
|
29
|
+
|
30
|
+
#
|
31
|
+
# Shortcut method for creating a new {Version} object.
|
32
|
+
#
|
33
|
+
# @param [String] version
|
34
|
+
# the version (as a string) to create
|
35
|
+
#
|
36
|
+
# @return [Chef::Sugar::Constraints::Version]
|
37
|
+
# the new version object
|
38
|
+
#
|
39
|
+
def version(version)
|
40
|
+
Chef::Sugar::Constraints::Version.new(version)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Shortcut method for creating a new {Constraint} object.
|
45
|
+
#
|
46
|
+
# @param [String, Array<String>] constraints
|
47
|
+
# the list of constraints to use
|
48
|
+
#
|
49
|
+
# @return [Chef::Sugar::Constraints::Constraint]
|
50
|
+
# the new constraint object
|
51
|
+
#
|
52
|
+
def constraint(*constraints)
|
53
|
+
Chef::Sugar::Constraints::Constraint.new(*constraints)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module DSL
|
58
|
+
# @see Chef::Sugar::Constraints#version
|
59
|
+
def version(version)
|
60
|
+
Chef::Sugar::Constraints::Version.new(version)
|
61
|
+
end
|
62
|
+
|
63
|
+
# @see Chef::Sugar::Constraints#constraint
|
64
|
+
def constraint(*constraints)
|
65
|
+
Chef::Sugar::Constraints.constraint(*constraints)
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# This wrapper/convenience method is only available in the recipe DSL. It
|
70
|
+
# creates a new version object from the {Chef::VERSION}.
|
71
|
+
#
|
72
|
+
# @example Check if Chef 11+
|
73
|
+
# chef_version.satisfies?('>= 11.0.0')
|
74
|
+
#
|
75
|
+
# @return [Chef::Sugar::Constraints::Version]
|
76
|
+
# a version object, wrapping the current {Chef::VERSION}
|
77
|
+
#
|
78
|
+
def chef_version
|
79
|
+
version(Chef::VERSION)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/chef/sugar/platform.rb
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require_relative 'constraints'
|
18
|
+
|
17
19
|
class Chef
|
18
20
|
module Sugar
|
19
21
|
module Platform
|
@@ -270,6 +272,18 @@ class Chef
|
|
270
272
|
def ios_xr?(node)
|
271
273
|
node['platform'] == 'ios_xr'
|
272
274
|
end
|
275
|
+
|
276
|
+
#
|
277
|
+
# Return the platform_version for the node. Acts like a String
|
278
|
+
# but also provides a mechanism for checking version constraints.
|
279
|
+
#
|
280
|
+
# @param [Chef::Node] node
|
281
|
+
#
|
282
|
+
# @return [Chef::Sugar::Constraints::Version]
|
283
|
+
#
|
284
|
+
def platform_version(node)
|
285
|
+
Chef::Sugar::Constraints::Version.new(node['platform_version'])
|
286
|
+
end
|
273
287
|
end
|
274
288
|
|
275
289
|
module DSL
|
data/lib/chef/sugar/version.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Chef::Sugar::Constraints do
|
4
|
-
# it_behaves_like 'a chef sugar'
|
5
|
-
|
6
4
|
describe '#version' do
|
7
5
|
let(:version) { described_class.version('1.2.3') }
|
8
6
|
|
@@ -10,6 +8,10 @@ describe Chef::Sugar::Constraints do
|
|
10
8
|
expect(version).to be_a(Chef::Sugar::Constraints::Version)
|
11
9
|
end
|
12
10
|
|
11
|
+
it 'behaves like a String' do
|
12
|
+
expect(version).to be_a(String)
|
13
|
+
end
|
14
|
+
|
13
15
|
it 'returns true with the version is satisifed' do
|
14
16
|
expect(version).to be_satisfies('~> 1.2.0')
|
15
17
|
end
|
@@ -171,6 +171,13 @@ describe Chef::Sugar::Platform do
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
describe '#platform_version' do
|
175
|
+
it 'returns the platform version' do
|
176
|
+
node = { 'platform_version' => '1.2.3' }
|
177
|
+
expect(described_class.platform_version(node)).to eq('1.2.3')
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
174
181
|
context 'dynamic matchers' do
|
175
182
|
describe '#ubuntu_after_lucid?' do
|
176
183
|
it 'returns true when the version is later than 10.04' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-sugar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/chef/sugar/architecture.rb
|
104
104
|
- lib/chef/sugar/cloud.rb
|
105
105
|
- lib/chef/sugar/constraints.rb
|
106
|
+
- lib/chef/sugar/constraints_dsl.rb
|
106
107
|
- lib/chef/sugar/core_extensions.rb
|
107
108
|
- lib/chef/sugar/core_extensions/array.rb
|
108
109
|
- lib/chef/sugar/core_extensions/object.rb
|