berkshelf 3.0.0.beta2 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +0 -1
  5. data/Guardfile +0 -4
  6. data/README.md +1 -1
  7. data/Thorfile +2 -11
  8. data/berkshelf.gemspec +2 -5
  9. data/features/berksfile.feature +2 -10
  10. data/features/commands/apply.feature +31 -0
  11. data/features/{configure_command.feature → commands/configure.feature} +9 -11
  12. data/features/{contingent_command.feature → commands/contingent.feature} +10 -20
  13. data/features/{cookbook_command.feature → commands/cookbook.feature} +4 -11
  14. data/features/{init_command.feature → commands/init.feature} +10 -19
  15. data/features/{install_command.feature → commands/install.feature} +161 -82
  16. data/features/{list_command.feature → commands/list.feature} +4 -14
  17. data/features/{outdated_command.feature → commands/outdated.feature} +21 -63
  18. data/features/{package_command.feature → commands/package.feature} +11 -22
  19. data/features/{shelf → commands/shelf}/list.feature +3 -8
  20. data/features/{shelf → commands/shelf}/show.feature +5 -9
  21. data/features/{shelf → commands/shelf}/uninstall.feature +6 -10
  22. data/features/{show_command.feature → commands/show.feature} +13 -38
  23. data/features/commands/update.feature +48 -0
  24. data/features/commands/upload.feature +197 -0
  25. data/features/commands/vendor.feature +53 -0
  26. data/features/community_site.feature +39 -0
  27. data/features/config.feature +79 -9
  28. data/features/help.feature +10 -19
  29. data/features/json_formatter.feature +19 -44
  30. data/features/licenses.feature +27 -61
  31. data/features/lockfile.feature +120 -354
  32. data/features/resolver.feature +28 -0
  33. data/features/step_definitions/berksfile_steps.rb +39 -0
  34. data/features/step_definitions/chef/config_steps.rb +1 -1
  35. data/features/step_definitions/chef_server_steps.rb +27 -27
  36. data/features/step_definitions/config_steps.rb +3 -0
  37. data/features/step_definitions/filesystem_steps.rb +10 -0
  38. data/features/step_definitions/json_steps.rb +0 -7
  39. data/features/step_definitions/lockfile_steps.rb +53 -0
  40. data/features/step_definitions/utility_steps.rb +4 -4
  41. data/features/support/env.rb +1 -0
  42. data/generator_files/Berksfile.erb +1 -1
  43. data/generator_files/README.md.erb +62 -6
  44. data/generator_files/Vagrantfile.erb +15 -4
  45. data/lib/berkshelf.rb +2 -4
  46. data/lib/berkshelf/api_client.rb +5 -7
  47. data/lib/berkshelf/berksfile.rb +24 -20
  48. data/lib/berkshelf/cached_cookbook.rb +8 -1
  49. data/lib/berkshelf/cli.rb +5 -10
  50. data/lib/berkshelf/community_rest.rb +4 -5
  51. data/lib/berkshelf/config.rb +8 -2
  52. data/lib/berkshelf/cookbook_store.rb +9 -14
  53. data/lib/berkshelf/dependency.rb +16 -13
  54. data/lib/berkshelf/errors.rb +15 -1
  55. data/lib/berkshelf/formatters/json.rb +1 -1
  56. data/lib/berkshelf/init_generator.rb +17 -3
  57. data/lib/berkshelf/installer.rb +12 -1
  58. data/lib/berkshelf/logger.rb +7 -4
  59. data/lib/berkshelf/resolver.rb +1 -1
  60. data/lib/berkshelf/version.rb +1 -1
  61. data/spec/spec_helper.rb +0 -9
  62. data/spec/support/chef_server.rb +24 -7
  63. data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +3 -3
  64. data/spec/unit/berkshelf/berksfile_spec.rb +35 -1
  65. data/spec/unit/berkshelf/cached_cookbook_spec.rb +8 -0
  66. data/spec/unit/berkshelf/community_rest_spec.rb +76 -25
  67. data/spec/unit/berkshelf/cookbook_generator_spec.rb +9 -3
  68. data/spec/unit/berkshelf/dependency_spec.rb +16 -1
  69. data/spec/unit/berkshelf/init_generator_spec.rb +71 -7
  70. metadata +44 -116
  71. data/.cane +0 -4
  72. data/features/apply_command.feature +0 -40
  73. data/features/groups_install.feature +0 -113
  74. data/features/update_command.feature +0 -136
  75. data/features/upload_command.feature +0 -327
  76. data/features/vendor_command.feature +0 -83
  77. data/lib/berkshelf/chef.rb +0 -7
  78. data/lib/berkshelf/chef/cookbook.rb +0 -5
  79. data/lib/berkshelf/chef/cookbook/chefignore.rb +0 -75
  80. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_download/unpacks_the_archive.json +0 -1
  81. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
  82. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_cookbook.json +0 -1
  83. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_version.json +0 -1
  84. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/returns_the_cookbook_and_version_information.json +0 -1
  85. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
  86. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
  87. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/returns_the_version_number_of_the_latest_version_of_the_cookbook.json +0 -1
  88. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_satisfy/returns_the_version_number_of_the_best_solution.json +0 -1
  89. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
  90. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
  91. data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/returns_an_array_containing_an_item_for_each_version.json +0 -1
  92. data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +0 -3694
  93. data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_source_as_sources.yml +0 -3829
  94. data/spec/unit/berkshelf/chef/cookbook/chefignore_spec.rb +0 -19
