bundler 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (108) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGELOG.md +28 -6
  3. data/ISSUES.md +1 -1
  4. data/README.md +7 -5
  5. data/Rakefile +173 -0
  6. data/UPGRADING.md +103 -0
  7. data/bundler.gemspec +28 -0
  8. data/lib/bundler.rb +1 -0
  9. data/lib/bundler/capistrano.rb +2 -31
  10. data/lib/bundler/cli.rb +18 -16
  11. data/lib/bundler/deployment.rb +37 -0
  12. data/lib/bundler/dsl.rb +3 -3
  13. data/lib/bundler/gem_helper.rb +4 -7
  14. data/lib/bundler/graph.rb +3 -3
  15. data/lib/bundler/installer.rb +1 -0
  16. data/lib/bundler/lockfile_parser.rb +1 -1
  17. data/lib/bundler/man/bundle +1 -1
  18. data/lib/bundler/man/bundle-config +92 -0
  19. data/lib/bundler/man/bundle-config.txt +72 -30
  20. data/lib/bundler/man/bundle-exec +1 -1
  21. data/lib/bundler/man/bundle-exec.txt +1 -1
  22. data/lib/bundler/man/bundle-install +1 -1
  23. data/lib/bundler/man/bundle-install.txt +1 -1
  24. data/lib/bundler/man/bundle-package +1 -1
  25. data/lib/bundler/man/bundle-package.txt +1 -1
  26. data/lib/bundler/man/bundle-update +1 -1
  27. data/lib/bundler/man/bundle-update.txt +1 -1
  28. data/lib/bundler/man/bundle.txt +1 -1
  29. data/lib/bundler/man/gemfile.5 +2 -2
  30. data/lib/bundler/man/gemfile.5.txt +2 -2
  31. data/lib/bundler/settings.rb +2 -2
  32. data/lib/bundler/source.rb +2 -3
  33. data/lib/bundler/templates/Executable +1 -1
  34. data/lib/bundler/templates/newgem/Gemfile.tt +1 -1
  35. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  36. data/lib/bundler/templates/newgem/newgem.gemspec.tt +11 -12
  37. data/lib/bundler/version.rb +1 -1
  38. data/lib/bundler/vlad.rb +9 -0
  39. data/man/bundle-config.ronn +90 -0
  40. data/man/bundle-exec.ronn +98 -0
  41. data/man/bundle-install.ronn +310 -0
  42. data/man/bundle-package.ronn +59 -0
  43. data/man/bundle-update.ronn +176 -0
  44. data/man/bundle.ronn +77 -0
  45. data/man/gemfile.5.ronn +254 -0
  46. data/man/index.txt +6 -0
  47. data/spec/cache/gems_spec.rb +205 -0
  48. data/spec/cache/git_spec.rb +9 -0
  49. data/spec/cache/path_spec.rb +27 -0
  50. data/spec/cache/platform_spec.rb +57 -0
  51. data/spec/install/deploy_spec.rb +171 -0
  52. data/spec/install/deprecated_spec.rb +43 -0
  53. data/spec/install/gems/c_ext_spec.rb +48 -0
  54. data/spec/install/gems/env_spec.rb +107 -0
  55. data/spec/install/gems/flex_spec.rb +272 -0
  56. data/spec/install/gems/groups_spec.rb +209 -0
  57. data/spec/install/gems/locked_spec.rb +48 -0
  58. data/spec/install/gems/packed_spec.rb +72 -0
  59. data/spec/install/gems/platform_spec.rb +181 -0
  60. data/spec/install/gems/resolving_spec.rb +72 -0
  61. data/spec/install/gems/simple_case_spec.rb +709 -0
  62. data/spec/install/gems/sudo_spec.rb +77 -0
  63. data/spec/install/gems/win32_spec.rb +26 -0
  64. data/spec/install/gemspec_spec.rb +96 -0
  65. data/spec/install/git_spec.rb +552 -0
  66. data/spec/install/invalid_spec.rb +17 -0
  67. data/spec/install/path_spec.rb +335 -0
  68. data/spec/install/upgrade_spec.rb +26 -0
  69. data/spec/lock/flex_spec.rb +625 -0
  70. data/spec/lock/git_spec.rb +35 -0
  71. data/spec/other/check_spec.rb +221 -0
  72. data/spec/other/config_spec.rb +40 -0
  73. data/spec/other/console_spec.rb +102 -0
  74. data/spec/other/exec_spec.rb +241 -0
  75. data/spec/other/ext_spec.rb +16 -0
  76. data/spec/other/gem_helper_spec.rb +116 -0
  77. data/spec/other/help_spec.rb +36 -0
  78. data/spec/other/init_spec.rb +40 -0
  79. data/spec/other/newgem_spec.rb +24 -0
  80. data/spec/other/open_spec.rb +51 -0
  81. data/spec/other/show_spec.rb +99 -0
  82. data/spec/pack/gems_spec.rb +22 -0
  83. data/spec/quality_spec.rb +55 -0
  84. data/spec/resolver/basic_spec.rb +20 -0
  85. data/spec/resolver/platform_spec.rb +57 -0
  86. data/spec/runtime/environment_rb_spec.rb +170 -0
  87. data/spec/runtime/executable_spec.rb +110 -0
  88. data/spec/runtime/load_spec.rb +107 -0
  89. data/spec/runtime/platform_spec.rb +90 -0
  90. data/spec/runtime/require_spec.rb +261 -0
  91. data/spec/runtime/setup_spec.rb +412 -0
  92. data/spec/runtime/with_clean_env_spec.rb +15 -0
  93. data/spec/spec_helper.rb +81 -0
  94. data/spec/support/builders.rb +566 -0
  95. data/spec/support/helpers.rb +243 -0
  96. data/spec/support/indexes.rb +113 -0
  97. data/spec/support/matchers.rb +89 -0
  98. data/spec/support/path.rb +71 -0
  99. data/spec/support/platforms.rb +49 -0
  100. data/spec/support/ruby_ext.rb +19 -0
  101. data/spec/support/rubygems_ext.rb +30 -0
  102. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  103. data/spec/support/sudo.rb +21 -0
  104. data/spec/update/gems_spec.rb +86 -0
  105. data/spec/update/git_spec.rb +159 -0
  106. data/spec/update/source_spec.rb +50 -0
  107. metadata +170 -32
  108. data/ROADMAP.md +0 -36
