rkh-bundler 1.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +42 -0
  3. data/CHANGELOG.md +1105 -0
  4. data/ISSUES.md +67 -0
  5. data/LICENSE +23 -0
  6. data/README.md +31 -0
  7. data/Rakefile +208 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +31 -0
  10. data/bundler.gemspec +31 -0
  11. data/lib/bundler.rb +353 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +693 -0
  14. data/lib/bundler/definition.rb +568 -0
  15. data/lib/bundler/dep_proxy.rb +43 -0
  16. data/lib/bundler/dependency.rb +134 -0
  17. data/lib/bundler/deployment.rb +58 -0
  18. data/lib/bundler/dsl.rb +256 -0
  19. data/lib/bundler/endpoint_specification.rb +78 -0
  20. data/lib/bundler/environment.rb +47 -0
  21. data/lib/bundler/fetcher.rb +225 -0
  22. data/lib/bundler/gem_helper.rb +162 -0
  23. data/lib/bundler/gem_helpers.rb +23 -0
  24. data/lib/bundler/gem_installer.rb +9 -0
  25. data/lib/bundler/gem_tasks.rb +2 -0
  26. data/lib/bundler/graph.rb +148 -0
  27. data/lib/bundler/index.rb +187 -0
  28. data/lib/bundler/installer.rb +190 -0
  29. data/lib/bundler/lazy_specification.rb +79 -0
  30. data/lib/bundler/lockfile_parser.rb +127 -0
  31. data/lib/bundler/match_platform.rb +13 -0
  32. data/lib/bundler/psyched_yaml.rb +15 -0
  33. data/lib/bundler/remote_specification.rb +57 -0
  34. data/lib/bundler/resolver.rb +486 -0
  35. data/lib/bundler/ruby_version.rb +94 -0
  36. data/lib/bundler/rubygems_ext.rb +153 -0
  37. data/lib/bundler/rubygems_integration.rb +394 -0
  38. data/lib/bundler/runtime.rb +233 -0
  39. data/lib/bundler/settings.rb +128 -0
  40. data/lib/bundler/setup.rb +23 -0
  41. data/lib/bundler/shared_helpers.rb +71 -0
  42. data/lib/bundler/source.rb +869 -0
  43. data/lib/bundler/spec_set.rb +137 -0
  44. data/lib/bundler/templates/Executable +16 -0
  45. data/lib/bundler/templates/Executable.standalone +12 -0
  46. data/lib/bundler/templates/Gemfile +4 -0
  47. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  48. data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
  49. data/lib/bundler/templates/newgem/README.md.tt +29 -0
  50. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  51. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  52. data/lib/bundler/templates/newgem/gitignore.tt +17 -0
  53. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  54. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  55. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
  56. data/lib/bundler/ui.rb +88 -0
  57. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  58. data/lib/bundler/vendor/net/http/persistent.rb +468 -0
  59. data/lib/bundler/vendor/thor.rb +358 -0
  60. data/lib/bundler/vendor/thor/actions.rb +314 -0
  61. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  62. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  63. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  64. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  65. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  66. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  67. data/lib/bundler/vendor/thor/base.rb +576 -0
  68. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  69. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  70. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  71. data/lib/bundler/vendor/thor/error.rb +30 -0
  72. data/lib/bundler/vendor/thor/group.rb +273 -0
  73. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  74. data/lib/bundler/vendor/thor/parser.rb +4 -0
  75. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  76. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  77. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  78. data/lib/bundler/vendor/thor/parser/options.rb +172 -0
  79. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  80. data/lib/bundler/vendor/thor/runner.rb +309 -0
  81. data/lib/bundler/vendor/thor/shell.rb +88 -0
  82. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  83. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  84. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  85. data/lib/bundler/vendor/thor/task.rb +113 -0
  86. data/lib/bundler/vendor/thor/util.rb +229 -0
  87. data/lib/bundler/vendor/thor/version.rb +3 -0
  88. data/lib/bundler/vendored_thor.rb +7 -0
  89. data/lib/bundler/version.rb +6 -0
  90. data/lib/bundler/vlad.rb +11 -0
  91. data/man/bundle-config.ronn +130 -0
  92. data/man/bundle-exec.ronn +111 -0
  93. data/man/bundle-install.ronn +335 -0
  94. data/man/bundle-package.ronn +59 -0
  95. data/man/bundle-update.ronn +176 -0
  96. data/man/bundle.ronn +83 -0
  97. data/man/gemfile.5.ronn +324 -0
  98. data/man/index.txt +6 -0
  99. data/spec/bundler/dsl_spec.rb +48 -0
  100. data/spec/bundler/gem_helper_spec.rb +174 -0
  101. data/spec/bundler/source_spec.rb +25 -0
  102. data/spec/cache/gems_spec.rb +239 -0
  103. data/spec/cache/git_spec.rb +124 -0
  104. data/spec/cache/path_spec.rb +103 -0
  105. data/spec/cache/platform_spec.rb +57 -0
  106. data/spec/install/deploy_spec.rb +211 -0
  107. data/spec/install/gems/c_ext_spec.rb +48 -0
  108. data/spec/install/gems/dependency_api_spec.rb +402 -0
  109. data/spec/install/gems/env_spec.rb +107 -0
  110. data/spec/install/gems/flex_spec.rb +313 -0
  111. data/spec/install/gems/groups_spec.rb +268 -0
  112. data/spec/install/gems/packed_spec.rb +84 -0
  113. data/spec/install/gems/platform_spec.rb +208 -0
  114. data/spec/install/gems/post_install_spec.rb +47 -0
  115. data/spec/install/gems/resolving_spec.rb +72 -0
  116. data/spec/install/gems/simple_case_spec.rb +814 -0
  117. data/spec/install/gems/standalone_spec.rb +260 -0
  118. data/spec/install/gems/sudo_spec.rb +74 -0
  119. data/spec/install/gems/win32_spec.rb +26 -0
  120. data/spec/install/gemspec_spec.rb +170 -0
  121. data/spec/install/git_spec.rb +796 -0
  122. data/spec/install/invalid_spec.rb +35 -0
  123. data/spec/install/path_spec.rb +405 -0
  124. data/spec/install/upgrade_spec.rb +26 -0
  125. data/spec/lock/git_spec.rb +35 -0
  126. data/spec/lock/lockfile_spec.rb +809 -0
  127. data/spec/other/check_spec.rb +265 -0
  128. data/spec/other/clean_spec.rb +492 -0
  129. data/spec/other/config_spec.rb +138 -0
  130. data/spec/other/console_spec.rb +54 -0
  131. data/spec/other/exec_spec.rb +229 -0
  132. data/spec/other/ext_spec.rb +37 -0
  133. data/spec/other/help_spec.rb +39 -0
  134. data/spec/other/init_spec.rb +40 -0
  135. data/spec/other/newgem_spec.rb +87 -0
  136. data/spec/other/open_spec.rb +35 -0
  137. data/spec/other/outdated_spec.rb +93 -0
  138. data/spec/other/platform_spec.rb +881 -0
  139. data/spec/other/show_spec.rb +88 -0
  140. data/spec/quality_spec.rb +62 -0
  141. data/spec/realworld/edgecases_spec.rb +177 -0
  142. data/spec/resolver/basic_spec.rb +20 -0
  143. data/spec/resolver/platform_spec.rb +82 -0
  144. data/spec/runtime/executable_spec.rb +120 -0
  145. data/spec/runtime/load_spec.rb +107 -0
  146. data/spec/runtime/platform_spec.rb +90 -0
  147. data/spec/runtime/require_spec.rb +261 -0
  148. data/spec/runtime/setup_spec.rb +755 -0
  149. data/spec/runtime/with_clean_env_spec.rb +80 -0
  150. data/spec/spec_helper.rb +98 -0
  151. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  152. data/spec/support/artifice/endpoint.rb +54 -0
  153. data/spec/support/artifice/endpoint_500.rb +37 -0
  154. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  155. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  156. data/spec/support/artifice/endpoint_extra.rb +27 -0
  157. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  158. data/spec/support/artifice/endpoint_fallback.rb +18 -0
  159. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  160. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  161. data/spec/support/builders.rb +604 -0
  162. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  163. data/spec/support/fakeweb/windows.rb +23 -0
  164. data/spec/support/helpers.rb +317 -0
  165. data/spec/support/indexes.rb +112 -0
  166. data/spec/support/matchers.rb +77 -0
  167. data/spec/support/path.rb +73 -0
  168. data/spec/support/platforms.rb +86 -0
  169. data/spec/support/ruby_ext.rb +20 -0
  170. data/spec/support/rubygems_ext.rb +37 -0
  171. data/spec/support/rubygems_hax/platform.rb +22 -0
  172. data/spec/support/sudo.rb +21 -0
  173. data/spec/update/gems_spec.rb +134 -0
  174. data/spec/update/git_spec.rb +196 -0
  175. data/spec/update/source_spec.rb +51 -0
  176. metadata +338 -0
