berkshelf 0.4.0 → 0.5.0.rc1

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 (51) hide show
  1. data/berkshelf.gemspec +8 -3
  2. data/bin/berks +1 -1
  3. data/features/groups_install.feature +67 -0
  4. data/features/install.feature +1 -71
  5. data/features/json_formatter.feature +0 -17
  6. data/features/step_definitions/filesystem_steps.rb +1 -3
  7. data/features/update.feature +3 -6
  8. data/features/vendor_install.feature +20 -0
  9. data/generator_files/Vagrantfile.erb +25 -3
  10. data/lib/berkshelf.rb +27 -17
  11. data/lib/berkshelf/base_generator.rb +5 -0
  12. data/lib/berkshelf/berksfile.rb +82 -77
  13. data/lib/berkshelf/cli.rb +37 -26
  14. data/lib/berkshelf/cookbook_source.rb +14 -4
  15. data/lib/berkshelf/errors.rb +4 -1
  16. data/lib/berkshelf/formatters.rb +69 -5
  17. data/lib/berkshelf/formatters/human_readable.rb +26 -8
  18. data/lib/berkshelf/formatters/json.rb +51 -23
  19. data/lib/berkshelf/init_generator.rb +4 -4
  20. data/lib/berkshelf/location.rb +29 -6
  21. data/lib/berkshelf/locations/chef_api_location.rb +23 -5
  22. data/lib/berkshelf/locations/git_location.rb +13 -6
  23. data/lib/berkshelf/locations/path_location.rb +8 -4
  24. data/lib/berkshelf/locations/site_location.rb +9 -3
  25. data/lib/berkshelf/ui.rb +34 -0
  26. data/lib/berkshelf/uploader.rb +37 -103
  27. data/lib/berkshelf/vagrant.rb +65 -0
  28. data/lib/berkshelf/vagrant/action/clean.rb +24 -0
  29. data/lib/berkshelf/vagrant/action/install.rb +47 -0
  30. data/lib/berkshelf/vagrant/action/set_ui.rb +17 -0
  31. data/lib/berkshelf/vagrant/action/upload.rb +40 -0
  32. data/lib/berkshelf/vagrant/config.rb +70 -0
  33. data/lib/berkshelf/vagrant/middleware.rb +52 -0
  34. data/lib/berkshelf/version.rb +1 -1
  35. data/lib/thor/monkies.rb +3 -0
  36. data/lib/thor/monkies/hash_with_indifferent_access.rb +13 -0
  37. data/lib/vagrant_init.rb +2 -0
  38. data/spec/spec_helper.rb +5 -0
  39. data/spec/support/chef_api.rb +6 -1
  40. data/spec/unit/berkshelf/berksfile_spec.rb +93 -55
  41. data/spec/unit/berkshelf/formatters_spec.rb +99 -1
  42. data/spec/unit/berkshelf/init_generator_spec.rb +1 -1
  43. data/spec/unit/berkshelf/location_spec.rb +44 -7
  44. data/spec/unit/berkshelf/lockfile_spec.rb +2 -2
  45. data/spec/unit/berkshelf/uploader_spec.rb +2 -20
  46. data/spec/unit/berkshelf_spec.rb +2 -2
  47. metadata +100 -14
  48. data/features/without.feature +0 -26
  49. data/lib/berkshelf/core_ext/fileutils.rb +0 -90
  50. data/lib/berkshelf/core_ext/kernel.rb +0 -33
  51. data/spec/unit/berkshelf/core_ext/fileutils_spec.rb +0 -20
