kitchen-cabinet 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: babfe7dd1b78e4ff80e697ad246bba4d055f3d13
4
- data.tar.gz: b0d16169272b58d5ef7801a9eb165d8c11dd5153
3
+ metadata.gz: 5f84400a4f194f5eae711a028481ab6be4a64db0
4
+ data.tar.gz: 637199f3aed3bae2cfd0759079559377ba7544ee
5
5
  SHA512:
6
- metadata.gz: a88ae74c7de007219983a798f24beef4a1ea35097a09bd1a902c17f6b1193cb01a9d41a079c2911c8d982349e200e84e26ebaad9344bfae0dd09eca02c820327
7
- data.tar.gz: 2fa52eedfe8c53e5c46cd83f0042d673b79bbf7d2a23df0f1b708bd02380dec418a2cf872d4ce857e3cac6244a8053f0d95357081d79a43faefcc32819517fda
6
+ metadata.gz: 03f94ce6903470b8b3f9134bb49bec4c6b621140c049d3775fc5df260a35ec634cb0a5eed220b9782cad6a9d58881d2f9f9e18be8a05403ea1296c1df268ef53
7
+ data.tar.gz: b88c607411b138ea233a0004f64a59ae439bf37d96d803e12169817e7636f025dbde68de0dc01600373f64d36107934ed1e94f5471e70a78130a4ed5bb9774e7
@@ -1,9 +1,10 @@
1
1
  AllCops:
2
- Excludes:
2
+ Exclude:
3
3
  - test/**
4
4
  - vendor/**
5
5
  - ruby/**
6
6
  - pkg/**
7
+ - kitchen-cabinet.gemspec
7
8
 
8
9
  AlignParameters:
9
10
  Enabled: false
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - 2.1.0
6
+ - 2.1.1
6
7
  bundler_args: --without integration development
7
8
  script:
8
9
  - bundle exec rubocop
@@ -1,3 +1,8 @@
1
+ ## v3.0.0
2
+ * kitchen cabinet now shells out for knife, so its compatible with omnibus chef and chefdk
3
+ * instead of always specifying dependencies in a gemfile, kitchen-cabinet will now install things like chefspec directly in the embedded ruby of chefdk or omnibus chef (this prevents having to install the gem version of chef on top of your existing setup)
4
+ * Less runtime dependencies! There's no need to rely on test-kitchen or berkshelf when I'm just going to replace the generic generated templates with generic generated templates of my own!
5
+
1
6
  ## v2.1.1
2
7
  * Fixed issue where git would create the contents of .git/ in the main cookbook folder.
3
8
  * Modified Berksfile so that site: opscode is commented out. This should make issues with new cookbook versions accidentally being inserted into your chef server much less common.
data/Gemfile CHANGED
@@ -1,33 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'berkshelf', '~> 2.0', '>= 2.0.14'
4
- gem 'chef', '~> 11.8', '>= 11.8.0'
5
-
6
3
  group :unit do
7
4
  gem 'foodcritic', '~> 3', '>= 3.0.0'
8
- gem 'rubocop', '~> 0.18', '>= 0.18.0'
9
- gem 'chefspec', '~> 3.2', '>= 3.2.0'
10
- end
11
-
12
- group :integration do
13
- gem 'test-kitchen', '~> 1.1', '>= 1.1.0'
14
- gem 'kitchen-vagrant', '~> 0', '>= 0.14.0'
15
- end
16
-
17
- group :release do
18
- gem 'stove', '~> 1.1', '>= 1.1.0'
19
- gem 'rspec_junit_formatter'
20
- gem 'rubocop-checkstyle_formatter'
5
+ gem 'rubocop', '~> 0.21', '>= 0.21.0'
6
+ gem 'rspec', '~> 2.14', '>= 2.14.1'
21
7
  end
22
8
 
23
9
  group :development do
24
10
  gem 'rake', '~> 10.1', '>= 10.1.0'
25
- gem 'serverspec', '~> 0.14', '>= 0.14.2'
26
- gem 'guard', '~> 1.8', '>= 1.8.3'
27
11
  gem 'guard-rubocop', '~> 0.2', '>= 0.2.2'
28
- gem 'guard-foodcritic', '~> 1.0', '>= 1.0.0'
29
- gem 'guard-kitchen', '~> 0.0', '>= 0.0.0'
30
- gem 'guard-rspec', '~> 3.1', '>= 3.1.0'
31
12
  gem 'rb-fsevent', :require => false
32
13
  gem 'rb-inotify', :require => false
33
14
  gem 'terminal-notifier-guard', :require => false
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'rubygems/command.rb'
3
+ require 'rubygems/dependency_installer.rb'
4
+
5
+ Gem::Command.build_args = ARGV
6
+
7
+ inst = Gem::DependencyInstaller.new
8
+ if File.exist?('/opt/chefdk')
9
+ %w(chefspec serverspec guard guard-rubocop guard-foodcritic guard-kitchen guard-rspec rspec).each do |gems|
10
+ `chef gem install #{gems}`
11
+ end
12
+
13
+ elsif File.exist?('/opt/chef')
14
+ puts 'Consider switching to chefdk or the gem version of chef.'
15
+ puts 'Some functionality of kitchen-cabinet may not be unavailable with your current setup.'
16
+ %w(foodcritic rubocop test-kitchen kitchen-vagrant chefspec serverspec guard guard-rubocop guard-foodcritic guard-kitchen guard-rspec rspec).each do |gems|
17
+ `sudo /opt/chef/embedded/bin/gem install #{gems} --no-ri --no-rdoc`
18
+ end
19
+ else
20
+ inst.install 'chef', '~> 11.12.2'
21
+ inst.install 'chefspec', '~> 0.0.0'
22
+ end
23
+
24
+ # create dummy rakefile to indicate success
25
+ f = File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w')
26
+ f.write("task :default\n")
27
+ f.close
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'kitchen-cabinet'
3
- s.version = '2.1.1'
3
+ s.version = '3.0.0'
4
4
  s.date = Time.now.strftime('%Y-%m-%d')
5
5
  s.homepage = 'https://github.com/onehealth/kitchen-cabinet'
6
6
  s.summary = 'Initializes a chef cookbook repo with relevant tools'
@@ -16,12 +16,10 @@ EOF
16
16
  s.required_ruby_version = '>= 1.9.3'
17
17
  s.require_paths = ['lib']
18
18
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
- s.files = `git ls-files`.split($/)
19
+ s.files = `git ls-files`.split($RS)
20
20
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ s.extensions = 'ext/mkrf_conf.rb'
21
22
 
22
- s.add_runtime_dependency 'test-kitchen', '~> 1.1', '>= 1.1.1'
23
- s.add_runtime_dependency 'bundler', '~> 1.5', '>= 1.5.1'
24
- s.add_runtime_dependency 'berkshelf', '~> 2.0', '>= 2.0.12'
25
23
  s.add_runtime_dependency 'git', '~> 1.2', '>= 1.2.6'
26
24
  s.add_runtime_dependency 'erubis', '~> 2.7', '>= 2.7.0'
27
25
  s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
@@ -7,105 +7,59 @@ class Cabinet
7
7
  require 'erubis'
8
8
  def self.init(cookbook_name, options, cookbook_path)
9
9
  init_chef(cookbook_name, options, cookbook_path)
10
- init_git(cookbook_name, options, cookbook_path)
11
- init_berkshelf(cookbook_name, options, cookbook_path)
12
- init_kitchen(cookbook_name, cookbook_path)
10
+ init_git(cookbook_path)
13
11
  init_spec(cookbook_name, cookbook_path)
14
- write_configs(cookbook_name, options, cookbook_path)
12
+ write_configs(cookbook_name, cookbook_path)
15
13
  puts "Cookbook #{cookbook_name} created successfully"
16
14
  puts 'Next steps...'
17
- puts " $ cd #{cookbook_path}"
15
+ puts ' $ cd ' + cookbook_path + '/' + cookbook_name
18
16
  puts ' $ bundle install'
19
17
  puts ' $ bundle exec berks install'
20
18
  end
21
19
 
22
- def self.chef_check
23
- if File.exist?('/opt/chef')
24
- ENV['GEM_HOME'] = '/opt/chef/embedded/lib/ruby/gems/1.9.1'
25
- elsif File.exist?('C:\opscode\chef\\')
26
- ENV['GEM_HOME'] = 'C:\opscode\chef\embedded\lib\ruby\gems\1.9.1'
27
- elsif Gem::Specification.find_by_name('chef')
28
- ENV['GEM_HOME']
29
- else
30
- puts 'You don\'t appear to have chef installed.'
31
- puts 'Please install the gem or omnibus version - `gem install chef` or http://www.getchef.com/chef/install/'
32
- exit
33
- end
34
- end
35
-
36
- def self.chef_rewrite(cookbook_path)
20
+ def self.chef_rewrite(cookbook_path, cookbook_name)
37
21
  %w(metadata.rb recipes/default.rb).each do |file|
38
22
  puts "\tRewriting #{file}"
39
- contents = "\# Encoding: utf-8\n#{File.read(File.join(cookbook_path, file))}"
40
- File.open(File.join(cookbook_path, file), 'w') { |f| f.write(contents) }
23
+ contents = "\# Encoding: utf-8\n#{File.read(File.join(cookbook_path, cookbook_name, file))}"
24
+ File.open(File.join(cookbook_path, cookbook_name, file), 'w') { |f| f.write(contents) }
41
25
  end
42
- metadata_replace = File.read(File.join(cookbook_path, 'metadata.rb'))
26
+ metadata_replace = File.read(File.join(cookbook_path, cookbook_name, 'metadata.rb'))
43
27
  replace = metadata_replace.gsub(/version '0.1.0'/, "version IO.read(File.join(File.dirname(__FILE__), 'VERSION')) rescue \"0.1.0\"")
44
- File.open(File.join(cookbook_path, 'metadata.rb'), 'w') { |file| file.puts replace }
28
+ File.open(File.join(cookbook_path, cookbook_name, 'metadata.rb'), 'w') { |file| file.puts replace }
45
29
  end
46
30
 
47
31
  def self.init_chef(cookbook_name, options, cookbook_path)
48
- tool = 'chef'
49
- puts "* Initializing #{tool}"
50
- chef_check
51
- puts "Using #{tool} from " + ENV['GEM_HOME']
52
- require 'chef/knife/cookbook_create'
53
- create_cookbook = Chef::Knife::CookbookCreate.new
54
- create_cookbook.name_args = [cookbook_name]
55
- create_cookbook.config[:cookbook_path] = options[:path]
32
+ puts '* Initializing chef'
33
+ cookbook_path = options[:path]
56
34
  if File.exist?(File.join(ENV['HOME'], '.chef', 'knife.rb'))
57
- require 'chef'
58
- Chef::Config.from_file(File.join(ENV['HOME'], '.chef', 'knife.rb'))
35
+ `knife cookbook create #{cookbook_name} -o #{cookbook_path} -r md`
36
+ else
37
+ copyright = options[:copyright] || 'Copyright_Holder'
38
+ license = options[:license] || 'License_Type'
39
+ email = options[:email] || 'Email'
40
+ `knife cookbook create #{cookbook_name} -C #{copyright} -I #{license} -m #{email} -o #{cookbook_path} -r md`
59
41
  end
60
- create_cookbook.config[:cookbook_copyright] = options[:copyright] || Chef::Config[:cookbook_copyright]
61
- create_cookbook.config[:cookbook_license] = options[:license] || Chef::Config[:cookbook_license]
62
- create_cookbook.config[:cookbook_email] = options[:email] || Chef::Config[:cookbook_email]
63
- create_cookbook.run
64
- chef_rewrite(cookbook_path)
42
+ chef_rewrite(cookbook_path, cookbook_name)
65
43
  end
66
44
 
67
- def self.init_git(cookbook_name, options, cookbook_path)
68
- tool = 'git'
69
- puts "* Initializing #{tool}"
45
+ def self.init_git(cookbook_path)
46
+ puts '* Initializing git'
70
47
  require 'git'
71
48
  Git.init(cookbook_path, git_dir: "#{cookbook_path}/.git")
72
49
  end
73
50
 
74
- def self.init_berkshelf(cookbook_name, options, cookbook_path)
75
- tool = 'berkshelf'
76
- puts "* Initializing #{tool}"
77
- require 'berkshelf'
78
- require 'berkshelf/base_generator'
79
- require 'berkshelf/init_generator'
80
- Berkshelf::InitGenerator.new(
81
- [cookbook_path],
82
- skip_test_kitchen: true,
83
- skip_vagrant: true
84
- ).invoke_all
85
- end
86
-
87
- def self.init_kitchen(cookbook_name, cookbook_path)
88
- tool = 'kitchen'
89
- puts "* Initializing #{tool}"
90
- require 'kitchen'
91
- require 'kitchen/generator/init'
92
- Kitchen::Generator::Init.new([], {}, destination_root: cookbook_path).invoke_all
93
- end
94
-
95
51
  def self.init_spec(cookbook_name, cookbook_path)
96
52
  require 'kitchen-cabinet/spec'
97
- @tool = %w(chefspec serverspec)
98
- @tool.each do |tool|
53
+ %w(chefspec serverspec).each do |tool|
99
54
  Spec.install_specs(tool, cookbook_path, cookbook_name)
100
55
  end
101
56
  end
102
57
 
103
- def self.write_configs(cookbook_name, options, cookbook_path)
104
- @template = %w(chefignore .gitignore Gemfile Berksfile .kitchen.yml Guardfile Thorfile .rubocop.yml VERSION)
58
+ def self.write_configs(cookbook_name, cookbook_path)
105
59
  puts 'this is the ' + cookbook_name + ' cookbook.'
106
60
  require 'kitchen-cabinet/config'
107
- @template.each do |template|
108
- Initconfig.write_config(cookbook_name, options, cookbook_path, template)
61
+ %w(chefignore .gitignore Gemfile Berksfile .kitchen.yml Guardfile Thorfile .rubocop.yml VERSION).each do |template|
62
+ Initconfig.write_config(cookbook_name, cookbook_path, template)
109
63
  end
110
64
  end
111
65
  end
@@ -1,6 +1,6 @@
1
1
  # Writes configs for cabinet and update.
2
2
  class Initconfig
3
- def self.write_config(cookbook_name, options, cookbook_path, template)
3
+ def self.write_config(cookbook_name, cookbook_path, template)
4
4
  tname = File.read(File.join(File.dirname(File.expand_path(__FILE__)), "templates/#{template}.eruby"))
5
5
  eruby = Erubis::Eruby.new(tname)
6
6
  File.open(File.join(cookbook_path, "#{template}"), 'w') { |f| f.write(eruby.result(:cookbook_name => cookbook_name)) }
@@ -4,14 +4,13 @@
4
4
  # Removes duplication of code between chefspec and serverspec installs.
5
5
  class Spec
6
6
  def self.install_specs(tool, cookbook_path, cookbook_name)
7
- @spec = %w(spec_helper.rb default_spec.rb)
8
7
  if tool == 'chefspec'
9
8
  spec_path = File.join(cookbook_path, 'spec')
10
9
  elsif tool == 'serverspec'
11
10
  spec_path = File.join(cookbook_path, 'test', 'integration', 'default', 'serverspec')
12
11
  end
13
12
  puts "* Initializing #{tool}"
14
- @spec.each do |spec|
13
+ %w(spec_helper.rb default_spec.rb).each do |spec|
15
14
  FileUtils.mkdir_p(spec_path)
16
15
  tname = File.read(File.join(File.dirname(File.expand_path(__FILE__)), "templates/#{tool}/#{spec}.eruby"))
17
16
  eruby = Erubis::Eruby.new(tname)
@@ -1,27 +1,16 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ <% unless File.exist?('/opt/chefdk') -%>
3
4
  gem 'berkshelf', '~> 2.0', '>= 2.0.14'
4
5
 
5
6
  group :unit do
6
7
  gem 'foodcritic', '~> 3', '>= 3.0.0'
7
8
  gem 'rubocop', '~> 0.18', '>= 0.18.0'
8
9
  gem 'chefspec', '~> 3.2', '>= 3.2.0'
9
- end
10
-
11
- group :integration do
12
- gem 'test-kitchen', '~> 1.1', '>= 1.1.0'
13
- gem 'kitchen-vagrant', '~> 0', '>= 0.14.0'
14
- end
15
-
16
- group :release do
17
- gem 'rspec_junit_formatter'
18
- gem 'rubocop-checkstyle_formatter'
19
- gem 'thor-scmversion', '~> 1.4', '>= 1.4.0'
20
- gem 'git', '~> 1.2', '>= 1.2.6'
10
+ gem 'serverspec', '~> 0.14', '>= 0.14.2'
21
11
  end
22
12
 
23
13
  group :development do
24
- gem 'serverspec', '~> 0.14', '>= 0.14.2'
25
14
  gem 'guard', '~> 1.8', '>= 1.8.3'
26
15
  gem 'guard-rubocop', '~> 0.2', '>= 0.2.2'
27
16
  gem 'guard-foodcritic', '~> 1.0', '>= 1.0.0'
@@ -31,3 +20,15 @@ group :development do
31
20
  gem 'rb-inotify', :require => false
32
21
  gem 'terminal-notifier-guard', :require => false
33
22
  end
23
+
24
+ group :integration do
25
+ gem 'test-kitchen', '~> 1.2', '>= 1.2.1'
26
+ gem 'kitchen-vagrant', '~> 0.15', '>= 0.15.0'
27
+ end
28
+ <% end -%>
29
+ group :release do
30
+ gem 'rspec_junit_formatter'
31
+ gem 'rubocop-checkstyle_formatter'
32
+ gem 'thor-scmversion', '~> 1.4', '>= 1.4.0'
33
+ gem 'git', '~> 1.2', '>= 1.2.6'
34
+ end
@@ -3,12 +3,11 @@
3
3
 
4
4
  # The Update class helps you maintain the versions and config of your cookbook creation tools
5
5
  class Update
6
- def self.update_cookbook(cookbook_name, options, cookbook_path)
7
- @template = %w(chefignore Gemfile Guardfile Thorfile .rubocop.yml)
6
+ def self.update_cookbook(cookbook_name, cookbook_path)
8
7
  require 'kitchen-cabinet/config'
9
8
  puts "Updating #{cookbook_name}..."
10
- @template.each do |template|
11
- Initconfig.write_config(cookbook_name, options, cookbook_path, template)
9
+ %w(chefignore Gemfile Guardfile Thorfile .rubocop.yml).each do |template|
10
+ Initconfig.write_config(cookbook_name, cookbook_path, template)
12
11
  puts "#{template} is up to date!"
13
12
  end
14
13
  end
metadata CHANGED
@@ -1,75 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-cabinet
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Price
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-14 00:00:00.000000000 Z
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: test-kitchen
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.1'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 1.1.1
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.1'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 1.1.1
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.5'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.5.1
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.5'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 1.5.1
53
- - !ruby/object:Gem::Dependency
54
- name: berkshelf
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '2.0'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 2.0.12
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '2.0'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 2.0.12
73
13
  - !ruby/object:Gem::Dependency
74
14
  name: git
75
15
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +77,8 @@ description: |+
137
77
  email: tprice@onehealth.com
138
78
  executables:
139
79
  - cabinet
140
- extensions: []
80
+ extensions:
81
+ - ext/mkrf_conf.rb
141
82
  extra_rdoc_files: []
142
83
  files:
143
84
  - ".gitignore"
@@ -151,6 +92,7 @@ files:
151
92
  - README.md
152
93
  - Rakefile
153
94
  - bin/cabinet
95
+ - ext/mkrf_conf.rb
154
96
  - kitchen-cabinet.gemspec
155
97
  - lib/kitchen-cabinet/cabinet.rb
156
98
  - lib/kitchen-cabinet/config.rb