@@ -0,0 +1,28 @@
1
+ Feature: Berkshelf resolver
2
+ Background:
3
+ * the Berkshelf API server's cache is empty
4
+ * the Chef Server has cookbooks:
5
+ | berkshelf | 1.0.0 |
6
+ | berkshelf | 2.0.0 |
7
+ * the Berkshelf API server's cache is up to date
8
+ * I have a Berksfile pointing at the local Berkshelf API with:
9
+ """
10
+ cookbook 'berkshelf'
11
+ """
12
+
13
+ Scenario: with DEBUG_RESOLVER=1
14
+ Given the environment variable DEBUG_RESOLVER is "1"
15
+ When I successfully run `berks install`
16
+ Then the output should contain:
17
+ """
18
+ Attempting to find a solution
19
+ Adding constraint berkshelf >= 0.0.0 from root
20
+ """
21
+
22
+ Scenario: without DEBUG_RESOLVER
23
+ Given the environment variable DEBUG_RESOLVER is nil
24
+ When I successfully run `berks install`
25
+ Then the output should not contain:
26
+ """
27
+ Attempting to find a solution
28
+ """
@@ -0,0 +1,39 @@
1
+ Given /I have a Berksfile pointing at the community API endpoint with:/ do |content|
2
+ steps %Q{
3
+ Given a file named "Berksfile" with:
4
+ """
5
+ source '#{Berkshelf::Berksfile::DEFAULT_API_URL}'
6
+
7
+ #{content}
8
+ """
9
+ }
10
+ end
11
+
12
+ Given /^I have a Berksfile pointing at the local Berkshelf API$/ do
13
+ steps %Q{
14
+ Given I have a Berksfile pointing at the local Berkshelf API with:
15
+ """
16
+ """
17
+ }
18
+ end
19
+
20
+ Given /^I have a Berksfile pointing at the local Berkshelf API with:$/ do |content|
21
+ steps %Q{
22
+ Given I have a Berksfile at "." pointing at the local Berkshelf API with:
23
+ """
24
+ #{content}
25
+ """
26
+ }
27
+ end
28
+
29
+ Given /^I have a Berksfile at "(.+)" pointing at the local Berkshelf API with:$/ do |path, content|
30
+ steps %Q{
31
+ Given a directory named "#{path}"
32
+ And a file named "#{path}/Berksfile" with:
33
+ """
34
+ source 'http://0.0.0.0:#{BERKS_API_PORT}'
35
+
36
+ #{content}
37
+ """
38
+ }
39
+ end
@@ -3,7 +3,7 @@ Given(/^I do not have a Berkshelf config$/) do
3
3
  end
4
4
 
5
5
  Given /^I do not have a Chef config$/ do
6
- path = tmp_path.join('knife.rb').to_s
6
+ path = tmp_path.join('knife.rb').to_s
7
7
  Berkshelf.chef_config = Ridley::Chef::Config.new(path)
