jackchop 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Berksfile.lock ADDED
@@ -0,0 +1 @@
1
+ cookbook 'test_cookbook', :path => '/Users/rteabeault/projects/jackchop/test_cookbook'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jackchop.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Rally Dev Pair
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Jackchop
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jackchop.png)](http://badge.fury.io/rb/jackchop)
4
+
5
+ ![Jackchop](/img/jackchop.jpg "Jackchop")
6
+
7
+ With jackchop you can have your cookbooks carved in minutes.
8
+
9
+ Jackchop is Rally's wrapper around berkshelf and other chef related tools. Its intention is to ensure that
10
+ we are creating and testing our cookbooks in a consistent manner.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'jackchop'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install jackchop
25
+
26
+ ## Usage
27
+
28
+ TODO: Write usage instructions here
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/version_task'
3
+
4
+ Rake::VersionTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/jackchop ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path("../../lib", __FILE__)
3
+ require 'jackchop'
4
+
5
+ Jackchop::Cli.start
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rake", "~> 10.0.4"
4
+ gem "strainer", "~>2.0.0"
5
+ gem "foodcritic", "~> 2.1.0"
6
+ gem "chef", "~> 11.4.0"
7
+ gem "berkshelf", "~> 1.4.3"
8
+ gem "chefspec", "~> 1.0.0"
9
+ gem "jackchop", :git => "https://github.com/RallySoftware-cookbooks/jackchop"
10
+
11
+ # Workaround for json dependency for chef and berkshelf. Chef
12
+ # wants <= 1.7.7 and berkshelf >= 1.5 but bundler tries to grab 1.8.0
13
+ # which violates chef's requirement. Seems like a bundler bug.
14
+ gem "json", "1.7.7"
15
+
16
+
17
+ gem "kitchen-vagrant", :group => :integration
18
+ gem "minitest-chef-handler", :group => :integration
@@ -0,0 +1,4 @@
1
+ require 'rake'
2
+ require 'jackchop/rake_tasks'
3
+
4
+ task :default => 'test'
@@ -0,0 +1,3 @@
1
+ knife test: bundle exec knife cookbook test $COOKBOOK
2
+ foodcritic: bundle exec foodcritic --epic-fail any $SANDBOX/$COOKBOOK
3
+ chefspec: bundle exec rspec $SANDBOX/$COOKBOOK
@@ -0,0 +1,18 @@
1
+ ---
2
+ driver_plugin: vagrant
3
+ platforms:
4
+ - name: centos
5
+ driver_config:
6
+ box: <%= options[:berkshelf_config].vagrant.vm.box %>
7
+ box_url: <%= options[:berkshelf_config].vagrant.vm.box_url %>
8
+ require_chef_omnibus: 11.4.4
9
+ customize:
10
+ cpus: 1
11
+ memory: 256
12
+ network:
13
+ - ["private_network", { ip: "10.0.2.15" }]
14
+ suites:
15
+ - name: default
16
+ run_list:
17
+ - recipe[<%= cookbook_name %>]
18
+ - recipe[minitest-handler]
@@ -0,0 +1,8 @@
1
+ gemfile:
2
+ - Gemfile
3
+ language: ruby
4
+ rvm:
5
+ - 1.9.3
6
+ bundler_args: --without integration
7
+ before_script: bundle exec berks install
8
+ script: bundle exec rake strainer
data/img/jackchop.jpg ADDED
Binary file
data/jackchop.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jackchop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jackchop"
8
+ spec.version = Jackchop::VERSION
9
+ spec.authors = ["Russell Teabeault", "Eli Klein"]
10
+ spec.email = ["rteabeault@rallydev.com", "eklein@rallydev.com"]
11
+ spec.description = %q{Rally's gem for cookbook development}
12
+ spec.summary = %q{Used to create new cookbooks with the desired testing frameworks and tasks.}
13
+ spec.homepage = "http://github.com/RallySoftware-cookbooks/jackchop"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency("version", "~> 1.0.0")
25
+
26
+ spec.add_dependency "berkshelf", "~> 1.4.3"
27
+ spec.add_dependency "chef", "~> 11.4.4"
28
+ spec.add_dependency "chefspec", "~> 1.0.0"
29
+ spec.add_dependency "thor", "~> 0.18.1"
30
+ spec.add_dependency "ridley", "~> 0.11.1"
31
+
32
+ # Workaround for json dependency for chef and berkshelf. Chef
33
+ # wants <= 1.7.7 and berkshelf >= 1.5 but bundler tries to grab 1.8.0
34
+ # which violates chef's requirement. Seems like a bundler bug.
35
+ spec.add_dependency "json", "~> 1.7.7"
36
+ end
@@ -0,0 +1,24 @@
1
+ module Jackchop
2
+ class Cookbook < Thor
3
+ desc "init [PATH]", "Initialize an existing cookbook"
4
+ def init(path = Dir.pwd)
5
+ Berkshelf::InitGenerator.new([path], default_berkshelf_options.merge(options)).invoke_all
6
+ Jackchop::InitGenerator.new([path], options).invoke_all
7
+ end
8
+
9
+ desc "create [NAME]", "Creates a new cookbook"
10
+ def create(name)
11
+
12
+ Berkshelf::CookbookGenerator.new([File.join(Dir.pwd, name), name], default_berkshelf_options.merge(options)).invoke_all
13
+ Jackchop::InitGenerator.new([File.join(Dir.pwd, name)], options).invoke_all
14
+ end
15
+
16
+ def default_berkshelf_options
17
+ { :chef_minitest => true }
18
+ end
19
+
20
+ def self.banner(task, namespace = false, subcommand = true)
21
+ "#{basename} #{task.formatted_usage(self, namespace, subcommand).split(':').join(' ')}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'thor'
2
+ require 'jackchop/cli/cookbook'
3
+
4
+ module Jackchop
5
+ class Cli < Thor
6
+ desc "cookbook", "Cookbook related tasks"
7
+ subcommand 'cookbook', Cookbook
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ module Jackchop
2
+ class BaseGenerator < Thor::Group
3
+ include Thor::Actions
4
+
5
+ argument :path,
6
+ type: :string,
7
+ required: true
8
+
9
+ def self.source_root
10
+ Jackchop.root.join("generator_files")
11
+ end
12
+
13
+ private
14
+
15
+ def target
16
+ @target ||= Pathname.new(File.expand_path(path))
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,36 @@
1
+ require 'chef/knife'
2
+ require 'chef/knife/cookbook_create_specs'
3
+
4
+ module Jackchop
5
+ class InitGenerator < BaseGenerator
6
+
7
+ class_option :berkshelf_config,
8
+ type: :hash,
9
+ default: Berkshelf::Config.instance
10
+
11
+ def generate
12
+ template "kitchen.yml.erb", target.join('.kitchen.yml')
13
+ template "travis.yml.erb", target.join('.travis.yml')
14
+ template "Rakefile.erb", target.join("Rakefile")
15
+ template "Strainerfile.erb", target.join("Strainerfile")
16
+ template "Gemfile.erb", target.join("Gemfile"), :force => true
17
+
18
+ chef_spec = ChefSpec::Knife::CookbookCreateSpecs.new
19
+ chef_spec.config[:cookbook_path] = File.dirname(target)
20
+ chef_spec.name_args[0] = File.basename(target)
21
+ chef_spec.run
22
+ end
23
+
24
+ private
25
+
26
+ def cookbook_name
27
+ @cookbook_name ||= begin
28
+ metadata = Ridley::Chef::Cookbook::Metadata.from_file(target.join("metadata.rb").to_s)
29
+ metadata.name.empty? ? File.basename(target) : metadata.name
30
+ rescue IOError
31
+ File.basename(target)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,27 @@
1
+ desc "All tests using Strainer and Test Kitchen"
2
+ task :test do
3
+ Rake::Task['strainer'].invoke
4
+ Rake::Task['kitchen'].invoke
5
+ end
6
+
7
+ desc "Test cookbook using strainer"
8
+ task :strainer do
9
+ puts "--> Running Strainer..."
10
+ sh "bundle exec strainer test"
11
+ end
12
+
13
+ desc "Run integration tests using Test Kitchen"
14
+ task :kitchen do
15
+ if File.exists?(File.join(Dir.pwd, '.kitchen.yml'))
16
+ begin
17
+ require 'kitchen/rake_tasks'
18
+ Kitchen::RakeTasks.new
19
+
20
+ puts "--> Running Test Kitchen..."
21
+ Rake::Task["kitchen:all"].invoke
22
+ rescue LoadError
23
+ puts "Kitchen yml file found but unable to load test-kitchen"
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1,3 @@
1
+ module Jackchop
2
+ VERSION = File.open(File.expand_path('../../../VERSION', __FILE__)).read
3
+ end
data/lib/jackchop.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'thor'
2
+ require 'ridley'
3
+ require 'berkshelf'
4
+ require 'jackchop/generators/base_generator'
5
+ require 'jackchop/generators/init_generator'
6
+ require 'jackchop/cli'
7
+
8
+ module Jackchop
9
+ def self.root
10
+ @root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,221 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jackchop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Russell Teabeault
9
+ - Eli Klein
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-05-14 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.3'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.3'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: version
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0
63
+ - !ruby/object:Gem::Dependency
64
+ name: berkshelf
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 1.4.3
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.4.3
79
+ - !ruby/object:Gem::Dependency
80
+ name: chef
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 11.4.4
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 11.4.4
95
+ - !ruby/object:Gem::Dependency
96
+ name: chefspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: 1.0.0
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 1.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: thor
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: 0.18.1
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ version: 0.18.1
127
+ - !ruby/object:Gem::Dependency
128
+ name: ridley
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ~>
133
+ - !ruby/object:Gem::Version
134
+ version: 0.11.1
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ~>
141
+ - !ruby/object:Gem::Version
142
+ version: 0.11.1
143
+ - !ruby/object:Gem::Dependency
144
+ name: json
145
+ requirement: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ~>
149
+ - !ruby/object:Gem::Version
150
+ version: 1.7.7
151
+ type: :runtime
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ~>
157
+ - !ruby/object:Gem::Version
158
+ version: 1.7.7
159
+ description: Rally's gem for cookbook development
160
+ email:
161
+ - rteabeault@rallydev.com
162
+ - eklein@rallydev.com
163
+ executables:
164
+ - jackchop
165
+ extensions: []
166
+ extra_rdoc_files: []
167
+ files:
168
+ - .gitignore
169
+ - Berksfile.lock
170
+ - Gemfile
171
+ - LICENSE.txt
172
+ - README.md
173
+ - Rakefile
174
+ - VERSION
175
+ - bin/jackchop
176
+ - generator_files/Gemfile.erb
177
+ - generator_files/Rakefile.erb
178
+ - generator_files/Strainerfile.erb
179
+ - generator_files/kitchen.yml.erb
180
+ - generator_files/travis.yml.erb
181
+ - img/jackchop.jpg
182
+ - jackchop.gemspec
183
+ - lib/jackchop.rb
184
+ - lib/jackchop/cli.rb
185
+ - lib/jackchop/cli/cookbook.rb
186
+ - lib/jackchop/generators/base_generator.rb
187
+ - lib/jackchop/generators/init_generator.rb
188
+ - lib/jackchop/rake_tasks.rb
189
+ - lib/jackchop/version.rb
190
+ homepage: http://github.com/RallySoftware-cookbooks/jackchop
191
+ licenses:
192
+ - MIT
193
+ post_install_message:
194
+ rdoc_options: []
195
+ require_paths:
196
+ - lib
197
+ required_ruby_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ segments:
204
+ - 0
205
+ hash: 2674304610272158957
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ none: false
208
+ requirements:
209
+ - - ! '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ segments:
213
+ - 0
214
+ hash: 2674304610272158957
215
+ requirements: []
216
+ rubyforge_project:
217
+ rubygems_version: 1.8.25
218
+ signing_key:
219
+ specification_version: 3
220
+ summary: Used to create new cookbooks with the desired testing frameworks and tasks.
221
+ test_files: []