berkshelf 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -3
  3. data/Gemfile +31 -31
  4. data/Gemfile.lock +3 -3
  5. data/Guardfile +13 -13
  6. data/Rakefile +1 -0
  7. data/Thorfile +16 -16
  8. data/berkshelf.gemspec +35 -35
  9. data/features/step_definitions/chef/config_steps.rb +4 -4
  10. data/features/step_definitions/chef_server_steps.rb +6 -6
  11. data/features/step_definitions/cli_steps.rb +3 -3
  12. data/features/step_definitions/config_steps.rb +5 -5
  13. data/features/step_definitions/filesystem_steps.rb +12 -11
  14. data/features/support/env.rb +21 -21
  15. data/lib/berkshelf.rb +66 -66
  16. data/lib/berkshelf/base_generator.rb +10 -11
  17. data/lib/berkshelf/berksfile.rb +38 -38
  18. data/lib/berkshelf/cached_cookbook.rb +7 -7
  19. data/lib/berkshelf/cli.rb +126 -126
  20. data/lib/berkshelf/commands/shelf.rb +19 -18
  21. data/lib/berkshelf/commands/test_command.rb +2 -2
  22. data/lib/berkshelf/community_rest.rb +38 -38
  23. data/lib/berkshelf/config.rb +42 -41
  24. data/lib/berkshelf/cookbook_generator.rb +38 -38
  25. data/lib/berkshelf/cookbook_store.rb +4 -4
  26. data/lib/berkshelf/core_ext/file_utils.rb +1 -1
  27. data/lib/berkshelf/dependency.rb +23 -21
  28. data/lib/berkshelf/downloader.rb +24 -25
  29. data/lib/berkshelf/errors.rb +17 -17
  30. data/lib/berkshelf/file_syncer.rb +9 -8
  31. data/lib/berkshelf/formatters/human.rb +3 -3
  32. data/lib/berkshelf/formatters/json.rb +2 -2
  33. data/lib/berkshelf/init_generator.rb +64 -64
  34. data/lib/berkshelf/installer.rb +103 -102
  35. data/lib/berkshelf/location.rb +9 -9
  36. data/lib/berkshelf/locations/git.rb +16 -16
  37. data/lib/berkshelf/locations/github.rb +1 -1
  38. data/lib/berkshelf/locations/path.rb +2 -2
  39. data/lib/berkshelf/lockfile.rb +309 -315
  40. data/lib/berkshelf/mixin/git.rb +3 -3
  41. data/lib/berkshelf/packager.rb +4 -4
  42. data/lib/berkshelf/resolver.rb +2 -2
  43. data/lib/berkshelf/resolver/graph.rb +1 -1
  44. data/lib/berkshelf/shell.rb +1 -1
  45. data/lib/berkshelf/source.rb +6 -6
  46. data/lib/berkshelf/source_uri.rb +2 -2
  47. data/lib/berkshelf/ssl_policies.rb +3 -3
  48. data/lib/berkshelf/thor.rb +1 -1
  49. data/lib/berkshelf/uploader.rb +48 -48
  50. data/lib/berkshelf/validator.rb +2 -2
  51. data/lib/berkshelf/version.rb +1 -1
  52. data/lib/berkshelf/visualizer.rb +11 -11
  53. data/spec/config/knife.rb +2 -2
  54. data/spec/fixtures/Berksfile +3 -3
  55. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  56. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  57. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  58. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  59. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  60. data/spec/spec_helper.rb +9 -9
  61. data/spec/support/chef_api.rb +11 -12
  62. data/spec/support/chef_server.rb +10 -10
  63. data/spec/support/git.rb +23 -23
  64. data/spec/support/kitchen.rb +2 -2
  65. data/spec/support/matchers/filepath_matchers.rb +2 -2
  66. data/spec/support/path_helpers.rb +12 -12
  67. data/spec/support/shared_examples/formatter.rb +1 -1
  68. data/spec/unit/berkshelf/berksfile_spec.rb +78 -78
  69. data/spec/unit/berkshelf/cached_cookbook_spec.rb +42 -42
  70. data/spec/unit/berkshelf/cli_spec.rb +6 -6
  71. data/spec/unit/berkshelf/community_rest_spec.rb +83 -83
  72. data/spec/unit/berkshelf/config_spec.rb +13 -13
  73. data/spec/unit/berkshelf/cookbook_generator_spec.rb +39 -39
  74. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  75. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +5 -6
  76. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  77. data/spec/unit/berkshelf/dependency_spec.rb +43 -43
  78. data/spec/unit/berkshelf/downloader_spec.rb +20 -20
  79. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  80. data/spec/unit/berkshelf/file_syncer_spec.rb +86 -86
  81. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  82. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  83. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  84. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  85. data/spec/unit/berkshelf/init_generator_spec.rb +92 -92
  86. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  87. data/spec/unit/berkshelf/location_spec.rb +11 -11
  88. data/spec/unit/berkshelf/locations/base_spec.rb +35 -35
  89. data/spec/unit/berkshelf/locations/git_spec.rb +87 -87
  90. data/spec/unit/berkshelf/locations/path_spec.rb +40 -40
  91. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  92. data/spec/unit/berkshelf/lockfile_spec.rb +197 -197
  93. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  94. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  95. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  96. data/spec/unit/berkshelf/resolver/graph_spec.rb +1 -1
  97. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  98. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  99. data/spec/unit/berkshelf/source_spec.rb +12 -11
  100. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  101. data/spec/unit/berkshelf/ssl_policies_spec.rb +25 -25
  102. data/spec/unit/berkshelf/uploader_spec.rb +54 -54
  103. data/spec/unit/berkshelf/validator_spec.rb +16 -16
  104. data/spec/unit/berkshelf/visualizer_spec.rb +17 -17
  105. data/spec/unit/berkshelf_spec.rb +18 -18
  106. metadata +5 -5