8
8
  Berkshelf.chef_config.save
9
9
 
@@ -1,4 +1,4 @@
1
- World(Berkshelf::RSpec::ChefAPI)
1
+ World(Berkshelf::RSpec::ChefServer)
2
2
 
3
3
  Given(/^the Chef Server is empty$/) do
4
4
  Berkshelf::RSpec::ChefServer.reset!
@@ -6,48 +6,48 @@ end
6
6
 
7
7
  Given /^the Chef Server has cookbooks:$/ do |cookbooks|
8
8
  cookbooks.raw.each do |name, version|
9
- purge_cookbook(name, version)
10
- cb_path = generate_cookbook(tmp_path, name, version)
11
- upload_cookbook(cb_path, freeze: false, force: true)
9
+ chef_cookbook(name, { 'metadata.rb' => "version '#{version}'" })
12
10
  end
13
11
  end
14
12
 
15
13
  Given /^the Chef Server has frozen cookbooks:$/ do |cookbooks|
16
14
  cookbooks.raw.each do |name, version|
17
- purge_cookbook(name, version)
18
- cb_path = generate_cookbook(tmp_path, name, version)
19
- upload_cookbook(cb_path, freeze: true, force: true)
15
+ chef_cookbook(name, { 'metadata.rb' => "version '#{version}'", frozen: true })
20
16
  end
21
- end
17
+ end
22
18
 
23
- Then /^the Chef Server should have the cookbooks:$/ do |cookbooks|
24
- cookbooks.raw.each do |name, version|
25
- expect(server_has_cookbook?(name, version)).to be_true
26
- end
19
+ Given(/^the Chef Server has an environment named "(.*?)"$/) do |name|
20
+ chef_environment(name, { 'description' => 'This is an environment' })
27
21
  end
28
22
 
29
- Then /^the Chef Server should not have the cookbooks:$/ do |cookbooks|
30
- cookbooks.raw.each do |name, version|
31
- expect(server_has_cookbook?(name, version)).to be_false
23
+ Given(/^the Chef Server does not have an environment named "(.*?)"$/) do |name|
24
+ if chef_server.data_store.exists?(['environments', name])
25
+ chef_server.data_store.delete(['environments', name])
32
26
  end
33
27
  end
34
28
 
35
- Then(/^the version locks in the "(.*?)" environment should be:$/) do |environment_name, version_locks|
36
- environment_cookbook_versions = environment(environment_name).cookbook_versions
37
- version_locks.hashes.each do |hash|
38
- expect(environment_cookbook_versions[hash['cookbook']]).to eq(hash['version_lock'])
29
+ Then /^the Chef Server should have the cookbooks:$/ do |cookbooks|
30
+ list = chef_cookbooks
31
+ cookbooks.raw.each do |name, version|
32
+ expect(list.keys).to include(name)
33
+ expect(list[name]).to include(version) unless version.nil?
39
34
  end
40
35
  end
41
36
 
42
- Given(/^The Chef Server has an environment named "(.*?)"$/) do |environment_name|
43
- delete_environment(environment_name)
44
- begin
45
- create_environment(environment_name)
46
- rescue Ridley::Errors::HTTPConflict; end
37
+ Then /^the Chef Server should not have the cookbooks:$/ do |cookbooks|
38
+ list = chef_cookbooks
39
+ cookbooks.raw.each do |name, version|
40
+ unless version.nil?
41
+ expect(list.keys).to_not include(name)
42
+ else
43
+ expect(list[name] || []).to_not include(version)
44
+ end
45
+ end
47
46
  end
48
47
 
49
- Given(/^The Chef Server does not have an environment named "(.*?)"$/) do |environment_name|
50
- if environment_exists?(environment_name)
51
- delete_environment(environment_name)
48
+ Then(/^the version locks in the "(.*?)" environment should be:$/) do |name, locks|
49
+ list = chef_environment_locks(name)
50
+ locks.raw.each do |cookbook, version|
51
+ expect(list[cookbook]).to eq(version)
52
52
  end
53
53
  end
@@ -27,6 +27,9 @@ Then /^a Berkshelf config file should exist and contain:$/ do |table|
27
27
  check_file_presence([Berkshelf.config.path], true)
28
28
 
