berkshelf 0.4.0.rc4 → 0.4.0

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 (56) hide show
  1. data/.gitignore +2 -0
  2. data/Guardfile +6 -3
  3. data/features/default_locations.feature +122 -0
  4. data/features/install.feature +20 -4
  5. data/features/lockfile.feature +1 -6
  6. data/features/update.feature +2 -3
  7. data/generator_files/Berksfile.erb +2 -0
  8. data/generator_files/gitignore.erb +6 -0
  9. data/lib/berkshelf.rb +6 -10
  10. data/lib/berkshelf/berksfile.rb +203 -14
  11. data/lib/berkshelf/cached_cookbook.rb +5 -1
  12. data/lib/berkshelf/cli.rb +4 -0
  13. data/lib/berkshelf/cookbook_source.rb +49 -91
  14. data/lib/berkshelf/cookbook_store.rb +2 -0
  15. data/lib/berkshelf/downloader.rb +71 -51
  16. data/lib/berkshelf/errors.rb +7 -3
  17. data/lib/berkshelf/formatters.rb +6 -6
  18. data/lib/berkshelf/location.rb +171 -0
  19. data/lib/berkshelf/locations/chef_api_location.rb +252 -0
  20. data/lib/berkshelf/locations/git_location.rb +76 -0
  21. data/lib/berkshelf/locations/path_location.rb +38 -0
  22. data/lib/berkshelf/locations/site_location.rb +150 -0
  23. data/lib/berkshelf/lockfile.rb +2 -2
  24. data/lib/berkshelf/resolver.rb +12 -15
  25. data/lib/berkshelf/uploader.rb +2 -9
  26. data/lib/berkshelf/version.rb +1 -1
  27. data/spec/fixtures/lockfile_spec/without_lock/.gitkeep +0 -0
  28. data/spec/support/chef_api.rb +7 -1
  29. data/spec/unit/berkshelf/berksfile_spec.rb +157 -12
  30. data/spec/unit/berkshelf/cached_cookbook_spec.rb +19 -0
  31. data/spec/unit/berkshelf/cookbook_generator_spec.rb +1 -0
  32. data/spec/unit/berkshelf/cookbook_source_spec.rb +25 -35
  33. data/spec/unit/berkshelf/cookbook_store_spec.rb +3 -3
  34. data/spec/unit/berkshelf/downloader_spec.rb +171 -43
  35. data/spec/unit/berkshelf/formatters_spec.rb +13 -16
  36. data/spec/unit/berkshelf/{cookbook_source/location_spec.rb → location_spec.rb} +10 -10
  37. data/spec/unit/berkshelf/{cookbook_source → locations}/chef_api_location_spec.rb +4 -4
  38. data/spec/unit/berkshelf/{cookbook_source → locations}/git_location_spec.rb +8 -8
  39. data/spec/unit/berkshelf/{cookbook_source → locations}/path_location_spec.rb +5 -5
  40. data/spec/unit/berkshelf/{cookbook_source → locations}/site_location_spec.rb +17 -3
  41. data/spec/unit/berkshelf/lockfile_spec.rb +26 -17
  42. data/spec/unit/berkshelf/resolver_spec.rb +6 -5
  43. data/spec/unit/berkshelf/uploader_spec.rb +6 -4
  44. metadata +27 -31
  45. data/lib/berkshelf/cookbook_source/chef_api_location.rb +0 -256
  46. data/lib/berkshelf/cookbook_source/git_location.rb +0 -78
  47. data/lib/berkshelf/cookbook_source/location.rb +0 -167
  48. data/lib/berkshelf/cookbook_source/path_location.rb +0 -40
  49. data/lib/berkshelf/cookbook_source/site_location.rb +0 -149
  50. data/lib/berkshelf/dsl.rb +0 -45
  51. data/lib/berkshelf/tx_result.rb +0 -12
  52. data/lib/berkshelf/tx_result_set.rb +0 -37
  53. data/spec/fixtures/lockfile_spec/without_lock/Berksfile.lock +0 -5
  54. data/spec/unit/berkshelf/dsl_spec.rb +0 -42
  55. data/spec/unit/berkshelf/tx_result_set_spec.rb +0 -77
  56. data/spec/unit/berkshelf/tx_result_spec.rb +0 -21
