vendorificator 0.5.git.v0.4.0.63.g8e9d54d → 0.5.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 (44) hide show
  1. checksums.yaml +9 -9
  2. data/.travis.yml +2 -2
  3. data/CHANGELOG.md +10 -0
  4. data/Gemfile +5 -12
  5. data/README.md +27 -1
  6. data/Rakefile +2 -8
  7. data/features/chef_cookbook.feature +4 -4
  8. data/features/download.feature +1 -1
  9. data/features/edgecases.feature +15 -0
  10. data/features/environment.feature +3 -2
  11. data/features/fake_mode.feature +15 -0
  12. data/features/git.feature +4 -4
  13. data/features/overlay.feature +99 -0
  14. data/features/step_definitions/basic.rb +22 -0
  15. data/features/step_definitions/git.rb +16 -0
  16. data/features/step_definitions/vendorificator.rb +9 -4
  17. data/features/support/aruba_ext.rb +4 -0
  18. data/features/support/env.rb +3 -0
  19. data/features/tarball.feature +2 -2
  20. data/features/tarball_edit.feature +3 -3
  21. data/features/tool.feature +6 -4
  22. data/features/tool_shortcuts.feature +3 -3
  23. data/features/tool_specs.feature +62 -0
  24. data/features/vendor.feature +4 -3
  25. data/lib/vendorificator.rb +7 -1
  26. data/lib/vendorificator/cli.rb +12 -11
  27. data/lib/vendorificator/config.rb +32 -1
  28. data/lib/vendorificator/environment.rb +23 -27
  29. data/lib/vendorificator/hooks/chef_cookbook.rb +2 -2
  30. data/lib/vendorificator/overlay.rb +17 -0
  31. data/lib/vendorificator/segment.rb +376 -0
  32. data/lib/vendorificator/segment/overlay.rb +114 -0
  33. data/lib/vendorificator/segment/vendor.rb +115 -0
  34. data/lib/vendorificator/vendor.rb +25 -279
  35. data/lib/vendorificator/vendor/tool.rb +40 -23
  36. data/lib/vendorificator/version.rb +1 -1
  37. data/spec/vendorificator/config_spec.rb +66 -0
  38. data/spec/vendorificator/environment_spec.rb +7 -7
  39. data/spec/vendorificator/fixtures/vendorfiles/overlay.rb +4 -0
  40. data/spec/vendorificator/segment/vendor_spec.rb +19 -0
  41. data/spec/vendorificator/segment_spec.rb +106 -0
  42. data/spec/vendorificator/vendor_spec.rb +0 -89
  43. data/vendorificator.gemspec +5 -5
  44. metadata +45 -29
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTc4NGQ5NzBiMmUyNzA4MGI5MjJhNDNmMmVmMWM0Y2JlZjZkMjlmOQ==
4
+ YTEyYjlkYjZhZjk4ZjdmOTgzMDRmN2Y1NzZmMTg4YzQ2NTI4NDBiOQ==
5
5
  data.tar.gz: !binary |-
6
- ZTJmMmY3NGJlZDUwMWQ1YWQ0NzFhZjczYmYyYjE3ZTc2ODc4NWU3Nw==
7
- !binary "U0hBNTEy":
6
+ ZjBhOWEzNzQ3NjZlODNkYjI1YjA4NmQ4ZTgyZWYyMjU4MjBjMjQxYQ==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- ODE3NmJhZTliZmMwMzk1NjQ3M2I5MjRmNjk1NzA1MDI5MWFkZDY0MGQ1MTQy
10
- NjA3NTc2ZTNhOWFiZmRlMGFkMjA3ZDFjOTQ0ZTc0MDM0NWFjNjVkOTIzNTc2
11
- ZjYyMTA1ODcyMTVmNzY4ODg3MGZhOWI4OWUwYTgwODliZDJkMmY=
9
+ OGRhOGEwNzExYmNkMWJmYzc4NTMzZjM2Nzc1OWY3ZWYyOTQ4NzUxYzJjMmM4
10
+ ODMwOWExOTQ3MGJkZjM1MWFiYjBiNzk5YWZmNTI5ZGQ1ZjY2Mzg1ZTJiNTA3
11
+ OTgzZDM3N2UxMTk5NTI5NGE1ZjIwYmRiOTk1N2IwZDE1Y2YwYWE=
12
12
  data.tar.gz: !binary |-
