berkshelf 3.0.0.beta4 → 3.0.0.beta5

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +3 -0
  5. data/berkshelf-complete.sh +10 -3
  6. data/berkshelf.gemspec +12 -11
  7. data/features/berksfile.feature +0 -2
  8. data/features/commands/apply.feature +0 -1
  9. data/features/commands/contingent.feature +0 -3
  10. data/features/commands/cookbook.feature +0 -3
  11. data/features/commands/init.feature +0 -2
  12. data/features/commands/install.feature +42 -35
  13. data/features/commands/list.feature +0 -3
  14. data/features/commands/outdated.feature +0 -4
  15. data/features/commands/package.feature +2 -39
  16. data/features/commands/shelf/list.feature +0 -2
  17. data/features/commands/shelf/show.feature +0 -5
  18. data/features/commands/shelf/uninstall.feature +0 -5
  19. data/features/commands/show.feature +0 -3
  20. data/features/commands/update.feature +0 -3
  21. data/features/commands/upload.feature +0 -13
  22. data/features/commands/vendor.feature +0 -5
  23. data/features/community_site.feature +0 -2
  24. data/features/config.feature +0 -6
  25. data/features/json_formatter.feature +0 -5
  26. data/features/licenses.feature +0 -5
  27. data/features/lockfile.feature +0 -20
  28. data/features/step_definitions/chef_server_steps.rb +8 -2
  29. data/generator_files/Gemfile.erb +2 -2
  30. data/lib/berkshelf.rb +0 -4
  31. data/lib/berkshelf/berksfile.rb +21 -51
  32. data/lib/berkshelf/cli.rb +26 -15
  33. data/lib/berkshelf/config.rb +4 -0
  34. data/lib/berkshelf/cookbook_generator.rb +1 -1
  35. data/lib/berkshelf/cookbook_store.rb +8 -0
  36. data/lib/berkshelf/core_ext/file.rb +2 -2
  37. data/lib/berkshelf/core_ext/pathname.rb +5 -7
  38. data/lib/berkshelf/dependency.rb +8 -1
  39. data/lib/berkshelf/downloader.rb +37 -0
  40. data/lib/berkshelf/errors.rb +1 -0
  41. data/lib/berkshelf/formatters.rb +1 -0
  42. data/lib/berkshelf/formatters/human_readable.rb +23 -9
  43. data/lib/berkshelf/formatters/json.rb +7 -9
  44. data/lib/berkshelf/git.rb +0 -1
  45. data/lib/berkshelf/init_generator.rb +1 -1
  46. data/lib/berkshelf/installer.rb +43 -19
  47. data/lib/berkshelf/location.rb +8 -13
  48. data/lib/berkshelf/locations/git_location.rb +12 -19
  49. data/lib/berkshelf/locations/mercurial_location.rb +5 -18
  50. data/lib/berkshelf/locations/path_location.rb +7 -0
  51. data/lib/berkshelf/lockfile.rb +5 -1
  52. data/lib/berkshelf/packager.rb +73 -0
  53. data/lib/berkshelf/resolver.rb +7 -5
  54. data/lib/berkshelf/resolver/graph.rb +7 -0
  55. data/lib/berkshelf/source.rb +22 -2
  56. data/lib/berkshelf/ui.rb +0 -2
  57. data/lib/berkshelf/version.rb +1 -1
  58. data/spec/support/git.rb +1 -0
  59. data/spec/support/mercurial.rb +37 -36
  60. data/spec/unit/berkshelf/berksfile_spec.rb +2 -34
  61. data/spec/unit/berkshelf/cli_spec.rb +3 -2
  62. data/spec/unit/berkshelf/config_spec.rb +3 -3
  63. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +46 -0
  64. data/spec/unit/berkshelf/dependency_spec.rb +3 -3
  65. data/spec/unit/berkshelf/formatters_spec.rb +4 -4
  66. data/spec/unit/berkshelf/git_spec.rb +8 -8
  67. data/spec/unit/berkshelf/installer_spec.rb +2 -2
  68. data/spec/unit/berkshelf/locations/git_location_spec.rb +2 -8
  69. data/spec/unit/berkshelf/locations/mercurial_location_spec.rb +4 -23
  70. data/spec/unit/berkshelf/lockfile_spec.rb +1 -1
  71. data/spec/unit/berkshelf/mercurial_spec.rb +6 -7
  72. data/spec/unit/berkshelf/packager_spec.rb +39 -0
  73. data/spec/unit/berkshelf/ui_spec.rb +2 -2
  74. data/spec/unit/berkshelf_spec.rb +2 -2
  75. metadata +37 -24
  76. data/lib/berkshelf/api_client.rb +0 -65
  77. data/lib/berkshelf/api_client/remote_cookbook.rb +0 -55
  78. data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +0 -23
  79. data/spec/unit/berkshelf/api_client_spec.rb +0 -57