@@ -1,7 +1,7 @@
1
1
  module Berkshelf
2
2
  # All tasks that operate on the Berkshelf shelf.
3
3
  class Shelf < Thor
4
- desc 'list', 'List all cookbooks and their versions'
4
+ desc "list", "List all cookbooks and their versions"
5
5
  def list
6
6
  cookbooks = store.cookbooks.inject({}) do |hash, cookbook|
7
7
  (hash[cookbook.cookbook_name] ||= []).push(cookbook.version)
@@ -9,17 +9,17 @@ module Berkshelf
9
9
  end
10
10
 
11
11
  if cookbooks.empty?
12
- Berkshelf.formatter.msg 'There are no cookbooks in the Berkshelf shelf'
12
+ Berkshelf.formatter.msg "There are no cookbooks in the Berkshelf shelf"
13
13
  else
14
- Berkshelf.formatter.msg 'Cookbooks in the Berkshelf shelf:'
14
+ Berkshelf.formatter.msg "Cookbooks in the Berkshelf shelf:"
15
15
  cookbooks.sort.each do |cookbook, versions|
16
16
  Berkshelf.formatter.msg(" * #{cookbook} (#{versions.sort.join(', ')})")
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
- method_option :version, aliases: '-v', type: :string, desc: 'Version to show'
22
- desc 'show', 'Display information about a cookbook in the Berkshelf shelf'
21
+ method_option :version, aliases: "-v", type: :string, desc: "Version to show"
22
+ desc "show", "Display information about a cookbook in the Berkshelf shelf"
23
23
  def show(name)
24
24
  cookbooks = find(name, options[:version])
25
25
 
@@ -35,9 +35,9 @@ module Berkshelf
35
35
  end
36
36
  end
37
37
 
38
- method_option :version, aliases: '-v', type: :string, desc: 'Version to remove'
39
- method_option :force, aliases: '-f', type: :boolean, desc: 'Force removal, even if other cookbooks are contingent', default: false
40
- desc 'uninstall', 'Remove a cookbook from the Berkshelf shelf'
38
+ method_option :version, aliases: "-v", type: :string, desc: "Version to remove"
39
+ method_option :force, aliases: "-f", type: :boolean, desc: "Force removal, even if other cookbooks are contingent", default: false
40
+ desc "uninstall", "Remove a cookbook from the Berkshelf shelf"
41
41
  def uninstall(name)
