summaryrefslogtreecommitdiff
blob: b2a253c81643ce4b991ce65a50ef1fc0cd0f1d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
Port the changes made in the ruby repository back to the official(?) rubygems repo.
This is also the official nomination for the 'most retarded upstream' award.

Upstream: yes, at one of two
Reference: http://redmine.ruby-lang.org/issues/show/3607

diff -Naur site_ruby/1.9.1/rubygems/config_file.rb lib/rubygems/config_file.rb
--- site_ruby/1.9.1/rubygems/config_file.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems/config_file.rb	2010-06-08 15:14:51.000000000 +0200
@@ -46,29 +46,12 @@
   PLATFORM_DEFAULTS = {}
 
   system_config_path =
-    if Gem.respond_to? :system_config_path
-      Gem::system_config_path
-    else
     begin
-      require 'Win32API'
-
-      CSIDL_COMMON_APPDATA = 0x0023
-      path = 0.chr * 260
-      if RUBY_VERSION > '1.9' then
-        SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
-                                       'L', :stdcall
-        SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
-      else
-        SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
-                                       'L'
-        SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
-      end
-
-      path.strip
+      require 'etc.so'
+      Etc.sysconfdir
     rescue LoadError
       '/etc'
     end
-    end
 
   SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
 
diff -Naur site_ruby/1.9.1/rubygems/custom_require.rb lib/rubygems/custom_require.rb
--- site_ruby/1.9.1/rubygems/custom_require.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems/custom_require.rb	2010-07-29 17:14:57.000000000 +0200
@@ -4,8 +4,6 @@
 # See LICENSE.txt for permissions.
 #++
 
-require 'rubygems'
-
 module Kernel
 
   ##
@@ -30,17 +28,17 @@
   def require(path) # :doc:
     gem_original_require path
   rescue LoadError => load_error
-    if load_error.message =~ /#{Regexp.escape path}\z/ and
-       spec = Gem.searcher.find(path) then
-      Gem.activate(spec.name, "= #{spec.version}")
-      gem_original_require path
-    else
-      raise load_error
+    if load_error.message.end_with?(path)
+      if Gem.try_activate(path)
+        return gem_original_require(path)
+      end
     end
+
+    raise load_error
   end
 
   private :require
   private :gem_original_require
 
-end
+end unless Kernel.private_method_defined?(:gem_original_require)
 
