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,4 +1,4 @@
1
- require 'aruba/api'
1
+ require "aruba/api"
2
2
 
3
3
  World(Aruba::Api)
4
4
  World(Berkshelf::RSpec::ChefAPI)
@@ -22,12 +22,12 @@ end
22
22
  Given /^the cookbook store has the git cookbooks:$/ do |cookbooks|
23
23
  cookbooks.raw.each do |name, version, sha|
24
24
  folder = "#{name}-#{sha}"
25
- metadata = File.join(folder, 'metadata.rb')
25
+ metadata = File.join(folder, "metadata.rb")
26
26
 
27
27
  create_directory(folder)
28
28
  write_file(metadata, [
29
29
  "name '#{name}'",
30
- "version '#{version}'"
30
+ "version '#{version}'",
31
31
  ].join("\n"))
32
32
  end
33
33
  end
@@ -133,7 +133,6 @@ Then /^I should have a new cookbook skeleton "(.*?)" with Chef-Minitest support$
133
133
  }
134
134
  end
135
135
 
136
-
137
136
  Then /^I should have a new cookbook skeleton "(.*?)" with Foodcritic support$/ do |name|
138
137
  steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
139
138
 
@@ -215,15 +214,15 @@ Then(/^I should have a new cookbook skeleton "(.*?)" with no Test Kitchen suppor
215
214
  end
216
215
 
217
216
  Then /^the cookbook "(.*?)" should have the following files:$/ do |name, files|
218
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, true)
217
+ check_file_presence(files.raw.map { |file_row| ::File.join(name, file_row[0]) }, true)
219
218
  end
220
219
 
221
220
  Then /^the cookbook "(.*?)" should not have the following files:$/ do |name, files|
222
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, false)
221
+ check_file_presence(files.raw.map { |file_row| ::File.join(name, file_row[0]) }, false)
223
222
  end
224
223
 
225
224
  Then /^the git cookbook "(.*?)" should not have the following directories:$/ do |name, directories|
226
- check_directory_presence(directories.raw.map{|directory_row| ::File.join(cookbook_store.storage_path.to_path, name, directory_row[0])}, false)
225
+ check_directory_presence(directories.raw.map { |directory_row| ::File.join(cookbook_store.storage_path.to_path, name, directory_row[0]) }, false)
227
226
  end
228
227
 
229
228
  Then /^the file "(.*?)" in the cookbook "(.*?)" should contain:$/ do |file_name, cookbook_name, content|
@@ -238,19 +237,21 @@ end
238
237
  Then /^the resulting "(.+)" Vagrantfile should contain:$/ do |cookbook_name, content|
239
238
  expect(Pathname.new(current_dir).join(cookbook_name)).to have_structure {
240
239
  file "Vagrantfile" do
241
- content.respond_to?(:raw) ?
242
- content.raw.flatten.each { |string| contains string } :
240
+ if content.respond_to?(:raw)
241
+ content.raw.flatten.each { |string| contains string }
242
+ else
243
243
  contains(content)
244
+ end
244
245
  end
245
246
  }
246
247
  end
247
248
 
248
249
  Then /^the directory "(.*?)" should have the following files:$/ do |name, files|
249
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, true)
250
+ check_file_presence(files.raw.map { |file_row| ::File.join(name, file_row[0]) }, true)
250
251
  end
251
252
 
252
253
  Then /^the directory "(.*?)" should not have the following files:$/ do |name, files|
253
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, false)
254
+ check_file_presence(files.raw.map { |file_row| ::File.join(name, file_row[0]) }, false)
254
255
  end
255
256
 
256
257
  Then /^the file "(.*?)" in the directory "(.*?)" should not contain:$/ do |file_name, directory_name, content|
@@ -1,18 +1,18 @@
1
- require 'spork'
1
+ require "spork"
2
2
 
3
3
  def windows?
4
4
  !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
5
5
  end
6
6
 
7
7
  Spork.prefork do
8
- require 'aruba/cucumber'
9
- require 'aruba/in_process'
10
- require 'aruba/spawn_process'
11
- require 'cucumber/rspec/doubles'
12
- require 'berkshelf/api/rspec' unless windows?
13
- require 'berkshelf/api/cucumber' unless windows?
8
+ require "aruba/cucumber"
9
+ require "aruba/in_process"
10
+ require "aruba/spawn_process"
11
+ require "cucumber/rspec/doubles"
12
+ require "berkshelf/api/rspec" unless windows?
13
+ require "berkshelf/api/cucumber" unless windows?
14
14
 