42
42
  cookbooks = find(name, options[:version])
43
43
  cookbooks.each { |c| uninstall_cookbook(c, options[:force]) }
@@ -67,14 +67,15 @@ module Berkshelf
67
67
  # the list of cookbooks that match the parameters - this is always an
68
68
  # array!
69
69
  def find(name, version = nil)
70
- cookbooks = if version
71
- [store.cookbook(name, version)].compact
72
- else
73
- store.cookbooks(name).sort
74
- end
70
+ cookbooks =
71
+ if version
72
+ [store.cookbook(name, version)].compact
73
+ else
74
+ store.cookbooks(name).sort
75
+ end
75
76
 
76
77
  if cookbooks.empty?
77
- raise CookbookNotFound.new(name, version, 'in the Berkshelf shelf')
78
+ raise CookbookNotFound.new(name, version, "in the Berkshelf shelf")
78
79
  end
79
80
 
80
81
  cookbooks
@@ -95,10 +96,10 @@ module Berkshelf
95
96
  # if contingencies exist
96
97
  def uninstall_cookbook(cookbook, force = false)
97
98
  unless options[:force] || (contingent = contingencies(cookbook)).empty?
98
- contingent = contingent.map { |c| "#{c.cookbook_name} (#{c.version})" }.join(', ')
99
+ contingent = contingent.map { |c| "#{c.cookbook_name} (#{c.version})" }.join(", ")
99
100
  confirm = Berkshelf.ui.ask("[#{contingent}] depend on #{cookbook.cookbook_name}.\n\nAre you sure you want to continue? (y/N)")
100
101
 
101
- exit unless confirm.to_s.upcase[0] == 'Y'
102
+ exit unless confirm.to_s.upcase[0] == "Y"
102
103
  end
103
104
 
104
105
  FileUtils.rm_rf(cookbook.path)
@@ -120,7 +121,7 @@ module Berkshelf
120
121
  end
121
122
 
122
123
  class Cli < Thor
123
- desc 'shelf SUBCOMMAND', 'Interact with the cookbook store'
124
- subcommand 'shelf', Berkshelf::Shelf
124
+ desc "shelf SUBCOMMAND", "Interact with the cookbook store"
125
+ subcommand "shelf", Berkshelf::Shelf
125
126
  end
126
127
  end
@@ -1,5 +1,5 @@
1
1
  begin
2
- require 'kitchen/cli'
2
+ require "kitchen/cli"
3
3
  rescue LoadError; end
4
4
 
5
5
  module Berkshelf
@@ -8,6 +8,6 @@ module Berkshelf
8
8
  end
9
9
 
10
10
  class Cli < Thor
11
- register(Berkshelf::TestCommand, 'test', 'test [COMMAND]', 'Testing tasks for your cookbook', hide: true)
11
+ register(Berkshelf::TestCommand, "test", "test [COMMAND]", "Testing tasks for your cookbook", hide: true)
12
12
  end
13
13
  end if defined?(Kitchen::CLI)
@@ -1,6 +1,6 @@
1
- require 'open-uri'
2
- require 'retryable'
3
- require 'mixlib/archive'
1
+ require "open-uri"
2
+ require "retryable"
3
+ require "mixlib/archive"
4
4
 
5
5
  module Berkshelf
6
6
  class CommunityREST < Faraday::Connection
@@ -25,30 +25,30 @@ module Berkshelf
25
25
  #
26
26
  # @return [String]
27
27
  def uri_escape_version(version)
28
- version.to_s.gsub('.', '_')
28
+ version.to_s.tr(".", "_")
29
29
  end
30
30
 
31
31
  # @param [String] uri
32
32
  #
33
33
  # @return [String]