@@ -1,7 +1,106 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Berkshelf
4
+ describe Formatters do
5
+ before(:each) do
6
+ @original = Formatters.class_variable_get :@@formatters
7
+ Formatters.class_variable_set :@@formatters, Hash.new
8
+ end
9
+
10
+ after(:each) do
11
+ Formatters.class_variable_set :@@formatters, @original
12
+ end
13
+
14
+ describe "ClassMethods" do
15
+ subject { Formatters }
16
+ let(:format_id) { :rspec }
17
+ let(:format_klass) { Class.new }
18
+
19
+ describe "::register" do
20
+ it "adds the class of the includer to the list of registered formatters with the id" do
21
+ subject.register(format_id, format_klass)
22
+
23
+ subject.formatters.should have_key(format_id)
24
+ subject.formatters[format_id].should eql(format_klass)
25
+ end
26
+
27
+ context "when given a string instead of a symbol as the ID" do
28
+ it "converts the string to a symbol and registers it" do
29
+ subject.register("rspec", format_klass)
30
+
31
+ subject.formatters.should have_key(:rspec)
32
+ subject.formatters[:rspec].should eql(format_klass)
33
+ end
34
+ end
35
+
36
+ context "when a formatter of the given ID has already been registered" do
37
+ it "raises an InternalError" do
38
+ subject.register(format_id, format_klass)
39
+
40
+ lambda {
41
+ subject.register(format_id, format_klass)
42
+ }.should raise_error(Berkshelf::InternalError)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "::formatters" do
48
+ before(:each) do
49
+ subject.register(format_id, format_klass)
50
+ end
51
+
52
+ it "returns a hash where formatter ID's are keys and values are formatter classes" do
53
+ subject.formatters.should be_a(Hash)
54
+ subject.formatters.should have(1).item
55
+ subject.formatters.keys.first.should eql(format_id)
56
+ subject.formatters.values.first.should eql(format_klass)
57
+ end
58
+ end
59
+
60
+ describe "::get" do
61
+ before(:each) do
62
+ subject.register(format_id, format_klass)
63
+ end
64
+
65
+ it "returns the class constant of the given formatter ID" do
66
+ subject[format_id].should eql(format_klass)
67
+ end
68
+
69
+ context "when the ID has not been registered" do
70
+ it "returns nil" do
71
+ subject[:not_there].should be_nil
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+
4
78
  describe Formatters::AbstractFormatter do
79
+ before(:each) do
80
+ @original = Formatters.class_variable_get :@@formatters
81
+ Formatters.class_variable_set :@@formatters, Hash.new
82
+ end
83
+
84
+ after(:each) do
85
+ Formatters.class_variable_set :@@formatters, @original
86
+ end
87
+
88
+ describe "ClassMethods" do
89
+ subject do
90
+ Class.new do
91
+ include Formatters::AbstractFormatter
92
+ end
93
+ end
94
+
95
+ describe "::register_formatter" do
96
+ it "delegates to Formatters" do
97
+ Formatters.should_receive(:register).with(:rspec, subject)
98
+
99
+ subject.register_formatter(:rspec)
100
+ end
101
+ end
102
+ end
103
+
5
104
  subject do
6
105
  Class.new do
7
106
  include Formatters::AbstractFormatter
@@ -13,7 +112,6 @@ module Berkshelf
13
112
  lambda { subject.use("my_coobook","1.2.3") }.should raise_error(AbstractFunction)
14
113
  lambda { subject.use("my_coobook","1.2.3","http://community") }.should raise_error(AbstractFunction)
15
114
  lambda { subject.upload("my_coobook","1.2.3","http://chef_server") }.should raise_error(AbstractFunction)
16
- lambda { subject.shims_written("/Users/jcocktosten") }.should raise_error(AbstractFunction)
17
115
  lambda { subject.msg("something you should know") }.should raise_error(AbstractFunction)
18
116
  lambda { subject.error("whoa this is bad") }.should raise_error(AbstractFunction)
19
117
  end
@@ -61,12 +61,12 @@ module Berkshelf
61
61
  specify do
62
62
  target.should have_structure {
63
63
  file "Vagrantfile" do
64
+ contains "require 'berkshelf/vagrant'"
64
65
  contains "recipe[some_cookbook::default]"
65
66
  end
66
67
  file "Gemfile" do
67
68
  contains "gem 'vagrant'"
68
69
  end
69
- directory "cookbooks"
70
70
  }
71
71
  end
72
72
  end
@@ -7,7 +7,7 @@ module Berkshelf
7
7
  end
8
8
  end
9
9
 
10
- describe "::location_key" do
10
+ describe "::set_location_key" do
11
11
  before(:each) do
12
12
  @original = CookbookSource.class_variable_get :@@location_keys
13
13
  CookbookSource.class_variable_set :@@location_keys, {}
@@ -18,7 +18,7 @@ module Berkshelf
18
18
  end
19
19
 
20
20
  it "adds the given location key with the includer's Class to CookbookSource.location_keys" do
21
- subject.location_key(:reset)
21
+ subject.set_location_key(:reset)
22
22
 
23
23
  CookbookSource.location_keys.should have(1).item
24
24
  CookbookSource.location_keys.should include(:reset)
