chef-gen-flavors 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +5 -0
  3. data/LICENSE +2 -0
  4. data/Manifest.txt +0 -37
  5. data/README.md +113 -330
  6. data/chef-gen-flavors.gemspec +9 -9
  7. data/lib/chef_gen/flavors.rb +34 -100
  8. metadata +16 -47
  9. data/lib/chef_gen/flavor_base.rb +0 -266
  10. data/lib/chef_gen/snippet/attributes.rb +0 -35
  11. data/lib/chef_gen/snippet/chef_spec.rb +0 -111
  12. data/lib/chef_gen/snippet/cookbook_base.rb +0 -160
  13. data/lib/chef_gen/snippet/example_file.rb +0 -38
  14. data/lib/chef_gen/snippet/example_template.rb +0 -40
  15. data/lib/chef_gen/snippet/git_init.rb +0 -21
  16. data/lib/chef_gen/snippet/recipes.rb +0 -37
  17. data/lib/chef_gen/snippet/resource_provider.rb +0 -42
  18. data/lib/chef_gen/snippet/standard_ignore.rb +0 -73
  19. data/lib/chef_gen/snippet/style_foodcritic.rb +0 -51
  20. data/lib/chef_gen/snippet/style_rubocop.rb +0 -94
  21. data/lib/chef_gen/snippet/style_tailor.rb +0 -48
  22. data/lib/chef_gen/snippet/test_kitchen.rb +0 -109
  23. data/lib/chef_gen/snippets.rb +0 -18
  24. data/shared/snippet/attributes/attributes_default_rb.erb +0 -8
  25. data/shared/snippet/chef_spec/_rspec.erb +0 -2
  26. data/shared/snippet/chef_spec/spec_chef_runner_context_rb.erb +0 -36
  27. data/shared/snippet/chef_spec/spec_recipes_default_spec_rb.erb +0 -7
  28. data/shared/snippet/chef_spec/spec_spec_helper_rb.erb +0 -95
  29. data/shared/snippet/cookbookbase/Berksfile.erb +0 -12
  30. data/shared/snippet/cookbookbase/CHANGELOG_md.erb +0 -5
  31. data/shared/snippet/cookbookbase/Gemfile.erb +0 -18
  32. data/shared/snippet/cookbookbase/Guardfile.erb +0 -16
  33. data/shared/snippet/cookbookbase/README_md.erb +0 -92
  34. data/shared/snippet/cookbookbase/Rakefile.erb +0 -20
  35. data/shared/snippet/cookbookbase/metadata_rb.erb +0 -10
  36. data/shared/snippet/examplefile/files_default_example_conf +0 -34
  37. data/shared/snippet/exampletemplate/templates_default_example_conf_erb +0 -22
  38. data/shared/snippet/recipes/recipes_default_rb.erb +0 -9
  39. data/shared/snippet/resourceprovider/providers_default_rb.erb +0 -20
  40. data/shared/snippet/resourceprovider/resources_default_rb.erb +0 -9
  41. data/shared/snippet/stylerubocop/_rubocop_yml.erb +0 -31
  42. data/shared/snippet/testkitchen/_kitchen_yml.erb +0 -30
  43. data/shared/snippet/testkitchen/libraries_kitchen_helper_rb +0 -13
  44. data/shared/snippet/testkitchen/test_integration_default_serverspec_recipes_default_spec_rb.erb +0 -16
  45. data/shared/snippet/testkitchen/test_integration_default_serverspec_spec_helper_rb.erb +0 -7