34
34
  def version_from_uri(uri)
35
- File.basename(uri.to_s).gsub('_', '.')
35
+ File.basename(uri.to_s).tr("_", ".")
36
36
  end
37
37
 
38
38
  private
39
39
 
40
- def is_gzip_file(path)
41
- # You cannot write "\x1F\x8B" because the default encoding of
42
- # ruby >= 1.9.3 is UTF-8 and 8B is an invalid in UTF-8.
43
- IO.binread(path, 2) == [0x1F, 0x8B].pack("C*")
44
- end
40
+ def is_gzip_file(path)
41
+ # You cannot write "\x1F\x8B" because the default encoding of
42
+ # ruby >= 1.9.3 is UTF-8 and 8B is an invalid in UTF-8.
43
+ IO.binread(path, 2) == [0x1F, 0x8B].pack("C*")
44
+ end
45
45
 
46
- def is_tar_file(path)
47
- IO.binread(path, 8, 257).to_s == "ustar\x0000"
48
- end
46
+ def is_tar_file(path)
47
+ IO.binread(path, 8, 257).to_s == "ustar\x0000"
48
+ end
49
49
  end
50
50
 
51
- V1_API = 'https://supermarket.chef.io'.freeze
51
+ V1_API = "https://supermarket.chef.io".freeze
52
52
 
53
53
  # @return [String]
54
54
  attr_reader :api_uri
@@ -97,14 +97,14 @@ module Berkshelf
97
97
  # @return [String, nil]
98
98
  # cookbook filepath, or nil if archive does not contain a cookbook
99
99
  def download(name, version)
100
- archive = stream(find(name, version)[:file])
100
+ archive = stream(find(name, version)[:file])
101
101
  scratch = Dir.mktmpdir
102
102
  extracted = self.class.unpack(archive.path, scratch)
103
103
 
104
104
  if File.cookbook?(extracted)
105
105
  extracted
106
106
  else
107
- Dir.glob(File.join(extracted, '*')).find do |dir|
107
+ Dir.glob(File.join(extracted, "*")).find do |dir|
108
108
  File.cookbook?(dir)
109
109
  end
110
110
  end
@@ -133,7 +133,7 @@ module Berkshelf
133
133
 
134
134
  case response.status
135
135
  when (200..299)
136
- self.class.version_from_uri response.body['latest_version']
136
+ self.class.version_from_uri response.body["latest_version"]
137
137
  when 404
138
138
  raise CookbookNotFound.new(name, nil, "at `#{api_uri}'")
139
139
  else
@@ -149,7 +149,7 @@ module Berkshelf
149
149
 
150
150
  case response.status
151
151
  when (200..299)
152
- response.body['versions'].collect do |version_uri|
152
+ response.body["versions"].collect do |version_uri|
153
153
  self.class.version_from_uri(version_uri)
154
154
  end
155
155
  when 404
@@ -176,11 +176,11 @@ module Berkshelf
176
176
  #
177
177
  # @return [Tempfile]
178
178
  def stream(target)
179
- local = Tempfile.new('community-rest-stream')
179
+ local = Tempfile.new("community-rest-stream")
180
180
  local.binmode
181
181
 
182
182
  Retryable.retryable(tries: retries, on: OpenURI::HTTPError, sleep: retry_interval) do
183
- open(target, 'rb', open_uri_options) do |remote|
183
+ open(target, "rb", open_uri_options) do |remote|
184
184
  local.write(remote.read)
185
185
  end
186
186
  end
@@ -192,27 +192,27 @@ module Berkshelf
192
192
 
193
193
  private
194
194
 
195
- def open_uri_options
196
- options = {}
197
- options.merge!(headers)
198
- options.merge!(open_uri_proxy_options)
199
- options.merge!(ssl_verify_mode: ssl_verify_mode)
200
- end
195
+ def open_uri_options
196
+ options = {}
197
+ options.merge!(headers)
198
+ options.merge!(open_uri_proxy_options)
199
+ options.merge!(ssl_verify_mode: ssl_verify_mode)
200
+ end
201
201
 