15
- Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
15
+ Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }
16
16
 
17
17
  World(Berkshelf::RSpec::PathHelpers)
18
18
  World(Berkshelf::RSpec::Kitchen)
@@ -29,13 +29,13 @@ Spork.prefork do
29
29
 
30
30
  # Legacy ENV variables until we can move over to all InProcess
31
31
  Berkshelf.instance_variable_set(:@berkshelf_path, nil)
32
- ENV['BERKSHELF_PATH'] = berkshelf_path.to_s
33
- ENV['BERKSHELF_CONFIG'] = Berkshelf.config.path.to_s
34
- ENV['BERKSHELF_CHEF_CONFIG'] = chef_config_path.to_s
32
+ ENV["BERKSHELF_PATH"] = berkshelf_path.to_s
33
+ ENV["BERKSHELF_CONFIG"] = Berkshelf.config.path.to_s
34
+ ENV["BERKSHELF_CHEF_CONFIG"] = chef_config_path.to_s
35
35
 
36
36
  aruba.config.command_launcher = :in_process
37
37
  aruba.config.main_class = Berkshelf::Cli::Runner
38
- @dirs = ["spec/tmp/aruba"] # set aruba's temporary directory
38
+ @dirs = ["spec/tmp/aruba"] # set aruba's temporary directory
39
39
 
40
40
  stub_kitchen!
41
41
  clean_tmp_path
@@ -50,9 +50,9 @@ Spork.prefork do
50
50
  options: {
51
51
  url: "http://localhost:#{CHEF_SERVER_PORT}",
52
52
  client_name: "reset",
53
- client_key: File.expand_path("spec/config/berkshelf.pem")
54
- }
55
- }
53
+ client_key: File.expand_path("spec/config/berkshelf.pem"),
54
+ },
55
+ },
56
56
  ]
57
57
 
58
58
  Berkshelf::RSpec::ChefServer.start(port: CHEF_SERVER_PORT)
@@ -62,21 +62,21 @@ Spork.prefork do
62
62
  @aruba_timeout_seconds = Cucumber::JRUBY ? 35 : 15
63
63
  end
64
64
 
65
- Before('@spawn') do
65
+ Before("@spawn") do
66
66
  aruba.config.command_launcher = :spawn
67
67
 
68
68
  Berkshelf.instance_variable_set(:@berkshelf_path, nil)
69
- set_environment_variable('BERKSHELF_PATH', berkshelf_path.to_s)
70
- set_environment_variable('BERKSHELF_CONFIG', Berkshelf.config.path.to_s)
71
- set_environment_variable('BERKSHELF_CHEF_CONFIG', chef_config_path.to_s)
69
+ set_environment_variable("BERKSHELF_PATH", berkshelf_path.to_s)
70
+ set_environment_variable("BERKSHELF_CONFIG", Berkshelf.config.path.to_s)
71
+ set_environment_variable("BERKSHELF_CHEF_CONFIG", chef_config_path.to_s)
72
72
  end
73
73
 
74
- Before('@slow_process') do
74
+ Before("@slow_process") do
75
75
  aruba.config.io_wait_timeout = Cucumber::JRUBY ? 70 : 30
76
76
  @aruba_timeout_seconds = Cucumber::JRUBY ? 140 : 60
77
77
  end
78
78
  end
79
79
 
80
80
  Spork.each_run do
81
- require 'berkshelf/cli'
81
+ require "berkshelf/cli"
82
82
  end
@@ -1,49 +1,49 @@
1
- require 'buff/extensions'
2
- require 'cleanroom'
3
- require 'digest/md5'
4
- require 'forwardable'
5
- require 'json'
6
- require 'pathname'
7
- require 'ridley'
8
- require 'semverse'
9
- require 'solve'
10
- require 'thor'
11
- require 'uri'
12
- require 'celluloid'
1
+ require "buff/extensions"
2
+ require "cleanroom"
3
+ require "digest/md5"
4
+ require "forwardable"
5
+ require "json"
6
+ require "pathname"
7
+ require "ridley"
8
+ require "semverse"
9
+ require "solve"
10
+ require "thor"
11
+ require "uri"
12
+ require "celluloid"
13
13
 
14
14
  JSON.create_id = nil
15
15
 
16
- require_relative 'berkshelf/core_ext'
17
- require_relative 'berkshelf/thor_ext'
16
+ require_relative "berkshelf/core_ext"
17
+ require_relative "berkshelf/thor_ext"
18
18
 