@@ -1,35 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # a cookbook that has attributes
4
- module Attributes
5
- # declares directories
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_attributes_dirs(recipe)
10
- @directories << 'attributes'
11
- end
12
-
13
- # declares files
14
- # @param recipe [Chef::Recipe] the recipe into which resources
15
- # will be injected
16
- # @return [void]
17
- def snippet_attributes_files(recipe)
18
- @templates_if_missing << File.join('attributes', 'default.rb')
19
- end
20
-
21
- # copies snippet content
22
- # @param path [String] the path to the temporary generator cookbook
23
- # @return [void]
24
- def content_attribute_files(path)
25
- copy_snippet_file(
26
- File.join(
27
- File.dirname(__FILE__), '..', '..', '..',
28
- 'shared', 'snippet', 'attributes', 'attributes_default_rb.erb'
29
- ),
30
- File.join(path, 'templates', 'default', 'attributes_default_rb.erb')
31
- )
32
- end
33
- end
34
- end
35
- end
@@ -1,111 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # creates a framework for ChefSpec unit testing
4
- module ChefSpec
5
- # declares directories
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_chefspec_dirs(recipe)
10
- @directories << 'spec'
11
- @directories << File.join('spec', 'recipes')
12
- end
13
-
14
- # declares files
15
- # @param recipe [Chef::Recipe] the recipe into which resources
16
- # will be injected
17
- # @return [void]
18
- def snippet_chefspec_files(recipe)
19
- @templates << '.rspec'
20
- @templates_if_missing << File.join('spec', 'spec_helper.rb')
21
- @templates_if_missing << File.join('spec', 'recipes', 'default_spec.rb')
22
- @templates_if_missing << File.join('spec', 'chef_runner_context.rb')
23
- end
24
-
25
- # adds chefspec files to the git and chefignore patterns
26
- # @param recipe [Chef::Recipe] the recipe into which resources
27
- # will be injected
28
- # @return [void]
29
- def snippet_chefspec_ignore(recipe)
30
- return unless respond_to?(:chefignore_patterns)
31
- %w(
32
- .rspec
33
- spec/*
34
- spec/fixtures/*
35
- ).each do |e|
36
- chefignore_patterns << e
37
- end
38
- end
39
-
40
- # adds chefspec gems to the Gemfile
41
- # @param recipe [Chef::Recipe] the recipe into which resources
42
- # will be injected
43
- # @return [void]
44
- def snippet_chefspec_gems(recipe)
45
- return unless respond_to?(:cookbook_gems)
46
- cookbook_gems['chefspec'] = '~> 4.1'
47
- cookbook_gems['guard-rspec'] = '~> 4.5'
48
- cookbook_gems['ci_reporter_rspec'] = '~> 1.0'
49
- end
50
-
51
- # adds chefspec rake tasks to the Rakefile
52
- # @param recipe [Chef::Recipe] the recipe into which resources
53
- # will be injected
54
- # @return [void]
55
- def snippet_chefspec_raketasks(recipe)
56
- return unless respond_to?(:rake_tasks)
57
- rake_tasks['chefspec'] = <<'END'
58
- require 'rspec/core/rake_task'
59
- RSpec::Core::RakeTask.new(:chefspec)
60
-
61
- desc 'Generate ChefSpec coverage report'
62
- task :coverage do
63
- ENV['COVERAGE'] = 'true'
64
- Rake::Task[:chefspec].invoke
65
- end
66
- task spec: :chefspec
67
- END
68
- end
69
-
70
- # adds chefspec sets to the Guardfile
71
- # @param recipe [Chef::Recipe] the recipe into which resources
72
- # will be injected
73
- # @return [void]
74
- def snippet_chefspec_guardsets(recipe)
75
- return unless respond_to?(:guard_sets)
76
- guard_sets['chefspec'] = <<'END'
77
- rspec_command = ENV.key?('DISABLE_PRY_RESCUE') ? 'rspec' : 'rescue rspec'
78
- guard :rspec, all_on_start: true, cmd: "bundle exec #{rspec_command}" do
79
- watch(%r{^spec/recipes/.+_spec\.rb$})
80
- watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
81
- watch(%r{^attributes/.+\.rb$}) { 'spec' }
82
- watch(%r{^resources/.+\.rb$}) { 'spec' }
83
- watch(%r{^providers/.+\.rb$}) { 'spec' }
84
- watch(%r{^libraries/.+\.rb$}) { 'spec' }
85
- watch(%r{^recipes/(.+)\.rb$}) { |m| "spec/recipes/#{m[1]}_spec.rb" }
86
- end
87
- END
88
- end
89
-
90
- # copies snippet content
91
- # @param path [String] the path to the temporary generator cookbook
92
- # @return [void]
93
- def content_chefspec_files(path)
94
- %w(
95
- _rspec.erb
96
- spec_spec_helper_rb.erb
97
- spec_recipes_default_spec_rb.erb
98
- spec_chef_runner_context_rb.erb
99
- ).each do |file|
100
- copy_snippet_file(
101
- File.join(
102
- File.dirname(__FILE__), '..', '..', '..',
103
- 'shared', 'snippet', 'chef_spec', file
104
- ),
105
- File.join(path, 'templates', 'default', file)
106
- )
107
- end
108
- end
109
- end
110
- end
111
- end
@@ -1,160 +0,0 @@
1
- # rubocop:disable Metrics/MethodLength
2
-
3
- require 'chef/mixin/params_validate'
4
-
5
- module ChefGen
6
- module Snippet
7
- # creates the basic files that every cookbook should have
8
- # each file is managed through a separate method to allow for
9
- # people to mix this in but turn off just one file
10
- module CookbookBase
11
- # adds a Hash for gems to add to the gemfile
12
- attr_reader :cookbook_gems
13
-
14
- # adds an Array of gem sources, defaulting to rubygems
15
- attr_reader :gem_sources
16
-
17
- # adds an Array of berks sources, defaulting to supermarket
18
- attr_reader :berks_sources
19
-
20
- # adds a Hash of rake tasks
21
- attr_reader :rake_tasks
22
-
23
- # adds a Hash of guard sets
24
- attr_reader :guard_sets
25
-
26
- # initializes instance vars
27
- def init_cookbookbase_instancevars
28
- @gem_sources = %w(https://rubygems.org)
29
- @berks_sources = %w(https://supermarket.chef.io)
30
- @rake_tasks = {}
31
- @guard_sets = {}
32
- @cookbook_gems = {
33
- 'rake' => '~> 10.4',
34
- 'pry' => '~> 0.10',
35
- 'pry-byebug' => '~> 3.1',
36
- 'pry-rescue' => '~> 1.4',
37
- 'pry-stack_explorer' => '~> 0.4',
38
- 'berkshelf' => '~> 3.3',
39
- 'guard' => '~> 2.12'
40
- }
41
- end
42
-
43
- # declares files
44
- # @param recipe [Chef::Recipe] the recipe into which resources
45
- # will be injected
46
- # @return [void]
47
- def snippet_cookbookbase_files(recipe)
48
- @templates_if_missing << 'metadata.rb'
49
- @templates_if_missing << 'README.md'
50
- @templates_if_missing << 'CHANGELOG.md'
51
- end
52
-
53
- # declares the Gemfile with lazy evaluation of the gems
54
- # @param recipe [Chef::Recipe] the recipe into which resources
55
- # will be injected
56
- # @return [void]
57
- def snippet_cookbookbase_gemfile(recipe)
58
- gems = @cookbook_gems
59
- sources = @gem_sources
60
- lazy_vars = Chef::DelayedEvaluator.new do
61
- { gems: gems, sources: sources }
62
- end
63
- # :nocov:
64
- add_render(
65
- %w(Gemfile),
66
- resource_action: :create,
67
- attrs: { variables: lazy_vars }
68
- )
69
- # :nocov:
70
- end
71
-
72
- # declares the Berksfile with lazy evaluation of the sources
73
- # @param recipe [Chef::Recipe] the recipe into which resources
74
- # will be injected
75
- # @return [void]
76
- def snippet_cookbookbase_berksfile(recipe)
77
- sources = @berks_sources
78
- lazy_vars = Chef::DelayedEvaluator.new do
79
- { sources: sources }
80
- end
81
- # :nocov:
82
- add_render(
83
- %w(Berksfile),
84
- resource_action: :create,
85
- attrs: { variables: lazy_vars }
86
- )
87
- # :nocov:
88
- end
89
-
90
- # declares the Rakefile with lazy evaluation of the tasks
91
- # @param recipe [Chef::Recipe] the recipe into which resources
92
- # will be injected
93
- # @return [void]
94
- def snippet_cookbookbase_rakefile(recipe)
95
- tasks = @rake_tasks
96
- lazy_vars = Chef::DelayedEvaluator.new do
97
- { tasks: tasks }
98
- end
99
- # :nocov:
100
- add_render(
101
- %w(Rakefile),
102
- resource_action: :create,
103
- attrs: { variables: lazy_vars }
104
- )
105
- # :nocov:
106
- end
107
-
108
- # declares the Guardfile with lazy evaluation of the guards
109
- # @param recipe [Chef::Recipe] the recipe into which resources
110
- # will be injected
111
- # @return [void]
112
- def snippet_cookbookbase_guardfile(recipe)
113
- guards = @guard_sets
114
- lazy_vars = Chef::DelayedEvaluator.new do
115
- { guards: guards }
116
- end
117
- # :nocov:
118
- add_render(
119
- %w(Guardfile),
120
- resource_action: :create,
121
- attrs: { variables: lazy_vars }
122
- )
123
- # :nocov:
124
- end
125
-
126
- # adds base files to the git and chefignore patterns
127
- # @param recipe [Chef::Recipe] the recipe into which resources
128
- # will be injected
129
- # @return [void]
130
- def snippet_cookbookbase_ignore(recipe)
131
- return unless respond_to?(:chefignore_patterns)
132
- %w(
133
- Gemfile Rakefile Guardfile Berksfile
134
- ).each do |e|
135
- chefignore_patterns << e
136
- end
137
- end
138
-
139
- # copies snippet content
140
- # @param path [String] the path to the temporary generator cookbook
141
- # @return [void]
142
- def content_cookbookbase_files(path)
143
- %w(
144
- Gemfile.erb Berksfile.erb Rakefile.erb Guardfile.erb
145
- metadata_rb.erb README_md.erb CHANGELOG_md.erb
146
- ).each do |file|
147
- # :nocov:
148
- copy_snippet_file(
149
- File.join(
150
- File.dirname(__FILE__), '..', '..', '..',
151
- 'shared', 'snippet', 'cookbookbase', file
152
- ),
153
- File.join(path, 'templates', 'default', file)
154
- )
155
- # :nocov:
156
- end
157
- end
158
- end
159
- end
160
- end
@@ -1,38 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # a sample cookbook_file source
4
- module ExampleFile
5
- # declares directories
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_examplefile_dirs(recipe)
10
- @directories << 'files'
11
- @directories << File.join('files', 'default')
12
- end
13
-
14
- # declares files
15
- # @param recipe [Chef::Recipe] the recipe into which resources
16
- # will be injected
17
- # @return [void]
18
- def snippet_examplefile_files(recipe)
19
- @files_if_missing << File.join('files', 'default', 'example.conf')
20
- end
21
-
22
- # copies snippet content
23
- # @param path [String] the path to the temporary generator cookbook
24
- # @return [void]
25
- def content_examplefile_files(path)
26
- %w(files_default_example_conf).each do |file|
27
- copy_snippet_file(
28
- File.join(
29
- File.dirname(__FILE__), '..', '..', '..',
30
- 'shared', 'snippet', 'examplefile', file
31
- ),
32
- File.join(path, 'files', 'default', file)
33
- )
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,40 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # a sample template source
4
- module ExampleTemplate
5
- # declares directories
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_exampletemplate_dirs(recipe)
10
- @directories << 'templates'
11
- @directories << File.join('templates', 'default')
12
- end
13
-
14
- # declares files
15
- # @param recipe [Chef::Recipe] the recipe into which resources
16
- # will be injected
17
- # @return [void]
18
- def snippet_exampletemplate_files(recipe)
19
- @files_if_missing << File.join(
20
- 'templates', 'default', 'example.conf.erb'
21
- )
22
- end
23
-
24
- # copies snippet content
25
- # @param path [String] the path to the temporary generator cookbook
26
- # @return [void]
27
- def content_exampletemplate_files(path)
28
- %w(templates_default_example_conf_erb).each do |file|
29
- copy_snippet_file(
30
- File.join(
31
- File.dirname(__FILE__), '..', '..', '..',
32
- 'shared', 'snippet', 'exampletemplate', file
33
- ),
34
- File.join(path, 'files', 'default', file)
35
- )
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,21 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # initializes a git repo
4
- module GitInit
5
- # executes 'git init .'
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_gitinit(recipe)
10
- c = generator_context
11
- target_path = @target_path
12
- # :nocov:
13
- recipe.send(:execute, 'initialize git repo') do
14
- command('git init .')
15
- cwd target_path
16
- end if c.have_git && !c.skip_git_init
17
- # :nocov:
18
- end
19
- end
20
- end
21
- end
@@ -1,37 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # a cookbook that has recipes
4
- module Recipes
5
- # declares directories
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_recipes_dirs(recipe)
10
- @directories << 'recipes'
11
- end
12
-
13
- # declares files
14
- # @param recipe [Chef::Recipe] the recipe into which resources
15
- # will be injected
16
- # @return [void]
17
- def snippet_recipes_files(recipe)
18
- @templates_if_missing << File.join('recipes', 'default.rb')
19
- end
20
-
21
- # copies snippet content
22
- # @param path [String] the path to the temporary generator cookbook
23
- # @return [void]
24
- def content_recipes_files(path)
25
- %w(recipes_default_rb.erb).each do |file|
26
- copy_snippet_file(
27
- File.join(
28
- File.dirname(__FILE__), '..', '..', '..',
29
- 'shared', 'snippet', 'recipes', file
30
- ),
31
- File.join(path, 'templates', 'default', file)
32
- )
33
- end
34
- end
35
- end
36
- end
37
- end