202
- def open_uri_proxy_options
203
- if proxy && proxy[:user] && proxy[:password]
204
- {proxy_http_basic_authentication: [ proxy[:uri], proxy[:user], proxy[:password] ]}
205
- else
206
- {}
207
- end
202
+ def open_uri_proxy_options
203
+ if proxy && proxy[:user] && proxy[:password]
204
+ { proxy_http_basic_authentication: [ proxy[:uri], proxy[:user], proxy[:password] ] }
205
+ else
206
+ {}
208
207
  end
208
+ end
209
209
 
210
- def ssl_verify_mode
211
- if Berkshelf::Config.instance.ssl.verify.nil? || Berkshelf::Config.instance.ssl.verify
212
- OpenSSL::SSL::VERIFY_PEER
213
- else
214
- OpenSSL::SSL::VERIFY_NONE
215
- end
210
+ def ssl_verify_mode
211
+ if Berkshelf::Config.instance.ssl.verify.nil? || Berkshelf::Config.instance.ssl.verify
212
+ OpenSSL::SSL::VERIFY_PEER
213
+ else
214
+ OpenSSL::SSL::VERIFY_NONE
216
215
  end
216
+ end
217
217
  end
218
218
  end
@@ -1,17 +1,17 @@
1
- require 'buff/config/json'
2
- require 'openssl'
1
+ require "buff/config/json"
2
+ require "openssl"
3
3
 
4
4
  module Berkshelf
5
5
  class Config < Buff::Config::JSON
6
6
  class << self
7
7
  # @return [String]
8
8
  def store_location
9
- File.join(Berkshelf.berkshelf_path, 'config.json')
9
+ File.join(Berkshelf.berkshelf_path, "config.json")
10
10
  end
11
11
 
12
12
  # @return [String]
13
13
  def local_location
14
- ENV['BERKSHELF_CONFIG'] || File.join('.', '.berkshelf', 'config.json')
14
+ ENV["BERKSHELF_CONFIG"] || File.join(".", ".berkshelf", "config.json")
15
15
  end
16
16
 
17
17
  # @return [String]
@@ -41,11 +41,12 @@ module Berkshelf
41
41
  #
42
42
  # @return [Config]
43
43
  def instance
44
- @instance ||= if file
45
- from_json file
46
- else
47
- new
48
- end
44
+ @instance ||=
45
+ if file
46
+ from_json file
47
+ else
48
+ new
49
+ end
49
50
  coerce_ssl
50
51
  end
51
52
 
@@ -56,7 +57,7 @@ module Berkshelf
56
57
  @instance = nil
57
58
  self.instance
58
59
  end
59
-
60
+
60
61
  # force proper X509 types from any configuration strings
61
62
  #
62
63
  # @return [Config]
@@ -88,97 +89,97 @@ module Berkshelf
88
89
  end
89
90
  end
90
91
 
91
- attribute 'api.timeout',
92
+ attribute "api.timeout",
92
93
  type: String,
93
- default: '30'
94
- attribute 'chef.chef_server_url',
94
+ default: "30"
95
+ attribute "chef.chef_server_url",
95
96
  type: String,
96
97
  default: Berkshelf.chef_config.chef_server_url
97
- attribute 'chef.validation_client_name',
98
+ attribute "chef.validation_client_name",
98
99
  type: String,
99
100
  default: Berkshelf.chef_config.validation_client_name
100
- attribute 'chef.validation_key_path',
101
+ attribute "chef.validation_key_path",
101
102
  type: String,
102
103
  default: Berkshelf.chef_config.validation_key
103
- attribute 'chef.client_key',
104
+ attribute "chef.client_key",
104
105
  type: String,
105
106
  default: Berkshelf.chef_config.client_key
106
- attribute 'chef.node_name',
107
+ attribute "chef.node_name",
107
108
  type: String,
108
109
  default: Berkshelf.chef_config.node_name