@@ -1,65 +0,0 @@
1
- module Berkshelf
2
- # Used to communicate with a remotely hosted [Berkshelf API Server](https://github.com/riotgames/berkshelf-api).
3
- #
4
- # @example
5
- # client = Berkshelf::APIClient.new("https://api.berkshelf.com")
6
- # client.universe #=> [...]
7
- class APIClient < Faraday::Connection
8
- require_relative 'api_client/remote_cookbook'
9
-
10
- # @return [String]
11
- attr_reader :url
12
-
13
- # @return [Integer]
14
- # how many retries to attempt on HTTP requests
15
- attr_reader :retries
16
-
17
- # @return [Float]
18
- # time to wait between retries
19
- attr_reader :retry_interval
20
-
21
- # @param [String, Addressable::URI] url
22
- #
23
- # @option options [Integer] :retries
24
- # how many retries to perform before giving up
25
- # @option options [Float] :retry_interval
26
- # how long to wait (in seconds) between each retry
27
- def initialize(url, options = {})
28
- options = options.reverse_merge(retries: 5, retry_interval: 0.5)
29
- @url = url
30
- @retries = options[:retries]
31
- @retry_interval = options[:retry_interval]
32
-
33
- options[:builder] ||= Faraday::Builder.new do |b|
34
- b.response :parse_json
35
- b.response :gzip
36
- b.request :retry,
37
- max: self.retries,
38
- interval: self.retry_interval,
39
- exceptions: [ Faraday::Error::TimeoutError ]
40
-
41
- b.adapter :net_http
42
- end
43
-
44
- super(self.url, options)
45
- end
46
-
47
- # Retrieves the entire universe of known cookbooks from the API source
48
- #
49
- # @return [Array<APIClient::RemoteCookbook>]
50
- def universe
51
- response = get("universe")
52
-
53
- case response.status
54
- when 200
55
- [].tap do |cookbooks|
56
- response.body.each do |name, versions|
57
- versions.each { |version, attributes| cookbooks << RemoteCookbook.new(name, version, attributes) }
58
- end
59
- end
60
- else
61
- raise RuntimeError, "bad response #{response.inspect}"
62
- end
63
- end
64
- end
65
- end
@@ -1,55 +0,0 @@
1
- require 'json'
2
-
3
- module Berkshelf
4
- class APIClient
5
- # A representation of cookbook metadata indexed by a Berkshelf API Server. Returned
6
- # by sending messages to a {Berkshelf::APIClient} and used to download cookbooks
7
- # indexed by the Berkshelf API Server.
8
- class RemoteCookbook
9
- # @return [String]
10
- attr_reader :name
11
- # @return [String]
12
- attr_reader :version
13
-
14
- # @param [String] name
15
- # @param [String] version
16
- # @param [Hash] attributes
17
- def initialize(name, version, attributes = {})
18
- @name = name
19
- @version = version
20
- @attributes = attributes
21
- end
22
-
23
- # @return [Hash]
24
- def dependencies
25
- @attributes[:dependencies]
26
- end
27
-
28
- # @return [Hash]
29
- def platforms
30
- @attributes[:platforms]
31
- end
32
-
33
- # @return [Symbol]
34
- def location_type
35
- @attributes[:location_type].to_sym
36
- end
37
-
38
- # @return [String]
39
- def location_path
40
- @attributes[:location_path]
41
- end
42
-
43
- def to_hash
44
- {
45
- name: name,
46
- version: version
47
- }
48
- end
49
-
50
- def to_json(options = {})
51
- ::JSON.pretty_generate(to_hash, options)
52
- end
53
- end
54
- end
55
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::APIClient::RemoteCookbook do
4
- let(:name) { "ruby" }
5
- let(:version) { "1.2.3" }
6
- let(:dependencies) { double('dependencies') }
7
- let(:platforms) { double('platforms') }
8
- let(:location_type) { "chef_server" }
9
- let(:location_path) { "http://localhost:8080" }
10
-
11
- let(:attributes) do
12
- { dependencies: dependencies, platforms: platforms, location_path: location_path, location_type: location_type }
13
- end
14
-
15
- subject { described_class.new(name, version, attributes) }
16
-
17
- its(:name) { should eql(name) }
18
- its(:version) { should eql(version) }
19
- its(:dependencies) { should eql(dependencies) }
20
- its(:platforms) { should eql(platforms) }
21
- its(:location_type) { should eql(:chef_server) }
22
- its(:location_path) { should eql(location_path) }
23
- end
@@ -1,57 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::APIClient, :api_client do
4
- let(:instance) { described_class.new("http://localhost:26210") }
5
-
6
- describe "#universe" do
7
- before do
8
- berks_dependency("ruby", "1.2.3", dependencies: { "build-essential" => ">= 1.2.2" })
9
- berks_dependency("ruby", "2.0.0", dependencies: { "build-essential" => ">= 1.2.2" })
10
- berks_dependency("elixir", "1.0.0", platforms: { "CentOS" => "6.0" })
11
- end
12
-
13
- subject { instance.universe }
14
-
15
- it "returns an array of APIClient::RemoteCookbook" do
16
- expect(subject).to be_a(Array)
17
-
18
- subject.each do |remote|
19
- expect(remote).to be_a(Berkshelf::APIClient::RemoteCookbook)
20
- end
21
- end
22
-
23
- it "contains a item for each dependency" do
24
- expect(subject).to have(3).items
25
- expect(subject[0].name).to eql("ruby")
26
- expect(subject[0].version).to eql("1.2.3")
27
- expect(subject[1].name).to eql("ruby")
28
- expect(subject[1].version).to eql("2.0.0")
29
- expect(subject[2].name).to eql("elixir")
30
- expect(subject[2].version).to eql("1.0.0")
31
- end
32
-
33
- it "has the dependencies for each" do
34
- expect(subject[0].dependencies).to include("build-essential" => ">= 1.2.2")
35
- expect(subject[1].dependencies).to include("build-essential" => ">= 1.2.2")
36
- expect(subject[2].dependencies).to be_empty
37
- end
38
-
39
- it "has the platforms for each" do
40
- expect(subject[0].platforms).to be_empty
41
- expect(subject[1].platforms).to be_empty
42
- expect(subject[2].platforms).to include("CentOS" => "= 6.0.0")
43
- end
44
-
45
- it "has a location_path for each" do
46
- subject.each do |remote|
47
- expect(remote.location_path).to_not be_nil
48
- end
49
- end
50
-
51
- it "has a location_type for each" do
52
- subject.each do |remote|
53
- expect(remote.location_type).to_not be_nil
54
- end
55
- end
56
- end
57
- end