19
19
  module Berkshelf
20
20
  Encoding.default_external = Encoding::UTF_8
21
21
 
22
- require_relative 'berkshelf/version'
23
- require_relative 'berkshelf/errors'
22
+ require_relative "berkshelf/version"
23
+ require_relative "berkshelf/errors"
24
24
 
25
25
  module Mixin
26
- autoload :Git, 'berkshelf/mixin/git'
27
- autoload :Logging, 'berkshelf/mixin/logging'
26
+ autoload :Git, "berkshelf/mixin/git"
27
+ autoload :Logging, "berkshelf/mixin/logging"
28
28
  end
29
29
 
30
- autoload :FileSyncer, 'berkshelf/file_syncer'
31
- autoload :Shell, 'berkshelf/shell'
32
- autoload :Uploader, 'berkshelf/uploader'
33
- autoload :Visualizer, 'berkshelf/visualizer'
30
+ autoload :FileSyncer, "berkshelf/file_syncer"
31
+ autoload :Shell, "berkshelf/shell"
32
+ autoload :Uploader, "berkshelf/uploader"
33
+ autoload :Visualizer, "berkshelf/visualizer"
34
34
 
35
- autoload :BaseFormatter, 'berkshelf/formatters/base'
36
- autoload :HumanFormatter, 'berkshelf/formatters/human'
37
- autoload :JsonFormatter, 'berkshelf/formatters/json'
38
- autoload :NullFormatter, 'berkshelf/formatters/null'
35
+ autoload :BaseFormatter, "berkshelf/formatters/base"
36
+ autoload :HumanFormatter, "berkshelf/formatters/human"
37
+ autoload :JsonFormatter, "berkshelf/formatters/json"
38
+ autoload :NullFormatter, "berkshelf/formatters/null"
39
39
 
40
- autoload :Location, 'berkshelf/location'
41
- autoload :BaseLocation, 'berkshelf/locations/base'
42
- autoload :GitLocation, 'berkshelf/locations/git'
43
- autoload :GithubLocation, 'berkshelf/locations/github'
44
- autoload :PathLocation, 'berkshelf/locations/path'
40
+ autoload :Location, "berkshelf/location"
41
+ autoload :BaseLocation, "berkshelf/locations/base"
42
+ autoload :GitLocation, "berkshelf/locations/git"
43
+ autoload :GithubLocation, "berkshelf/locations/github"
44
+ autoload :PathLocation, "berkshelf/locations/path"
45
45
 
46
- DEFAULT_FILENAME = 'Berksfile'.freeze
46
+ DEFAULT_FILENAME = "Berksfile".freeze
47
47
 
48
48
  class << self
49
49
  include Mixin::Logging
@@ -53,7 +53,7 @@ module Berkshelf
53
53
 
54
54
  # @return [Pathname]
55
55
  def root
56
- @root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
56
+ @root ||= Pathname.new(File.expand_path("../", File.dirname(__FILE__)))
57
57
  end
58
58
 
59
59
  # @return [Berkshelf::Shell]
@@ -69,7 +69,7 @@ module Berkshelf
69
69
  #
70
70
  # @return [String]
71
71
  def berkshelf_path
72
- @berkshelf_path ||= File.expand_path(ENV['BERKSHELF_PATH'] || '~/.berkshelf')
72
+ @berkshelf_path ||= File.expand_path(ENV["BERKSHELF_PATH"] || "~/.berkshelf")
73
73
  end
74
74
 
75
75
  # The Berkshelf configuration.
@@ -88,7 +88,7 @@ module Berkshelf
88
88
  #
89
89
  # @return [Ridley::Chef::Config]
90
90
  def chef_config
91
- @chef_config ||= Ridley::Chef::Config.new(ENV['BERKSHELF_CHEF_CONFIG'])
91
+ @chef_config ||= Ridley::Chef::Config.new(ENV["BERKSHELF_CHEF_CONFIG"])
92
92
  end
93
93
 
94
94
  # @param [Ridley::Chef::Config]
@@ -139,15 +139,15 @@ module Berkshelf
139
139
  ridley_options[:ssl] = ssl_options
140
140
 
141
141
  unless ridley_options[:server_url].present?
142
- raise ChefConnectionError, 'Missing required attribute in your Berkshelf configuration: chef.server_url'
142
+ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.server_url"
143
143
  end
144
144
 
145
145
  unless ridley_options[:client_name].present?
146
- raise ChefConnectionError, 'Missing required attribute in your Berkshelf configuration: chef.node_name'
146
+ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.node_name"
147
147
  end
