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