@@ -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
@@ -0,0 +1,81 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'fileutils'
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ require 'rspec'
8
+
9
+ # Require the correct version of popen for the current platform
10
+ if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/
11
+ begin
12
+ require 'win32/open3'
13
+ rescue LoadError
14
+ abort "Run `gem install win32-open3` to be able to run specs"
15
+ end
16
+ else
17
+ require 'open3'
18
+ end
19
+
20
+ Dir["#{File.expand_path('../support', __FILE__)}/*.rb"].each do |file|
21
+ require file
22
+ end
23
+
24
+ $debug = false
25
+ $show_err = true
26
+
27
+ Spec::Rubygems.setup
28
+ FileUtils.rm_rf(Spec::Path.gem_repo1)
29
+ ENV['RUBYOPT'] = "-I#{Spec::Path.root}/spec/support/rubygems_hax"
30
+
31
+ RSpec.configure do |config|
32
+ config.include Spec::Builders
33
+ config.include Spec::Helpers
34
+ config.include Spec::Indexes
35
+ config.include Spec::Matchers
36
+ config.include Spec::Path
37
+ config.include Spec::Rubygems
38
+ config.include Spec::Platforms
39
+ config.include Spec::Sudo
40
+
41
+ config.filter_run :focus => true
42
+ config.run_all_when_everything_filtered = true
43
+
44
+ original_wd = Dir.pwd
45
+ original_path = ENV['PATH']
46
+ original_gem_home = ENV['GEM_HOME']
47
+
48
+ def pending_jruby_shebang_fix
49
+ pending "JRuby executables do not have a proper shebang" if RUBY_PLATFORM == "java"
50
+ end
51
+
52
+ def check(*args)
53
+ # suppresses ruby warnings about "useless use of == in void context"
54
+ # e.g. check foo.should == bar
55
+ end
56
+
57
+ config.before :all do
58
+ build_repo1
59
+ end
60
+
61
+ config.before :each do
62
+ reset!
63
+ system_gems []
64
+ in_app_root
65
+ end
66
+
67
+ config.after :each do
68
+ Dir.chdir(original_wd)
69
+ # Reset ENV
70
+ ENV['PATH'] = original_path
71
+ ENV['GEM_HOME'] = original_gem_home
72
+ ENV['GEM_PATH'] = original_gem_home
73
+ ENV['BUNDLE_PATH'] = nil
74
+ ENV['BUNDLE_GEMFILE'] = nil
75
+ ENV['BUNDLER_TEST'] = nil
76
+ ENV['BUNDLE_FROZEN'] = nil
77
+ ENV['BUNDLER_SPEC_PLATFORM'] = nil
78
+ ENV['BUNDLER_SPEC_VERSION'] = nil
79
+ ENV['BUNDLE_APP_CONFIG'] = nil
80
+ end
81
+ end
@@ -0,0 +1,566 @@
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"
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
+ Gem.source_index.find_name('').each do |gem|
171
+ puts gem.full_name
172
+ end
173
+ Y
174
+ end
175
+
176
+ # The rcov gem is platform mswin32, but has no arch
177
+ build_gem "rcov" do |s|
178
+ s.platform = Gem::Platform.new([nil, "mswin32", nil])
179
+ s.write "lib/rcov.rb", "RCOV = '1.0.0'"
180
+ end
181
+
182
+ build_gem "net-ssh"
183
+ build_gem "net-sftp", "1.1.1" do |s|
184
+ s.add_dependency "net-ssh", ">= 1.0.0", "< 1.99.0"
185
+ end
186
+
187
+ # Test comlicated gem dependencies for install
188
+ build_gem "net_a" do |s|
189
+ s.add_dependency "net_b"
190
+ s.add_dependency "net_build_extensions"
191
+ end
192
+
193
+ build_gem "net_b"
194
+
195
+ build_gem "net_build_extensions" do |s|
196
+ s.add_dependency "rake"
197
+ s.extensions << "Rakefile"
198
+ s.write "Rakefile", <<-RUBY
199
+ task :default do
200
+ path = File.expand_path("../lib", __FILE__)
201
+ FileUtils.mkdir_p(path)
202
+ File.open("\#{path}/net_build_extensions.rb", "w") do |f|
203
+ f.puts "NET_BUILD_EXTENSIONS = 'YES'"
204
+ end
205
+ end
206
+ RUBY
207
+ end
208
+
209
+ build_gem "net_c" do |s|
210
+ s.add_dependency "net_a"
211
+ s.add_dependency "net_d"
212
+ end
213
+
214
+ build_gem "net_d"
215
+
216
+ build_gem "net_e" do |s|
217
+ s.add_dependency "net_d"
218
+ end
219
+
220
+ build_gem "foo"
221
+ end
222
+ end
223
+
224
+ def build_repo2(&blk)
225
+ FileUtils.rm_rf gem_repo2
226
+ FileUtils.cp_r gem_repo1, gem_repo2
227
+ update_repo2(&blk) if block_given?
228
+ end
229
+
230
+ def build_repo3
231
+ build_repo gem_repo3 do
232
+ build_gem "rack"
233
+ end
234
+ FileUtils.rm_rf Dir[gem_repo3("prerelease*")]
235
+ end
236
+
237
+ def update_repo2
238
+ update_repo gem_repo2 do
239
+ build_gem "rack", "1.2" do |s|
240
+ s.executables = "rackup"
241
+ end
242
+ yield if block_given?
243
+ end
244
+ end
245
+
246
+ def build_repo(path, &blk)
247
+ return if File.directory?(path)
248
+ rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first
249
+ if rake_path
250
+ FileUtils.mkdir_p("#{path}/gems")
251
+ FileUtils.cp rake_path, "#{path}/gems/"
252
+ else
253
+ abort "You need to `rm -rf #{tmp}`"
254
+ end
255
+ update_repo(path, &blk)
256
+ end
257
+
258
+ def update_repo(path)
259
+ @_build_path = "#{path}/gems"
260
+ yield
261
+ @_build_path = nil
262
+ with_gem_path_as Path.base_system_gems do
263
+ Dir.chdir(path) { gem_command :generate_index }
264
+ end
265
+ end
266
+
267
+ def build_index(&block)
268
+ index = Bundler::Index.new
269
+ IndexBuilder.run(index, &block) if block_given?
270
+ index
271
+ end
272
+
273
+ def build_spec(name, version, platform = nil, &block)
274
+ Array(version).map do |v|
275
+ Gem::Specification.new do |s|
276
+ s.name = name
277
+ s.version = Gem::Version.new(v)
278
+ s.platform = platform
279
+ DepBuilder.run(s, &block) if block_given?
280
+ end
281
+ end
282
+ end
283
+
284
+ def build_dep(name, requirements = Gem::Requirement.default, type = :runtime)
285
+ Bundler::Dependency.new(name, :version => requirements)
286
+ end
287
+
288
+ def build_lib(name, *args, &blk)
289
+ build_with(LibBuilder, name, args, &blk)
290
+ end
291
+
292
+ def build_gem(name, *args, &blk)
293
+ build_with(GemBuilder, name, args, &blk)
294
+ end
295
+
296
+ def build_git(name, *args, &block)
297
+ opts = Hash === args.last ? args.last : {}
298
+ spec = build_with(GitBuilder, name, args, &block)
299
+ GitReader.new(opts[:path] || lib_path(spec.full_name))
300
+ end
301
+
302
+ def update_git(name, *args, &block)
303
+ build_with(GitUpdater, name, args, &block)
304
+ end
305
+
306
+ private
307
+
308
+ def build_with(builder, name, args, &blk)
309
+ @_build_path ||= nil
310
+ options = args.last.is_a?(Hash) ? args.pop : {}
311
+ versions = args.last || "1.0"
312
+ spec = nil
313
+
314
+ options[:path] ||= @_build_path
315
+
316
+ Array(versions).each do |version|
317
+ spec = builder.new(self, name, version)
318
+ yield spec if block_given?
319
+ spec._build(options)
320
+ end
321
+
322
+ spec
323
+ end
324
+
325
+ class IndexBuilder
326
+ include Builders
327
+
328
+ def self.run(index, &block)
329
+ new(index).run(&block)
330
+ end
331
+
332
+ def initialize(index)
333
+ @index = index
334
+ end
335
+
336
+ def run(&block)
337
+ instance_eval(&block)
338
+ end
339
+
340
+ def gem(*args, &block)
341
+ build_spec(*args, &block).each do |s|
342
+ @index << s
343
+ end
344
+ end
345
+
346
+ def platforms(platforms)
347
+ platforms.split(/\s+/).each do |platform|
348
+ platform = 'x86-mswin32' if platform == 'mswin32'
349
+ platform = Gem::Platform.new(platform)
350
+ if String === platform
351
+ class << platform
352
+ undef =~
353
+ alias =~ ==
354
+ end
355
+ end
356
+ yield Gem::Platform.new(platform)
357
+ end
358
+ end
359
+
360
+ def versions(versions)
361
+ versions.split(/\s+/).each { |version| yield v(version) }
362
+ end
363
+ end
364
+
365
+ class DepBuilder
366
+ include Builders
367
+
368
+ def self.run(spec, &block)
369
+ new(spec).run(&block)
370
+ end
371
+
372
+ def initialize(spec)
373
+ @spec = spec
374
+ end
375
+
376
+ def run(&block)
377
+ instance_eval(&block)
378
+ end
379
+
380
+ def runtime(name, requirements)
381
+ @spec.add_runtime_dependency(name, requirements)
382
+ end
383
+
384
+ alias dep runtime
385
+ end
386
+
387
+ class LibBuilder
388
+ def initialize(context, name, version)
389
+ @context = context
390
+ @name = name
391
+ @spec = Gem::Specification.new do |s|
392
+ s.name = name
393
+ s.version = version
394
+ s.summary = "This is just a fake gem for testing"
395
+ end
396
+ @files = {}
397
+ end
398
+
399
+ def method_missing(*args, &blk)
400
+ @spec.send(*args, &blk)
401
+ end
402
+
403
+ def write(file, source = "")
404
+ @files[file] = source
405
+ end
406
+
407
+ def executables=(val)
408
+ Array(val).each do |file|
409
+ write "bin/#{file}", "require '#{@name}' ; puts #{@name.upcase}"
410
+ end
411
+ @spec.executables = Array(val)
412
+ end
413
+
414
+ def add_c_extension
415
+ require_paths << 'ext'
416
+ extensions << "ext/extconf.rb"
417
+ write "ext/extconf.rb", <<-RUBY
418
+ require "mkmf"
419
+
420
+ # exit 1 unless with_config("simple")
421
+
422
+ extension_name = "very_simple_binary_c"
423
+ dir_config extension_name
424
+ create_makefile extension_name
425
+ RUBY
426
+ write "ext/very_simple_binary.c", <<-C
427
+ #include "ruby.h"
428
+
429
+ void Init_very_simple_binary_c() {
430
+ rb_define_module("VerySimpleBinaryInC");
431
+ }
432
+ C
433
+ end
434
+
435
+ def _build(options)
436
+ path = options[:path] || _default_path
437
+
438
+ if options[:rubygems_version]
439
+ @spec.rubygems_version = options[:rubygems_version]
440
+ def @spec.mark_version; end
441
+ def @spec.validate; end
442
+ end
443
+
444
+ case options[:gemspec]
445
+ when false
446
+ # do nothing
447
+ when :yaml
448
+ @files["#{name}.gemspec"] = @spec.to_yaml
449
+ else
450
+ @files["#{name}.gemspec"] = @spec.to_ruby
451
+ end
452
+
453
+ unless options[:no_default]
454
+ @files = _default_files.merge(@files)
455
+ end
456
+
457
+ @files.each do |file, source|
458
+ file = Pathname.new(path).join(file)
459
+ FileUtils.mkdir_p(file.dirname)
460
+ File.open(file, 'w') { |f| f.puts source }
461
+ end
462
+ @spec.files = @files.keys
463
+ path
464
+ end
465
+
466
+ def _default_files
467
+ @_default_files ||= { "lib/#{name}.rb" => "#{Builders.constantize(name)} = '#{version}'" }
468
+ end
469
+
470
+ def _default_path
471
+ @context.tmp('libs', @spec.full_name)
472
+ end
473
+ end
474
+
475
+ class GitBuilder < LibBuilder
476
+ def _build(options)
477
+ path = options[:path] || _default_path
478
+ super(options.merge(:path => path))
479
+ Dir.chdir(path) do
480
+ `git init`
481
+ `git add *`
482
+ `git commit -m 'OMG INITIAL COMMIT'`
483
+ end
484
+ end
485
+ end
486
+
487
+ class GitUpdater < LibBuilder
488
+ WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
489
+ NULL = WINDOWS ? "NUL" : "/dev/null"
490
+
491
+ def silently(str)
492
+ `#{str} 2>#{NULL}`
493
+ end
494
+
495
+ def _build(options)
496
+ libpath = options[:path] || _default_path
497
+
498
+ Dir.chdir(libpath) do
499
+ silently "git checkout master"
500
+
501
+ if branch = options[:branch]
502
+ raise "You can't specify `master` as the branch" if branch == "master"
503
+
504
+ if `git branch | grep #{branch}`.empty?
505
+ silently("git branch #{branch}")
506
+ end
507
+
508
+ silently("git checkout #{branch}")
509
+ elsif tag = options[:tag]
510
+ `git tag #{tag}`
511
+ end
512
+
513
+ current_ref = `git rev-parse HEAD`.strip
514
+ _default_files.keys.each do |path|
515
+ _default_files[path] << "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'"
516
+ end
517
+ super(options.merge(:path => libpath))
518
+ `git add *`
519
+ `git commit -m "BUMP"`
520
+ end
521
+ end
522
+ end
523
+
524
+ class GitReader
525
+ attr_reader :path
526
+
527
+ def initialize(path)
528
+ @path = path
529
+ end
530
+
531
+ def ref_for(ref, len = nil)
532
+ ref = git "rev-parse #{ref}"
533
+ ref = ref[0..len] if len
534
+ ref
535
+ end
536
+
537
+ private
538
+
539
+ def git(cmd)
540
+ Dir.chdir(@path) { `git #{cmd}`.strip }
541
+ end
542
+
543
+ end
544
+
545
+ class GemBuilder < LibBuilder
546
+
547
+ def _build(opts)
548
+ lib_path = super(opts.merge(:path => @context.tmp(".tmp/#{@spec.full_name}"), :no_default => opts[:no_default]))
549
+ Dir.chdir(lib_path) do
550
+ destination = opts[:path] || _default_path
551
+ FileUtils.mkdir_p(destination)
552
+ Gem::Builder.new(@spec).build
553
+ if opts[:to_system]
554
+ `gem install --ignore-dependencies #{@spec.full_name}.gem`
555
+ else
556
+ FileUtils.mv("#{@spec.full_name}.gem", opts[:path] || _default_path)
557
+ end
558
+ end
559
+ end
560
+
561
+ def _default_path
562
+ @context.gem_repo1('gems')
563
+ end
564
+ end
565
+ end
566
+ end