@@ -0,0 +1,80 @@
1
+ require "spec_helper"
2
+
3
+ describe "Bundler.with_env helpers" do
4
+
5
+ shared_examples_for "Bundler.with_*_env" do
6
+ it "should reset and restore the environment" do
7
+ gem_path = ENV['GEM_PATH']
8
+
9
+ Bundler.with_clean_env do
10
+ `echo $GEM_PATH`.strip.should_not == gem_path
11
+ end
12
+
13
+ ENV['GEM_PATH'].should == gem_path
14
+ end
15
+ end
16
+
17
+ around do |example|
18
+ env = Bundler::ORIGINAL_ENV.dup
19
+ Bundler::ORIGINAL_ENV['BUNDLE_PATH'] = "./Gemfile"
20
+ example.run
21
+ Bundler::ORIGINAL_ENV.replace env
22
+ end
23
+
24
+ describe "Bundler.with_clean_env" do
25
+
26
+ it_should_behave_like "Bundler.with_*_env"
27
+
28
+ it "should not pass any bundler environment variables" do
29
+ Bundler.with_clean_env do
30
+ `echo $BUNDLE_PATH`.strip.should_not == './Gemfile'
31
+ end
32
+ end
33
+
34
+ it "should not pass RUBYOPT changes" do
35
+ lib_path = File.expand_path('../../../lib', __FILE__)
36
+ Bundler::ORIGINAL_ENV['RUBYOPT'] = " -I#{lib_path} -rbundler/setup"
37
+
38
+ Bundler.with_clean_env do
39
+ `echo $RUBYOPT`.strip.should_not include '-rbundler/setup'
40
+ `echo $RUBYOPT`.strip.should_not include "-I#{lib_path}"
41
+ end
42
+
43
+ Bundler::ORIGINAL_ENV['RUBYOPT'].should == " -I#{lib_path} -rbundler/setup"
44
+ end
45
+
46
+ it "should not change ORIGINAL_ENV" do
47
+ Bundler::ORIGINAL_ENV['BUNDLE_PATH'].should == './Gemfile'
48
+ end
49
+
50
+ end
51
+
52
+ describe "Bundler.with_original_env" do
53
+
54
+ it_should_behave_like "Bundler.with_*_env"
55
+
56
+ it "should pass bundler environment variables set before Bundler was run" do
57
+ Bundler.with_original_env do
58
+ `echo $BUNDLE_PATH`.strip.should == './Gemfile'
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "Bundler.clean_system" do
64
+ it "runs system inside with_clean_env" do
65
+ Bundler.clean_system(%{echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh})
66
+ $?.exitstatus.should == 42
67
+ end
68
+ end
69
+
70
+ describe "Bundler.clean_exec" do
71
+ it "runs exec inside with_clean_env" do
72
+ pid = Kernel.fork do
73
+ Bundler.clean_exec(%{echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh})
74
+ end
75
+ Process.wait(pid)
76
+ $?.exitstatus.should == 42
77
+ end
78
+ end
79
+
80
+ end
@@ -0,0 +1,98 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'bundler/psyched_yaml'
4
+ require 'fileutils'
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ require 'rspec'
8
+ require 'uri'
9
+ require 'digest/sha1'
10
+
11
+ # Require the correct version of popen for the current platform
12
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/
13
+ begin
14
+ require 'win32/open3'
15
+ rescue LoadError
16
+ abort "Run `gem install win32-open3` to be able to run specs"
17
+ end
18
+ else
19
+ require 'open3'
20
+ end
21
+
22
+ Dir["#{File.expand_path('../support', __FILE__)}/*.rb"].each do |file|
23
+ require file unless file =~ /fakeweb\/.*\.rb/
24
+ end
25
+
26
+ $debug = false
27
+ $show_err = true
28
+
29
+ Spec::Rubygems.setup
30
+ FileUtils.rm_rf(Spec::Path.gem_repo1)
31
+ ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -r#{Spec::Path.root}/spec/support/rubygems_hax/platform.rb"
32
+ ENV['BUNDLE_SPEC_RUN'] = "true"
33
+
34
+ RSpec.configure do |config|
35
+ config.include Spec::Builders
36
+ config.include Spec::Helpers
37
+ config.include Spec::Indexes
38
+ config.include Spec::Matchers
39
+ config.include Spec::Path
40
+ config.include Spec::Rubygems
41
+ config.include Spec::Platforms
42
+ config.include Spec::Sudo
43
+
44
+ if Spec::Sudo.test_sudo?
45
+ config.filter_run :sudo => true
46
+ else
47
+ config.filter_run_excluding :sudo => true
48
+ end
49
+
50
+ if ENV['BUNDLER_REALWORLD_TESTS']
51
+ config.filter_run :realworld => true
52
+ else
53
+ config.filter_run_excluding :realworld => true
54
+ end
55
+
56
+ if RUBY_VERSION >= "1.9"
57
+ config.filter_run_excluding :ruby => "1.8"
58
+ else
59
+ config.filter_run_excluding :ruby => "1.9"
60
+ end
61
+
62
+ config.filter_run :focused => true unless ENV['CI']
63
+ config.run_all_when_everything_filtered = true
64
+ config.alias_example_to :fit, :focused => true
65
+
66
+ original_wd = Dir.pwd
67
+ original_path = ENV['PATH']
68
+ original_gem_home = ENV['GEM_HOME']
69
+
70
+ def pending_jruby_shebang_fix
71
+ pending "JRuby executables do not have a proper shebang" if RUBY_PLATFORM == "java"
72
+ end
73
+
74
+ config.before :all do
75
+ build_repo1
76
+ end
77
+
78
+ config.before :each do
79
+ reset!
80
+ system_gems []
81
+ in_app_root
82
+ end
83
+
84
+ config.after :each do
85
+ Dir.chdir(original_wd)
86
+ # Reset ENV
87
+ ENV['PATH'] = original_path
88
+ ENV['GEM_HOME'] = original_gem_home
89
+ ENV['GEM_PATH'] = original_gem_home
90
+ ENV['BUNDLE_PATH'] = nil
91
+ ENV['BUNDLE_GEMFILE'] = nil
92
+ ENV['BUNDLER_TEST'] = nil
93
+ ENV['BUNDLE_FROZEN'] = nil
94
+ ENV['BUNDLER_SPEC_PLATFORM'] = nil
95
+ ENV['BUNDLER_SPEC_VERSION'] = nil
96
+ ENV['BUNDLE_APP_CONFIG'] = nil
97
+ end
98
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path("../endpoint_marshal_fail", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointMarshalFailBasicAuthentication < EndpointMarshalFail
6
+ before do
7
+ unless env["HTTP_AUTHORIZATION"]
8
+ halt 401, "Authentication info not supplied"
9
+ end
10
+ end
11
+ end
12
+
13
+ Artifice.activate_with(EndpointMarshalFailBasicAuthentication)
@@ -0,0 +1,54 @@
1
+ require File.expand_path("../../path.rb", __FILE__)
2
+ include Spec::Path
3
+
4
+ # Set up pretend http gem server with FakeWeb
5
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/artifice*/lib")].first}"
6
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/rack-*/lib")].first}"
7
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/rack-*/lib")].last}"
8
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/tilt*/lib")].first}"
9
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/sinatra*/lib")].first}"
10
+ require 'artifice'
11
+ require 'sinatra/base'
12
+
13
+ class Endpoint < Sinatra::Base
14
+
15
+ helpers do
16
+ def dependencies_for(gem_names, marshal = gem_repo1("Marshal.4.8"))
17
+ require 'rubygems'
18
+ Marshal.load(File.open(marshal).read).map do |gem, spec|
19
+ if gem_names.include?(spec.name)
20
+ {
21
+ :name => spec.name,
22
+ :number => spec.version.version,
23
+ :platform => spec.platform.to_s,
24
+ :dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
25
+ [dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
26
+ end
27
+ }
28
+ end
29
+ end.compact
30
+ end
31
+ end
32
+
33
+ get "/quick/Marshal.4.8/:id" do
34
+ redirect "/fetch/actual/gem/#{params[:id]}"
35
+ end
36
+
37
+ get "/fetch/actual/gem/:id" do
38
+ File.read("#{gem_repo1}/quick/Marshal.4.8/#{params[:id]}")
39
+ end
40
+
41
+ get "/gems/:id" do
42
+ File.read("#{gem_repo1}/gems/#{params[:id]}")
43
+ end
44
+
45
+ get "/api/v1/dependencies" do
46
+ Marshal.dump(dependencies_for(params[:gems]))
47
+ end
48
+
49
+ get "/specs.4.8.gz" do
50
+ File.read("#{gem_repo1}/specs.4.8.gz")
51
+ end
52
+ end
53
+
54
+ Artifice.activate_with(Endpoint)
@@ -0,0 +1,37 @@
1
+ require File.expand_path("../../path.rb", __FILE__)
2
+ include Spec::Path
3
+
4
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/artifice*/lib")].first}"
5
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/rack-*/lib")].first}"
6
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/rack-*/lib")].last}"
7
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/tilt*/lib")].first}"
8
+ $LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/sinatra*/lib")].first}"
9
+
10
+ require 'artifice'
11
+ require 'sinatra/base'
12
+
13
+ Artifice.deactivate
14
+
15
+ class Endpoint500 < Sinatra::Base
16
+ get "/quick/Marshal.4.8/:id" do
17
+ halt 500
18
+ end
19
+
20
+ get "/fetch/actual/gem/:id" do
21
+ halt 500
22
+ end
23
+
24
+ get "/gems/:id" do
25
+ halt 500
26
+ end
27
+
28
+ get "/api/v1/dependencies" do
29
+ halt 500
30
+ end
31
+
32
+ get "/specs.4.8.gz" do
33
+ halt 500
34
+ end
35
+ end
36
+
37
+ Artifice.activate_with(Endpoint500)
@@ -0,0 +1,16 @@
1
+ require File.expand_path("../endpoint", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointApiMissing < Endpoint
6
+ get "/fetch/actual/gem/:id" do
7
+ $stderr.puts params[:id]
8
+ if params[:id] == 'rack-1.0.gemspec.rz'
9
+ halt 404
10
+ else
11
+ File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
12
+ end
13
+ end
14
+ end
15
+
16
+ Artifice.activate_with(EndpointApiMissing)
@@ -0,0 +1,13 @@
1
+ require File.expand_path("../endpoint", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointBasicAuthentication < Endpoint
6
+ before do
7
+ unless env["HTTP_AUTHORIZATION"]
8
+ halt 401, "Authentication info not supplied"
9
+ end
10
+ end
11
+ end
12
+
13
+ Artifice.activate_with(EndpointBasicAuthentication)
@@ -0,0 +1,27 @@
1
+ require File.expand_path("../endpoint", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointExtra < Endpoint
6
+ get "/extra/api/v1/dependencies" do
7
+ halt 404
8
+ end
9
+
10
+ get "/extra/specs.4.8.gz" do
11
+ File.read("#{gem_repo2}/specs.4.8.gz")
12
+ end
13
+
14
+ get "/extra/quick/Marshal.4.8/:id" do
15
+ redirect "/extra/fetch/actual/gem/#{params[:id]}"
16
+ end
17
+
18
+ get "/extra/fetch/actual/gem/:id" do
19
+ File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
20
+ end
21
+
22
+ get "/extra/gems/:id" do
23
+ File.read("#{gem_repo2}/gems/#{params[:id]}")
24
+ end
25
+ end
26
+
27
+ Artifice.activate_with(EndpointExtra)
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../endpoint_extra", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointExtraMissing < EndpointExtra
6
+ get "/extra/fetch/actual/gem/:id" do
7
+ if params[:id] == 'missing-1.0.gemspec.rz'
8
+ halt 404
9
+ else
10
+ File.read("#{gem_repo2}/quick/Marshal.4.8/#{params[:id]}")
11
+ end
12
+ end
13
+ end
14
+
15
+ Artifice.activate_with(EndpointExtraMissing)
@@ -0,0 +1,18 @@
1
+ require File.expand_path("../endpoint", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointFallback < Endpoint
6
+ DEPENDENCY_LIMIT = 60
7
+
8
+ get "/api/v1/dependencies" do
9
+ if params[:gems].size <= DEPENDENCY_LIMIT
10
+ Marshal.dump(dependencies_for(params[:gems]))
11
+ else
12
+ status 413
13
+ "Too many gems to resolve, please request less than #{DEPENDENCY_LIMIT} gems"
14
+ end
15
+ end
16
+ end
17
+
18
+ Artifice.activate_with(EndpointFallback)
@@ -0,0 +1,11 @@
1
+ require File.expand_path("../endpoint_fallback", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointMarshalFail < EndpointFallback
6
+ get "/api/v1/dependencies" do
7
+ "f0283y01hasf"
8
+ end
9
+ end
10
+
11
+ Artifice.activate_with(EndpointMarshalFail)
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../endpoint", __FILE__)
2
+
3
+ Artifice.deactivate
4
+
5
+ class EndpointRedirect < Endpoint
6
+ get "/fetch/actual/gem/:id" do
7
+ redirect "/fetch/actual/gem/#{params[:id]}"
8
+ end
9
+
10
+ get "/api/v1/dependencies" do
11
+ status 404
12
+ end
13
+ end
14
+
15
+ Artifice.activate_with(EndpointRedirect)
@@ -0,0 +1,604 @@
1
+ module Spec
2
+ module Builders
3
+ def self.constantize(name)
4
+ name.gsub('-', '').upcase
5
+ end
6
+
7
+ def v(version)
8
+ Gem::Version.new(version)
9
+ end
10
+
11
+ def pl(platform)
12
+ Gem::Platform.new(platform)
13
+ end
14
+
15
+ def build_repo1
16
+ build_repo gem_repo1 do
17
+ build_gem "rack", %w(0.9.1 1.0.0) do |s|
18
+ s.executables = "rackup"
19
+ s.post_install_message = "Rack's post install message"
20
+ end
21
+
22
+ build_gem "thin" do |s|
23
+ s.add_dependency "rack"
24
+ s.post_install_message = "Thin's post install message"
25
+ end
26
+
27
+ build_gem "rack-obama" do |s|
28
+ s.add_dependency "rack"
29
+ s.post_install_message = "Rack-obama's post install message"
30
+ end
31
+
32
+ build_gem "rack_middleware", "1.0" do |s|
33
+ s.add_dependency "rack", "0.9.1"
34
+ end
35
+
36
+ build_gem "rails", "2.3.2" do |s|
37
+ s.executables = "rails"
38
+ s.add_dependency "rake", "0.8.7"
39
+ s.add_dependency "actionpack", "2.3.2"
40
+ s.add_dependency "activerecord", "2.3.2"
41
+ s.add_dependency "actionmailer", "2.3.2"
42
+ s.add_dependency "activeresource", "2.3.2"
43
+ end
44
+ build_gem "actionpack", "2.3.2" do |s|
45
+ s.add_dependency "activesupport", "2.3.2"
46
+ end
47
+ build_gem "activerecord", ["2.3.1", "2.3.2"] do |s|
48
+ s.add_dependency "activesupport", "2.3.2"
49
+ end
50
+ build_gem "actionmailer", "2.3.2" do |s|
51
+ s.add_dependency "activesupport", "2.3.2"
52
+ end
53
+ build_gem "activeresource", "2.3.2" do |s|
54
+ s.add_dependency "activesupport", "2.3.2"
55
+ end
56
+ build_gem "activesupport", %w(1.2.3 2.3.2 2.3.5)
57
+
58
+ build_gem "activemerchant" do |s|
59
+ s.add_dependency "activesupport", ">= 2.0.0"
60
+ end
61
+
62
+ build_gem "rails_fail" do |s|
63
+ s.add_dependency "activesupport", "= 1.2.3"
64
+ end
65
+
66
+ build_gem "missing_dep" do |s|
67
+ s.add_dependency "not_here"
68
+ end
69
+
70
+ build_gem "rspec", "1.2.7", :no_default => true do |s|
71
+ s.write "lib/spec.rb", "SPEC = '1.2.7'"
72
+ end
73
+
74
+ build_gem "rack-test", :no_default => true do |s|
75
+ s.write "lib/rack/test.rb", "RACK_TEST = '1.0'"
76
+ end
77
+
78
+ build_gem "platform_specific" do |s|
79
+ s.platform = Gem::Platform.local
80
+ s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Gem::Platform.local}'"
81
+ end
82
+
83
+ build_gem "platform_specific" do |s|
84
+ s.platform = "java"
85
+ s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 JAVA'"
86
+ end
87
+
88
+ build_gem "platform_specific" do |s|
89
+ s.platform = "ruby"
90
+ s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'"
91
+ end
92
+
93
+ build_gem "platform_specific" do |s|
94
+ s.platform = "x86-mswin32"
95
+ s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 MSWIN'"
96
+ end
97
+
98
+ build_gem "platform_specific" do |s|
99
+ s.platform = "x86-darwin-100"
100
+ s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 x86-darwin-100'"
101
+ end
102
+
103
+ build_gem "only_java" do |s|
104
+ s.platform = "java"
105
+ end
106
+
107
+ build_gem "nokogiri", "1.4.2"
108
+ build_gem "nokogiri", "1.4.2" do |s|
109
+ s.platform = "java"
110
+ s.write "lib/nokogiri.rb", "NOKOGIRI = '1.4.2 JAVA'"
111
+ s.add_dependency "weakling", ">= 0.0.3"
112
+ end
113
+
114
+ build_gem "weakling", "0.0.3"
115
+
116
+ build_gem "multiple_versioned_deps" do |s|
117
+ s.add_dependency "weakling", ">= 0.0.1", "< 0.1"
118
+ end
119
+
120
+ build_gem "not_released", "1.0.pre"
121
+
122
+ build_gem "has_prerelease", "1.0"
123
+ build_gem "has_prerelease", "1.1.pre"
124
+
125
+ build_gem "with_development_dependency" do |s|
126
+ s.add_development_dependency "activesupport", "= 2.3.5"
127
+ end
128
+
129
+ build_gem "with_implicit_rake_dep" do |s|
130
+ s.extensions << "Rakefile"
131
+ s.write "Rakefile", <<-RUBY
132
+ task :default do
133
+ path = File.expand_path("../lib", __FILE__)
134
+ FileUtils.mkdir_p(path)
135
+ File.open("\#{path}/implicit_rake_dep.rb", "w") do |f|
136
+ f.puts "IMPLICIT_RAKE_DEP = 'YES'"
137
+ end
138
+ end
139
+ RUBY
140
+ end
141
+
142
+ build_gem "another_implicit_rake_dep" do |s|
143
+ s.extensions << "Rakefile"
144
+ s.write "Rakefile", <<-RUBY
145
+ task :default do
146
+ path = File.expand_path("../lib", __FILE__)
147
+ FileUtils.mkdir_p(path)
148
+ File.open("\#{path}/another_implicit_rake_dep.rb", "w") do |f|
149
+ f.puts "ANOTHER_IMPLICIT_RAKE_DEP = 'YES'"
150
+ end
151
+ end
152
+ RUBY
153
+ end
154
+
155
+ build_gem "very_simple_binary" do |s|
156
+ s.add_c_extension
157
+ end
158
+
159
+ build_gem "bundler", "0.9" do |s|
160
+ s.executables = "bundle"
161
+ s.write "bin/bundle", "puts 'FAIL'"
162
+ end
163
+
164
+ # The bundler 0.8 gem has a rubygems plugin that always loads :(
165
+ build_gem "bundler", "0.8.1" do |s|
166
+ s.write "lib/bundler/omg.rb", ""
167
+ s.write "lib/rubygems_plugin.rb", "require 'bundler/omg' ; puts 'FAIL'"
168
+ end
169
+
170
+ build_gem "bundler_dep" do |s|
171
+ s.add_dependency "bundler"
172
+ end
173
+
174
+ # The yard gem iterates over Gem.source_index looking for plugins
175
+ build_gem "yard" do |s|
176
+ s.write "lib/yard.rb", <<-Y
177
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.10")
178
+ specs = Gem::Specification
179
+ else
180
+ specs = Gem.source_index.find_name('')
181
+ end
182
+ specs.each do |gem|
183
+ puts gem.full_name
184
+ end
185
+ Y
186
+ end
187
+
188
+ # The rcov gem is platform mswin32, but has no arch
189
+ build_gem "rcov" do |s|
190
+ s.platform = Gem::Platform.new([nil, "mswin32", nil])
191
+ s.write "lib/rcov.rb", "RCOV = '1.0.0'"
192
+ end
193
+
194
+ build_gem "net-ssh"
195
+ build_gem "net-sftp", "1.1.1" do |s|
196
+ s.add_dependency "net-ssh", ">= 1.0.0", "< 1.99.0"
197
+ end
198
+
199
+ # Test comlicated gem dependencies for install
200
+ build_gem "net_a" do |s|
201
+ s.add_dependency "net_b"
202
+ s.add_dependency "net_build_extensions"
203
+ end
204
+
205
+ build_gem "net_b"
206
+
207
+ build_gem "net_build_extensions" do |s|
208
+ s.add_dependency "rake"
209
+ s.extensions << "Rakefile"
210
+ s.write "Rakefile", <<-RUBY
211
+ task :default do
212
+ path = File.expand_path("../lib", __FILE__)
213
+ FileUtils.mkdir_p(path)
214
+ File.open("\#{path}/net_build_extensions.rb", "w") do |f|
215
+ f.puts "NET_BUILD_EXTENSIONS = 'YES'"
216
+ end
217
+ end
218
+ RUBY
219
+ end
220
+
221
+ build_gem "net_c" do |s|
222
+ s.add_dependency "net_a"
223
+ s.add_dependency "net_d"
224
+ end
225
+
226
+ build_gem "net_d"
227
+
228
+ build_gem "net_e" do |s|
229
+ s.add_dependency "net_d"
230
+ end
231
+
232
+ # Capistrano did this (at least until version 2.5.10)
233
+ build_gem "double_deps" do |s|
234
+ s.add_dependency "net-ssh", ">= 1.0.0"
235
+ s.add_dependency "net-ssh"
236
+ end
237
+
238
+ build_gem "foo"
239
+ end
240
+ end
241
+
242
+ def build_repo2(&blk)
243
+ FileUtils.rm_rf gem_repo2
244
+ FileUtils.cp_r gem_repo1, gem_repo2
245
+ update_repo2(&blk) if block_given?
246
+ end
247
+
248
+ def build_repo3
249
+ build_repo gem_repo3 do
250
+ build_gem "rack"
251
+ end
252
+ FileUtils.rm_rf Dir[gem_repo3("prerelease*")]
253
+ end
254
+
255
+ def update_repo2
256
+ update_repo gem_repo2 do
257
+ build_gem "rack", "1.2" do |s|
258
+ s.executables = "rackup"
259
+ end
260
+ yield if block_given?
261
+ end
262
+ end
263
+
264
+ def build_repo(path, &blk)
265
+ return if File.directory?(path)
266
+ rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first
267
+ if rake_path
268
+ FileUtils.mkdir_p("#{path}/gems")
269
+ FileUtils.cp rake_path, "#{path}/gems/"
270
+ else
271
+ abort "You need to `rm -rf #{tmp}`"
272
+ end
273
+ update_repo(path, &blk)
274
+ end
275
+
276
+ def update_repo(path)
277
+ @_build_path = "#{path}/gems"
278
+ yield
279
+ @_build_path = nil
280
+ with_gem_path_as Path.base_system_gems do
281
+ Dir.chdir(path) { gem_command :generate_index }
282
+ end
283
+ end
284
+
285
+ def build_index(&block)
286
+ index = Bundler::Index.new
287
+ IndexBuilder.run(index, &block) if block_given?
288
+ index
289
+ end
290
+
291
+ def build_spec(name, version, platform = nil, &block)
292
+ Array(version).map do |v|
293
+ Gem::Specification.new do |s|
294
+ s.name = name
295
+ s.version = Gem::Version.new(v)
296
+ s.platform = platform
297
+ DepBuilder.run(s, &block) if block_given?
298
+ end
299
+ end
300
+ end
301
+
302
+ def build_dep(name, requirements = Gem::Requirement.default, type = :runtime)
303
+ Bundler::Dependency.new(name, :version => requirements)
304
+ end
305
+
306
+ def build_lib(name, *args, &blk)
307
+ build_with(LibBuilder, name, args, &blk)
308
+ end
309
+
310
+ def build_gem(name, *args, &blk)
311
+ build_with(GemBuilder, name, args, &blk)
312
+ end
313
+
314
+ def build_git(name, *args, &block)
315
+ opts = args.last.is_a?(Hash) ? args.last : {}
316
+ builder = opts[:bare] ? GitBareBuilder : GitBuilder
317
+ spec = build_with(builder, name, args, &block)
318
+ GitReader.new(opts[:path] || lib_path(spec.full_name))
319
+ end
320
+
321
+ def update_git(name, *args, &block)
322
+ build_with(GitUpdater, name, args, &block)
323
+ end
324
+
325
+ private
326
+
327
+ def build_with(builder, name, args, &blk)
328
+ @_build_path ||= nil
329
+ options = args.last.is_a?(Hash) ? args.pop : {}
330
+ versions = args.last || "1.0"
331
+ spec = nil
332
+
333
+ options[:path] ||= @_build_path
334
+
335
+ Array(versions).each do |version|
336
+ spec = builder.new(self, name, version)
337
+ if !spec.authors or spec.authors.empty?
338
+ spec.authors = ["no one"]
339
+ end
340
+ yield spec if block_given?
341
+ spec._build(options)
342
+ end
343
+
344
+ spec
345
+ end
346
+
347
+ class IndexBuilder
348
+ include Builders
349
+
350
+ def self.run(index, &block)
351
+ new(index).run(&block)
352
+ end
353
+
354
+ def initialize(index)
355
+ @index = index
356
+ end
357
+
358
+ def run(&block)
359
+ instance_eval(&block)
360
+ end
361
+
362
+ def gem(*args, &block)
363
+ build_spec(*args, &block).each do |s|
364
+ @index << s
365
+ end
366
+ end
367
+
368
+ def platforms(platforms)
369
+ platforms.split(/\s+/).each do |platform|
370
+ platform.gsub!(/^(mswin32)$/, 'x86-\1')
371
+ yield Gem::Platform.new(platform)
372
+ end
373
+ end
374
+
375
+ def versions(versions)
376
+ versions.split(/\s+/).each { |version| yield v(version) }
377
+ end
378
+ end
379
+
380
+ class DepBuilder
381
+ include Builders
382
+
383
+ def self.run(spec, &block)
384
+ new(spec).run(&block)
385
+ end
386
+
387
+ def initialize(spec)
388
+ @spec = spec
389
+ end
390
+
391
+ def run(&block)
392
+ instance_eval(&block)
393
+ end
394
+
395
+ def runtime(name, requirements)
396
+ @spec.add_runtime_dependency(name, requirements)
397
+ end
398
+
399
+ alias dep runtime
400
+ end
401
+
402
+ class LibBuilder
403
+ def initialize(context, name, version)
404
+ @context = context
405
+ @name = name
406
+ @spec = Gem::Specification.new do |s|
407
+ s.name = name
408
+ s.version = version
409
+ s.summary = "This is just a fake gem for testing"
410
+ end
411
+ @files = {}
412
+ end
413
+
414
+ def method_missing(*args, &blk)
415
+ @spec.send(*args, &blk)
416
+ end
417
+
418
+ def write(file, source = "")
419
+ @files[file] = source
420
+ end
421
+
422
+ def executables=(val)
423
+ Array(val).each do |file|
424
+ write "#{@spec.bindir}/#{file}", "require '#{@name}' ; puts #{@name.upcase}"
425
+ end
426
+ @spec.executables = Array(val)
427
+ end
428
+
429
+ def add_c_extension
430
+ require_paths << 'ext'
431
+ extensions << "ext/extconf.rb"
432
+ write "ext/extconf.rb", <<-RUBY
433
+ require "mkmf"
434
+
435
+ # exit 1 unless with_config("simple")
436
+
437
+ extension_name = "very_simple_binary_c"
438
+ dir_config extension_name
439
+ create_makefile extension_name
440
+ RUBY
441
+ write "ext/very_simple_binary.c", <<-C
442
+ #include "ruby.h"
443
+
444
+ void Init_very_simple_binary_c() {
445
+ rb_define_module("VerySimpleBinaryInC");
446
+ }
447
+ C
448
+ end
449
+
450
+ def _build(options)
451
+ path = options[:path] || _default_path
452
+
453
+ if options[:rubygems_version]
454
+ @spec.rubygems_version = options[:rubygems_version]
455
+ def @spec.mark_version; end
456
+ def @spec.validate; end
457
+ end
458
+
459
+ case options[:gemspec]
460
+ when false
461
+ # do nothing
462
+ when :yaml
463
+ @files["#{name}.gemspec"] = @spec.to_yaml
464
+ else
465
+ @files["#{name}.gemspec"] = @spec.to_ruby
466
+ end
467
+
468
+ unless options[:no_default]
469
+ @files = _default_files.merge(@files)
470
+ end
471
+
472
+ @spec.authors = ["no one"]
473
+
474
+ @files.each do |file, source|
475
+ file = Pathname.new(path).join(file)
476
+ FileUtils.mkdir_p(file.dirname)
477
+ File.open(file, 'w') { |f| f.puts source }
478
+ end
479
+ @spec.files = @files.keys
480
+ path
481
+ end
482
+
483
+ def _default_files
484
+ @_default_files ||= { "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}'" }
485
+ end
486
+
487
+ def _default_path
488
+ @context.tmp('libs', @spec.full_name)
489
+ end
490
+ end
491
+
492
+ class GitBuilder < LibBuilder
493
+ def _build(options)
494
+ path = options[:path] || _default_path
495
+ super(options.merge(:path => path))
496
+ Dir.chdir(path) do
497
+ `git init`
498
+ `git add *`
499
+ `git config user.email "lol@wut.com"`
500
+ `git config user.name "lolwut"`
501
+ `git commit -m 'OMG INITIAL COMMIT'`
502
+ end
503
+ end
504
+ end
505
+
506
+ class GitBareBuilder < LibBuilder
507
+ def _build(options)
508
+ path = options[:path] || _default_path
509
+ super(options.merge(:path => path))
510
+ Dir.chdir(path) do
511
+ `git init --bare`
512
+ end
513
+ end
514
+ end
515
+
516
+ class GitUpdater < LibBuilder
517
+ WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
518
+ NULL = WINDOWS ? "NUL" : "/dev/null"
519
+
520
+ def silently(str)
521
+ `#{str} 2>#{NULL}`
522
+ end
523
+
524
+ def _build(options)
525
+ libpath = options[:path] || _default_path
526
+
527
+ Dir.chdir(libpath) do
528
+ silently "git checkout master"
529
+
530
+ if branch = options[:branch]
531
+ raise "You can't specify `master` as the branch" if branch == "master"
532
+
533
+ if `git branch | grep #{branch}`.empty?
534
+ silently("git branch #{branch}")
535
+ end
536
+
537
+ silently("git checkout #{branch}")
538
+ elsif tag = options[:tag]
539
+ `git tag #{tag}`
540
+ elsif options[:remote]
541
+ silently("git remote add origin file://#{options[:remote]}")
542
+ elsif options[:push]
543
+ silently("git push origin #{options[:push]}")
544
+ end
545
+
546
+ current_ref = `git rev-parse HEAD`.strip
547
+ _default_files.keys.each do |path|
548
+ _default_files[path] << "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
549
+ end
550
+ super(options.merge(:path => libpath))
551
+ `git add *`
552
+ `git commit -m "BUMP"`
553
+ end
554
+ end
555
+ end
556
+
557
+ class GitReader
558
+ attr_reader :path
559
+
560
+ def initialize(path)
561
+ @path = path
562
+ end
563
+
564
+ def ref_for(ref, len = nil)
565
+ ref = git "rev-parse #{ref}"
566
+ ref = ref[0..len] if len
567
+ ref
568
+ end
569
+
570
+ private
571
+
572
+ def git(cmd)
573
+ Dir.chdir(@path) { `git #{cmd}`.strip }
574
+ end
575
+
576
+ end
577
+
578
+ class GemBuilder < LibBuilder
579
+
580
+ def _build(opts)
581
+ lib_path = super(opts.merge(:path => @context.tmp(".tmp/#{@spec.full_name}"), :no_default => opts[:no_default]))
582
+ Dir.chdir(lib_path) do
583
+ destination = opts[:path] || _default_path
584
+ FileUtils.mkdir_p(destination)
585
+
586
+ if !@spec.authors or @spec.authors.empty?
587
+ @spec.authors = ["that guy"]
588
+ end
589
+
590
+ Gem::Builder.new(@spec).build
591
+ if opts[:to_system]
592
+ `gem install --ignore-dependencies #{@spec.full_name}.gem`
593
+ else
594
+ FileUtils.mv("#{@spec.full_name}.gem", opts[:path] || _default_path)
595
+ end
596
+ end
597
+ end
598
+
599
+ def _default_path
600
+ @context.gem_repo1('gems')
601
+ end
602
+ end
603
+ end
604
+ end