@@ -1,12 +0,0 @@
1
- module Berkshelf
2
- # @author Jamie Winsor <jamie@vialstudios.com>
3
- class TXResult < Struct.new(:status, :message, :source)
4
- def failed?
5
- status == :error
6
- end
7
-
8
- def success?
9
- status == :ok
10
- end
11
- end
12
- end
@@ -1,37 +0,0 @@
1
- module Berkshelf
2
- # @author Jamie Winsor <jamie@vialstudios.com>
3
- class TXResultSet
4
- attr_reader :results
5
-
6
- def initialize
7
- @results = []
8
- end
9
-
10
- def add_result(result)
11
- unless validate_result(result)
12
- raise ArgumentError, "Invalid Result: results must respond to :failed? and :success?"
13
- end
14
-
15
- @results << result
16
- end
17
-
18
- def failed
19
- results.select { |result| result.failed? }
20
- end
21
-
22
- def success
23
- results.select { |result| result.success? }
24
- end
25
-
26
- def has_errors?
27
- !failed.empty?
28
- end
29
-
30
- private
31
-
32
- def validate_result(result)
33
- result.respond_to?(:failed?) &&
34
- result.respond_to?(:success?)
35
- end
36
- end
37
- end
@@ -1,5 +0,0 @@
1
- cookbook 'nginx', :locked_version => '0.101.0'
2
- cookbook 'build-essential', :locked_version => '1.1.0'
3
- cookbook 'runit', :locked_version => '0.15.0'
4
- cookbook 'bluepill', :locked_version => '1.0.6'
5
- cookbook 'ohai', :locked_version => '1.0.2'
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
- require 'berkshelf/dsl'
3
-
4
- module Berkshelf
5
- describe DSL do
6
- subject do
7
- Class.new do
8
- include Berkshelf::DSL
9
- end.new
10
- end
11
-
12
- describe "#cookbook" do
13
- it "calls add source to the instance of the implementing class with a CookbookSource" do
14
- subject.should_receive(:add_source).with(kind_of(CookbookSource))
15
-
16
- subject.cookbook "ntp"
17
- end
18
- end
19
-
20
- describe '#group' do
21
- it "calls add source to the instance of the implementing class with a CookbookSource" do
22
- subject.should_receive(:add_source).with(kind_of(CookbookSource))
23
-
24
- subject.group "awesome" do
25
- subject.cookbook "ntp"
26
- end
27
- end
28
- end
29
-
30
- describe "#metadata" do
31
- before(:each) do
32
- Dir.chdir fixtures_path.join('cookbooks/example_cookbook')
33
- end
34
-
35
- it "calls add source to the instance of the implementing class with a CookbookSource" do
36
- subject.should_receive(:add_source).with(kind_of(CookbookSource))
37
-
38
- subject.metadata
39
- end
40
- end
41
- end
42
- end
@@ -1,77 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Berkshelf
4
- describe TXResultSet do
5
- subject { TXResultSet.new }
6
-
7
- let(:failed_result) do
8
- result = double("result")
9
- result.stub(:failed?) { true }
10
- result.stub(:success?) { false }
11
- result
12
- end
13
-
14
- let(:successful_result) do
15
- result = double("result")
16
- result.stub(:failed?) { false }
17
- result.stub(:success?) { true }
18
- result
19
- end
20
-
21
- describe "#add_result" do
22
- it "adds a result to the results attribute" do
23
- subject.add_result(successful_result)
24
-
25
- subject.results.should have(1).result
26
- end
27
-
28
- it "raises an ArgumentError if an invalid result is given" do
29
- lambda {
30
- subject.add_result("string_isnt_a_result")
31
- }.should raise_error(ArgumentError)
32
- end
33
- end
34
-
35
- describe "#failed" do
36
- it "returns the failed results if there were failed results" do
37
- subject.add_result(failed_result)
38
-
39
- subject.failed.should have(1).result
40
- end
41
-
42
- it "returns no results if there were no failures" do
43
- subject.add_result(successful_result)
44
-
45
- subject.failed.should have(0).results
46
- end
47
- end
48
-
49
- describe "#success" do
50
- it "returns the successful results if there were successful results" do
51
- subject.add_result(successful_result)
52
-
53
- subject.success.should have(1).result
54
- end
55
-
56
- it "returns no results if there were no successes" do
57
- subject.add_result(failed_result)
58
-
59
- subject.success.should have(0).results
60
- end
61
- end
62
-
63
- describe "#has_errors?" do
64
- it "returns true if any result was a failure" do
65
- subject.add_result(failed_result)
66
-
67
- subject.failed.should be_true
68
- end
69
-
70
- it "returns false if every result was a success" do
71
- subject.add_result(successful_result)
72
-
73
- subject.failed.should be_true
74
- end
75
- end
76
- end
77
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Berkshelf
4
- describe TXResult do
5
- describe "#failed?" do
6
- subject { TXResult.new(:error, "message") }
7
-
8
- it "returns true when the status is :error" do
9
- subject.failed?.should be_true
10
- end
11
- end
12
-
13
- describe "#success" do
14
- subject { TXResult.new(:ok, "message") }
15
-
16
- it "returns true when the status is :ok" do
17
- subject.success?.should be_true
18
- end
19
- end
20
- end
21
- end