148
148
 
149
149
  unless ridley_options[:client_key].present?
150
- raise ChefConnectionError, 'Missing required attribute in your Berkshelf configuration: chef.client_key'
150
+ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.client_key"
151
151
  end
152
152
 
153
153
  # @todo Something scary going on here - getting an instance of Kitchen::Logger from test-kitchen
@@ -179,8 +179,8 @@ module Berkshelf
179
179
  def which(executable)
180
180
  if File.file?(executable) && File.executable?(executable)
181
181
  executable
182
- elsif ENV['PATH']
183
- path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
182
+ elsif ENV["PATH"]
183
+ path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |p|
184
184
  File.executable?(File.join(p, executable))
185
185
  end
186
186
  path && File.expand_path(executable, path)
@@ -189,36 +189,36 @@ module Berkshelf
189
189
 
190
190
  private
191
191
 
192
- def null_stream
193
- @null ||= begin
194
- strm = STDOUT.clone
195
- strm.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
196
- strm.sync = true
197
- strm
198
- end
192
+ def null_stream
193
+ @null ||= begin
194
+ strm = STDOUT.clone
195
+ strm.reopen(RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ ? "NUL:" : "/dev/null")
196
+ strm.sync = true
197
+ strm
199
198
  end
199
+ end
200
200
  end
201
201
  end
202
202
 
203
- require_relative 'berkshelf/lockfile'
204
- require_relative 'berkshelf/base_generator'
205
- require_relative 'berkshelf/berksfile'
206
- require_relative 'berkshelf/cached_cookbook'
207
- require_relative 'berkshelf/cli'
208
- require_relative 'berkshelf/community_rest'
209
- require_relative 'berkshelf/cookbook_generator'
210
- require_relative 'berkshelf/cookbook_store'
211
- require_relative 'berkshelf/config'
212
- require_relative 'berkshelf/dependency'
213
- require_relative 'berkshelf/downloader'
214
- require_relative 'berkshelf/init_generator'
215
- require_relative 'berkshelf/installer'
216
- require_relative 'berkshelf/logger'
217
- require_relative 'berkshelf/resolver'
218
- require_relative 'berkshelf/source'
219
- require_relative 'berkshelf/source_uri'
220
- require_relative 'berkshelf/validator'
221
- require_relative 'berkshelf/ssl_policies'
203
+ require_relative "berkshelf/lockfile"
204
+ require_relative "berkshelf/base_generator"
205
+ require_relative "berkshelf/berksfile"
206
+ require_relative "berkshelf/cached_cookbook"
207
+ require_relative "berkshelf/cli"
208
+ require_relative "berkshelf/community_rest"
209
+ require_relative "berkshelf/cookbook_generator"
210
+ require_relative "berkshelf/cookbook_store"
211
+ require_relative "berkshelf/config"
212
+ require_relative "berkshelf/dependency"
213
+ require_relative "berkshelf/downloader"
214
+ require_relative "berkshelf/init_generator"
215
+ require_relative "berkshelf/installer"
216
+ require_relative "berkshelf/logger"
217
+ require_relative "berkshelf/resolver"
218
+ require_relative "berkshelf/source"
219
+ require_relative "berkshelf/source_uri"
220
+ require_relative "berkshelf/validator"
221
+ require_relative "berkshelf/ssl_policies"
222
222
 
223
223
  Ridley.logger = Berkshelf.logger
224
224
  Berkshelf.logger.level = Logger::WARN
@@ -1,10 +1,10 @@
1
- require 'thor/group'
1
+ require "thor/group"
2
2
 
3
3
  module Berkshelf
4
4
  class BaseGenerator < Thor::Group
5
5
  class << self
6
6
  def source_root
7
- Berkshelf.root.join('generator_files')
7
+ Berkshelf.root.join("generator_files")
8
8
  end
9
9
  end
10
10
 
@@ -12,12 +12,11 @@ module Berkshelf
12
12
  # this generator.
13
13
  #
14
14
  # @return [Array<String>]
15
- PATTERNS = [
16
- "environment",
17
- "application",
18
- "library",
19
- "wrapper"
20
- ].freeze
15
+ PATTERNS = %w{
16
+ environment
17
+ application
18
+ library
19
+ wrapper}.freeze
21
20
 
22
21
  shell = Berkshelf.ui
23
22
 
@@ -36,8 +35,8 @@ module Berkshelf
36
35
 
37
36
  private
38
37
 
