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,42 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # a cookbook that has provides resources and providers
4
- module ResourceProvider
5
- # declares directories
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_resourceprovider_dirs(recipe)
10
- @directories << 'resources'
11
- @directories << 'providers'
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_resourceprovider_files(recipe)
19
- @templates_if_missing << File.join('resources', 'default.rb')
20
- @templates_if_missing << File.join('providers', 'default.rb')
21
- end
22
-
23
- # copies snippet content
24
- # @param path [String] the path to the temporary generator cookbook
25
- # @return [void]
26
- def content_resourceprovider_files(path)
27
- %w(
28
- resources_default_rb.erb
29
- providers_default_rb.erb
30
- ).each do |file|
31
- copy_snippet_file(
32
- File.join(
33
- File.dirname(__FILE__), '..', '..', '..',
34
- 'shared', 'snippet', 'resourceprovider', file
35
- ),
36
- File.join(path, 'templates', 'default', file)
37
- )
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,73 +0,0 @@
1
- # rubocop:disable Metrics/MethodLength
2
- module ChefGen
3
- module Snippet
4
- # populates the list of ignore patterns for chefignore and .gitignore
5
- module StandardIgnore
6
- # adds an array for chefignore patterns
7
- attr_reader :chefignore_patterns
8
-
9
- # adds an array for gitignore patterns
10
- attr_reader :gitignore_patterns
11
-
12
- # initializes the pattern arrays
13
- def init_standardignore_instancevars
14
- @chefignore_patterns = %w(
15
- .DS_Store Icon? nohup.out ehthumbs.db Thumbs.db
16
- .sasscache \#* .#* *~ *.sw[az] *.bak REVISION TAGS*
17
- tmtags *_flymake.* *_flymake *.tmproj .project .settings
18
- mkmf.log a.out *.o *.pyc *.so *.com *.class *.dll
19
- *.exe */rdoc/ .watchr test/* features/* Procfile
20
- .git */.git .gitignore .gitmodules .gitconfig .gitattributes
21
- .svn */.bzr/* */.hg/*
22
- )
23
- @gitignore_patterns = %w(
24
- Berksfile.lock *~ *# .#* \#*# .*.sw[az] *.un~
25
- bin/* .bundle/*
26
- )
27
- end
28
-
29
- # rubocop:disable Metrics/AbcSize
30
-
31
- # declares ignore files
32
- # @param recipe [Chef::Recipe] the recipe into which resources
33
- # will be injected
34
- # @return [void]
35
- def snippet_standardignore_files(recipe)
36
- add_chefignore_resource(recipe)
37
- add_gitignore_resource(recipe)
38
- end
39
-
40
- private
41
-
42
- # add the chefignore file resource, with content from the list
43
- # of patterns in the instance var set to reasonable defaults
44
- # and lazily evaluated
45
- # @param recipe [Chef::Recipe] the recipe into which resources
46
- # will be injected
47
- # @return [void]
48
- def add_chefignore_resource(recipe)
49
- patterns = @chefignore_patterns
50
- # :nocov:
51
- recipe.send(:file, File.join(@target_path, 'chefignore')) do
52
- content lazy { patterns.sort.uniq.join("\n") + "\n" }
53
- end
54
- # :nocov:
55
- end
56
-
57
- # add the .gitignore file resource, with content from the list
58
- # of patterns in the instance var set to reasonable defaults
59
- # and lazily evaluated
60
- # @param recipe [Chef::Recipe] the recipe into which resources
61
- # will be injected
62
- # @return [void]
63
- def add_gitignore_resource(recipe)
64
- patterns = @gitignore_patterns
65
- # :nocov:
66
- recipe.send(:file, File.join(@target_path, '.gitignore')) do
67
- content lazy { patterns.sort.uniq.join("\n") + "\n" }
68
- end
69
- # :nocov:
70
- end
71
- end
72
- end
73
- end
@@ -1,51 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # sets up style testing using Foodcritic
4
- module StyleFoodcritic
5
- # adds foodcritic gems to the Gemfile
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_stylefoodcritic_gems(recipe)
10
- return unless respond_to?(:cookbook_gems)
11
- cookbook_gems['foodcritic'] = '~> 4.0'
12
- cookbook_gems['guard-foodcritic'] = '~> 1.1'
13
- end
14
-
15
- # adds foodcritic rake tasks to the Rakefile
16
- # @param recipe [Chef::Recipe] the recipe into which resources
17
- # will be injected
18
- # @return [void]
19
- def snippet_foodcritic_raketasks(recipe)
20
- return unless respond_to?(:rake_tasks)
21
- rake_tasks['foodcritic'] = <<'END'
22
- require 'foodcritic'
23
- require 'foodcritic/rake_task'
24
-
25
- FoodCritic::Rake::LintTask.new(:foodcritic)
26
- task style: :foodcritic
27
- END
28
- end
29
-
30
- # adds foodcritic sets to the Guardfile
31
- # @param recipe [Chef::Recipe] the recipe into which resources
32
- # will be injected
33
- # @return [void]
34
- def snippet_foodcritic_guardsets(recipe)
35
- return unless respond_to?(:guard_sets)
36
- guard_sets['foodcritic'] = <<'END'
37
- guard :foodcritic,
38
- cookbook_paths: '.',
39
- cli: '-f any -X spec -X test -X features' do
40
- watch(%r{^attributes/.+\.rb$})
41
- watch(%r{^resources/.+\.rb$})
42
- watch(%r{^providers/.+\.rb$})
43
- watch(%r{^libraries/.+\.rb$})
44
- watch(%r{^recipes/.+\.rb$})
45
- watch(%r{^metadata\.rb$})
46
- end
47
- END
48
- end
49
- end
50
- end
51
- end
@@ -1,94 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # sets up style testing using Rubocop
4
- module StyleRubocop
5
- # declares the rubocop config file
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_stylerubocop_config(recipe)
10
- @templates_if_missing << '.rubocop.yml'
11
- end
12
-
13
- # adds rubocop gems to the Gemfile
14
- # @param recipe [Chef::Recipe] the recipe into which resources
15
- # will be injected
16
- # @return [void]
17
- def snippet_stylerubocop_gems(recipe)
18
- return unless respond_to?(:cookbook_gems)
19
- cookbook_gems['rubocop'] = '~> 0.31'
20
- cookbook_gems['guard-rubocop'] = '~> 1.1'
21
- end
22
-
23
- # copies snippet content
24
- # @param path [String] the path to the temporary generator cookbook
25
- # @return [void]
26
- def content_stylerubocop_files(path)
27
- %w(_rubocop_yml.erb).each do |file|
28
- copy_snippet_file(
29
- File.join(
30
- File.dirname(__FILE__), '..', '..', '..',
31
- 'shared', 'snippet', 'stylerubocop', file
32
- ),
33
- File.join(path, 'templates', 'default', file)
34
- )
35
- end
36
- end
37
-
38
- # rubocop:disable Metrics/MethodLength
39
-
40
- # adds rubocop rake tasks to the Rakefile
41
- # @param recipe [Chef::Recipe] the recipe into which resources
42
- # will be injected
43
- # @return [void]
44
- def snippet_rubocop_raketasks(recipe)
45
- return unless respond_to?(:rake_tasks)
46
- rake_tasks['rubocop'] = <<'END'
47
- require 'rubocop/rake_task'
48
-
49
- RuboCop::RakeTask.new(:rubocop) do |t|
50
- t.formatters = ['progress']
51
- t.options = ['-D']
52
- t.patterns = %w(
53
- attributes/*.rb
54
- recipes/*.rb
55
- libraries/**/*.rb
56
- resources/*.rb
57
- providers/*.rb
58
- spec/**/*.rb
59
- test/**/*.rb
60
- ./metadata.rb
61
- ./Berksfile
62
- ./Gemfile
63
- ./Rakefile
64
- )
65
- end
66
- task style: :rubocop
67
- END
68
- end
69
-
70
- # adds rubocop sets to the Guardfile
71
- # @param recipe [Chef::Recipe] the recipe into which resources
72
- # will be injected
73
- # @return [void]
74
- def snippet_rubocop_guardsets(recipe)
75
- return unless respond_to?(:guard_sets)
76
- guard_sets['rubocop'] = <<'END'
77
- guard :rubocop, all_on_start: true, cli: ['-f', 'p', '-D'] do
78
- watch(%r{^attributes/.+\.rb$})
79
- watch(%r{^recipes/.+\.rb$})
80
- watch(%r{^libraries/.+\.rb$})
81
- watch(%r{^resources/.+\.rb$})
82
- watch(%r{^providers/.+\.rb$})
83
- watch(%r{^spec/.+\.rb$})
84
- watch(%r{^test/.+\.rb$})
85
- watch(%r{^metadata\.rb$})
86
- watch(%r{^Berksfile$})
87
- watch(%r{^Gemfile$})
88
- watch(%r{^Rakefile$})
89
- end
90
- END
91
- end
92
- end
93
- end
94
- end
@@ -1,48 +0,0 @@
1
- module ChefGen
2
- module Snippet
3
- # sets up style testing using Tailor
4
- module StyleTailor
5
- # adds tailor gems to the Gemfile
6
- # @param recipe [Chef::Recipe] the recipe into which resources
7
- # will be injected
8
- # @return [void]
9
- def snippet_styletailor_gems(recipe)
10
- return unless respond_to?(:cookbook_gems)
11
- cookbook_gems['tailor'] = '~> 1.4'
12
- cookbook_gems['guard-rake'] = '~> 0.0'
13
- end
14
-
15
- # rubocop:disable Metrics/MethodLength
16
-
17
- # adds tailor rake tasks to the Rakefile
18
- # @param recipe [Chef::Recipe] the recipe into which resources
19
- # will be injected
20
- # @return [void]
21
- def snippet_tailor_raketasks(recipe)
22
- return unless respond_to?(:rake_tasks)
23
- rake_tasks['tailor'] = <<'END'
24
- require 'tailor/rake_task'
25
- Tailor::RakeTask.new do |t|
26
- {
27
- spec: 'spec/recipes/*_spec.rb',
28
- spec_helper: 'spec/spec_helper.rb',
29
- attributes: 'attributes/*.rb',
30
- resources: 'resources/*.rb',
31
- providers: 'providers/*.rb',
32
- libraries: 'libraries/**/*.rb',
33
- recipes: 'recipes/*.rb',
34
- metadata: 'metadata.rb'
35
- }.each do |name, glob|
36
- t.file_set glob, name do |s|
37
- s.max_line_length 1000
38
- s.max_code_lines_in_method 1000
39
- s.max_code_lines_in_class 1000
40
- end
41
- end
42
- end
43
- task style: :tailor
44
- END
45
- end
46
- end
47
- end
48
- end
@@ -1,109 +0,0 @@
1
- # rubocop:disable Metrics/MethodLength
2
- module ChefGen
3
- module Snippet
4
- # creates a framework for Test Kitchen integration testing
5
- module TestKitchen
6
- # declares directories
7
- # @param recipe [Chef::Recipe] the recipe into which resources
8
- # will be injected
9
- # @return [void]
10
- def snippet_testkitchen_dirs(recipe)
11
- @directories << 'test'
12
- @directories << File.join('test', 'integration')
13
- @directories << File.join('test', 'integration', 'default')
14
- @directories << File.join(
15
- 'test', 'integration', 'default', 'serverspec'
16
- )
17
- @directories << File.join(
18
- 'test', 'integration', 'default', 'serverspec', 'recipes'
19
- )
20
- end
21
-
22
- # declares the Test Kitchen config
23
- # @param recipe [Chef::Recipe] the recipe into which resources
24
- # will be injected
25
- # @return [void]
26
- def snippet_testkitchen_files(recipe)
27
- @templates_if_missing << '.kitchen.yml'
28
- @templates_if_missing << File.join(
29
- 'test', 'integration', 'default', 'serverspec', 'spec_helper.rb'
30
- )
31
- @templates_if_missing << File.join(
32
- 'test', 'integration', 'default', 'serverspec',
33
- 'recipes', 'default_spec.rb'
34
- )
35
- end
36
-
37
- # adds testkitchen to the git and chefignore patterns
38
- # @param recipe [Chef::Recipe] the recipe into which resources
39
- # will be injected
40
- # @return [void]
41
- def snippet_testkitchen_ignore(recipe)
42
- %w(
43
- .vagrant
44
- .kitchen/
45
- .kitchen.local.yml
46
- ).each do |e|
47
- gitignore_patterns << e if respond_to?(:gitignore_patterns)
48
- chefignore_patterns << e if respond_to?(:chefignore_patterns)
49
- end
50
- end
51
-
52
- # adds testkitchen gems to the Gemfile
53
- # @param recipe [Chef::Recipe] the recipe into which resources
54
- # will be injected
55
- # @return [void]
56
- def snippet_testkitchen_gems(recipe)
57
- return unless respond_to?(:cookbook_gems)
58
- cookbook_gems['test-kitchen'] = '~> 1.4'
59
- cookbook_gems['kitchen-vagrant'] = '~> 0.16'
60
- end
61
-
62
- # adds testkitchen rake tasks to the Rakefile
63
- # @param recipe [Chef::Recipe] the recipe into which resources
64
- # will be injected
65
- # @return [void]
66
- def snippet_testkitchen_raketasks(recipe)
67
- return unless respond_to?(:rake_tasks)
68
- rake_tasks['testkitchen'] = <<'END'
69
- begin
70
- require 'kitchen/rake_tasks'
71
- Kitchen::RakeTasks.new
72
- rescue
73
- desc 'placeholder Test Kitchen task when plugins are missing'
74
- task 'kitchen:all' do
75
- puts 'test-kitchen plugins not installed; this is a placeholder task'
76
- end
77
- end
78
- task integration: 'kitchen:all'
79
- END
80
- end
81
-
82
- # copies snippet content
83
- # @param path [String] the path to the temporary generator cookbook
84
- # @return [void]
85
- def content_testkitchen_files(path)
86
- %w(
87
- _kitchen_yml.erb
88
- test_integration_default_serverspec_spec_helper_rb.erb
89
- test_integration_default_serverspec_recipes_default_spec_rb.erb
90
- ).each do |file|
91
- copy_snippet_file(
92
- File.join(
93
- File.dirname(__FILE__), '..', '..', '..',
94
- 'shared', 'snippet', 'testkitchen', file
95
- ),
96
- File.join(path, 'templates', 'default', file)
97
- )
98
- end
99
- copy_snippet_file(
100
- File.join(
101
- File.dirname(__FILE__), '..', '..', '..',
102
- 'shared', 'snippet', 'testkitchen', 'libraries_kitchen_helper_rb'
103
- ),
104
- File.join(path, 'libraries', 'kitchen_helper.rb')
105
- )
106
- end
107
- end
108
- end
109
- end
@@ -1,18 +0,0 @@
1
- module ChefGen
2
- # template snippets that flavors can compose to do common things
3
- module Snippet
4
- autoload :Attributes, 'chef_gen/snippet/attributes'
5
- autoload :ChefSpec, 'chef_gen/snippet/chef_spec'
6
- autoload :CookbookBase, 'chef_gen/snippet/cookbook_base'
7
- autoload :ExampleFile, 'chef_gen/snippet/example_file'
8
- autoload :ExampleTemplate, 'chef_gen/snippet/example_template'
9
- autoload :Recipes, 'chef_gen/snippet/recipes'
10
- autoload :ResourceProvider, 'chef_gen/snippet/resource_provider'
11
- autoload :StandardIgnore, 'chef_gen/snippet/standard_ignore'
12
- autoload :StyleRubocop, 'chef_gen/snippet/style_rubocop'
13
- autoload :StyleTailor, 'chef_gen/snippet/style_tailor'
14
- autoload :StyleFoodcritic, 'chef_gen/snippet/style_foodcritic'
15
- autoload :TestKitchen, 'chef_gen/snippet/test_kitchen'
16
- autoload :GitInit, 'chef_gen/snippet/git_init'
17
- end
18
- end
@@ -1,8 +0,0 @@
1
- #
2
- # Cookbook <%= cookbook_name %>
3
- # Copyright (c) <%= year %> <%= copyright_holder %>
4
- #
5
-
6
- # replace these with something real
7
- default['<%= cookbook_name %>']['attribute_1'] = 'foo'
8
- default['<%= cookbook_name %>']['attribute_2'] = 'bar'