13
- YzA5OGQ2NjgzYzY5NGY2MjZiZDRhMDNjNjFiNGY1Y2NhMGU4MTkyYTAyNGZh
14
- ZjA0Y2I4OWRiNjkyNjI1N2Q4MTQwMzVjMmE1NmE3MTk2MTg2N2NkMGZkMzEx
15
- Nzc4Nzc2YjNiZDA5OWVlZjY1NDM4Y2M3ZmVhZjY3N2ViNDIyOWE=
13
+ OTFhOGMwZjU4YzA4MzU2MmFkZjEwNTIwYWRkNDU4M2IyOWZlODNkOThkMmU0
14
+ MDk4M2EyNmM1NDAxMTlmYjE2NzIwYjNiNzk1YzQxZjM1ZTNhMGNkNWQ1NTMy
15
+ YzcwZWFmODc3ZmQwMWQyOWJlYjkxOTdjZmQwYTY2OGQ2OWViOTA=
@@ -4,9 +4,9 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
+ - 2.1.0
7
8
  - jruby-19mode
8
- - jruby-head
9
- - rbx-19mode
9
+ - rbx
10
10
  notifications:
11
11
  hipchat:
12
12
  secure: "bds8WNPnAmnj2ommhDk2JNclAY1Ei/bGeWONRhhKNv1zwrqMvZ7B6M5UapEZ\n6K8z70vFMrdIDEJjzuf+ATYS0BVWKnXCYaofiIfJ7V2hiBm7/xNZ15m2bIrM\nQFIMR/Lrkd+wFA0O8z6SaPjvdEgZC6im4zAAuRq7LpH3NTy6qaA="
@@ -1,5 +1,15 @@
1
1
  # Changes
2
2
 
3
+ ## 0.5.0
4
+
5
+ - Added overlays
6
+ - Added fake mode
7
+ - Tools now check specs from repo rather than copy from original
8
+ work tree; added tool extras for files that shouldn't be committed
9
+ to vendor branch.
10
+ - Better error messages
11
+ - Improved CLI syntax, verbosity levels
12
+
3
13
  ## 0.4.0
4
14
 
5
15
  - Dropped support for Ruby 1.8.7
data/Gemfile CHANGED
@@ -3,21 +3,14 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in vendorificator.gemspec
4
4
  gemspec
5
5
 
6
- group :development do
7
- git "git://github.com/sconover/wrong.git",
8
- :ref => '0cbc35a07cb63f6f409bb85da6ad7d107bdab021' do
9
- gem 'wrong'
10
- end
11
-
12
- git "git://github.com/cucumber/cucumber.git",
13
- :ref => 'd7452d0a0b7998462e28d10f9d2733947984063d' do
14
- gem 'cucumber'
15
- end
6
+ platforms :rbx do
7
+ gem 'racc'
8
+ gem 'rubysl', '~> 2.0'
9
+ gem 'psych'
16
10
  end
17
11
 
18
12
  group :development_workstation do
19
13
  gem "pry"
20
14
  gem "awesome_print"
21
- gem "relish"
22
- gem 'debugger'
15
+ gem 'debugger', :platforms => :mri
23
16
  end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vendorificator
2
2
 
3
- > **THIS PROGRAM IS STILL IN BETA**, use on your own risk!
3
+ > **THIS PROGRAM IS STILL IN BETA**, use at your own risk!
4
4
 
5
5
  ## About
6
6
 
@@ -254,6 +254,9 @@ Vendorificator. Takes the same arguments as `vendor`, plus:
254
254
  * `:command` -- command to run to download files
255
255
  * `:specs` -- files specifying what to download; these will be kept