109
- attribute 'chef.trusted_certs_dir',
110
+ attribute "chef.trusted_certs_dir",
110
111
  type: String,
111
112
  default: Berkshelf.chef_config.trusted_certs_dir
112
- attribute 'cookbook.copyright',
113
+ attribute "cookbook.copyright",
113
114
  type: String,
114
115
  default: Berkshelf.chef_config.cookbook_copyright
115
- attribute 'cookbook.email',
116
+ attribute "cookbook.email",
116
117
  type: String,
117
118
  default: Berkshelf.chef_config.cookbook_email
118
- attribute 'cookbook.license',
119
+ attribute "cookbook.license",
119
120
  type: String,
120
121
  default: Berkshelf.chef_config.cookbook_license
121
- attribute 'allowed_licenses',
122
+ attribute "allowed_licenses",
122
123
  type: Array,
123
124
  default: Array.new
124
- attribute 'raise_license_exception',
125
+ attribute "raise_license_exception",
125
126
  type: Buff::Boolean,
126
127
  default: false
127
- attribute 'vagrant.vm.box',
128
+ attribute "vagrant.vm.box",
128
129
  type: String,
129
- default: 'bento/ubuntu-14.04',
130
+ default: "bento/ubuntu-14.04",
130
131
  required: true
131
132
  # @todo Deprecated, remove?
132
- attribute 'vagrant.vm.box_url',
133
+ attribute "vagrant.vm.box_url",
133
134
  type: String,
134
135
  default: nil
135
- attribute 'vagrant.vm.forward_port',
136
+ attribute "vagrant.vm.forward_port",
136
137
  type: Hash,
137
138
  default: Hash.new
138
- attribute 'vagrant.vm.provision',
139
+ attribute "vagrant.vm.provision",
139
140
  type: String,
140
- default: 'chef_solo'
141
+ default: "chef_solo"
141
142
  # @todo Deprecated, remove. There's a really weird tri-state here where
142
143
  # nil is used to represent an unset value, just FYI
143
- attribute 'vagrant.omnibus.enabled',
144
+ attribute "vagrant.omnibus.enabled",
144
145
  type: Buff::Boolean,
145
146
  default: nil
146
- attribute 'vagrant.omnibus.version',
147
+ attribute "vagrant.omnibus.version",
147
148
  type: String,
148
- default: 'latest'
149
- attribute 'ssl.verify',
149
+ default: "latest"
150
+ attribute "ssl.verify",
150
151
  type: Buff::Boolean,
151
152
  default: true,
152
153
  required: true
153
- attribute 'ssl.cert_store',
154
+ attribute "ssl.cert_store",
154
155
  type: Buff::Boolean,
155
156
  default: false,
156
157
  required: false
157
- attribute 'ssl.ca_file',
158
+ attribute "ssl.ca_file",
158
159
  type: String,
159
160
  default: nil,
160
161
  required: false
161
- attribute 'ssl.ca_path',
162
+ attribute "ssl.ca_path",
162
163
  type: String,
163
164
  default: nil,
164
165
  required: false
165
- attribute 'ssl.client_cert',
166
+ attribute "ssl.client_cert",
166
167
  type: String,
167
168
  default: nil,
168
169
  required: false
169
- attribute 'ssl.client_key',
170
+ attribute "ssl.client_key",
170
171
  type: String,
171
172
  default: nil,
172
173
  required: false
173
- attribute 'github',
174
+ attribute "github",
174
175
  type: Array,
175
176
  default: [],
176
177
  required: false
177
- attribute 'gitlab',
178
+ attribute "gitlab",
178
179
  type: Array,
179
180
  default: [],
180
181
  required: false
181
- attribute 'github_protocol',
182
+ attribute "github_protocol",
182
183
  # :git, :ssh, or :https
183
184
  type: Symbol,
184
185
  default: :https,
@@ -1,6 +1,6 @@
1
1
  module Berkshelf
2
2
  class CookbookGenerator < BaseGenerator
3
- require_relative 'config'
3
+ require_relative "config"
4
4
 