@@ -26,7 +26,24 @@ module Berkshelf
26
26
  end
27
27
  end
28
28
 
29
- describe "::valid_options" do
29
+ describe "::location_key" do
30
+ before(:each) do
31
+ @original = CookbookSource.class_variable_get :@@location_keys
32
+ CookbookSource.class_variable_set :@@location_keys, {}
33
+ end
34
+
35
+ after(:each) do
36
+ CookbookSource.class_variable_set :@@location_keys, @original
37
+ end
38
+
39
+ it "returns the class' registered location key" do
40
+ subject.set_location_key(:reset)
41
+
42
+ subject.location_key.should eql(:reset)
43
+ end
44
+ end
45
+
46
+ describe "::set_valid_options" do
30
47
  before(:each) do
31
48
  @original = CookbookSource.class_variable_get :@@valid_options
32
49
  CookbookSource.class_variable_set :@@valid_options, []
@@ -37,14 +54,14 @@ module Berkshelf
37
54
  end
38
55
 
39
56
  it "adds the given symbol to the list of valid options on CookbookSource" do
40
- subject.valid_options(:mundo)
57
+ subject.set_valid_options(:mundo)
41
58
 
42
59
  CookbookSource.valid_options.should have(1).item
43
60
  CookbookSource.valid_options.should include(:mundo)
44
61
  end
45
62
 
46
63
  it "adds parameters to the list of valid options on the CookbookSource" do
47
- subject.valid_options(:riot, :arenanet)
64
+ subject.set_valid_options(:riot, :arenanet)
48
65
 
49
66
  CookbookSource.valid_options.should have(2).items
50
67
  CookbookSource.valid_options.should include(:riot)
@@ -150,7 +167,7 @@ module Berkshelf
150
167
  end
151
168
 
152
169
  describe "#validate_cached" do
153
- let(:cached) { double('cached-cb', version: "0.1.0") }
170
+ let(:cached) { double('cached-cb', cookbook_name: name, version: "0.1.0") }
154
171
 
155
172
  it "raises a ConstraintNotSatisfied error if the version constraint does not satisfy the cached version" do
156
173
  constraint.should_receive(:satisfies?).with(cached.version).and_return(false)
@@ -160,11 +177,31 @@ module Berkshelf
160
177
  }.should raise_error(ConstraintNotSatisfied)
161
178
  end
162
179
 
163
- it "returns true if the version constraint satisfies the cached version" do
180
+ it "returns true if cached_cookbooks satisfies the version constraint" do
164
181
  constraint.should_receive(:satisfies?).with(cached.version).and_return(true)
165
182
 
166
183
  subject.validate_cached(cached).should be_true
167
184
  end
185
+
186
+ context "when the cached_cookbooks satisfies the version constraint" do
187
+ it "returns true if the name of the cached_cookbook matches the name of the location" do
188
+ constraint.should_receive(:satisfies?).with(cached.version).and_return(true)
189
+ cached.stub(:name) { name }
190
+
191
+ subject.validate_cached(cached).should be_true
192
+ end
193
+
194
+ it "raises an AmbiguousCookbookName error if the cached_cookbook's name does not match the location's" do
195
+ pending "Implement when Opscode makes the 'name' a required attribute in Cookbook metadata"
196
+
197
+ constraint.should_receive(:satisfies?).with(cached.version).and_return(true)
198
+ cached.stub(:cookbook_name) { "artifact" }
199
+
200
+ lambda {
201
+ subject.validate_cached(cached)
202
+ }.should raise_error(AmbiguousCookbookName)
203
+ end
204
+ end
168
205
  end
169
206
  end
170
207
  end
@@ -22,8 +22,8 @@ module Berkshelf
22
22
  Lockfile.new(resolver.sources).write
23
23
 
