berkshelf 0.4.0.rc2 → 0.4.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. data/features/install.feature +15 -0
  2. data/{lib/berkshelf/generator_files → generator_files}/Berksfile.erb +0 -0
  3. data/{lib/berkshelf/generator_files → generator_files}/Gemfile.erb +0 -0
  4. data/{lib/berkshelf/generator_files → generator_files}/README.md.erb +0 -0
  5. data/{lib/berkshelf/generator_files → generator_files}/Thorfile.erb +0 -0
  6. data/{lib/berkshelf/generator_files → generator_files}/Vagrantfile.erb +0 -0
  7. data/{lib/berkshelf/generator_files → generator_files}/chefignore +4 -1
  8. data/{lib/berkshelf/generator_files → generator_files}/default_recipe.erb +0 -0
  9. data/{lib/berkshelf/generator_files → generator_files}/gitignore.erb +1 -0
  10. data/{lib/berkshelf/generator_files → generator_files}/licenses/apachev2.erb +0 -0
  11. data/{lib/berkshelf/generator_files → generator_files}/licenses/gplv2.erb +0 -0
  12. data/{lib/berkshelf/generator_files → generator_files}/licenses/gplv3.erb +0 -0
  13. data/{lib/berkshelf/generator_files → generator_files}/licenses/mit.erb +0 -0
  14. data/{lib/berkshelf/generator_files → generator_files}/licenses/reserved.erb +0 -0
  15. data/{lib/berkshelf/generator_files → generator_files}/metadata.rb.erb +0 -0
  16. data/lib/berkshelf/base_generator.rb +1 -1
  17. data/lib/berkshelf/berksfile.rb +5 -1
  18. data/lib/berkshelf/core_ext/fileutils.rb +10 -0
  19. data/lib/berkshelf/errors.rb +1 -0
  20. data/lib/berkshelf/git.rb +1 -1
  21. data/lib/berkshelf/version.rb +1 -1
  22. data/spec/unit/berkshelf/core_ext/fileutils_spec.rb +20 -0
  23. data/spec/unit/berkshelf/git_spec.rb +15 -4
  24. metadata +18 -16
@@ -65,6 +65,21 @@ Feature: install cookbooks from a Berksfile
65
65
  """
66
66
  And the exit status should be 0
67
67
 
68
+ @wip
69
+ Scenario: installing a Berksfile that contains a path location which contains a broken symlink
70
+ Given a Berksfile with path location sources to fixtures:
71
+ | example_cookbook_broken_link | example_cookbook_broken_link |
72
+ When I run the install command with flags:
73
+ | --shims |
74
+ Then the following directories should exist:
75
+ | cookbooks |
76
+ | cookbooks/example_cookbook |
77
+ And the output should contain:
78
+ """
79
+ Shims written to:
80
+ """
81
+ And the exit status should be 0
82
+
68
83
  Scenario: installing a Berksfile that contains a Git location
69
84
  Given I write to "Berksfile" with:
70
85
  """