256
256
  on the vendor branch together with downloaded dependencies
257
+ * `:extras` -- files that are needed for the tool to work, but which
258
+ won't be committed to the vendor branch together with specs and
259
+ dependencies
257
260
 
258
261
  Two convenience shortcuts are provided, `rubygems_bundler`, and
259
262
  `chef_berkshelf`. They take no arguments. Their definitions are
@@ -273,6 +276,29 @@ tool 'cookbooks', # <- chef_berkshelf
273
276
  :command => 'berks install --path vendor/cookbooks'
274
277
  ```
275
278
 
279
+ #### overlay
280
+
281
+ Overlays multiple modules in the same directory, instead of each of them being
282
+ conjured in its own.
283
+
284
+ ```ruby
285
+ overlay '/xyzzy' do
286
+ vendor 'foo', :version => '0.23' do |v|
287
+ File.open('README.foo', 'w') { |f| f.puts "Hello, foos!" }
288
+ end
289
+ vendor 'bar', :version => '0.42' do |v|
290
+ File.open('README.bar', 'w') { |f| f.puts "Hello, bars!" }
291
+ end
292
+ end
293
+ ```
294
+
295
+ ### Fake Mode
296
+
297
+ To develop a solution based on Vendorificator without having
298
+ everything committed to a dozen of branches, tagged, and noted, set
299
+ `vendorificator.stub` Git setting to `true`. Then, Vendorificator will
300
+ work live in the main repo, and ignore the output directory in Git.
301
+
276
302
  ## Contributing
277
303
 
278
304
  1. Fork it
data/Rakefile CHANGED
@@ -11,13 +11,6 @@ begin
11
11
  rescue LoadError
12
12
  end
13
13
 
14
- namespace :relish do
15
- desc "Publish documentation to Relish"
16
- task :push do
17
- sh "relish push 3ofcoins/vendorificator"
18
- end
19
- end
20
-
21
14
  task :info do
22
15
  sh 'which git'
23
16
  sh 'git --version'
@@ -29,9 +22,10 @@ begin
29
22
 
30
23
  desc 'Run Cucumber features'
31
24
  Cucumber::Rake::Task.new(:features) do |t|
32
- t.fork = false
25
+ # t.fork = false
33
26
  t.cucumber_opts = %w{--format progress}
34
27
  t.cucumber_opts += %w{--tags ~@berkshelf} unless defined?(Berkshelf)
28
+ t.cucumber_opts += ENV['CUCUMBER_OPTS'].split if ENV['CUCUMBER_OPTS']
35
29
  end
36
30
  rescue LoadError
37
31
  desc 'Cucumber rake task not available'
@@ -7,8 +7,8 @@ Scenario: A single cookbook, without dependencies
7
7
  """
8
8
  When I run vendor command "install"
9
9
  Then following has been conjured:
10
- | Name | cookbooks/apt |
11
- | With file | metadata.rb |
10
+ | Name | cookbooks/apt |
11
+ | With file | metadata.rb |
12
12
 
13
13
  Scenario: Dependency hook
14
14
  Given a repository with following Vendorfile:
@@ -28,8 +28,8 @@ Scenario: Ignored dependency
28
28
  """
29
29
  When I run vendor command "install"
30
30
  Then following has been conjured:
31
- | Name | cookbooks/memcached |
32
- | With file | metadata.rb |
31
+ | Name | cookbooks/memcached |
32
+ | With file | metadata.rb |
33
33
  And following has not been conjured:
34
34
  | Name | cookbooks/runit |
35
35
  | With file | metadata.rb |
@@ -7,7 +7,7 @@ Scenario: just URL as name
7
7
  """
8
8
  When I run vendor command "install"
9
9
  Then following has been conjured:
10
- | Name | testrepo-0.1.tar.gz |
10
+ | Name | testrepo-0.1.tar.gz |
11
11
  And there's a git commit note including "ea207a" in "download_checksum"
12
12
  And there's a git commit note including "20480" in "download_filesize"
13
13
  And there's a git commit note including "test-assets.3ofcoins" in "download_url"
@@ -32,3 +32,18 @@ Scenario: module with a .gitignore file
32
32
  whatever
33
33
  """
34
34
  And git repository is clean
35
+
36
+ Scenario: Git overlay in root directory
37
+ Given a repository with following Vendorfile:
38
+ """ruby
39
+ overlay '/' do
40
+ git "file://#{ENV['FIXTURES_DIR']}/git/testrepo"
41
+ end
42
+ """
43
+ When I run vendor command "install"
44
+ Then following has been conjured:
45
+ | Name | testrepo |
46
+ | Branch | vendor/overlay/layer/testrepo |
47
+ | Version | 10e9ac58c77bc229d8c59a5b4eb7422916453148 |
48
+ | With file | test/alias.c |
49
+ | Path | . |
@@ -60,8 +60,9 @@ Scenario: Running tasks without Vendorfile where they don't need it
60
60
  Scenario: Running tasks without Vendorfile where they need it
61
61
  Given a directory named "foo"
62
62
  When I cd to "foo"
63
- And I run vendor command "pull"
64
- Then the last vendor output should match /Vendorfile not found/
63
+ And I try to run vendor command "pull"
64
+ Then it fails
65
+ And the last vendor output should match /Vendorfile not found/
65
66
 
66
67
  Scenario: Getting module list
67
68
  Given a repository with following Vendorfile:
@@ -0,0 +1,15 @@
1
+ Feature: Fake mode for development.
2
+
3
+ Scenario: Conjuring a simple module in fake mode works.
4
+ Given a repository with following Vendorfile:
5
+ """ruby
6
+ vendor 'generated', :version => '0.23' do |v|
7
+ File.open('README', 'w') { |f| f.puts "Hello, World!" }
8
+ end
9
+ """
10
+ When I set the fake mode variable
11
+ And I run vendor command "install -v 1"
12
+ Then a file named "README" should exist
13
+ And tag "vendor/generated/0.23" does not exist
14
+ And branch "vendor/generated" does not exist
15
+
@@ -49,10 +49,10 @@ Scenario: Vendorificating a certain tag from a git repo
49
49
  """
50
50
  When I run vendor command "install"
51
51
  Then following has been conjured:
52
- | Name | testrepo |
53
- | Version | email-v0 |
54
- | Without file | README.md |
55
- | With file | test/alias.c |
52
+ | Name | testrepo |
53
+ | Version | email-v0 |
54
+ | Without file | README.md |
55
+ | With file | test/alias.c |
56
56
  And there's a git log message including "at revision f81247bde4ef7a1c7d280140cc0bcf0b8221a51f"
57
57
  And there's a git commit note including "f81247" in "git_revision"
58
58
 
@@ -0,0 +1,99 @@
1
+ Feature: Overlay usage
2
+
3
+ Scenario: overlay with a single vendor
4
+ Given a repository with following Vendorfile:
5
+ """ruby
6
+ overlay '/foo' do
7
+ vendor 'generated', :version => '0.23' do |v|
8
+ File.open('README', 'w') { |f| f.puts "Hello, World!" }
9
+ end
10
+ end
11
+ """
12
+ When I run vendor command "install -v 1"
13
+ Then the following has been conjured:
14
+ | Name | generated |
15
+ | Branch | vendor/overlay/foo/layer/generated |
16
+ | Version | 0.23 |
17
+ | Path | foo |
18
+ | With file | README |
19
+ And the file "foo/README" should contain "Hello, World!"
20
+ And branch "vendor/overlay/foo/layer/generated" exists
21
+ And branch "vendor/overlay/foo/merged" exists
22
+ And branch "vendor/generated" does not exist
23
+ And tag "vendor/overlay/foo/layer/generated/0.23" exists
24
+ And tag "vendor/generated/0.23" does not exist
25
+
26
+ Scenario: Overlay in repository root
27
+ Given a repository with following Vendorfile:
28
+ """ruby
29
+ overlay '/' do
30
+ vendor 'generated', :version => '0.23' do |v|
31
+ File.open('README.foo', 'w') { |f| f.puts "Hello, World!" }
32
+ end
33
+ end
34
+ """
35
+ When I run vendor command "install -v 1"
36
+ Then the following has been conjured:
37
+ | Name | generated |
38
+ | Branch | vendor/overlay/layer/generated |
39
+ | Version | 0.23 |
40
+ | With file | README.foo |
41
+ | Path | . |
42
+ And the file "README.foo" should contain "Hello, World!"
43
+ And branch "vendor/overlay/layer/generated" exists
44
+ And branch "vendor/generated" does not exist
45
+ And branch "vendor/overlay/merged" exists
46
+
47
+ Scenario: overlay with multiple sources
48
+ Given a repository with following Vendorfile:
49
+ """ruby
50
+ overlay '/xyzzy' do
51
+ vendor 'foo', :version => '0.23' do |v|
52
+ File.open('README.foo', 'w') { |f| f.puts "Hello, World! -- foo" }
53
+ end
54
+ vendor 'bar', :version => '0.42' do |v|
55
+ File.open('README.bar', 'w') { |f| f.puts "Hello, World! -- bar" }
56
+ end
57
+ end
58
+ """
59
+ When I run vendor command "install -v 1"
60
+ Then the following has been conjured:
61
+ | Name | foo |
62
+ | Branch | vendor/overlay/xyzzy/layer/foo |
63
+ | Version | 0.23 |
64
+ | With file | README.foo |
65
+ | Path | xyzzy |
66
+ And the following has been conjured:
67
+ | Name | bar |
68
+ | Branch | vendor/overlay/xyzzy/layer/bar |
69
+ | Version | 0.42 |
70
+ | With file | README.bar |
71
+ | Path | xyzzy |
72
+ And the file "xyzzy/README.foo" should contain "Hello, World! -- foo"
73
+ And the file "xyzzy/README.bar" should contain "Hello, World! -- bar"
74
+ And branch "vendor/overlay/xyzzy/layer/foo" exists
75
+ And branch "vendor/overlay/xyzzy/layer/bar" exists
76
+ And branch "vendor/overlay/xyzzy/merged" exists
77
+ And branch "vendor/foo" does not exist
78
+ And branch "vendor/bar" does not exist
79
+
80
+ Scenario: Overlay ID
81
+ Given a repository with following Vendorfile:
82
+ """ruby
83
+ overlay 'base', path: '/special_base_path' do
84
+ vendor 'generated', :version => '0.23' do |v|
85
+ File.open('README.foo', 'w') { |f| f.puts "Hello, World!" }
86
+ end
87
+ end
88
+ """
89
+ When I run vendor command "install -v 1"
90
+ Then the following has been conjured:
91
+ | Name | generated |
92
+ | Branch | vendor/overlay/base/layer/generated |
93
+ | Version | 0.23 |
94
+ | With file | README.foo |
95
+ | Path | special_base_path |
96
+ And the file "special_base_path/README.foo" should contain "Hello, World!"
97
+ And branch "vendor/overlay/base/layer/generated" exists
98
+ And branch "vendor/overlay/base/merged" exists
99
+ And branch "vendor/generated" does not exist
@@ -30,6 +30,12 @@ Given /^a remote repository$/ do
30
30
  run_simple 'git remote add origin ../remote-repository'
31
31
  end
32
32
 
33
+ When /^I set the fake mode variable$/ do
34
+ Dir.chdir(current_dir) do
35
+ MiniGit::Capturing.git :config, 'vendorificator.stub', 'true'
36
+ end
37
+ end
38
+
33
39
  When /(?:I have following Gemfile|I change Gemfile to|following Gemfile):$/ do |gemfile_contents|
34
40
  write_file('Gemfile', gemfile_contents)
35
41
  run_simple(without_bundler('bundle'))
@@ -52,3 +58,19 @@ When /^I run vendor command "(.*)"$/ do |args|
52
58
  end
53
59
  end
54
60
  end
61
+
62
+ Before do
63
+ @last_vendor_exception = nil
64
+ end
65
+
66
+ When /^I try to run vendor command "(.*)"$/ do |args|
67
+ begin
68
+ step "I run vendor command \"#{args}\""
69
+ rescue => exc
70
+ @last_vendor_exception = exc
71
+ end
72
+ end
73
+
74
+ Then 'it fails' do
75
+ assert { !!@last_vendor_exception }
76
+ end
@@ -62,3 +62,19 @@ end
62
62
  Then /^notes ref "(.*?)" exists in the remote repo$/ do |ref_name|
63
63
  assert { remote_git.note_refs.include?(ref_name) }
64
64
  end
65
+
66
+ def branch_contains?(branch, path)
67
+ @branch_files ||= {}
68
+ @branch_files[branch] ||= git.capturing.
69
+ ls_tree( {:r => true, :z => true, :name_only => true}, branch).
70
+ split("\0")
71
+ @branch_files[branch].include?(path)
72
+ end
73
+
74
+ Then(/^the branch "(.*?)" should contain file "(.*?)"$/) do |branch, path|
75
+ assert { branch_contains?(branch, path) }
76
+ end
77
+
78
+ Then(/^the branch "(.*?)" should not contain file "(.*?)"$/) do |branch, path|
79
+ deny { branch_contains?(branch, path) }
80
+ end
@@ -1,5 +1,9 @@
1
1
  def vendor_path_for(mod, path)
2
- File.join('vendor', mod['Path'] || mod['Name'], path)
2
+ if mod['Path']
3
+ File.join mod['Path'], path
4
+ else
5
+ File.join 'vendor', mod['Name'], path
6
+ end
3
7
  end
4
8
 
5
9
  Then /^(?:the )?following has( not)? been conjured:$/ do |not_p, table|
@@ -8,12 +12,13 @@ Then /^(?:the )?following has( not)? been conjured:$/ do |not_p, table|
8
12
  step "I'm on \"master\" branch"
9
13
 
10
14
  table.transpose.hashes.each do |mod|
11
- step "branch \"vendor/#{mod['Name']}\" #{exists_p}"
15
+ branch = mod['Branch'] || "vendor/#{mod['Name']}"
16
+ step "branch \"#{branch}\" #{exists_p}"
12
17
 
13
18
  if mod['Version']
14
- step "tag \"vendor/#{mod['Name']}/#{mod['Version']}\" #{exists_p}"
19
+ step "tag \"#{branch}/#{mod['Version']}\" #{exists_p}"
15
20
  else
16
- step "tag matching /^vendor\\/#{Regexp.quote(mod['Name']).gsub('/', '\\/')}\\// #{exists_p}"
21
+ step "tag matching /^#{Regexp.quote(branch).gsub('/', '\\/')}\\// #{exists_p}"
17
22
  end
18
23
 
19
24
  if mod['With file']
@@ -1,5 +1,6 @@
1
1
  require 'shellwords'
2
2
  require 'stringio'
3
+ require 'tee' if ENV['CUCUMBER_DEBUG']
3
4
 
4
5
  module Vendorificator
5
6
  module TestSupport
@@ -29,6 +30,7 @@ module Vendorificator
29
30
  def with_redirected_stdout(&block)
30
31
  redirect_stdout
31
32
  yield
33
+ ensure
32
34
  bring_back_stdout
33
35
  end
34
36
 
@@ -55,6 +57,8 @@ module Vendorificator
55
57
  @orig_stderr = $stderr
56
58
  $stdout = @mock_stdout = StringIO.new
57
59
  $stderr = @mock_stderr = StringIO.new
60
+ $stdout = Tee.new(STDOUT, @mock_stdout, :stdout => false) if ENV['CUCUMBER_DEBUG']
61
+ $stderr = Tee.new(STDERR, @mock_stderr, :stdout => false) if ENV['CUCUMBER_DEBUG']
58
62
  end
59
63
 
60
64
  def bring_back_stdout