24
24
  File.read('Berksfile.lock').split(/\r?\n/).sort.should == [
25
- "cookbook 'bluepill', :locked_version => '1.0.4'",
26
- "cookbook 'build-essential', :locked_version => '1.0.2'",
25
+ "cookbook 'bluepill', :locked_version => '1.1.0'",
26
+ "cookbook 'build-essential', :locked_version => '1.1.0'",
27
27
  "cookbook 'nginx', :locked_version => '0.101.0'",
28
28
  "cookbook 'ohai', :locked_version => '1.0.2'",
29
29
  "cookbook 'runit', :locked_version => '0.15.0'"
@@ -2,30 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  module Berkshelf
4
4
  describe Uploader do
5
- subject { Uploader.new(Chef::Config[:chef_server_url], client_key: Chef::Config[:client_key], node_name: Chef::Config[:node_name]) }
5
+ subject { Uploader.new(server_url: Chef::Config[:chef_server_url], client_key: Chef::Config[:client_key], client_name: Chef::Config[:node_name]) }
6
6
 
7
7
  describe "#upload" do
8
8
  let(:cookbook) { double('nginx', name: "nginx-0.101.2", cookbook_name: "nginx", version: "0.101.2") }
9
9
 
10
- context "when cookbook is valid" do
11
- before(:each) do
12
- cookbook.should_receive(:validate!).and_return(true)
13
- cookbook.should_receive(:checksums).and_return(
14
- "da97c94bb6acb2b7900cbf951654fea3" =>
15
- File.expand_path("spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb")
16
- )
17
- subject.should_receive(:create_sandbox)
18
- subject.should_receive(:upload_checksums_to_sandbox)
19
- subject.should_receive(:commit_sandbox)
20
- subject.should_receive(:save_cookbook)
21
- end
22
-
23
- it "returns true" do
24
- subject.upload(cookbook).should be_true
25
- end
26
- end
27
-
28
- context "when cookbook is not valid" do
10
+ context "when cookbook is invalid" do
29
11
  before(:each) { cookbook.should_receive(:validate!).and_raise(CookbookSyntaxError) }
30
12
 
31
13
  it "raises a CookbookSyntaxError error" do
@@ -60,11 +60,11 @@ describe Berkshelf do
60
60
 
61
61
  class CustomFormatter
62
62
  include Berkshelf::Formatters::AbstractFormatter
63
- Berkshelf.formatters["custom"] = self
63
+ register_formatter :custom
64
64
  end
65
65
 
66
66
  before do
67
- Berkshelf.set_format "custom"
67
+ Berkshelf.set_format :custom
68
68
  end
69
69
 
70
70
  it "should be the custom class" do
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.5.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josiah Kiehl
@@ -12,8 +12,24 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-09-11 00:00:00.000000000 Z
15
+ date: 2012-09-19 00:00:00.000000000 Z
16
16
  dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: ridley
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.3
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.3
17
33
  - !ruby/object:Gem::Dependency
18
34
  name: solve
19
35
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +94,54 @@ dependencies:
78
94
  - - ~>
79
95
  - !ruby/object:Gem::Version
80
96
  version: 0.16.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: vagrant
99
+ requirement: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ version: 1.0.3
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 1.0.3
113
+ - !ruby/object:Gem::Dependency
114
+ name: activesupport
115
+ requirement: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ - !ruby/object:Gem::Dependency
130
+ name: multi_json
131
+ requirement: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ type: :runtime
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
81
145
  - !ruby/object:Gem::Dependency
82
146
  name: redcarpet
83
147
  requirement: !ruby/object:Gem::Requirement
@@ -350,6 +414,22 @@ dependencies:
350
414
  - - ! '>='
351
415
  - !ruby/object:Gem::Version
352
416
  version: '0'
417
+ - !ruby/object:Gem::Dependency
418
+ name: rb-fsevent
419
+ requirement: !ruby/object:Gem::Requirement
420
+ none: false
421
+ requirements:
422
+ - - ~>
423
+ - !ruby/object:Gem::Version
424
+ version: 0.9.1
425
+ type: :development
426
+ prerelease: false
427
+ version_requirements: !ruby/object:Gem::Requirement
428
+ none: false
429
+ requirements:
430
+ - - ~>
431
+ - !ruby/object:Gem::Version
432
+ version: 0.9.1
353
433
  description: Manages a Cookbook's, or an Application's, Cookbook dependencies
354
434
  email:
355
435
  - josiah@skirmisher.net
@@ -372,6 +452,7 @@ files:
372
452
  - bin/berks
373
453
  - features/cookbook_command.feature
374
454
  - features/default_locations.feature
455
+ - features/groups_install.feature
375
456
  - features/init_command.feature
376
457
  - features/install.feature
377
458
  - features/json_formatter.feature
@@ -384,7 +465,7 @@ files:
384
465
  - features/support/env.rb
385
466
  - features/update.feature
386
467
  - features/upload_command.feature
387
- - features/without.feature
468
+ - features/vendor_install.feature
388
469
  - generator_files/Berksfile.erb
389
470
  - generator_files/Gemfile.erb
390
471
  - generator_files/README.md.erb
@@ -409,8 +490,6 @@ files:
409
490
  - lib/berkshelf/cookbook_store.rb
410
491
  - lib/berkshelf/core_ext.rb
411
492
  - lib/berkshelf/core_ext/file.rb
412
- - lib/berkshelf/core_ext/fileutils.rb
413
- - lib/berkshelf/core_ext/kernel.rb
414
493
  - lib/berkshelf/core_ext/pathname.rb
415
494
  - lib/berkshelf/core_ext/string.rb
416
495
  - lib/berkshelf/downloader.rb
@@ -428,8 +507,19 @@ files:
428
507
  - lib/berkshelf/lockfile.rb
429
508
  - lib/berkshelf/resolver.rb
430
509
  - lib/berkshelf/thor.rb
510
+ - lib/berkshelf/ui.rb
431
511
  - lib/berkshelf/uploader.rb
512
+ - lib/berkshelf/vagrant.rb
513
+ - lib/berkshelf/vagrant/action/clean.rb
514
+ - lib/berkshelf/vagrant/action/install.rb
515
+ - lib/berkshelf/vagrant/action/set_ui.rb
516
+ - lib/berkshelf/vagrant/action/upload.rb
517
+ - lib/berkshelf/vagrant/config.rb
518
+ - lib/berkshelf/vagrant/middleware.rb
432
519
  - lib/berkshelf/version.rb
520
+ - lib/thor/monkies.rb
521
+ - lib/thor/monkies/hash_with_indifferent_access.rb
522
+ - lib/vagrant_init.rb
433
523
  - spec/fixtures/Berksfile
434
524
  - spec/fixtures/cookbooks/example_cookbook-0.5.0/README.md
435
525
  - spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb
@@ -467,7 +557,6 @@ files:
467
557
  - spec/unit/berkshelf/cookbook_generator_spec.rb
468
558
  - spec/unit/berkshelf/cookbook_source_spec.rb
469
559
  - spec/unit/berkshelf/cookbook_store_spec.rb
470
- - spec/unit/berkshelf/core_ext/fileutils_spec.rb
471
560
  - spec/unit/berkshelf/downloader_spec.rb
472
561
  - spec/unit/berkshelf/formatters_spec.rb
473
562
  - spec/unit/berkshelf/git_spec.rb
@@ -496,12 +585,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
496
585
  required_rubygems_version: !ruby/object:Gem::Requirement
497
586
  none: false
498
587
  requirements:
499
- - - ! '>='
588
+ - - ! '>'
500
589
  - !ruby/object:Gem::Version
501
- version: '0'
502
- segments:
503
- - 0
504
- hash: -718551766010983641
590
+ version: 1.3.1
505
591
  requirements: []
506
592
  rubyforge_project:
507
593
  rubygems_version: 1.8.23
@@ -511,6 +597,7 @@ summary: Manages a Cookbook's, or an Application's, Cookbook dependencies
511
597
  test_files:
512
598
  - features/cookbook_command.feature
513
599
  - features/default_locations.feature
600
+ - features/groups_install.feature
514
601
  - features/init_command.feature
515
602
  - features/install.feature
516
603
  - features/json_formatter.feature
@@ -523,7 +610,7 @@ test_files:
523
610
  - features/support/env.rb
524
611
  - features/update.feature
525
612
  - features/upload_command.feature
526
- - features/without.feature
613
+ - features/vendor_install.feature
527
614
  - spec/fixtures/Berksfile
528
615
  - spec/fixtures/cookbooks/example_cookbook-0.5.0/README.md
529
616
  - spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb
@@ -561,7 +648,6 @@ test_files:
561
648
  - spec/unit/berkshelf/cookbook_generator_spec.rb
562
649
  - spec/unit/berkshelf/cookbook_source_spec.rb
563
650
  - spec/unit/berkshelf/cookbook_store_spec.rb
564
- - spec/unit/berkshelf/core_ext/fileutils_spec.rb
565
651
  - spec/unit/berkshelf/downloader_spec.rb
566
652
  - spec/unit/berkshelf/formatters_spec.rb
567
653
  - spec/unit/berkshelf/git_spec.rb