bourdain 1.3.2 → 1.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7eaf6efe6460156dd99798d547efc2b74c6c975
4
- data.tar.gz: c3b098365fd5ad4110ebdc02b6d0a47d8e7aab11
3
+ metadata.gz: 117b60c641b6c056e3e29697f9e12656f237a3de
4
+ data.tar.gz: 9dab833b7832fce0c41a462006794697547bbc22
5
5
  SHA512:
6
- metadata.gz: 6d411e186adaaf6ae87727c10166962e797c6c17078c62b0d356bf9e9dcc8a76c64d98039cedfcf3ea6e86f06311387f80adacdc16e8e4ae230102e638288662
7
- data.tar.gz: c067373d916944faeb80987ca96e940cd8f50eed70e61f6c69a6830dc927c2f66b8d9f2d4573a13a58cb1742550884c63761990428b93b11bf4aa1f51b029f8d
6
+ metadata.gz: c0fcff7bf0d08bee9bee2ada6bf3002a4df2a7449fba5b6744dad6567f28abf0e782becae7e46bebba5d39d34f50e0eacec055ab48a6d055de9bb0a5f0022e32
7
+ data.tar.gz: e16eb27cb9d80efe02a63620e87d2ae2164e2fdedd1ef494e41bd511e553da3aa2fb0c4105cd0b4c6395df3a911f2ef9196c779aabfcd21815c1e423d2b23407
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2
1
+ 1.3.3
@@ -14,7 +14,7 @@ def apply_template file, opts
14
14
  template_name, locals = opts[:template], opts[:locals]
15
15
  locals = Bourdain::Helpers::Locals.new(locals).bind unless locals.nil?
16
16
  template_path = gem_path('templates', *template_name)
17
- template = ERB.new File.read(template_path)
17
+ template = ERB.new File.read(template_path), nil, '-'
18
18
  contents = template.result(locals).strip
19
19
  File.open(file, 'w') { |f| f.write contents }
20
20
  end
@@ -14,6 +14,7 @@ module Bourdain
14
14
  --recipe :: Generate a default recipe (default: true)
15
15
  --berksfile :: Generate a Berksfile (default: true)
16
16
  --gitignore (-i) :: Generate a .gitignore (default: true)
17
+ --rakefile (-r) :: Generate a Rakefile (default: true)
17
18
  --metadata :: Generate cookbook metadata (default: true)
18
19
  --readme (-m) :: Generate a Readme (default: true)
19
20
  --kitchenfile :: Generate a Test Kitchen file (default: true)
@@ -37,6 +38,12 @@ module Bourdain
37
38
  return
38
39
  end
39
40
 
41
+ type = case path
42
+ when /apps/ then :app
43
+ when /realms/ then :realm
44
+ when /bases/ then :base
45
+ when /forks/ then :fork
46
+ end
40
47
  name = File.basename(normalized(path))
41
48
 
42
49
  FileUtils.mkdir_p path
@@ -69,7 +76,12 @@ module Bourdain
69
76
 
70
77
  if opts[:gitignore]
71
78
  apply_template File.join(path, '.gitignore'), \
72
- template: %w[ cookbook gitignore ]
79
+ template: %w[ cookbook gitignore ], locals: { type: type }
80
+ end
81
+
82
+ if opts[:rakefile]
83
+ apply_template File.join(path, 'Rakefile'), \
84
+ template: %w[ cookbook Rakefile ]
73
85
  end
74
86
 
75
87
  if opts[:metadata]
@@ -83,10 +95,10 @@ module Bourdain
83
95
  end
84
96
 
85
97
  if opts[:kitchenfile]
86
- minitest_path = File.join(path, 'test', 'integration', 'default', 'minitest')
98
+ minitest_path = File.join(path, 'files', 'default', 'test')
87
99
  FileUtils.mkdir_p minitest_path
88
- apply_template File.join(minitest_path, 'test_default.rb'), \
89
- template: %w[ cookbook busser_minitest.rb ], locals: {
100
+ apply_template File.join(minitest_path, 'default_test.rb'), \
101
+ template: %w[ cookbook minitest.rb ], locals: {
90
102
  cookbook_name: name, recipe_name: 'default'
91
103
  }
92
104
  apply_template File.join(path, '.kitchen.yml'), \
@@ -37,7 +37,7 @@ module Bourdain
37
37
  }
