chef-sugar-dip 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cf37f8947f5193bb9209e1c332249b076fc88172
4
+ data.tar.gz: 6eb14a8f4dd56ae7303d5775b6a4b1011ef96b7f
5
+ SHA512:
6
+ metadata.gz: 80e5aca74e078ceecd5429cd48f6c81f21dd5cc4fed9dc275d4833ca9b0e3bfc78917103f3343a282b92c44ced59d6105cd9cbe288ad9d908b081892f98a8684
7
+ data.tar.gz: 18cb2575fdcbd5014eff2ece1227bd08a1e2a3a0fc3b147d5bd9a935bf0be1d2af90cecd34a43c5ccd8a1148a722a4b306a85a11cf488cffa36a2030a9ad56c7
@@ -0,0 +1,27 @@
1
+ *~
2
+ *#
3
+ .#*
4
+ \#*#
5
+ .*.sw[a-z]
6
+ *.un~
7
+ *.tmp
8
+ *.bk
9
+ *.bkup
10
+ .kitchen.local.yml
11
+ Berksfile.lock
12
+ Gemfile.lock
13
+
14
+ .bundle/
15
+ .cache/
16
+ .kitchen/
17
+ .vagrant/
18
+ .vagrant.d/
19
+ .yardoc/
20
+ bin/
21
+ coverage/
22
+ doc/
23
+ pkg/
24
+ tmp/
25
+ vendor/
26
+ .rspec
27
+ .DS_Store
@@ -0,0 +1,14 @@
1
+ driver:
2
+ name: vagrant
3
+
4
+ provisioner:
5
+ name: chef_zero
6
+ require_chef_omnibus: 11.8.0
7
+
8
+ platforms:
9
+ - name: ubuntu-12.04
10
+ - name: centos-6.4
11
+
12
+ suites:
13
+ - name: default
14
+ run_list: chef-sugar-dip::default
@@ -0,0 +1,8 @@
1
+ source 'https://api.berkshelf.com'
2
+
3
+ group :tests do
4
+ cookbook 'dip-cookbook',
5
+ path: 'spec/fixtures/cookbooks/dip-cookbook'
6
+ end
7
+
8
+ metadata
@@ -0,0 +1,8 @@
1
+ Chef Sugar Dip Changelog
2
+ =========================
3
+ This file is used to list changes made in each version of the chef-sugar-dip
4
+ cookbook and gem.
5
+
6
+ v1.0.0 (2014-04-20)
7
+ -------------------
8
+ - First public release
@@ -0,0 +1,22 @@
1
+ Contributing to Chef Sugar Dip
2
+ ===============================
3
+ The process for contributing to Chef sugar is rather straight-forward. It is
4
+ unlikely that you'll need to modify the actual Chef recipe, so it's assumed that
5
+ you want to work on the Gem itself.
6
+
7
+ 1. Fork the repository on GitHub.
8
+ 2. Clone your fork.
9
+ 3. Create a new, semantically-named branch:
10
+
11
+ $ git checkout -b my_feature_branch
12
+
13
+ 4. Make any changes, ensuring you write adequate test coverage.
14
+ 5. Document your changes (YARD).
15
+ 6. Run the tests (make sure they pass).
16
+ 7. Submit a Pull Request on GitHub.
17
+ 8. (optional) Ping me on Twitter (@JeanMertz)
18
+
19
+ Additionally, please **DO NOT**:
20
+ - Modify the version of the cookbook or gem.
21
+ - Update the CHANGELOG
22
+ - Make unnecessary changes to the gemspec
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2013-2014 Seth Vargo
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chef/sugar/dip/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'chef-sugar-dip'
8
+ spec.version = Chef::Sugar::Dip::VERSION
9
+ spec.authors = ['Jean Mertz']
10
+ spec.email = ['jean@mertz.fm']
11
+ spec.description = 'An extension to the awesome "chef-sugar" gem ' \
12
+ 'produced by Seth Vargo.'
13
+ spec.summary = 'A collection of helper methods and modules, extending' \
14
+ ' the helper methods available in the "chef-sugar" gem.'
15
+ spec.homepage = 'https://github.com/JeanMertz/chef-sugar-dip'
16
+ spec.license = 'Apache 2.0'
17
+
18
+ spec.required_ruby_version = '>= 1.9'
19
+
20
+ spec.files = `git ls-files`.split($/)
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency 'chef-sugar', '~> 1.2', '>= 1.2.6'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.3'
28
+ spec.add_development_dependency 'chefspec', '~> 3.0'
29
+ spec.add_development_dependency 'berkshelf', '~> 3.1'
30
+ spec.add_development_dependency 'test-kitchen', '~> 1.1'
31
+ spec.add_development_dependency 'kitchen-vagrant', '~> 0.14'
32
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Copyright 2014, Jean Mertz <jean@mertz.fm>
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
+ class Chef
18
+ module Sugar
19
+ require_relative 'dip/cookbook'
20
+ require_relative 'dip/file_system'
21
+ require_relative 'dip/ip'
22
+ end
23
+ end
24
+
25
+ require 'chef/sugar'
@@ -0,0 +1,126 @@
1
+ #
2
+ # Copyright 2014, Jean Mertz <jean@mertz.fm>
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
+ class Chef
18
+ module Sugar
19
+ module Cookbook
20
+ extend self
21
+
22
+ #
23
+ # Return array of cookbook files
24
+ #
25
+ # @params [String] cookbook name
26
+ #
27
+ # @return [Array]
28
+ # the array of cookbook files
29
+ #
30
+ def files(node, cookbook_name)
31
+ object(node, cookbook_name).send(:file_filenames)
32
+ end
33
+
34
+ #
35
+ # Return path of cookbook file.
36
+ #
37
+ # @params [String] cookbook name
38
+ # @params [String] file name
39
+ # if file is in subfolder, provide <folder/file_name>
40
+ #
41
+ # @return [String]
42
+ # path to cookbook file
43
+ #
44
+ def file_path(node, cookbook_name, path)
45
+ object(node, cookbook_name)
46
+ .preferred_filename_on_disk_location(node, :files, path)
47
+ end
48
+
49
+ #
50
+ # Return array of cookbook templates
51
+ #
52
+ # @params [String] cookbook name
53
+ #
54
+ # @return [Array]
55
+ # the array of cookbook templates
56
+ #
57
+ def templates(node, cookbook_name)
58
+ object(node, cookbook_name).send(:template_filenames)
59
+ end
60
+
61
+ #
62
+ # Return Metadata object for current cookbook
63
+ #
64
+ # @params [String] cookbook name
65
+ #
66
+ # @return [Chef::Cookbook::Metadata]
67
+ # the metadata object of current cookbook
68
+ #
69
+ def metadata(node, cookbook_name)
70
+ object(node, cookbook_name).metadata
71
+ end
72
+
73
+ #
74
+ # Return absolute root path of cookbook
75
+ #
76
+ # @params [String] cookbook name
77
+ #
78
+ # @return [String]
79
+ # absolute path to cookbook
80
+ #
81
+ def root(node, cookbook_name)
82
+ object(node, cookbook_name).send(:root_dir)
83
+ end
84
+
85
+ private
86
+
87
+ #
88
+ # Return Cookbook object
89
+ #
90
+ # @params [String] cookbook name
91
+ #
92
+ # @return [Chef::Cookbook]
93
+ #
94
+ def object(node, cookbook_name)
95
+ node.run_context.cookbook_collection[cookbook_name]
96
+ end
97
+ end
98
+
99
+ module DSL
100
+ # @see Chef::Sugar::Cookbook#files
101
+ def cookbook_files(cookbook_name)
102
+ Chef::Sugar::Cookbook.files(node, cookbook_name)
103
+ end
104
+
105
+ # @see Chef::Sugar::Cookbook#file
106
+ def cookbook_file_path(cookbook_name, path)
107
+ Chef::Sugar::Cookbook.file_path(node, cookbook_name, path)
108
+ end
109
+
110
+ # @see Chef::Sugar::Cookbook#templates
111
+ def cookbook_templates(cookbook_name)
112
+ Chef::Sugar::Cookbook.templates(node, cookbook_name)
113
+ end
114
+
115
+ # @see Chef::Sugar::Cookbook#metadata
116
+ def metadata(cookbook_name)
117
+ Chef::Sugar::Cookbook.metadata(node, cookbook_name)
118
+ end
119
+
120
+ # @see Chef::Sugar::Cookbook#root
121
+ def cookbook_root(cookbook_name)
122
+ Chef::Sugar::Cookbook.root(node, cookbook_name)
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # Copyright 2014, Jean Mertz <jean@mertz.fm>
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
+ class Chef
18
+ module Sugar
19
+ module FileSystem
20
+ extend self
21
+
22
+ #
23
+ # Returns temporary storage path, with optional appended string
24
+ #
25
+ # @example create file path to download file to
26
+ #
27
+ # tmp('elasticsearch/v2.0.0.tar.gz')
28
+ # => /var/chef/cache/elasticsearch/v2.0.0.tar.gz
29
+ #
30
+ # @param [String] path
31
+ # a string that is appended to the temporary path
32
+ #
33
+ def tmp(path = nil)
34
+ File.join(*[Chef::Config[:file_cache_path], path].compact)
35
+ end
36
+ end
37
+
38
+ module DSL
39
+ # @see Chef::Sugar::FileSystem#tmp
40
+ def tmp(path = nil); Chef::Sugar::FileSystem.tmp(path); end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Copyright 2014, Jean Mertz <jean@mertz.fm>
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
+ class Chef
18
+ module Sugar
19
+ module IP
20
+ extend self
21
+
22
+ #
23
+ # Return node's public IP
24
+ #
25
+ # @param [Chef::Node] node
26
+ # the node to calculate the public IP for
27
+ #
28
+ # @return [String]
29
+ # the node's ip address
30
+ #
31
+ def public_ip(node)
32
+ node['cloud'] ? node['cloud']['public_ipv4'] : node['ipaddress']
33
+ end
34
+ end
35
+
36
+ module DSL
37
+ # @see Chef::Sugar::IP#public_ip
38
+ def public_ip(other = nil); Chef::Sugar::IP.public_ip(other || node); end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,23 @@
1
+ #
2
+ # Copyright 2014, Jean Mertz <jean@mertz.fm>
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
+ class Chef
18
+ module Sugar
19
+ module Dip
20
+ VERSION = '1.0.0'
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ name 'chef-sugar-dip'
2
+ maintainer 'Jean Mertz'
3
+ maintainer_email 'jean@mertz.fm'
4
+ license 'Apache 2.0'
5
+ description 'Installs chef-sugar-dip. Please see the chef-sugar-dip ' \
6
+ 'Ruby gem for more information.'
7
+ long_description <<-EOH
8
+ Chef Sugar Dip is a Gem & Chef Recipe that adds a few helpful methods on top of
9
+ the Chef Sugar Gem, built by Seth Vargo. It includes series of helpful syntactic
10
+ sugars on top of the Chef core and other resources to make a cleaner, more lean
11
+ recipe DSL, enforce DRY principles, and make writing Chef recipes an awesome and
12
+ fun experience!
13
+
14
+ For the most up-to-date information and documentation, please visit the [Chef
15
+ Sugar project page on GitHub](https://github.com/sethvargo/chef-sugar).
16
+ EOH
17
+
18
+ version '1.0.0'
@@ -0,0 +1,3 @@
1
+ {
2
+ "test": "test value"
3
+ }
@@ -0,0 +1,5 @@
1
+ name 'dip-cookbook'
2
+ maintainer 'Jean Mertz'
3
+ maintainer_email 'jean@mertz.fm'
4
+ license 'Apache 2.0'
5
+ version '1.0.0'
@@ -0,0 +1,8 @@
1
+ chef_gem('chef-sugar-dip') do
2
+ version '1.0.0'
3
+ source run_context.cookbook_collection['dip-cookbook']
4
+ .preferred_filename_on_disk_location(node, :files, 'chef-sugar-dip-1.0.0.gem')
5
+ action :nothing
6
+ end.run_action(:install)
7
+
8
+ require 'chef/sugar/dip'
@@ -0,0 +1,3 @@
1
+ {
2
+ "test": "<%= test_value %>"
3
+ }
@@ -0,0 +1,22 @@
1
+ require 'rspec'
2
+ require 'chefspec'
3
+ require 'chefspec/berkshelf'
4
+ require 'chef/sugar/dip'
5
+
6
+ require_relative 'support/shared_examples'
7
+
8
+ RSpec.configure do |config|
9
+ # Prohibit using the should syntax
10
+ config.expect_with :rspec do |spec|
11
+ spec.syntax = :expect
12
+ end
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+
20
+ # ChefSpec configuration
21
+ config.log_level = :fatal
22
+ end
@@ -0,0 +1,20 @@
1
+ module RSpec
2
+ shared_examples 'a chef sugar' do
3
+ it 'acts as a singleton' do
4
+ described_class.module_eval("def foo; 'result'; end")
5
+ klass = Class.new.tap { |k| k.send(:include, described_class) }
6
+ expect(described_class.foo).to eq(klass.new.foo)
7
+ end
8
+
9
+ described_class.instance_methods.each do |name|
10
+ it "defines a `#{name}` DSL method" do
11
+ expect(Chef::Sugar::DSL).to satisfy do |dsl|
12
+ klass_name = described_class.name.downcase.split('::').last
13
+
14
+ dsl.method_defined?(name) ||
15
+ dsl.method_defined?("#{klass_name}_#{name}")
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chef::Sugar::Cookbook do
4
+ it_behaves_like 'a chef sugar'
5
+
6
+ let(:chef_instance) { ChefSpec::Runner.new }
7
+ let(:chef_run) { chef_instance.converge('dip-cookbook::default') }
8
+
9
+ context '#files' do
10
+ it 'returns the list of cookbook files' do
11
+ expect(described_class.files(chef_run.node, 'dip-cookbook').last)
12
+ .to include('files/default/test.json')
13
+ end
14
+ end
15
+
16
+ context '#templates' do
17
+ it 'returns the list of cookbook templates' do
18
+ expect(described_class.templates(chef_run.node, 'dip-cookbook').last)
19
+ .to include('templates/default/test.json.erb')
20
+ end
21
+ end
22
+
23
+ context '#file_path' do
24
+ it 'returns the absolute path of a requested file' do
25
+ expect(described_class
26
+ .file_path(chef_run.node, 'dip-cookbook', 'test.json'))
27
+ .to include('files/default/test.json')
28
+ end
29
+ end
30
+
31
+ context '#metadata' do
32
+ it 'returns a Chef::Cookbook::Metadata object' do
33
+ expect(described_class.metadata(chef_run.node, 'dip-cookbook'))
34
+ .to be_instance_of Chef::Cookbook::Metadata
35
+ end
36
+ end
37
+
38
+ context '#root' do
39
+ it 'returns the absolute path of the cookbook' do
40
+ expect(described_class.root(chef_run.node, 'dip-cookbook'))
41
+ .to include('cookbooks/dip-cookbook')
42
+ end
43
+ end
44
+
45
+ # context 'without any arguments' do
46
+ # it 'returns the default Chef cache path' do
47
+ # expect(described_class.tmp).to eq('/chef/cache')
48
+ # end
49
+ # end
50
+ #
51
+ # context 'with a custom path as argument' do
52
+ # it 'merges default Chef cache path with provided argument' do
53
+ # expect(described_class.tmp('my/path')).to eq('/chef/cache/my/path')
54
+ # end
55
+ # end
56
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chef::Sugar::FileSystem do
4
+ it_behaves_like 'a chef sugar'
5
+
6
+ before do
7
+ allow(Chef::Config).to receive(:[]).with(:file_cache_path) { '/chef/cache' }
8
+ end
9
+
10
+ context 'without any arguments' do
11
+ it 'returns the default Chef cache path' do
12
+ expect(described_class.tmp).to eq('/chef/cache')
13
+ end
14
+ end
15
+
16
+ context 'with a custom path as argument' do
17
+ it 'merges default Chef cache path with provided argument' do
18
+ expect(described_class.tmp('my/path')).to eq('/chef/cache/my/path')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chef::Sugar::IP do
4
+ it_behaves_like 'a chef sugar'
5
+
6
+ let(:node) { { 'ipaddress' => '1.2.3.4' } }
7
+
8
+ context 'when not on a cloud' do
9
+ it 'returns the default IP address' do
10
+ expect(described_class.public_ip(node)).to eq('1.2.3.4')
11
+ end
12
+ end
13
+
14
+ context 'when the target is on the cloud' do
15
+ before do
16
+ node['cloud'] = {}
17
+ node['cloud']['public_ipv4'] = '13.14.15.16'
18
+ end
19
+
20
+ it 'uses the public ipv4' do
21
+ expect(described_class.public_ip(node)).to eq('13.14.15.16')
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'chef-sugar-dip::default' do
4
+ let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
5
+
6
+ it 'installs the chef gem' do
7
+ expect(chef_run).to install_chef_gem('chef-sugar-dip')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-sugar-dip
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jean Mertz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef-sugar
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.6
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.2.6
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: chefspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: berkshelf
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.1'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.1'
75
+ - !ruby/object:Gem::Dependency
76
+ name: test-kitchen
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: kitchen-vagrant
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.14'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.14'
103
+ description: An extension to the awesome "chef-sugar" gem produced by Seth Vargo.
104
+ email:
105
+ - jean@mertz.fm
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".kitchen.yml"
112
+ - Berksfile
113
+ - CHANGELOG.md
114
+ - CONTRIBUTING.md
115
+ - Gemfile
116
+ - LICENSE
117
+ - chef-sugar-dip.gemspec
118
+ - lib/chef/sugar/dip.rb
119
+ - lib/chef/sugar/dip/cookbook.rb
120
+ - lib/chef/sugar/dip/file_system.rb
121
+ - lib/chef/sugar/dip/ip.rb
122
+ - lib/chef/sugar/dip/version.rb
123
+ - metadata.rb
124
+ - spec/fixtures/cookbooks/dip-cookbook/files/default/chef-sugar-dip-1.0.0.gem
125
+ - spec/fixtures/cookbooks/dip-cookbook/files/default/test.json
126
+ - spec/fixtures/cookbooks/dip-cookbook/metadata.rb
127
+ - spec/fixtures/cookbooks/dip-cookbook/recipes/default.rb
128
+ - spec/fixtures/cookbooks/dip-cookbook/templates/default/test.json.erb
129
+ - spec/spec_helper.rb
130
+ - spec/support/shared_examples.rb
131
+ - spec/unit/chef/sugar/dip/cookbook_spec.rb
132
+ - spec/unit/chef/sugar/dip/file_system_spec.rb
133
+ - spec/unit/chef/sugar/dip/ip_spec.rb
134
+ - spec/unit/recipes/default_spec.rb
135
+ homepage: https://github.com/JeanMertz/chef-sugar-dip
136
+ licenses:
137
+ - Apache 2.0
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '1.9'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.2.2
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: A collection of helper methods and modules, extending the helper methods
159
+ available in the "chef-sugar" gem.
160
+ test_files:
161
+ - spec/fixtures/cookbooks/dip-cookbook/files/default/chef-sugar-dip-1.0.0.gem
162
+ - spec/fixtures/cookbooks/dip-cookbook/files/default/test.json
163
+ - spec/fixtures/cookbooks/dip-cookbook/metadata.rb
164
+ - spec/fixtures/cookbooks/dip-cookbook/recipes/default.rb
165
+ - spec/fixtures/cookbooks/dip-cookbook/templates/default/test.json.erb
166
+ - spec/spec_helper.rb
167
+ - spec/support/shared_examples.rb
168
+ - spec/unit/chef/sugar/dip/cookbook_spec.rb
169
+ - spec/unit/chef/sugar/dip/file_system_spec.rb
170
+ - spec/unit/chef/sugar/dip/ip_spec.rb
171
+ - spec/unit/recipes/default_spec.rb