29
29
  table.raw.each do |key, value|
30
+ if value == "BOOLEAN[true]"
31
+ value = true
32
+ end
30
33
  expect(Berkshelf.config[key]).to eq(value)
31
34
  end
32
35
  end
@@ -208,6 +208,16 @@ Then /^I should have a new cookbook skeleton "(.*?)" with no Vagrant support$/ d
208
208
  }
209
209
  end
210
210
 
211
+ Then(/^I should have a new cookbook skeleton "(.*?)" with no Test Kitchen support$/) do |name|
212
+ expect(Pathname.new(current_dir).join(name)).to have_structure {
213
+ file "Gemfile" do
214
+ does_not_contain "gem 'test-kitchen'"
215
+ end
216
+ no_file ".kitchen.yml"
217
+ no_file ".kitchen.yml.local"
218
+ }
219
+ end
220
+
211
221
  Then /^the cookbook "(.*?)" should have the following files:$/ do |name, files|
212
222
  check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, true)
213
223
  end
@@ -14,13 +14,6 @@ class Hash
14
14
  end
15
15
  end
16
16
 
17
- Then /^the file "(.*?)" should contain JSON:$/ do |file, data|
18
- target = JSON.pretty_generate(JSON.parse(data).sort_by_key)
19
- actual = JSON.pretty_generate(JSON.parse(File.read(File.join(current_dir, file))).sort_by_key)
20
-
21
- expect(actual).to eq(target)
22
- end
23
-
24
17
  Then /^the output should contain JSON:$/ do |data|
25
18
  target = JSON.pretty_generate(JSON.parse(data).sort_by_key)
26
19
  actual = JSON.pretty_generate(JSON.parse(all_output).sort_by_key)
@@ -2,3 +2,56 @@ Then(/^the output should warn about the old lockfile format$/) do
2
2
  message = Berkshelf::Lockfile.class_eval('LockfileLegacy.send(:warning_message)')
3
3
  expect(all_output).to include(message)
4
4
  end
5
+
6
+ Given /^the Lockfile has:$/ do |table|
7
+ result = { 'dependencies' => {} }
8
+
9
+ table.raw.each do |name, locked_or_path, ref, rel|
10
+ result['dependencies'][name] = {}
11
+
12
+ if locked_or_path =~ /(\d+\.){2}\d/
13
+ result['dependencies'][name]['locked_version'] = locked_or_path
14
+ else
15
+ result['dependencies'][name]['path'] = locked_or_path
16
+ end
17
+
18
+ unless ref.nil?
19
+ result['dependencies'][name]['rel'] = ref
20
+ end
21
+
22
+ unless rel.nil?
23
+ result['dependencies'][name]['rel'] = rel
24
+ end
25
+ end
26
+
27
+ File.open(File.join(current_dir, 'Berksfile.lock'), 'w') do |file|
28
+ file.write(JSON.pretty_generate(result) + "\n")
29
+ end
30
+ end
31
+
32
+ Then /^the Lockfile should have:$/ do |table|
33
+ hash = JSON.parse(File.read(File.join(current_dir, 'Berksfile.lock')))
34
+ dependencies = hash['dependencies']
35
+
36
+ table.raw.each do |name, locked_or_path, ref, rel|
37
+ expect(dependencies).to have_key(name)
38
+
39
+ if locked_or_path =~ /(\d+\.){2}\d/
40
+ expect(dependencies[name]).to have_key('locked_version')
41
+ expect(dependencies[name]['locked_version']).to eq(locked_or_path)
42
+ else
43
+ expect(dependencies[name]).to have_key('path')
44
+ expect(dependencies[name]['path']).to eq(locked_or_path)
45
+ end
46
+
47
+ unless ref.nil?
48
+ expect(dependencies[name]).to have_key('ref')
49
+ expect(dependencies[name]['ref']).to eq(ref)
50
+ end
51
+
52
+ unless rel.nil?
53
+ expect(dependencies[name]).to have_key('rel')
54
+ expect(dependencies[name]['rel']).to eq(rel)
55
+ end
56
+ end
57
+ end
@@ -2,8 +2,8 @@ Given /^pending\s+"([^\"]+)"$/ do |msg|
2
2
  pending
3
3
  end