38
38
 
39
39
  if opts[:minitest]
40
- minitest_path = File.join('test', 'integration', 'default', 'minitest', "test_#{name}.rb")
40
+ minitest_path = File.join('files', 'default', 'test', "#{name}_test.rb")
41
41
  FileUtils.mkdir_p File.dirname(minitest_path)
42
42
  apply_template minitest_path, \
43
43
  template: %w[ cookbook busser_minitest.rb ], locals: {
@@ -1,3 +1,4 @@
1
1
  source 'https://api.berkshelf.com'
2
2
  metadata
3
- cookbook 'apt'
3
+ cookbook 'apt'
4
+ cookbook 'minitest-handler'
@@ -0,0 +1,164 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rake'
4
+
5
+
6
+ def master?
7
+ `git rev-parse --abbrev-ref HEAD`.strip == 'master'
8
+ end
9
+
10
+
11
+ def test_kitchen?
12
+ File.exist? '.kitchen.yml'
13
+ end
14
+
15
+
16
+ def realm?
17
+ `git ls-files` =~ /\bBerksfile\.lock\b/
18
+ end
19
+
20
+
21
+ def current_version
22
+ File.read('VERSION').strip
23
+ end
24
+
25
+
26
+ def youre_dirty?
27
+ dirty = `git diff HEAD --numstat`.split("\n").length > 0
28
+ raise unless $?.exitstatus.zero?
29
+ dirty
30
+ end
31
+
32
+
33
+ def youre_dirty!
34
+ if youre_dirty?
35
+ raise "You you have uncommitted changes! Commit or stash before continuing."
36
+ end
37
+ end
38
+
39
+
40
+ def youre_behind?
41
+ `git fetch >/dev/null 2>&1`
42
+ `git pull --tags >/dev/null 2>&1`
43
+ behind = `git log ..origin/master --oneline`.split("\n").length > 0
44
+ raise unless $?.exitstatus.zero?
45
+ return behind
46
+ end
47
+
48
+
49
+ def youre_behind!
50
+ if youre_behind?
51
+ raise "You're out of sync with the remote! Try 'git pull --rebase'"
52
+ end
53
+ end
54
+
55
+
56
+ def bump component
57
+ youre_dirty!
58
+ youre_behind!
59
+ `tony bump #{component}`
60
+ if realm?
61
+ `berks`
62
+ `git add Berksfile.lock`
63
+ end
64
+ version = current_version
65
+ `git add VERSION`
66
+ `git commit -m "Version bump to #{version}"`
67
+ `git tag -a v#{version} -m v#{version}`
68
+ raise 'Could not add tag' unless $?.exitstatus.zero?
69
+ puts 'Version is now "%s"' % version
70
+ end
71
+
72
+
73
+ def bump_and_release component
74
+ lint
75
+ bump component
76
+ youre_dirty!
77
+ youre_behind!
78
+ `git push`
79
+ raise 'Push failed' unless $?.exitstatus.zero?
80
+ `git push --tag`
81
+ raise 'Tag push failed' unless $?.exitstatus.zero?
82
+ end
83
+
84
+
85
+ def repo_root_dir
86
+ `git rev-parse --show-toplevel`.strip
87
+ end
88
+
89
+
90
+ def lint
91
+ system "knife cookbook test #{File.basename repo_root_dir} -o .."
92
+ raise 'Failed "knife cookbook test"' unless $?.exitstatus.zero?
93
+ system 'foodcritic .' # Merely a suggestion
94
+
95
+ unless realm?
96
+ if Dir.exist? File.join(repo_root_dir, 'environments')
97
+ raise "Hey, I found environments, but this isn't realm!"
98
+ end
99
+
100
+ if Dir.exist? File.join(repo_root_dir, 'roles')
101
+ raise "Hey, I found roles, but this isn't realm!"
102
+ end
103
+
104
+ if Dir.exist? File.join(repo_root_dir, 'data_bags')
105
+ raise "Hey, I found data bags--this isn't realm!"
106
+ end
107
+ end
108
+ end
109
+
110
+
111
+
112
+
113
+ desc 'Perform syntax check and linting'
114
+ task :lint do
115
+ lint
116
+ end
117
+
118
+
119
+ if test_kitchen?
120
+ desc 'Execute default Test Kitchen test suite'
121
+ task test: :lint do
122
+ system 'kitchen test'
123
+ end
124
+ end
125
+
126
+
127
+ desc 'Print the current version'
128
+ task :version do
129
+ puts current_version
130
+ end
131
+
132
+
133
+ if master?
134
+ namespace :release do
135
+ desc 'Release new major version'
136
+ task :major do
137
+ bump_and_release :major
138
+ end
139
+
140
+ desc 'Release new minor version'
141
+ task :minor do
142
+ bump_and_release :minor
143
+ end
144
+
145
+ task :patch do
146
+ bump_and_release :patch
147
+ end
148
+ end
149
+
150
+ desc 'Release a new patch version'
151
+ task release: %w[ release:patch ]
152
+
153
+
154
+ if realm?
155
+ desc 'Apply Berksfile lock to an environment'
156
+ task :constrain, [ :env ] do |_, args|
157
+ lint
158
+ youre_dirty!
159
+ youre_behind!
160
+ `git tag -a #{args[:env]} -m #{args[:env]} --force`
161
+ `git push --tag --force`
162
+ end
163
+ end
164
+ end
@@ -13,6 +13,7 @@ Vagrant.configure('2') do |config|
13
13
  chef.run_list = %w(
14
14
  recipe[apt]
15
15
  recipe[<%= name %>]
16
+ recipe[minitest-handler]
16
17
  )
17
18
  end
18
19
  end
@@ -1,24 +1,25 @@
1
- <% if name == 'default' %>
2
- # User for <%= cookbook_name %> directories, files, and services
3
- default['<%= cookbook_name %>']['user'] = '<%= cookbook_name %>'
4
-
5
- # Directory to install the <%= cookbook_name %> source
6
- default['<%= cookbook_name %>']['home'] = '/opt/<%= cookbook_name %>'
7
-
8
- # Directory to store the <%= cookbook_name %> logs
9
- default['<%= cookbook_name %>']['logs'] = '/var/log/<%= cookbook_name %>'
10
-
11
- # Directory to store the <%= cookbook_name %> data
12
- default['<%= cookbook_name %>']['data'] = '/var/data/<%= cookbook_name %>'
13
-
14
- # Version of <%= cookbook_name %> to install
15
- default['<%= cookbook_name %>']['version'] = '1.0.0'
16
-
17
- # Full URL (%pattern-sensitive) for <%= cookbook_name %> releases
18
- default['<%= cookbook_name %>']['url'] = \
19
- 'http://example.com/<%= cookbook_name %>%{version}.tar.gz'
20
-
21
- # SHA-256 checksum for the bundled release
22
- default['<%= cookbook_name %>']['checksum'] = \
23
- '...'
24
- <% end %>
1
+ <%- if name == 'default' -%>
2
+ <%- attribute_ns = cookbook_name.gsub(/^(bjn|app|base|fork|realm)_/, '') -%>
3
+ # # User for <%= attribute_ns %> directories, files, and services
4
+ # default['<%= attribute_ns %>']['user'] = '<%= attribute_ns %>'
5
+ #
6
+ # # Directory to install the <%= attribute_ns %> source
7
+ # default['<%= attribute_ns %>']['home'] = '/opt/<%= attribute_ns %>'
8
+ #
9
+ # # Directory to store the <%= attribute_ns %> logs
10
+ # default['<%= attribute_ns %>']['logs'] = '/var/log/<%= attribute_ns %>'
11
+ #
12
+ # # Directory to store the <%= attribute_ns %> data
13
+ # default['<%= attribute_ns %>']['data'] = '/var/data/<%= attribute_ns %>'
14
+ #
15
+ # # Version of <%= attribute_ns %> to install
16
+ # default['<%= attribute_ns %>']['version'] = '1.0.0'
17
+ #
18
+ # # Full URL (%pattern-sensitive) for <%= attribute_ns %> releases
19
+ # default['<%= attribute_ns %>']['url'] = \
20
+ # 'http://example.com/<%= attribute_ns %>%{version}.tar.gz'
21
+ #
22
+ # # SHA-256 checksum for the bundled release
23
+ # default['<%= attribute_ns %>']['checksum'] = \
24
+ # '...'
25
+ <%- end -%>
@@ -1,5 +1,7 @@
1
1
  .vagrant
2
+ <%- unless type == :realm -%>
2
3
  Berksfile.lock
4
+ <%- end -%>
3
5
  *~
4
6
  *#
5
7
  .#*
@@ -1,4 +1,4 @@
1
- require 'minitest/autorun'
1
+ require 'minitest/spec'
2
2
 
3
3
  describe '<%= cookbook_name %>::<%= recipe_name %>' do
4
4
  it 'has done the thing' do
@@ -2,37 +2,37 @@
2
2
  # Cookbook Name:: <%= cookbook_name %>
3
3
  # Recipe:: <%= name %>
4
4
  #
5
- # Copyright (C) <%= Time.now.year %> Blue Jeans Network
6
- #
7
- <% if name == 'default' %>
8
- # group node['<%= cookbook_name %>']['user'] do
5
+ <%- attribute_ns = cookbook_name.gsub(/^(bjn|app|base|fork|realm)_/, '') -%>
6
+
7
+ <%- if name == 'default' -%>
8
+ # group node['<%= attribute_ns %>']['user'] do
9
9
  # system true
10
10
  # end
11
11
 
12
- # user node['<%= cookbook_name %>']['user'] do
13
- # gid node['<%= cookbook_name %>']['user']
12
+ # user node['<%= attribute_ns %>']['user'] do
13
+ # gid node['<%= attribute_ns %>']['user']
14
14
  # shell '/bin/false'
15
15
  # system true
16
16
  # end
17
17
 
18
- # directory node['<%= cookbook_name %>']['logs'] do
19
- # owner node['<%= cookbook_name %>']['user']
20
- # group node['<%= cookbook_name %>']['user']
18
+ # directory node['<%= attribute_ns %>']['logs'] do
19
+ # owner node['<%= attribute_ns %>']['user']
20
+ # group node['<%= attribute_ns %>']['user']
21
21
  # recursive true
22
22
  # end
23
23
 
24
- # directory node['<%= cookbook_name %>']['data'] do
25
- # owner node['<%= cookbook_name %>']['user']
26
- # group node['<%= cookbook_name %>']['user']
24
+ # directory node['<%= attribute_ns %>']['data'] do
25
+ # owner node['<%= attribute_ns %>']['user']
26
+ # group node['<%= attribute_ns %>']['user']
27
27
  # recursive true
28
28
  # end
29
29
 
30
- # ark '<%= cookbook_name %>' do
31
- # url node['<%= cookbook_name %>']['url']
32
- # checksum node['<%= cookbook_name %>']['checksum']
33
- # version node['<%= cookbook_name %>']['version']
34
- # home_dir node['<%= cookbook_name %>']['home']
35
- # owner node['<%= cookbook_name %>']['user']
36
- # group node['<%= cookbook_name %>']['user']
30
+ # ark '<%= attribute_ns %>' do
31
+ # url node['<%= attribute_ns %>']['url']
32
+ # checksum node['<%= attribute_ns %>']['checksum']
33
+ # version node['<%= attribute_ns %>']['version']
34
+ # home_dir node['<%= attribute_ns %>']['home']
35
+ # owner node['<%= attribute_ns %>']['user']
36
+ # group node['<%= attribute_ns %>']['user']
37
37
  # end
38
- <% end %>
38
+ <%- end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bourdain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-14 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pmap
@@ -128,14 +128,15 @@ files:
128
128
  - templates/chef/knife_plugin_node_log.rb
129
129
  - templates/chef/role.json
130
130
  - templates/cookbook/Berksfile
131
+ - templates/cookbook/Rakefile
131
132
  - templates/cookbook/Readme.md
132
133
  - templates/cookbook/VERSION
133
134
  - templates/cookbook/Vagrantfile
134
135
  - templates/cookbook/attributes/example.rb
135
- - templates/cookbook/busser_minitest.rb
136
136
  - templates/cookbook/gitignore
137
137
  - templates/cookbook/kitchen.yml
138
138
  - templates/cookbook/metadata.rb
139
+ - templates/cookbook/minitest.rb
139
140
  - templates/cookbook/pre-commit
140
141
  - templates/cookbook/recipes/example.rb
141
142
  homepage: https://github.com/sczizzo/bourdain