chef-config 12.8.1 → 12.9.38

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,26 @@
1
- #
2
- # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "chef-config/windows"
19
- require "chef-config/logger"
20
-
21
- module ChefConfig
22
-
23
- class ConfigurationError < ArgumentError; end
24
- class InvalidPath < StandardError; end
25
-
26
- end
1
+ #
2
+ # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "chef-config/windows"
19
+ require "chef-config/logger"
20
+
21
+ module ChefConfig
22
+
23
+ class ConfigurationError < ArgumentError; end
24
+ class InvalidPath < StandardError; end
25
+
26
+ end
@@ -1,59 +1,59 @@
1
- #
2
- # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- module ChefConfig
19
-
20
- # Implements enough of Logger's API that we can use it in place of a real
21
- # logger for `ChefConfig.logger`
22
- class NullLogger
23
-
24
- def <<(_msg)
25
- end
26
-
27
- def add(_severity, _message = nil, _progname = nil)
28
- end
29
-
30
- def debug(_progname = nil, &block)
31
- end
32
-
33
- def info(_progname = nil, &block)
34
- end
35
-
36
- def warn(_progname = nil, &block)
37
- end
38
-
39
- def deprecation(_progname = nil, &block)
40
- end
41
-
42
- def error(_progname = nil, &block)
43
- end
44
-
45
- def fatal(_progname = nil, &block)
46
- end
47
-
48
- end
49
-
50
- @logger = NullLogger.new
51
-
52
- def self.logger=(new_logger)
53
- @logger = new_logger
54
- end
55
-
56
- def self.logger
57
- @logger
58
- end
59
- end
1
+ #
2
+ # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module ChefConfig
19
+
20
+ # Implements enough of Logger's API that we can use it in place of a real
21
+ # logger for `ChefConfig.logger`
22
+ class NullLogger
23
+
24
+ def <<(_msg)
25
+ end
26
+
27
+ def add(_severity, _message = nil, _progname = nil)
28
+ end
29
+
30
+ def debug(_progname = nil, &block)
31
+ end
32
+
33
+ def info(_progname = nil, &block)
34
+ end
35
+
36
+ def warn(_progname = nil, &block)
37
+ end
38
+
39
+ def deprecation(_progname = nil, &block)
40
+ end
41
+
42
+ def error(_progname = nil, &block)
43
+ end
44
+
45
+ def fatal(_progname = nil, &block)
46
+ end
47
+
48
+ end
49
+
50
+ @logger = NullLogger.new
51
+
52
+ def self.logger=(new_logger)
53
+ @logger = new_logger
54
+ end
55
+
56
+ def self.logger
57
+ @logger
58
+ end
59
+ end
@@ -1,38 +1,38 @@
1
- #
2
- # Copyright:: Copyright 2016, Chef Software Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- require "chef-config/path_helper"
18
-
19
- module ChefConfig
20
- module Mixin
21
- module DotD
22
- def load_dot_d(path)
23
- dot_d_files =
24
- begin
25
- entries = Array.new
26
- entries << Dir.glob(File.join(
27
- ChefConfig::PathHelper.escape_glob_dir(path), "*.rb"))
28
- entries.flatten.select do |entry|
29
- File.file?(entry)
30
- end
31
- end
32
- dot_d_files.sort.map do |conf|
33
- apply_config(IO.read(conf), conf)
34
- end
35
- end
36
- end
37
- end
38
- end
1
+ #
2
+ # Copyright:: Copyright 2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "chef-config/path_helper"
18
+
19
+ module ChefConfig
20
+ module Mixin
21
+ module DotD
22
+ def load_dot_d(path)
23
+ dot_d_files =
24
+ begin
25
+ entries = Array.new
26
+ entries << Dir.glob(File.join(
27
+ ChefConfig::PathHelper.escape_glob_dir(path), "*.rb"))
28
+ entries.flatten.select do |entry|
29
+ File.file?(entry)
30
+ end
31
+ end
32
+ dot_d_files.sort.map do |conf|
33
+ apply_config(IO.read(conf), conf)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Copyright:: Copyright 2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "fuzzyurl"
18
+
19
+ module ChefConfig
20
+ module Mixin
21
+ module FuzzyHostnameMatcher
22
+
23
+ def fuzzy_hostname_match_any?(hostname, matches)
24
+ return matches.to_s.split(/\s*,\s*/).compact.any? {
25
+ |m| fuzzy_hostname_match?(hostname, m)
26
+ } if (hostname != nil) && (matches != nil)
27
+
28
+ false
29
+ end
30
+
31
+ def fuzzy_hostname_match?(hostname, match)
32
+ # Do greedy matching by adding wildcard if it is not specified
33
+ match = "*" + match if !match.start_with?("*")
34
+ Fuzzyurl.matches?(Fuzzyurl.mask(hostname: match), hostname)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -1,222 +1,244 @@
1
- #
2
- # Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>)
3
- # Copyright:: Copyright 2015-2016, Chef, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "rake"
20
- require "rubygems"
21
- require "rubygems/package_task"
22
-
23
- module ChefConfig
24
- class PackageTask < Rake::TaskLib
25
-
26
- # Full path to root of top-level repository. All other files (like VERSION or
27
- # lib/<module_path>/version.rb are rooted at this path).
28
- attr_accessor :root_path
29
-
30
- # Name of the top-level module/library build built. This is used to define
31
- # the top level module which contains VERSION and MODULE_ROOT.
32
- attr_accessor :module_name
33
-
34
- # Should the generated version.rb be in a class or module? Default is false (module).
35
- attr_accessor :generate_version_class
36
-
37
- # Paths to the roots of any components that also support ChefPackageTask.
38
- # If relative paths are provided, they are rooted against root_path.
39
- attr_accessor :component_paths
40
-
41
- # This is the module name as it appears on the path "lib/module/".
42
- # e.g. for module_name "ChefDK", you'd want module_path to be "chef-dk".
43
- # The default is module_name but lower-cased.
44
- attr_writer :module_path
45
-
46
- def module_path
47
- @module_path || module_name.downcase
48
- end
49
-
50
- # Directory used to store package files and output that is generated.
51
- # This has the same meaning (or lack thereof) as package_dir in
52
- # rake/packagetask.
53
- attr_accessor :package_dir
54
-
55
- # Name of git remote used to push tags during a release. Default is origin.
56
- attr_accessor :git_remote
57
-
58
- def initialize(root_path = nil, module_name = nil)
59
- init(root_path, module_name)
60
- yield self if block_given?
61
- define unless root_path.nil? || module_name.nil?
62
- end
63
-
64
- def init(root_path, module_name)
65
- @root_path = root_path
66
- @module_name = module_name
67
- @component_paths = []
68
- @module_path = nil
69
- @package_dir = "pkg"
70
- @git_remote = "origin"
71
- @generate_version_class = false
72
- end
73
-
74
- def component_full_paths
75
- component_paths.map { |path| File.expand_path(path, root_path) }
76
- end
77
-
78
- def version_rb_path
79
- File.expand_path("lib/#{module_path}/version.rb", root_path)
80
- end
81
-
82
- def chef_root_path
83
- module_name == "Chef" ? root_path : File.dirname(root_path)
84
- end
85
-
86
- def version
87
- IO.read(File.join(chef_root_path, "VERSION")).strip
88
- end
89
-
90
- def full_package_dir
91
- File.expand_path(package_dir, root_path)
92
- end
93
-
94
- def class_or_module
95
- generate_version_class ? "class" : "module"
96
- end
97
-
98
- def with_clean_env(&block)
99
- if defined?(Bundler)
100
- Bundler.with_clean_env(&block)
101
- else
102
- yield
103
- end
104
- end
105
-
106
- def define
107
- raise "Need to provide package root and module name" if root_path.nil? || module_name.nil?
108
-
109
- desc "Build Gems of component dependencies"
110
- task :package_components do
111
- component_full_paths.each do |component_path|
112
- Dir.chdir(component_path) do
113
- sh "rake package"
114
- end
115
- end
116
- end
117
-
118
- task :package => :package_components
119
-
120
- desc "Build and install component dependencies"
121
- task :install_components => :package_components do
122
- component_full_paths.each do |component_path|
123
- Dir.chdir(component_path) do
124
- sh "rake install"
125
- end
126
- end
127
- end
128
-
129
- task :install => :install_components
130
-
131
- desc "Clean up builds of component dependencies"
132
- task :clobber_component_packages do
133
- component_full_paths.each do |component_path|
134
- Dir.chdir(component_path) do
135
- sh "rake clobber_package"
136
- end
137
- end
138
- end
139
-
140
- task :clobber_package => :clobber_component_packages
141
-
142
- desc "Update the version number for component dependencies"
143
- task :update_components_versions do
144
- component_full_paths.each do |component_path|
145
- Dir.chdir(component_path) do
146
- sh "rake version"
147
- end
148
- end
149
- end
150
-
151
- desc 'Regenerate lib/#{@module_path}/version.rb from VERSION file'
152
- task :version => :update_components_versions do
153
- contents = <<-VERSION_RB
154
- # Copyright:: Copyright 2010-2016, Chef Software, Inc.
155
- # License:: Apache License, Version 2.0
156
- #
157
- # Licensed under the Apache License, Version 2.0 (the "License");
158
- # you may not use this file except in compliance with the License.
159
- # You may obtain a copy of the License at
160
- #
161
- # http://www.apache.org/licenses/LICENSE-2.0
162
- #
163
- # Unless required by applicable law or agreed to in writing, software
164
- # distributed under the License is distributed on an "AS IS" BASIS,
165
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166
- # See the License for the specific language governing permissions and
167
- # limitations under the License.
168
-
169
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
170
- # NOTE: This file is generated by running `rake version` in the top level of
171
- # this repo. Do not edit this manually. Edit the VERSION file and run the rake
172
- # task instead.
173
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
174
-
175
- #{class_or_module} #{module_name}
176
- #{module_name.upcase}_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
177
- VERSION = "#{version}"
178
- end
179
-
180
- #
181
- # NOTE: the Chef::Version class is defined in version_class.rb
182
- #
183
- # NOTE: DO NOT Use the Chef::Version class on #{module_name}::VERSIONs. The
184
- # Chef::Version class is for _cookbooks_ only, and cannot handle
185
- # pre-release versions like "10.14.0.rc.2". Please use Rubygem's
186
- # Gem::Version class instead.
187
- #
188
- VERSION_RB
189
- IO.write(version_rb_path, contents)
190
- end
191
-
192
- Dir[File.expand_path("*gemspec", root_path)].reverse_each do |gemspec_path|
193
- gemspec = eval(IO.read(gemspec_path))
194
- Gem::PackageTask.new(gemspec) do |task|
195
- task.package_dir = full_package_dir
196
- end
197
- end
198
-
199
- desc "Build and install a #{module_path} gem"
200
- task :install => [:package] do
201
- with_clean_env do
202
- full_module_path = File.join(full_package_dir, module_path)
203
- sh %{gem install #{full_module_path}-#{version}.gem --no-rdoc --no-ri}
204
- end
205
- end
206
-
207
- task :uninstall do
208
- sh %{gem uninstall #{module_path} -x -v #{version} }
209
- end
210
-
211
- desc "Build it, tag it and ship it"
212
- task :ship => [:clobber_package, :gem] do
213
- sh("git tag #{version}")
214
- sh("git push #{git_remote} --tags")
215
- Dir[File.expand_path("*.gem", full_package_dir)].reverse_each do |built_gem|
216
- sh("gem push #{built_gem}")
217
- end
218
- end
219
- end
220
- end
221
-
222
- end
1
+ #
2
+ # Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>)
3
+ # Copyright:: Copyright 2015-2016, Chef, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "rake"
20
+ require "rubygems"
21
+ require "rubygems/package_task"
22
+
23
+ module ChefConfig
24
+ class PackageTask < Rake::TaskLib
25
+
26
+ # Full path to root of top-level repository. All other files (like VERSION or
27
+ # lib/<module_path>/version.rb are rooted at this path).
28
+ attr_accessor :root_path
29
+
30
+ # Name of the top-level module/library build built. This is used to define
31
+ # the top level module which contains VERSION and MODULE_ROOT.
32
+ attr_accessor :module_name
33
+
34
+ # Should the generated version.rb be in a class or module? Default is false (module).
35
+ attr_accessor :generate_version_class
36
+
37
+ # Paths to the roots of any components that also support ChefPackageTask.
38
+ # If relative paths are provided, they are rooted against root_path.
39
+ attr_accessor :component_paths
40
+
41
+ # This is the module name as it appears on the path "lib/module/".
42
+ # e.g. for module_name "ChefDK", you'd want module_path to be "chef-dk".
43
+ # The default is module_name but lower-cased.
44
+ attr_writer :module_path
45
+
46
+ def module_path
47
+ @module_path || module_name.downcase
48
+ end
49
+
50
+ # Directory used to store package files and output that is generated.
51
+ # This has the same meaning (or lack thereof) as package_dir in
52
+ # rake/packagetask.
53
+ attr_accessor :package_dir
54
+
55
+ # Name of git remote used to push tags during a release. Default is origin.
56
+ attr_accessor :git_remote
57
+
58
+ def initialize(root_path = nil, module_name = nil)
59
+ init(root_path, module_name)
60
+ yield self if block_given?
61
+ define unless root_path.nil? || module_name.nil?
62
+ end
63
+
64
+ def init(root_path, module_name)
65
+ @root_path = root_path
66
+ @module_name = module_name
67
+ @component_paths = []
68
+ @module_path = nil
69
+ @package_dir = "pkg"
70
+ @git_remote = "origin"
71
+ @generate_version_class = false
72
+ end
73
+
74
+ def component_full_paths
75
+ component_paths.map { |path| File.expand_path(path, root_path) }
76
+ end
77
+
78
+ def version_rb_path
79
+ File.expand_path("lib/#{module_path}/version.rb", root_path)
80
+ end
81
+
82
+ def chef_root_path
83
+ module_name == "Chef" ? root_path : File.dirname(root_path)
84
+ end
85
+
86
+ def version_file_path
87
+ File.join(chef_root_path, "VERSION")
88
+ end
89
+
90
+ def version
91
+ IO.read(version_file_path).strip
92
+ end
93
+
94
+ def full_package_dir
95
+ File.expand_path(package_dir, root_path)
96
+ end
97
+
98
+ def class_or_module
99
+ generate_version_class ? "class" : "module"
100
+ end
101
+
102
+ def with_clean_env(&block)
103
+ if defined?(Bundler)
104
+ Bundler.with_clean_env(&block)
105
+ else
106
+ yield
107
+ end
108
+ end
109
+
110
+ def define
111
+ raise "Need to provide package root and module name" if root_path.nil? || module_name.nil?
112
+
113
+ desc "Build Gems of component dependencies"
114
+ task :package_components do
115
+ component_full_paths.each do |component_path|
116
+ Dir.chdir(component_path) do
117
+ sh "rake package"
118
+ end
119
+ end
120
+ end
121
+
122
+ task :package => :package_components
123
+
124
+ desc "Build and install component dependencies"
125
+ task :install_components => :package_components do
126
+ component_full_paths.each do |component_path|
127
+ Dir.chdir(component_path) do
128
+ sh "rake install"
129
+ end
130
+ end
131
+ end
132
+
133
+ task :install => :install_components
134
+
135
+ desc "Clean up builds of component dependencies"
136
+ task :clobber_component_packages do
137
+ component_full_paths.each do |component_path|
138
+ Dir.chdir(component_path) do
139
+ sh "rake clobber_package"
140
+ end
141
+ end
142
+ end
143
+
144
+ task :clobber_package => :clobber_component_packages
145
+
146
+ desc "Update the version number for component dependencies"
147
+ task :update_components_versions do
148
+ component_full_paths.each do |component_path|
149
+ Dir.chdir(component_path) do
150
+ sh "rake version"
151
+ end
152
+ end
153
+ end
154
+
155
+ namespace :version do
156
+ desc 'Regenerate lib/#{@module_path}/version.rb from VERSION file'
157
+ task :update => :update_components_versions do
158
+ contents = <<-VERSION_RB
159
+ # Copyright:: Copyright 2010-2016, Chef Software, Inc.
160
+ # License:: Apache License, Version 2.0
161
+ #
162
+ # Licensed under the Apache License, Version 2.0 (the "License");
163
+ # you may not use this file except in compliance with the License.
164
+ # You may obtain a copy of the License at
165
+ #
166
+ # http://www.apache.org/licenses/LICENSE-2.0
167
+ #
168
+ # Unless required by applicable law or agreed to in writing, software
169
+ # distributed under the License is distributed on an "AS IS" BASIS,
170
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
171
+ # See the License for the specific language governing permissions and
172
+ # limitations under the License.
173
+
174
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
175
+ # NOTE: This file is generated by running `rake version` in the top level of
176
+ # this repo. Do not edit this manually. Edit the VERSION file and run the rake
177
+ # task instead.
178
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
179
+
180
+ #{class_or_module} #{module_name}
181
+ #{module_name.upcase}_ROOT = File.expand_path("../..", __FILE__)
182
+ VERSION = "#{version}"
183
+ end
184
+
185
+ #
186
+ # NOTE: the Chef::Version class is defined in version_class.rb
187
+ #
188
+ # NOTE: DO NOT Use the Chef::Version class on #{module_name}::VERSIONs. The
189
+ # Chef::Version class is for _cookbooks_ only, and cannot handle
190
+ # pre-release versions like "10.14.0.rc.2". Please use Rubygem's
191
+ # Gem::Version class instead.
192
+ #
193
+ VERSION_RB
194
+ IO.write(version_rb_path, contents)
195
+ end
196
+
197
+ task :bump => %w{version:bump_patch version:update}
198
+
199
+ task :show do
200
+ puts version
201
+ end
202
+
203
+ # Add 1 to the current patch version in the VERSION file, and write it back out.
204
+ task :bump_patch do
205
+ current_version = version
206
+ new_version = current_version.sub(/^(\d+\.\d+\.)(\d+)/) { "#{$1}#{$2.to_i + 1}" }
207
+ puts "Updating version in #{version_rb_path} from #{current_version.chomp} to #{new_version.chomp}"
208
+ IO.write(version_file_path, new_version)
209
+ end
210
+ end
211
+
212
+ task :version => "version:update"
213
+
214
+ Dir[File.expand_path("*gemspec", root_path)].reverse_each do |gemspec_path|
215
+ gemspec = eval(IO.read(gemspec_path))
216
+ Gem::PackageTask.new(gemspec) do |task|
217
+ task.package_dir = full_package_dir
218
+ end
219
+ end
220
+
221
+ desc "Build and install a #{module_path} gem"
222
+ task :install => [:package] do
223
+ with_clean_env do
224
+ full_module_path = File.join(full_package_dir, module_path)
225
+ sh %{gem install #{full_module_path}-#{version}.gem --no-rdoc --no-ri}
226
+ end
227
+ end
228
+
229
+ task :uninstall do
230
+ sh %{gem uninstall #{module_path} -x -v #{version} }
231
+ end
232
+
233
+ desc "Build it, tag it and ship it"
234
+ task :ship => [:clobber_package, :gem] do
235
+ sh("git tag #{version}")
236
+ sh("git push #{git_remote} --tags")
237
+ Dir[File.expand_path("*.gem", full_package_dir)].reverse_each do |built_gem|
238
+ sh("gem push #{built_gem}")
239
+ end
240
+ end
241
+ end
242
+ end
243
+
244
+ end