4
4
 
5
- Then /^the output should be the same as \`(.+)\`$/ do |command|
6
- run_simple(command)
7
- output = output_from(command)
8
- expect(all_output).to include(output)
5
+ Then /the output from \`(.+)\` should be the same as \`(.+)\`/ do |actual, expected|
6
+ run_simple(actual)
7
+ run_simple(expected)
8
+ expect(output_from(actual)).to eq(output_from(expected))
9
9
  end
@@ -36,6 +36,7 @@ Spork.prefork do
36
36
  Berkshelf.initialize_filesystem
37
37
  Berkshelf::CookbookStore.instance.initialize_filesystem
38
38
  reload_configs
39
+ Berkshelf::CachedCookbook.instance_variable_set(:@loaded_cookbooks, nil)
39
40
 
40
41
  endpoints = [
41
42
  {
@@ -1,4 +1,4 @@
1
- source "http://api.berkshelf.com"
1
+ source "https://api.berkshelf.com"
2
2
  <% if options[:chef_minitest] -%>
3
3
 
4
4
  group :integration do
@@ -1,13 +1,69 @@
1
- # <%= name %> cookbook
1
+ <%= name %> cookbook
2
+ <%= '='*"#{name} cookbook".length %>
3
+ TODO: Enter the cookbook description here.
2
4
 
3
- # Requirements
5
+ e.g.
6
+ This cookbook makes your favorite breakfast sandwich.
4
7
 
5
- # Usage
8
+ Requirements
9
+ ------------
10
+ TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
6
11
 
7
- # Attributes
12
+ e.g.
13
+ #### packages
14
+ - `toaster` - <%= name %> needs toaster to brown your bagel.
8
15
 
9
- # Recipes
16
+ Attributes
17
+ ----------
18
+ TODO: List you cookbook attributes here.
10
19
 
11
- # Author
20
+ e.g.
21
+ #### <%= name %>::default
22
+ <table>
23
+ <tr>
24
+ <th>Key</th>
25
+ <th>Type</th>
26
+ <th>Description</th>
27
+ <th>Default</th>
28
+ </tr>
29
+ <tr>
30
+ <td><tt>['<%= name %>']['bacon']</tt></td>
31
+ <td>Boolean</td>
32
+ <td>whether to include bacon</td>
33
+ <td><tt>true</tt></td>
34
+ </tr>
35
+ </table>
12
36
 
37
+ Usage
38
+ -----
39
+ #### <%= name %>::default
40
+ TODO: Write usage instructions for each cookbook.
41
+
42
+ e.g.
43
+ Just include `<%= name %>` in your node's `run_list`:
44
+
45
+ ```json
46
+ {
47
+ "name":"my_node",
48
+ "run_list": [
49
+ "recipe[<%= name %>]"
50
+ ]
51
+ }
52
+ ```
53
+
54
+ Contributing
55
+ ------------
56
+ TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
57
+
58
+ e.g.
59
+
60
+ 1. Fork the repository on Github
61
+ 2. Create a named feature branch (like `add_component_x`)
62
+ 3. Write you change
63
+ 4. Write tests for your change (if applicable)
64
+ 5. Run the tests, ensuring they all pass
65
+ 6. Submit a Pull Request using Github
66
+
67
+ License and Authors
68
+ -------------------
13
69
  Author:: <%= maintainer %> (<<%= maintainer_email %>>)
@@ -8,6 +8,17 @@ Vagrant.configure("2") do |config|
8
8
 
9
9
  config.vm.hostname = "<%= "#{cookbook_name.gsub('_','-')}-berkshelf" %>"
10
10
 
11
+ # Set the version of chef to install using the vagrant-omnibus plugin
12
+ <% if berkshelf_config.vagrant.omnibus.enabled -%>
13
+ <% if berkshelf_config.vagrant.omnibus.version == "latest" -%>
14
+ config.omnibus.chef_version = :latest
15
+ <% else %>
16
+ config.omnibus.chef_version = "<%= berkshelf_config.vagrant.omnibus.version %>"
17
+ <% end -%>
18
+ <% else %>
19
+ #config.omnibus.chef_version = :latest
20
+ <% end -%>
21
+
11
22
  # Every Vagrant virtual environment requires a box to build off of.
12
23
  config.vm.box = "<%= berkshelf_config.vagrant.vm.box %>"
13
24
 
@@ -96,10 +107,10 @@ Vagrant.configure("2") do |config|
96
107
  <% elsif berkshelf_config.vagrant.vm.provision == "chef_solo" -%>
97
108
  config.vm.provision :chef_solo do |chef|
98
109
  chef.json = {
99
- :mysql => {
100
- :server_root_password => 'rootpass',
101
- :server_debian_password => 'debpass',
102
- :server_repl_password => 'replpass'
110
+ mysql: {
111
+ server_root_password: 'rootpass',
112
+ server_debian_password: 'debpass',
113
+ server_repl_password: 'replpass'
103
114
  }
104
115
  }
105
116
 
@@ -1,6 +1,5 @@
1
1
  require 'buff/extensions'
2
2
  require 'archive/tar/minitar'
3
- require 'celluloid'
4
3
  require 'digest/md5'
5
4
  require 'forwardable'
6
5
  require 'hashie'
@@ -42,7 +41,7 @@ module Berkshelf
42
41
  @ui ||= Thor::Base.shell.new
43
42
  end
44
43
 
45
- # Returns the filepath to the location Berskhelf will use for
44
+ # Returns the filepath to the location Berkshelf will use for
46
45
  # storage; temp files will go here, Cookbooks will be downloaded
47
46
  # to or uploaded from here. By default this is '~/.berkshelf' but
48
47
  # can be overridden by specifying a value for the ENV variable
@@ -143,7 +142,6 @@ require_relative 'berkshelf/api_client'
143
142
  require_relative 'berkshelf/base_generator'
144
143
  require_relative 'berkshelf/berksfile'
145
144
  require_relative 'berkshelf/cached_cookbook'
146
- require_relative 'berkshelf/chef'
147
145
  require_relative 'berkshelf/cli'
148
146
  require_relative 'berkshelf/community_rest'
149
147
  require_relative 'berkshelf/cookbook_generator'
@@ -165,5 +163,5 @@ require_relative 'berkshelf/source_uri'
165
163
  require_relative 'berkshelf/ui'
166
164
  require_relative 'berkshelf/version'
167
165
 
168
- Ridley.logger = Celluloid.logger = Berkshelf.logger = Logger.new(STDOUT)
166
+ Ridley.logger = Berkshelf.logger = Logger.new(STDOUT)
169
167
  Berkshelf.logger.level = Logger::WARN
@@ -1,15 +1,13 @@
1
- require 'addressable/uri'
2
-
3
1
  module Berkshelf
4
2
  # Used to communicate with a remotely hosted [Berkshelf API Server](https://github.com/riotgames/berkshelf-api).
5
3
  #
6
4
  # @example
7
- # client = Berkshelf::APIClient.new("http://api.berkshelf.com")
5
+ # client = Berkshelf::APIClient.new("https://api.berkshelf.com")
8
6
  # client.universe #=> [...]
9
7
  class APIClient < Faraday::Connection
10
8
  require_relative 'api_client/remote_cookbook'
11
9
 
12
- # @return [Addressable::URI]
10
+ # @return [String]
13
11
  attr_reader :url
14
12
 
15
13
  # @return [Integer]
@@ -28,11 +26,11 @@ module Berkshelf
28
26
  # how long to wait (in seconds) between each retry
29
27
  def initialize(url, options = {})
30
28
  options = options.reverse_merge(retries: 5, retry_interval: 0.5)
31
- @url = Addressable::URI.parse(url)
29
+ @url = url
32
30
  @retries = options[:retries]
33
31
  @retry_interval = options[:retry_interval]
34
32
 
35
- builder = Faraday::Builder.new do |b|
33
+ options[:builder] ||= Faraday::Builder.new do |b|
36
34
  b.response :parse_json
37
35
  b.response :gzip
38
36
  b.request :retry,
@@ -43,7 +41,7 @@ module Berkshelf
43
41
  b.adapter :net_http
44
42
  end
45
43
 
46
- super(self.url, builder: builder)
44
+ super(self.url, options)
47
45
  end
48
46
 
49
47
  # Retrieves the entire universe of known cookbooks from the API source