@@ -46,4 +46,7 @@ features/*
46
46
  # Berkshelf
47
47
  Berksfile
48
48
  Berksfile.lock
49
- cookbooks/*
49
+ cookbooks/*
50
+
51
+ # Vagrant
52
+ .vagrant
@@ -1,3 +1,4 @@
1
+ .vagrant
1
2
  Berksfile.lock
2
3
  Gemfile.lock
3
4
  /cookbooks
@@ -5,7 +5,7 @@ module Berkshelf
5
5
  class BaseGenerator < Thor::Group
6
6
  class << self
7
7
  def source_root
8
- File.expand_path(File.join(File.dirname(__FILE__), "generator_files"))
8
+ Berkshelf.root.join("generator_files")
9
9
  end
10
10
  end
11
11
 
@@ -209,7 +209,11 @@ module Berkshelf
209
209
  #
210
210
  # @return [Berksfile]
211
211
  def load(content)
212
- instance_eval(content)
212
+ begin
213
+ instance_eval(content)
214
+ rescue => e
215
+ raise BerksfileReadError.new(e), "An error occurred while reading the Berksfile: #{e.message}"
216
+ end
213
217
  self
214
218
  end
215
219
 
@@ -63,6 +63,8 @@ module FileUtils
63
63
  class Entry_ #:nodoc:
64
64
  def link(dest)
65
65
  case
66
+ when broken_symlink?
67
+ warn "#{path} is a broken symlink. No link created."
66
68
  when directory?
67
69
  if !File.exist?(dest) and descendant_diretory?(dest, path)
68
70
  raise ArgumentError, "cannot link directory %s to itself %s" % [path, dest]
@@ -76,5 +78,13 @@ module FileUtils
76
78
  File.link path(), dest
77
79
  end
78
80
  end
81
+
82
+ # Check if the file at path is a broken symlink
83
+ #
84
+ # @return [Boolean]
85
+ def broken_symlink?
86
+ File.symlink?(path) && !File.exists?(File.readlink(path))
87
+ end
88
+
79
89
  end
80
90
  end
@@ -60,4 +60,5 @@ module Berkshelf
60
60
 
61
61
  class ConstraintNotSatisfied < BerkshelfError; status_code(111); end
62
62
  class InvalidChefAPILocation < BerkshelfError; status_code(112); end
63
+ class BerksfileReadError < BerkshelfError; status_code(113); end
63
64
  end
@@ -5,7 +5,7 @@ module Berkshelf
5
5
  # @author Jamie Winsor <jamie@vialstudios.com>
6
6
  class Git
7
7
  GIT_REGEXP = URI.regexp(%w{ https git })
8
- SSH_REGEXP = /(.+)@(.+):(.+)\/(.+)\.git/
8
+ SSH_REGEXP = /(.+)@(.+):(.+)\.git/
9
9
 
10
10
  class << self
11
11
  # @overload git(commands)
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "0.4.0.rc2"
2
+ VERSION = "0.4.0.rc3"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ module Berkshelf
4
+ describe FileUtils do
5
+ describe '#ln_r' do
6
+ it "should skip broken symlinks during traversal" do
7
+ Dir.mktmpdir do |dir|
8
+ path = Pathname.new(File.join(dir, 'ln_r_test'))
9
+ Dir.mkdir(path)
10
+ Dir.chdir(path) do
11
+ File.open('original', 'w') {}
12
+ File.symlink('original', 'link_to_original')
13
+ FileUtils.rm('original')
14
+ end
15
+ -> { FileUtils.ln_r(path, File.join(dir, 'link_to_dir')) }.should_not raise_error
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -58,7 +58,6 @@ module Berkshelf
58
58
 
59
59
  let(:readonly_uri) { "git://github.com/reset/thor-foodcritic.git" }
60
60
  let(:https_uri) { "https://github.com/reset/solve.git" }
61
- let(:ssh_uri) { "git@github.com:reset/solve.git" }
62
61
  let(:http_uri) { "http://github.com/reset/solve.git" }
63
62
  let(:invalid_uri) { "/something/on/disk" }
64
63
 
@@ -75,9 +74,15 @@ module Berkshelf
75
74
  end
76
75
  end
77
76
 
78
- context "given a valid Git SSH URI" do
77
+ context "given a valid Github SSH URI" do
78
+ it "returns true" do
79
+ subject.validate_uri("git@github.com:reset/solve.git").should be_true
80
+ end
81
+ end
82
+
83
+ context "given a valid SSH URI without an 'organization'" do
79
84
  it "returns true" do
80
- subject.validate_uri(ssh_uri).should be_true
85
+ subject.validate_uri("gituser@githost:solve.git").should be_true
81
86
  end
82
87
  end
83
88
 
@@ -115,7 +120,13 @@ module Berkshelf
115
120
 
116
121
  context "given a valid Git SSH URI" do
117
122
  it "returns true" do
118
- subject.validate_uri!(ssh_uri).should be_true
123
+ subject.validate_uri!("git@github.com:reset/solve.git").should be_true
124
+ end
125
+ end
126
+
127
+ context "given a valid SSH URI without an 'organization'" do
128
+ it "returns true" do
129
+ subject.validate_uri("gituser@githost:solve.git").should be_true
119
130
  end
120
131
  end
121
132
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.rc2
4
+ version: 0.4.0.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-07-27 00:00:00.000000000 Z
15
+ date: 2012-08-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: solve
@@ -382,6 +382,20 @@ files:
382
382
  - features/update.feature
383
383
  - features/upload_command.feature
384
384
  - features/without.feature
385
+ - generator_files/Berksfile.erb
386
+ - generator_files/Gemfile.erb
387
+ - generator_files/README.md.erb
388
+ - generator_files/Thorfile.erb
389
+ - generator_files/Vagrantfile.erb
390
+ - generator_files/chefignore
391
+ - generator_files/default_recipe.erb
392
+ - generator_files/gitignore.erb
393
+ - generator_files/licenses/apachev2.erb
394
+ - generator_files/licenses/gplv2.erb
395
+ - generator_files/licenses/gplv3.erb
396
+ - generator_files/licenses/mit.erb
397
+ - generator_files/licenses/reserved.erb
398
+ - generator_files/metadata.rb.erb
385
399
  - lib/berkshelf.rb
386
400
  - lib/berkshelf/base_generator.rb
387
401
  - lib/berkshelf/berksfile.rb
@@ -404,20 +418,6 @@ files:
404
418
  - lib/berkshelf/downloader.rb
405
419
  - lib/berkshelf/dsl.rb
406
420
  - lib/berkshelf/errors.rb
407
- - lib/berkshelf/generator_files/Berksfile.erb
408
- - lib/berkshelf/generator_files/Gemfile.erb
409
- - lib/berkshelf/generator_files/README.md.erb
410
- - lib/berkshelf/generator_files/Thorfile.erb
411
- - lib/berkshelf/generator_files/Vagrantfile.erb
412
- - lib/berkshelf/generator_files/chefignore
413
- - lib/berkshelf/generator_files/default_recipe.erb
414
- - lib/berkshelf/generator_files/gitignore.erb
415
- - lib/berkshelf/generator_files/licenses/apachev2.erb
416
- - lib/berkshelf/generator_files/licenses/gplv2.erb
417
- - lib/berkshelf/generator_files/licenses/gplv3.erb
418
- - lib/berkshelf/generator_files/licenses/mit.erb
419
- - lib/berkshelf/generator_files/licenses/reserved.erb
420
- - lib/berkshelf/generator_files/metadata.rb.erb
421
421
  - lib/berkshelf/git.rb
422
422
  - lib/berkshelf/init_generator.rb
423
423
  - lib/berkshelf/lockfile.rb
@@ -468,6 +468,7 @@ files:
468
468
  - spec/unit/berkshelf/cookbook_source/site_location_spec.rb
469
469
  - spec/unit/berkshelf/cookbook_source_spec.rb
470
470
  - spec/unit/berkshelf/cookbook_store_spec.rb
471
+ - spec/unit/berkshelf/core_ext/fileutils_spec.rb
471
472
  - spec/unit/berkshelf/downloader_spec.rb
472
473
  - spec/unit/berkshelf/dsl_spec.rb
473
474
  - spec/unit/berkshelf/git_spec.rb
@@ -556,6 +557,7 @@ test_files:
556
557
  - spec/unit/berkshelf/cookbook_source/site_location_spec.rb
557
558
  - spec/unit/berkshelf/cookbook_source_spec.rb
558
559
  - spec/unit/berkshelf/cookbook_store_spec.rb
560
+ - spec/unit/berkshelf/core_ext/fileutils_spec.rb
559
561
  - spec/unit/berkshelf/downloader_spec.rb
560
562
  - spec/unit/berkshelf/dsl_spec.rb
561
563
  - spec/unit/berkshelf/git_spec.rb