39
- def target
40
- @target ||= Pathname.new(File.expand_path(path))
41
- end
38
+ def target
39
+ @target ||= Pathname.new(File.expand_path(path))
40
+ end
42
41
  end
43
42
  end
@@ -31,7 +31,7 @@ module Berkshelf
31
31
 
32
32
  # Don't vendor VCS files.
33
33
  # Reference GNU tar --exclude-vcs: https://www.gnu.org/software/tar/manual/html_section/tar_49.html
34
- EXCLUDED_VCS_FILES_WHEN_VENDORING = ['.arch-ids', '{arch}', '.bzr', '.bzrignore', '.bzrtags', 'CVS', '.cvsignore', '_darcs', '.git', '.hg', '.hgignore', '.hgrags', 'RCS', 'SCCS', '.svn', '**/.git'].freeze
34
+ EXCLUDED_VCS_FILES_WHEN_VENDORING = [".arch-ids", "{arch}", ".bzr", ".bzrignore", ".bzrtags", "CVS", ".cvsignore", "_darcs", ".git", ".hg", ".hgignore", ".hgrags", "RCS", "SCCS", ".svn", "**/.git"].freeze
35
35
 
36
36
  include Mixin::Logging
37
37
  include Cleanroom
@@ -71,7 +71,7 @@ module Berkshelf
71
71
  @preferred_solver = :gecode
72
72
 
73
73
  if options[:except] && options[:only]
74
- raise ArgumentError, 'Cannot specify both :except and :only!'
74
+ raise ArgumentError, "Cannot specify both :except and :only!"
75
75
  elsif options[:except]
76
76
  except = Array(options[:except]).collect(&:to_sym)
77
77
  @filter = ->(dependency) { (except & dependency.groups).empty? }
@@ -173,7 +173,7 @@ module Berkshelf
173
173
  # path to the metadata file
174
174
  def metadata(options = {})
175
175
  path = options[:path] || File.dirname(filepath)
176
- metadata_path = File.expand_path(File.join(path, 'metadata.rb'))
176
+ metadata_path = File.expand_path(File.join(path, "metadata.rb"))
177
177
  metadata = Ridley::Chef::Cookbook::Metadata.from_file(metadata_path)
178
178
 
179
179
  add_dependency(metadata.name, nil, path: path, metadata: true)
@@ -306,7 +306,7 @@ module Berkshelf
306
306
  end
307
307
 
308
308
  if options[:path]
309
- metadata_file = File.join(options[:path], 'metadata.rb')
309
+ metadata_file = File.join(options[:path], "metadata.rb")
310
310
  end
311
311
 
312
312
  options[:constraint] = constraint
@@ -512,15 +512,15 @@ module Berkshelf
512
512
 
513
513
  latest = cookbooks.select do |cookbook|
514
514
  dependency.version_constraint.satisfies?(cookbook.version) &&
515
- Semverse::Version.coerce(cookbook.version) > dependency.locked_version
515
+ Semverse::Version.coerce(cookbook.version) > dependency.locked_version
516
516
  end.sort_by { |cookbook| cookbook.version }.last
517
517
 
518
518
  unless latest.nil?
519
519
  hash[name] ||= {
520
- 'local' => dependency.locked_version,
521
- 'remote' => {
522
- source => Semverse::Version.coerce(latest.version)
523
- }
520
+ "local" => dependency.locked_version,
521
+ "remote" => {
522
+ source => Semverse::Version.coerce(latest.version),
523
+ },
524
524
  }
525
525
  end
526
526
  end
@@ -609,7 +609,7 @@ module Berkshelf
609
609
  packager.validate!
610
610
 
611
611
  outdir = Dir.mktmpdir do |temp_dir|
612
- Berkshelf.ui.mute { vendor(File.join(temp_dir, 'cookbooks')) }
612
+ Berkshelf.ui.mute { vendor(File.join(temp_dir, "cookbooks")) }
613
613
  packager.run(temp_dir)
614
614
  end
615
615
 
@@ -626,7 +626,7 @@ module Berkshelf
626
626
  # @return [String, nil]
627
627
  # the expanded path cookbooks were vendored to or nil if nothing was vendored
628
628
  def vendor(destination)
629
- Dir.mktmpdir('vendor') do |scratch|
629
+ Dir.mktmpdir("vendor") do |scratch|
630
630
  chefignore = nil
631
631
  cached_cookbooks = install
632
632
  raw_metadata_files = []
@@ -639,8 +639,8 @@ module Berkshelf
639
639
  FileUtils.mkdir_p(cookbook_destination)