5
5
  LICENSE_MAP = {
6
6
  "apachev2" => "Apache 2.0",
@@ -27,7 +27,7 @@ module Berkshelf
27
27
  class_option :skip_test_kitchen,
28
28
  type: :boolean,
29
29
  default: false,
30
- desc: 'Skip adding a testing environment to your cookbook'
30
+ desc: "Skip adding a testing environment to your cookbook"
31
31
 
32
32
  class_option :foodcritic,
33
33
  type: :boolean,
@@ -78,56 +78,56 @@ module Berkshelf
78
78
  template "default_recipe.erb", target.join("recipes/default.rb")
79
79
  end
80
80
 
81
- template 'metadata.rb.erb', target.join('metadata.rb')
82
- template license_file, target.join('LICENSE')
83
- template 'README.md.erb', target.join('README.md')
84
- template 'CHANGELOG.md.erb', target.join('CHANGELOG.md')
81
+ template "metadata.rb.erb", target.join("metadata.rb")
82
+ template license_file, target.join("LICENSE")
83
+ template "README.md.erb", target.join("README.md")
84
+ template "CHANGELOG.md.erb", target.join("CHANGELOG.md")
85
85
 
86
86
  Berkshelf::InitGenerator.new([target], options.merge(default_options)).invoke_all
87
87
  end
88
88
 
89
89
  private
90
90
 
91
- def commented(content)
92
- content.split("\n").collect { |s| s == "" ? "#" : "# #{s}"}.join("\n")
93
- end
91
+ def commented(content)
92
+ content.split("\n").collect { |s| s == "" ? "#" : "# #{s}" }.join("\n")
93
+ end
94
94
 
95
- def license_name
96
- LICENSE_MAP.fetch(options[:license]) do |license|
97
- raise Berkshelf::LicenseNotFound.new(license)
98
- end
95
+ def license_name
96
+ LICENSE_MAP.fetch(options[:license]) do |license|
97
+ raise Berkshelf::LicenseNotFound.new(license)
99
98
  end
99
+ end
100
100
 
101
- def license
102
- ERB.new(File.read(File.join(self.class.source_root, license_file))).result(binding)
103
- end
101
+ def license
102
+ ERB.new(File.read(File.join(self.class.source_root, license_file))).result(binding)
103
+ end
104
104
 
105
- def license_file
106
- case options[:license]
107
- when 'apachev2'; 'licenses/apachev2.erb'
108
- when 'gplv2'; 'licenses/gplv2.erb'
109
- when 'gplv3'; 'licenses/gplv3.erb'
110
- when 'mit'; 'licenses/mit.erb'
111
- when 'reserved'; 'licenses/reserved.erb'
112
- else
113
- raise Berkshelf::LicenseNotFound.new(options[:license])
114
- end
105
+ def license_file
106
+ case options[:license]
107
+ when "apachev2" then "licenses/apachev2.erb"
108
+ when "gplv2" then "licenses/gplv2.erb"
109
+ when "gplv3" then "licenses/gplv3.erb"
110
+ when "mit" then "licenses/mit.erb"
111
+ when "reserved" then "licenses/reserved.erb"
112
+ else
113
+ raise Berkshelf::LicenseNotFound.new(options[:license])
115
114
  end
115
+ end
116
116
 
117
- def copyright_year
118
- Time.now.year
119
- end
117
+ def copyright_year
118
+ Time.now.year
119
+ end
120
120
 
121
- def maintainer
122
- options[:maintainer]
123
- end
121
+ def maintainer
122
+ options[:maintainer]
123
+ end
124
124
 
125
- def maintainer_email
126
- options[:maintainer_email]
127
- end
125
+ def maintainer_email
126
+ options[:maintainer_email]
127
+ end
128
128
 
129
- def default_options
130
- { metadata_entry: true, chefignore: true, cookbook_name: name }
131
- end
129
+ def default_options
130
+ { metadata_entry: true, chefignore: true, cookbook_name: name }
131
+ end
132
132
  end
133
133
  end