diff -Naur site_ruby/1.9.1/rubygems/install_update_options.rb lib/rubygems/install_update_options.rb
--- site_ruby/1.9.1/rubygems/install_update_options.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems/install_update_options.rb	2010-06-11 16:02:18.000000000 +0200
@@ -59,8 +59,7 @@
     end
 
     add_option(:"Install/Update", '-t', '--[no-]test',
-               'Run unit tests prior to installation') do |value, options|
-      options[:test] = value
+               'Ignored; just for compatiblity') do |value, options|
     end
 
     add_option(:"Install/Update", '-w', '--[no-]wrappers',
@@ -110,7 +109,7 @@
   # Default options for the gem install command.
 
   def install_update_defaults_str
-    '--rdoc --no-force --no-test --wrappers'
+    '--rdoc --no-force --wrappers'
   end
 
 end
diff -Naur site_ruby/1.9.1/rubygems/require_paths_builder.rb lib/rubygems/require_paths_builder.rb
--- site_ruby/1.9.1/rubygems/require_paths_builder.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems/require_paths_builder.rb	2010-06-27 03:41:40.000000000 +0200
@@ -2,15 +2,11 @@
 
 module Gem::RequirePathsBuilder
   def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
-    return if spec.require_paths == ["lib"] &&
-              (spec.bindir.nil? || spec.bindir == "bin")
-    file_name = File.join(gem_home, 'gems', "#{@spec.full_name}", ".require_paths")
-    file_name.untaint
-    File.open(file_name, "w") do |file|
-      spec.require_paths.each do |path|
-        file.puts path
-      end
-      file.puts spec.bindir if spec.bindir
+    require_paths = spec.require_paths
+    return if require_paths.size == 1 and require_paths.first == "lib"
+    file_name = "#{gem_home}/gems/#{@spec.full_name}/.require_paths".untaint
+    File.open(file_name, "wb") do |file|
+      file.puts require_paths
     end
   end
 end
diff -Naur site_ruby/1.9.1/rubygems/test_utilities.rb lib/rubygems/test_utilities.rb
--- site_ruby/1.9.1/rubygems/test_utilities.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems/test_utilities.rb	2010-02-22 03:52:35.000000000 +0100
@@ -131,30 +131,17 @@
 #--
 # This class was added to flush out problems in Rubinius' IO implementation.
 
-class TempIO
-
-  @@count = 0
-
+class TempIO < Tempfile
   def initialize(string = '')
-    @tempfile = Tempfile.new "TempIO-#{@@count += 1}"
-    @tempfile.binmode
-    @tempfile.write string
-    @tempfile.rewind
-  end
-
-  def method_missing(meth, *args, &block)
-    @tempfile.send(meth, *args, &block)
-  end
-
-  def respond_to?(meth)
-    @tempfile.respond_to? meth
+    super "TempIO"
+    binmode
+    write string
+    rewind
   end
 
   def string
-    @tempfile.flush
-
-    Gem.read_binary @tempfile.path
+    flush
+    Gem.read_binary path
   end
-
 end
 
diff -Naur site_ruby/1.9.1/rubygems/validator.rb lib/rubygems/validator.rb
--- site_ruby/1.9.1/rubygems/validator.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems/validator.rb	2010-04-22 10:24:42.000000000 +0200
@@ -165,6 +165,7 @@
     errors
   end
 
+=begin
   if RUBY_VERSION < '1.9' then
     class TestRunner
       def initialize(suite, ui)
@@ -192,6 +193,7 @@
 
     autoload :TestRunner, 'test/unit/ui/testrunnerutilities'
   end
+=end
 
   ##
   # Runs unit tests for a given gem specification
@@ -212,6 +214,7 @@
 
     test_files.each do |f| require f end
 
+=begin
     if RUBY_VERSION < '1.9' then
       suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")
 
@@ -226,6 +229,9 @@
       result = MiniTest::Unit.new
       result.run
     end
+=end
+    result = MiniTest::Unit.new
+    result.run
 
     result
   ensure
--- site_ruby/1.9.1/rubygems.rb	2010-08-24 13:01:50.000000000 +0200
+++ lib/rubygems.rb	2010-07-29 17:14:57.000000000 +0200
@@ -7,6 +7,11 @@
 
 gem_disabled = !defined? Gem
 
+unless gem_disabled
+  # Nuke the Quickloader stuff
+  Gem::QuickLoader.remove
+end
+
 require 'rubygems/defaults'
 require 'thread'
 require 'etc'
@@ -487,26 +492,8 @@
 
   ##
   # Finds the user's home directory.
-  #--
-  # Some comments from the ruby-talk list regarding finding the home
-  # directory:
-  #
-  #   I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
-  #   to be depending on HOME in those code samples. I propose that
-  #   it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
-  #   least on Win32).
 
   def self.find_home
-    unless RUBY_VERSION > '1.9' then
-      ['HOME', 'USERPROFILE'].each do |homekey|
-        return ENV[homekey] if ENV[homekey]
-      end
-
-      if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
-        return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
-      end
-    end
-
     File.expand_path "~"
   rescue
     if File::ALT_SEPARATOR then
@@ -594,17 +581,13 @@
   # so you can override the gem_prelude.rb default $LOAD_PATH paths.
 
   def self.load_path_insert_index
-    index = $LOAD_PATH.index ConfigMap[:sitelibdir]
+    $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
+  end
 
-    $LOAD_PATH.each_with_index do |path, i|
-      if path.instance_variables.include?(:@gem_prelude_index) or
-        path.instance_variables.include?('@gem_prelude_index') then
-        index = i
-        break
-      end
+  def self.remove_prelude_paths
+    Gem::QuickLoader::GemLoadPaths.each do |path|
+      $LOAD_PATH.delete(path)
     end
-
-    index
   end
 
   ##
@@ -1048,7 +1031,7 @@
 
 module Kernel
 
-  undef gem if respond_to? :gem # defined in gem_prelude.rb on 1.9
+  remove_method :gem if respond_to?(:gem, true) # defined in gem_prelude.rb on 1.9
 
   ##
   # Use Kernel#gem to activate a specific version of +gem_name+.
@@ -1126,13 +1109,27 @@
 
 require 'rubygems/config_file'
 
+class << Gem
+  remove_method :try_activate if Gem.respond_to?(:try_activate, true)
+
+  def try_activate(path)
+    spec = Gem.searcher.find(path)
+    return false unless spec
+
+    Gem.activate(spec.name, "= #{spec.version}")
+    return true
+  end
+end
+
 ##
 # Enables the require hook for RubyGems.
 #
-# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
-# constant at rubygems.rb load time.
+# if --disable-rubygems was used, then the prelude wasn't loaded, so
+# we need to load the custom_require now.
 
-require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9'
+if gem_disabled
+  require 'rubygems/custom_require'
+end
 
 Gem.clear_paths