chef-cookie_cutter 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chef/cookie_cutter/extended_provides/monkey_patches.rb +39 -0
- data/lib/chef/cookie_cutter/extended_provides.rb +5 -22
- data/lib/chef/cookie_cutter/fancy_property/cookbook_doc.rb +48 -0
- data/lib/chef/cookie_cutter/fancy_property/property.rb +150 -0
- data/lib/chef/cookie_cutter/fancy_property.rb +4 -162
- data/lib/chef/cookie_cutter/include_properties/dsl.rb +40 -0
- data/lib/chef/cookie_cutter/include_properties/errors.rb +41 -0
- data/lib/chef/cookie_cutter/include_properties.rb +33 -0
- data/lib/chef/cookie_cutter/{lwrp_include.rb → include_resource/cookbook_doc.rb} +5 -62
- data/lib/chef/cookie_cutter/include_resource/dsl.rb +56 -0
- data/lib/chef/cookie_cutter/include_resource/fake_resource.rb +40 -0
- data/lib/chef/cookie_cutter/include_resource/monkey_patches.rb +42 -0
- data/lib/chef/cookie_cutter/include_resource.rb +39 -0
- data/lib/chef/cookie_cutter/{fake_resource.rb → namespace/dsl.rb} +8 -15
- data/lib/chef/cookie_cutter/namespace/monkey_patches.rb +67 -0
- data/lib/chef/cookie_cutter/namespace/namespace.rb +46 -0
- data/lib/chef/cookie_cutter/namespace.rb +12 -82
- data/lib/chef/cookie_cutter/run_state/dsl.rb +50 -0
- data/lib/chef/cookie_cutter/run_state/errors.rb +34 -0
- data/lib/chef/cookie_cutter/run_state.rb +8 -51
- data/lib/chef/cookie_cutter/spec_matchers/monkey_patches.rb +48 -0
- data/lib/chef/cookie_cutter/spec_matchers.rb +3 -30
- data/lib/chef/cookie_cutter/version.rb +22 -0
- data/lib/chef/cookie_cutter.rb +3 -18
- metadata +20 -6
- data/lib/chef/cookie_cutter/lwrp_build_params.rb +0 -71
- data/lib/chef/cookie_cutter/shared_blocks.rb +0 -64
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright 2015, Ole Claussen <claussen.ole@gmail.com>
|
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
|
+
class Chef
|
19
|
+
module CookieCutter
|
20
|
+
VERSION = '1.0.0'
|
21
|
+
end
|
22
|
+
end
|
data/lib/chef/cookie_cutter.rb
CHANGED
@@ -14,31 +14,16 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
|
-
require 'chef/recipe'
|
18
|
-
require 'chef/resource'
|
19
|
-
require 'chef/resource/lwrp_base'
|
20
|
-
require 'chef/provider'
|
21
|
-
require 'chef/provider/lwrp_base'
|
22
17
|
|
23
18
|
class Chef
|
24
19
|
module CookieCutter
|
25
20
|
require_relative 'cookie_cutter/extended_provides'
|
26
|
-
require_relative 'cookie_cutter/fake_resource'
|
27
21
|
require_relative 'cookie_cutter/fancy_property'
|
28
|
-
require_relative 'cookie_cutter/
|
29
|
-
require_relative 'cookie_cutter/
|
22
|
+
require_relative 'cookie_cutter/include_properties'
|
23
|
+
require_relative 'cookie_cutter/include_resource'
|
30
24
|
require_relative 'cookie_cutter/namespace'
|
31
25
|
require_relative 'cookie_cutter/run_state'
|
32
|
-
require_relative 'cookie_cutter/shared_blocks'
|
33
26
|
require_relative 'cookie_cutter/spec_matchers'
|
27
|
+
require_relative 'cookie_cutter/version'
|
34
28
|
end
|
35
29
|
end
|
36
|
-
|
37
|
-
Chef::CookieCutter::ExtendedProvides.register
|
38
|
-
Chef::CookieCutter::FancyPropertyModule.register
|
39
|
-
Chef::CookieCutter::LWRPBuildParams.register
|
40
|
-
Chef::CookieCutter::LWRPInclude.register
|
41
|
-
Chef::CookieCutter::Namespace.register
|
42
|
-
Chef::CookieCutter::RunState.register
|
43
|
-
Chef::CookieCutter::SharedBlocks.register
|
44
|
-
Chef::CookieCutter::SpecMatchers.register
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-cookie_cutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ole Claussen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,14 +74,28 @@ extra_rdoc_files: []
|
|
74
74
|
files:
|
75
75
|
- lib/chef/cookie_cutter.rb
|
76
76
|
- lib/chef/cookie_cutter/extended_provides.rb
|
77
|
-
- lib/chef/cookie_cutter/
|
77
|
+
- lib/chef/cookie_cutter/extended_provides/monkey_patches.rb
|
78
78
|
- lib/chef/cookie_cutter/fancy_property.rb
|
79
|
-
- lib/chef/cookie_cutter/
|
80
|
-
- lib/chef/cookie_cutter/
|
79
|
+
- lib/chef/cookie_cutter/fancy_property/cookbook_doc.rb
|
80
|
+
- lib/chef/cookie_cutter/fancy_property/property.rb
|
81
|
+
- lib/chef/cookie_cutter/include_properties.rb
|
82
|
+
- lib/chef/cookie_cutter/include_properties/dsl.rb
|
83
|
+
- lib/chef/cookie_cutter/include_properties/errors.rb
|
84
|
+
- lib/chef/cookie_cutter/include_resource.rb
|
85
|
+
- lib/chef/cookie_cutter/include_resource/cookbook_doc.rb
|
86
|
+
- lib/chef/cookie_cutter/include_resource/dsl.rb
|
87
|
+
- lib/chef/cookie_cutter/include_resource/fake_resource.rb
|
88
|
+
- lib/chef/cookie_cutter/include_resource/monkey_patches.rb
|
81
89
|
- lib/chef/cookie_cutter/namespace.rb
|
90
|
+
- lib/chef/cookie_cutter/namespace/dsl.rb
|
91
|
+
- lib/chef/cookie_cutter/namespace/monkey_patches.rb
|
92
|
+
- lib/chef/cookie_cutter/namespace/namespace.rb
|
82
93
|
- lib/chef/cookie_cutter/run_state.rb
|
83
|
-
- lib/chef/cookie_cutter/
|
94
|
+
- lib/chef/cookie_cutter/run_state/dsl.rb
|
95
|
+
- lib/chef/cookie_cutter/run_state/errors.rb
|
84
96
|
- lib/chef/cookie_cutter/spec_matchers.rb
|
97
|
+
- lib/chef/cookie_cutter/spec_matchers/monkey_patches.rb
|
98
|
+
- lib/chef/cookie_cutter/version.rb
|
85
99
|
homepage: https://github.com/oclaussen/chef-cookie-cutter
|
86
100
|
licenses:
|
87
101
|
- Apache 2.0
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright 2015, Ole Claussen <claussen.ole@gmail.com>
|
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
|
-
class Chef
|
19
|
-
module CookieCutter
|
20
|
-
module LWRPBuildParams
|
21
|
-
module_function
|
22
|
-
|
23
|
-
def register
|
24
|
-
Chef::Resource::LWRPBase.send :prepend, MonkeyPatches::LWRPResource
|
25
|
-
Chef::Provider::LWRPBase.send :prepend, MonkeyPatches::LWRPProvider
|
26
|
-
end
|
27
|
-
|
28
|
-
module MonkeyPatches
|
29
|
-
# Monkey Patches for Chef::Resource::LWRPBase
|
30
|
-
# Makes the parameters of build_from_file (i.e. cookbook_name, filename
|
31
|
-
# and run_context) available in the created class.
|
32
|
-
module LWRPResource
|
33
|
-
module ClassMethods
|
34
|
-
def build_from_file(cookbook_name, filename, run_context)
|
35
|
-
define_singleton_method(:lwrp_cookbook_name) { cookbook_name }
|
36
|
-
define_singleton_method(:lwrp_filename) { filename }
|
37
|
-
define_singleton_method(:lwrp_run_context) { run_context }
|
38
|
-
super
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.prepended(base)
|
43
|
-
class << base
|
44
|
-
prepend ClassMethods
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Monkey Patches for Chef::Provider::LWRPBase
|
50
|
-
# Makes the parameters of build_from_file (i.e. cookbook_name, filename
|
51
|
-
# and run_context) available in the created class.
|
52
|
-
module LWRPProvider
|
53
|
-
module ClassMethods
|
54
|
-
def build_from_file(cookbook_name, filename, run_context)
|
55
|
-
define_singleton_method(:lwrp_cookbook_name) { cookbook_name }
|
56
|
-
define_singleton_method(:lwrp_filename) { filename }
|
57
|
-
define_singleton_method(:lwrp_run_context) { run_context }
|
58
|
-
super
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.prepended(base)
|
63
|
-
class << base
|
64
|
-
prepend ClassMethods
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright 2015, Ole Claussen <claussen.ole@gmail.com>
|
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
|
-
class Chef
|
19
|
-
module CookieCutter
|
20
|
-
module SharedBlocks
|
21
|
-
module_function
|
22
|
-
|
23
|
-
def register
|
24
|
-
Chef::Recipe.send :include, DSL
|
25
|
-
Chef::Resource.send :include, DSL
|
26
|
-
Chef::Provider.send :include, DSL
|
27
|
-
end
|
28
|
-
|
29
|
-
class SharedBlockAlreadyDefined < StandardError
|
30
|
-
def initialize(name)
|
31
|
-
super <<-EOH
|
32
|
-
A shared block with the name #{name} already exists. Please make sure that
|
33
|
-
every shared block you define has a unique name.
|
34
|
-
EOH
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class SharedBlockNotDefined < StandardError
|
39
|
-
def initialize(name)
|
40
|
-
super <<-EOH
|
41
|
-
The shared block with the name #{name} is not defined.
|
42
|
-
EOH
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
module DSL
|
47
|
-
def shared?(name)
|
48
|
-
exist_state?(:cookie_cutter, :shared_blocks, name)
|
49
|
-
end
|
50
|
-
|
51
|
-
def shared(name, &block)
|
52
|
-
fail SharedBlocks::SharedBlockAlreadyDefined, name if shared? name
|
53
|
-
store_state(:cookie_cutter, :shared_blocks, name, block)
|
54
|
-
end
|
55
|
-
|
56
|
-
def include_shared(name)
|
57
|
-
fail SharedBlocks::SharedBlockNotDefined, name unless shared? name
|
58
|
-
block = fetch_state(:cookie_cutter, :shared_blocks, name)
|
59
|
-
instance_eval(&block)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|