640
640
 
641
641
  # Dir.glob does not support backslash as a File separator
642
- src = cookbook.path.to_s.gsub('\\', '/')
643
- files = FileSyncer.glob(File.join(src, '*'))
642
+ src = cookbook.path.to_s.tr('\\', "/")
643
+ files = FileSyncer.glob(File.join(src, "*"))
644
644
 
645
645
  chefignore = Ridley::Chef::Chefignore.new(cookbook.path.to_s) rescue nil
646
646
  chefignore.apply!(files) if chefignore
@@ -649,7 +649,7 @@ module Berkshelf
649
649
  cookbook.compile_metadata(cookbook_destination)
650
650
  end
651
651
 
652
- raw_metadata_files << File::join(cookbook.cookbook_name, 'metadata.rb')
652
+ raw_metadata_files << File.join(cookbook.cookbook_name, "metadata.rb")
653
653
 
654
654
  FileUtils.cp_r(files, cookbook_destination)
655
655
  end
@@ -694,17 +694,17 @@ module Berkshelf
694
694
  #
695
695
  # @return [String] path
696
696
  # the path where the image was written
697
- def viz(outfile = nil, format = 'png')
698
- outfile = File.join(Dir.pwd, outfile || 'graph.png')
697
+ def viz(outfile = nil, format = "png")
698
+ outfile = File.join(Dir.pwd, outfile || "graph.png")
699
699
 
700
700
  validate_lockfile_present!
701
701
  validate_lockfile_trusted!
702
702
  vizualiser = Visualizer.from_lockfile(lockfile)
703
703
 
704
704
  case format
705
- when 'dot'
705
+ when "dot"
706
706
  vizualiser.to_dot_file(outfile)
707
- when 'png'
707
+ when "png"
708
708
  vizualiser.to_png(outfile)
709
709
  else
710
710
  raise ConfigurationError, "Vizualiser format #{format} not recognised."
@@ -730,10 +730,10 @@ module Berkshelf
730
730
  # if the lockfile does not exist on disk
731
731
  #
732
732
  # @return [true]
733
- def validate_lockfile_present!
734
- raise LockfileNotFound unless lockfile.present?
735
- true
736
- end
733
+ def validate_lockfile_present!
734
+ raise LockfileNotFound unless lockfile.present?
735
+ true
736
+ end
737
737
 
738
738
  # Ensure that all dependencies defined in the Berksfile exist in this
739
739
  # lockfile.
@@ -743,10 +743,10 @@ module Berkshelf
743
743
  # exist (or are not satisifed by) the lockfile
744
744
  #
745
745
  # @return [true]
746
- def validate_lockfile_trusted!
747
- raise LockfileOutOfSync unless lockfile.trusted?
748
- true
749
- end
746
+ def validate_lockfile_trusted!
747
+ raise LockfileOutOfSync unless lockfile.trusted?
748
+ true
749
+ end
750
750
 
751
751
  # Ensure that all dependencies in the lockfile are installed on this
752
752
  # system. You should validate that the lockfile can be trusted before
@@ -757,16 +757,16 @@ module Berkshelf
757
757
  # this system
758
758
  #
759
759
  # @return [true]
760
- def validate_dependencies_installed!
761
- lockfile.graph.locks.each do |_, dependency|
762
- unless dependency.installed?
763
- raise DependencyNotInstalled.new(dependency)
764
- end
760
+ def validate_dependencies_installed!
761
+ lockfile.graph.locks.each do |_, dependency|
762
+ unless dependency.installed?
763
+ raise DependencyNotInstalled.new(dependency)
765
764
  end
766
-
767
- true
768
765
  end
769
766
 
767
+ true
768
+ end
769
+
770
770
  # Determine if any cookbooks were specified that aren't in our shelf.
771
771
  #
772
772
  # @param [Array<String>] names
@@ -774,12 +774,12 @@ module Berkshelf
774
774
  #
775
775
  # @raise [DependencyNotFound]
776
776
  # if a cookbook name is given that does not exist
777
- def validate_cookbook_names!(names)
778
- missing = names - lockfile.graph.locks.keys
777
+ def validate_cookbook_names!(names)
778
+ missing = names - lockfile.graph.locks.keys
779
779
 
780
- unless missing.empty?
781
- raise DependencyNotFound.new(missing)
782
- end
780
+ unless missing.empty?
781
+ raise DependencyNotFound.new(missing)
783
782
  end
783
+ end
784
784
  end
785
785
  end