rubygems-update 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +5 -1
- data/History.txt +101 -4
- data/LICENSE.txt +42 -37
- data/MIT.txt +20 -0
- data/Manifest.txt +5 -4
- data/Rakefile +6 -7
- data/lib/rubygems.rb +175 -278
- data/lib/rubygems/builder.rb +7 -6
- data/lib/rubygems/command_manager.rb +16 -2
- data/lib/rubygems/commands/build_command.rb +13 -11
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +10 -19
- data/lib/rubygems/commands/contents_command.rb +5 -5
- data/lib/rubygems/commands/dependency_command.rb +17 -40
- data/lib/rubygems/commands/fetch_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +2 -1
- data/lib/rubygems/commands/lock_command.rb +4 -4
- data/lib/rubygems/commands/outdated_command.rb +18 -6
- data/lib/rubygems/commands/pristine_command.rb +25 -15
- data/lib/rubygems/commands/query_command.rb +9 -6
- data/lib/rubygems/commands/setup_command.rb +1 -1
- data/lib/rubygems/commands/specification_command.rb +8 -23
- data/lib/rubygems/commands/stale_command.rb +2 -1
- data/lib/rubygems/commands/unpack_command.rb +7 -5
- data/lib/rubygems/commands/update_command.rb +2 -4
- data/lib/rubygems/commands/which_command.rb +5 -9
- data/lib/rubygems/config_file.rb +9 -7
- data/lib/rubygems/custom_require.rb +6 -4
- data/lib/rubygems/defaults.rb +30 -14
- data/lib/rubygems/dependency.rb +44 -1
- data/lib/rubygems/dependency_installer.rb +37 -41
- data/lib/rubygems/dependency_list.rb +20 -9
- data/lib/rubygems/deprecate.rb +3 -3
- data/lib/rubygems/doc_manager.rb +10 -11
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +19 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +117 -123
- data/lib/rubygems/installer.rb +101 -94
- data/lib/rubygems/installer_test_case.rb +28 -30
- data/lib/rubygems/local_remote_options.rb +1 -1
- data/lib/rubygems/mock_gem_ui.rb +10 -3
- data/lib/rubygems/package.rb +0 -26
- data/lib/rubygems/package/tar_input.rb +5 -6
- data/lib/rubygems/package_task.rb +1 -1
- data/lib/rubygems/path_support.rb +72 -0
- data/lib/rubygems/platform.rb +12 -2
- data/lib/rubygems/remote_fetcher.rb +7 -6
- data/lib/rubygems/requirement.rb +3 -0
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +67 -67
- data/lib/rubygems/source_index.rb +58 -29
- data/lib/rubygems/spec_fetcher.rb +5 -1
- data/lib/rubygems/specification.rb +1422 -877
- data/lib/rubygems/test_case.rb +114 -64
- data/lib/rubygems/test_utilities.rb +4 -3
- data/lib/rubygems/text.rb +1 -1
- data/lib/rubygems/uninstaller.rb +37 -44
- data/test/rubygems/test_gem.rb +131 -102
- data/test/rubygems/test_gem_builder.rb +18 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -0
- data/test/rubygems/test_gem_commands_build_command.rb +31 -3
- data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
- data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
- data/test/rubygems/test_gem_commands_help_command.rb +58 -0
- data/test/rubygems/test_gem_commands_install_command.rb +25 -24
- data/test/rubygems/test_gem_commands_list_command.rb +1 -4
- data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
- data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
- data/test/rubygems/test_gem_commands_push_command.rb +1 -1
- data/test/rubygems/test_gem_commands_query_command.rb +15 -82
- data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
- data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
- data/test/rubygems/test_gem_commands_update_command.rb +19 -23
- data/test/rubygems/test_gem_commands_which_command.rb +7 -4
- data/test/rubygems/test_gem_dependency.rb +14 -8
- data/test/rubygems/test_gem_dependency_installer.rb +87 -33
- data/test/rubygems/test_gem_dependency_list.rb +7 -3
- data/test/rubygems/test_gem_doc_manager.rb +3 -3
- data/test/rubygems/test_gem_format.rb +1 -1
- data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
- data/test/rubygems/test_gem_indexer.rb +48 -47
- data/test/rubygems/test_gem_install_update_options.rb +6 -5
- data/test/rubygems/test_gem_installer.rb +61 -37
- data/test/rubygems/test_gem_path_support.rb +58 -0
- data/test/rubygems/test_gem_platform.rb +5 -5
- data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
- data/test/rubygems/test_gem_server.rb +23 -15
- data/test/rubygems/test_gem_source_index.rb +165 -127
- data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
- data/test/rubygems/test_gem_specification.rb +104 -74
- data/test/rubygems/test_gem_text.rb +15 -0
- data/test/rubygems/test_gem_uninstaller.rb +15 -26
- data/test/rubygems/test_kernel.rb +1 -2
- metadata +64 -14
- metadata.gz.sig +0 -0
- data/GPL.txt +0 -340
- data/pkgs/sources/lib/sources.rb +0 -3
- data/pkgs/sources/sources.gemspec +0 -14
- data/test/rubygems/functional.rb +0 -92
@@ -5,6 +5,7 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
require 'tsort'
|
8
|
+
require 'rubygems/deprecate'
|
8
9
|
|
9
10
|
##
|
10
11
|
# Gem::DependencyList is used for installing and uninstalling gems in the
|
@@ -22,16 +23,21 @@ class Gem::DependencyList
|
|
22
23
|
attr_accessor :development
|
23
24
|
|
24
25
|
##
|
25
|
-
# Creates a DependencyList from
|
26
|
+
# Creates a DependencyList from the current specs.
|
26
27
|
|
27
|
-
def self.
|
28
|
+
def self.from_specs
|
28
29
|
list = new
|
30
|
+
list.add(*Gem::Specification.map)
|
31
|
+
list
|
32
|
+
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
34
|
+
##
|
35
|
+
# Creates a DependencyList from a Gem::SourceIndex +source_index+
|
33
36
|
|
34
|
-
|
37
|
+
def self.from_source_index(ignored=nil)
|
38
|
+
warn "NOTE: DependencyList.from_source_index ignores it's arg" if ignored
|
39
|
+
|
40
|
+
from_specs
|
35
41
|
end
|
36
42
|
|
37
43
|
##
|
@@ -114,10 +120,9 @@ class Gem::DependencyList
|
|
114
120
|
|
115
121
|
def why_not_ok? quick = false
|
116
122
|
unsatisfied = Hash.new { |h,k| h[k] = [] }
|
117
|
-
source_index = Gem.source_index
|
118
123
|
each do |spec|
|
119
124
|
spec.runtime_dependencies.each do |dep|
|
120
|
-
inst =
|
125
|
+
inst = Gem::Specification.any? { |installed_spec|
|
121
126
|
dep.name == installed_spec.name and
|
122
127
|
dep.requirement.satisfied_by? installed_spec.version
|
123
128
|
}
|
@@ -128,6 +133,7 @@ class Gem::DependencyList
|
|
128
133
|
end
|
129
134
|
end
|
130
135
|
end
|
136
|
+
|
131
137
|
unsatisfied
|
132
138
|
end
|
133
139
|
|
@@ -236,6 +242,11 @@ class Gem::DependencyList
|
|
236
242
|
def active_count(specs, ignored)
|
237
243
|
specs.count { |spec| ignored[spec.full_name].nil? }
|
238
244
|
end
|
239
|
-
|
240
245
|
end
|
241
246
|
|
247
|
+
class Gem::DependencyList
|
248
|
+
class << self
|
249
|
+
extend Deprecate
|
250
|
+
deprecate :from_source_index, "from_specs", 2011, 11
|
251
|
+
end
|
252
|
+
end
|
data/lib/rubygems/deprecate.rb
CHANGED
@@ -50,16 +50,16 @@ module Deprecate
|
|
50
50
|
class_eval {
|
51
51
|
old = "_deprecated_#{name}"
|
52
52
|
alias_method old, name
|
53
|
-
define_method name do |*args|
|
53
|
+
define_method name do |*args, &block| # TODO: really works on 1.8.7?
|
54
54
|
klass = self.kind_of? Module
|
55
55
|
target = klass ? "#{self}." : "#{self.class}#"
|
56
56
|
msg = [ "NOTE: #{target}#{name} is deprecated",
|
57
57
|
repl == :none ? " with no replacement" : ", use #{repl}",
|
58
58
|
". It will be removed on or after %4d-%02d-01." % [year, month],
|
59
|
-
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}
|
59
|
+
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
|
60
60
|
]
|
61
61
|
warn "#{msg.join}." unless Deprecate.skip
|
62
|
-
send old, *args
|
62
|
+
send old, *args, &block
|
63
63
|
end
|
64
64
|
}
|
65
65
|
end
|
data/lib/rubygems/doc_manager.rb
CHANGED
@@ -86,7 +86,7 @@ class Gem::DocManager
|
|
86
86
|
def initialize(spec, rdoc_args="")
|
87
87
|
require 'fileutils'
|
88
88
|
@spec = spec
|
89
|
-
@doc_dir =
|
89
|
+
@doc_dir = spec.doc_dir
|
90
90
|
@rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
|
91
91
|
end
|
92
92
|
|
@@ -218,25 +218,24 @@ class Gem::DocManager
|
|
218
218
|
# Remove RDoc and RI documentation
|
219
219
|
|
220
220
|
def uninstall_doc
|
221
|
-
|
222
|
-
File.writable?
|
221
|
+
base_dir = @spec.base_dir
|
222
|
+
raise Gem::FilePermissionError.new base_dir unless File.writable? base_dir
|
223
223
|
|
224
|
-
|
224
|
+
# TODO: ok... that's twice... ugh
|
225
|
+
old_name = [
|
225
226
|
@spec.name, @spec.version, @spec.original_platform].join '-'
|
226
227
|
|
227
|
-
doc_dir =
|
228
|
+
doc_dir = @spec.doc_dir
|
228
229
|
unless File.directory? doc_dir then
|
229
|
-
doc_dir = File.join
|
230
|
+
doc_dir = File.join File.dirname(doc_dir), old_name
|
230
231
|
end
|
231
232
|
|
232
|
-
|
233
|
-
|
234
|
-
ri_dir = File.join @spec.installation_path, 'ri', @spec.full_name
|
235
|
-
|
233
|
+
ri_dir = @spec.ri_dir
|
236
234
|
unless File.directory? ri_dir then
|
237
|
-
ri_dir = File.join
|
235
|
+
ri_dir = File.join File.dirname(ri_dir), old_name
|
238
236
|
end
|
239
237
|
|
238
|
+
FileUtils.rm_rf doc_dir
|
240
239
|
FileUtils.rm_rf ri_dir
|
241
240
|
end
|
242
241
|
|
@@ -17,7 +17,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# Deal with possible spaces in the path, e.g. C:/Program Files
|
20
|
-
dest_path = '"' + dest_path + '"' if dest_path.include?(' ')
|
20
|
+
dest_path = '"' + dest_path.to_s + '"' if dest_path.to_s.include?(' ')
|
21
21
|
|
22
22
|
rake = ENV['rake']
|
23
23
|
|
@@ -50,6 +50,15 @@ class Gem::GemPathSearcher
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# Looks through the available gemspecs and finds the first
|
54
|
+
# one that contains +file+ as a requirable file.
|
55
|
+
|
56
|
+
def find_spec_for_file(file)
|
57
|
+
@gemspecs.find do |spec|
|
58
|
+
return spec if spec.contains_requirable_file?(file)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
53
62
|
def find_active(glob)
|
54
63
|
# HACK violation of encapsulation
|
55
64
|
@gemspecs.find do |spec|
|
@@ -132,9 +141,7 @@ class Gem::GemPathSearcher
|
|
132
141
|
# in reverse version order. (bar-2, bar-1, foo-2)
|
133
142
|
|
134
143
|
def init_gemspecs
|
135
|
-
|
136
|
-
|
137
|
-
specs.sort { |a, b|
|
144
|
+
Gem::Specification.sort { |a, b|
|
138
145
|
names = a.name <=> b.name
|
139
146
|
next names if names.nonzero?
|
140
147
|
b.version <=> a.version
|
@@ -150,5 +157,13 @@ class Gem::GemPathSearcher
|
|
150
157
|
spec.require_paths
|
151
158
|
end
|
152
159
|
|
153
|
-
|
160
|
+
extend Deprecate
|
154
161
|
|
162
|
+
deprecate :initialize, :none, 2011, 10
|
163
|
+
deprecate :find, :none, 2011, 10
|
164
|
+
deprecate :find_active, :none, 2011, 10
|
165
|
+
deprecate :find_all, :none, 2011, 10
|
166
|
+
deprecate :find_in_unresolved, :none, 2011, 10
|
167
|
+
deprecate :find_in_unresolved_tree, :none, 2011, 10
|
168
|
+
deprecate :find_spec_for_file, :none, 2011, 10
|
169
|
+
end
|
data/lib/rubygems/gem_runner.rb
CHANGED
@@ -75,7 +75,7 @@ class Gem::GemRunner
|
|
75
75
|
|
76
76
|
def do_configuration(args)
|
77
77
|
Gem.configuration = @config_file_class.new(args)
|
78
|
-
Gem.use_paths
|
78
|
+
Gem.use_paths Gem.configuration[:gemhome], Gem.configuration[:gempath]
|
79
79
|
Gem::Command.extra_args = Gem.configuration[:gem]
|
80
80
|
@doc_manager_class.configured_args = Gem.configuration[:rdoc]
|
81
81
|
end
|
data/lib/rubygems/indexer.rb
CHANGED
@@ -73,32 +73,31 @@ class Gem::Indexer
|
|
73
73
|
@rss_gems_host = options[:rss_gems_host]
|
74
74
|
|
75
75
|
@dest_directory = directory
|
76
|
-
@directory = File.join
|
76
|
+
@directory = File.join(Dir.tmpdir, "gem_generate_index_#{$$}")
|
77
77
|
|
78
78
|
marshal_name = "Marshal.#{Gem.marshal_version}"
|
79
79
|
|
80
80
|
@master_index = File.join @directory, 'yaml'
|
81
81
|
@marshal_index = File.join @directory, marshal_name
|
82
82
|
|
83
|
-
@quick_dir = File.join @directory, 'quick'
|
84
|
-
|
83
|
+
@quick_dir = File.join, @directory, 'quick'
|
85
84
|
@quick_marshal_dir = File.join @quick_dir, marshal_name
|
85
|
+
@quick_marshal_dir_base = File.join "quick", marshal_name # FIX: UGH
|
86
86
|
|
87
87
|
@quick_index = File.join @quick_dir, 'index'
|
88
88
|
@latest_index = File.join @quick_dir, 'latest_index'
|
89
89
|
|
90
90
|
@specs_index = File.join @directory, "specs.#{Gem.marshal_version}"
|
91
|
-
@latest_specs_index =
|
92
|
-
|
93
|
-
@prerelease_specs_index =
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
"prerelease_specs.#{Gem.marshal_version}"
|
91
|
+
@latest_specs_index =
|
92
|
+
File.join(@directory, "latest_specs.#{Gem.marshal_version}")
|
93
|
+
@prerelease_specs_index =
|
94
|
+
File.join(@directory, "prerelease_specs.#{Gem.marshal_version}")
|
95
|
+
@dest_specs_index =
|
96
|
+
File.join(@dest_directory, "specs.#{Gem.marshal_version}")
|
97
|
+
@dest_latest_specs_index =
|
98
|
+
File.join(@dest_directory, "latest_specs.#{Gem.marshal_version}")
|
99
|
+
@dest_prerelease_specs_index =
|
100
|
+
File.join(@dest_directory, "prerelease_specs.#{Gem.marshal_version}")
|
102
101
|
|
103
102
|
@rss_index = File.join @directory, 'index.rss'
|
104
103
|
|
@@ -123,12 +122,16 @@ class Gem::Indexer
|
|
123
122
|
##
|
124
123
|
# Build various indicies
|
125
124
|
|
126
|
-
def build_indicies
|
125
|
+
def build_indicies
|
127
126
|
# Marshal gemspecs are used by both modern and legacy RubyGems
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
|
128
|
+
Gem::Specification.dirs = []
|
129
|
+
Gem::Specification.add_specs(*map_gems_to_specs(gem_file_list))
|
130
|
+
|
131
|
+
build_marshal_gemspecs
|
132
|
+
build_legacy_indicies if @build_legacy
|
133
|
+
build_modern_indicies if @build_modern
|
134
|
+
build_rss
|
132
135
|
|
133
136
|
compress_indicies
|
134
137
|
end
|
@@ -136,7 +139,9 @@ class Gem::Indexer
|
|
136
139
|
##
|
137
140
|
# Builds indicies for RubyGems older than 1.2.x
|
138
141
|
|
139
|
-
def build_legacy_indicies
|
142
|
+
def build_legacy_indicies
|
143
|
+
index = collect_specs
|
144
|
+
|
140
145
|
say "Generating Marshal master index"
|
141
146
|
|
142
147
|
Gem.time 'Generated Marshal master index' do
|
@@ -152,16 +157,17 @@ class Gem::Indexer
|
|
152
157
|
##
|
153
158
|
# Builds Marshal quick index gemspecs.
|
154
159
|
|
155
|
-
def build_marshal_gemspecs
|
156
|
-
|
157
|
-
|
160
|
+
def build_marshal_gemspecs
|
161
|
+
count = Gem::Specification.count
|
162
|
+
progress = ui.progress_reporter count,
|
163
|
+
"Generating Marshal quick index gemspecs for #{count} gems",
|
158
164
|
"Complete"
|
159
165
|
|
160
166
|
files = []
|
161
167
|
|
162
168
|
Gem.time 'Generated Marshal quick index gemspecs' do
|
163
|
-
|
164
|
-
spec_file_name = "#{original_name}.gemspec.rz"
|
169
|
+
Gem::Specification.each do |spec|
|
170
|
+
spec_file_name = "#{spec.original_name}.gemspec.rz"
|
165
171
|
marshal_name = File.join @quick_marshal_dir, spec_file_name
|
166
172
|
|
167
173
|
marshal_zipped = Gem.deflate Marshal.dump(spec)
|
@@ -169,7 +175,7 @@ class Gem::Indexer
|
|
169
175
|
|
170
176
|
files << marshal_name
|
171
177
|
|
172
|
-
progress.updated original_name
|
178
|
+
progress.updated spec.original_name
|
173
179
|
end
|
174
180
|
|
175
181
|
progress.done
|
@@ -189,8 +195,8 @@ class Gem::Indexer
|
|
189
195
|
Gem.time "Generated #{name} index" do
|
190
196
|
open(file, 'wb') do |io|
|
191
197
|
specs = index.map do |*spec|
|
192
|
-
# We have to splat here because latest_specs is an array,
|
193
|
-
#
|
198
|
+
# We have to splat here because latest_specs is an array, while the
|
199
|
+
# others are hashes.
|
194
200
|
spec = spec.flatten.last
|
195
201
|
platform = spec.original_platform
|
196
202
|
|
@@ -213,13 +219,15 @@ class Gem::Indexer
|
|
213
219
|
##
|
214
220
|
# Builds indicies for RubyGems 1.2 and newer. Handles full, latest, prerelease
|
215
221
|
|
216
|
-
def build_modern_indicies
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
222
|
+
def build_modern_indicies
|
223
|
+
prerelease, released = Gem::Specification.partition { |s|
|
224
|
+
s.version.prerelease?
|
225
|
+
}
|
226
|
+
latest_specs = Gem::Specification.latest_specs
|
227
|
+
|
228
|
+
build_modern_index(released.sort, @specs_index, 'specs')
|
229
|
+
build_modern_index(latest_specs.sort, @latest_specs_index, 'latest specs')
|
230
|
+
build_modern_index(prerelease.sort, @prerelease_specs_index,
|
223
231
|
'prerelease specs')
|
224
232
|
|
225
233
|
@files += [@specs_index,
|
@@ -234,7 +242,7 @@ class Gem::Indexer
|
|
234
242
|
# Builds an RSS feed for past two days gem releases according to the gem's
|
235
243
|
# date.
|
236
244
|
|
237
|
-
def build_rss
|
245
|
+
def build_rss
|
238
246
|
if @rss_host.nil? or @rss_gems_host.nil? then
|
239
247
|
if Gem.configuration.really_verbose then
|
240
248
|
alert_warning "no --rss-host or --rss-gems-host, RSS generation disabled"
|
@@ -266,31 +274,18 @@ class Gem::Indexer
|
|
266
274
|
today = Gem::Specification::TODAY
|
267
275
|
yesterday = today - 86400
|
268
276
|
|
269
|
-
index =
|
270
|
-
spec_date = spec.date
|
271
|
-
|
272
|
-
case spec_date
|
273
|
-
when Date
|
274
|
-
Time.parse(spec_date.to_s) >= yesterday
|
275
|
-
when Time
|
276
|
-
spec_date >= yesterday
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
index = index.select do |_, spec|
|
277
|
+
index = Gem::Specification.select do |spec|
|
281
278
|
spec_date = spec.date
|
279
|
+
# TODO: remove this and make YAML based specs properly normalized
|
280
|
+
spec_date = Time.parse(spec_date.to_s) if Date === spec_date
|
282
281
|
|
283
|
-
|
284
|
-
when Date
|
285
|
-
Time.parse(spec_date.to_s) <= today
|
286
|
-
when Time
|
287
|
-
spec_date <= today
|
288
|
-
end
|
282
|
+
spec_date >= yesterday && spec_date <= today
|
289
283
|
end
|
290
284
|
|
291
|
-
index.sort_by { |
|
292
|
-
|
293
|
-
|
285
|
+
index.sort_by { |spec| [-spec.date.to_i, spec] }.each do |spec|
|
286
|
+
file_name = File.basename spec.cache_file
|
287
|
+
gem_path = CGI.escapeHTML "http://#{@rss_gems_host}/gems/#{file_name}"
|
288
|
+
size = File.stat(spec.loaded_from).size # rescue next
|
294
289
|
|
295
290
|
description = spec.description || spec.summary || ''
|
296
291
|
authors = Array spec.authors
|
@@ -341,54 +336,56 @@ class Gem::Indexer
|
|
341
336
|
@files << @rss_index
|
342
337
|
end
|
343
338
|
|
339
|
+
def map_gems_to_specs gems
|
340
|
+
gems.map { |gemfile|
|
341
|
+
if File.size(gemfile) == 0 then
|
342
|
+
alert_warning "Skipping zero-length gem: #{gemfile}"
|
343
|
+
next
|
344
|
+
end
|
345
|
+
|
346
|
+
begin
|
347
|
+
spec = Gem::Format.from_file_by_path(gemfile).spec
|
348
|
+
spec.loaded_from = gemfile
|
349
|
+
|
350
|
+
# HACK: fuck this shit - borks all tests that use pl1
|
351
|
+
# if File.basename(gemfile, ".gem") != spec.original_name then
|
352
|
+
# exp = spec.full_name
|
353
|
+
# exp << " (#{spec.original_name})" if
|
354
|
+
# spec.original_name != spec.full_name
|
355
|
+
# msg = "Skipping misnamed gem: #{gemfile} should be named #{exp}"
|
356
|
+
# alert_warning msg
|
357
|
+
# next
|
358
|
+
# end
|
359
|
+
|
360
|
+
abbreviate spec
|
361
|
+
sanitize spec
|
362
|
+
|
363
|
+
spec
|
364
|
+
rescue SignalException => e
|
365
|
+
alert_error "Received signal, exiting"
|
366
|
+
raise
|
367
|
+
rescue Exception => e
|
368
|
+
msg = ["Unable to process #{gemfile}",
|
369
|
+
"#{e.message} (#{e.class})",
|
370
|
+
"\t#{e.backtrace.join "\n\t"}"].join("\n")
|
371
|
+
alert_error msg
|
372
|
+
end
|
373
|
+
}.compact
|
374
|
+
end
|
375
|
+
|
344
376
|
##
|
345
377
|
# Collect specifications from .gem files from the gem directory.
|
346
378
|
|
347
379
|
def collect_specs(gems = gem_file_list)
|
348
|
-
|
349
|
-
|
350
|
-
progress = ui.progress_reporter gems.size,
|
351
|
-
"Loading #{gems.size} gems from #{@dest_directory}",
|
352
|
-
"Loaded all gems"
|
380
|
+
Deprecate.skip_during do
|
381
|
+
index = Gem::SourceIndex.new
|
353
382
|
|
354
|
-
|
355
|
-
|
356
|
-
if File.size(gemfile.to_s) == 0 then
|
357
|
-
alert_warning "Skipping zero-length gem: #{gemfile}"
|
358
|
-
next
|
359
|
-
end
|
360
|
-
|
361
|
-
begin
|
362
|
-
spec = Gem::Format.from_file_by_path(gemfile).spec
|
363
|
-
spec.loaded_from = gemfile
|
364
|
-
|
365
|
-
unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
|
366
|
-
expected_name = spec.full_name
|
367
|
-
expected_name << " (#{spec.original_name})" if
|
368
|
-
spec.original_name != spec.full_name
|
369
|
-
alert_warning "Skipping misnamed gem: #{gemfile} should be named #{expected_name}"
|
370
|
-
next
|
371
|
-
end
|
372
|
-
|
373
|
-
abbreviate spec
|
374
|
-
sanitize spec
|
375
|
-
|
376
|
-
index.add_spec spec, spec.original_name
|
377
|
-
|
378
|
-
progress.updated spec.original_name
|
379
|
-
|
380
|
-
rescue SignalException => e
|
381
|
-
alert_error "Received signal, exiting"
|
382
|
-
raise
|
383
|
-
rescue Exception => e
|
384
|
-
alert_error "Unable to process #{gemfile}\n#{e.message} (#{e.class})\n\t#{e.backtrace.join "\n\t"}"
|
385
|
-
end
|
383
|
+
map_gems_to_specs(gems).each do |spec|
|
384
|
+
index.add_spec spec, spec.original_name
|
386
385
|
end
|
387
386
|
|
388
|
-
|
387
|
+
index
|
389
388
|
end
|
390
|
-
|
391
|
-
index
|
392
389
|
end
|
393
390
|
|
394
391
|
##
|
@@ -448,7 +445,7 @@ class Gem::Indexer
|
|
448
445
|
# List of gem file names to index.
|
449
446
|
|
450
447
|
def gem_file_list
|
451
|
-
Dir
|
448
|
+
Dir[File.join(@dest_directory, "gems", '*.gem')]
|
452
449
|
end
|
453
450
|
|
454
451
|
##
|
@@ -456,8 +453,7 @@ class Gem::Indexer
|
|
456
453
|
|
457
454
|
def generate_index
|
458
455
|
make_temp_directories
|
459
|
-
|
460
|
-
build_indicies index
|
456
|
+
build_indicies
|
461
457
|
install_indicies
|
462
458
|
rescue SignalException
|
463
459
|
ensure
|
@@ -481,24 +477,22 @@ class Gem::Indexer
|
|
481
477
|
|
482
478
|
say "Moving index into production dir #{@dest_directory}" if verbose
|
483
479
|
|
484
|
-
files = @files
|
480
|
+
files = @files
|
485
481
|
files.delete @quick_marshal_dir if files.include? @quick_dir
|
486
482
|
|
487
|
-
if files.include? @quick_marshal_dir and
|
488
|
-
not files.include? @quick_dir then
|
483
|
+
if files.include? @quick_marshal_dir and not files.include? @quick_dir then
|
489
484
|
files.delete @quick_marshal_dir
|
490
|
-
quick_marshal_dir = @quick_marshal_dir.sub @directory, ''
|
491
485
|
|
492
|
-
dst_name = File.join
|
486
|
+
dst_name = File.join(@dest_directory, @quick_marshal_dir_base)
|
493
487
|
|
494
488
|
FileUtils.mkdir_p File.dirname(dst_name), :verbose => verbose
|
495
489
|
FileUtils.rm_rf dst_name, :verbose => verbose
|
496
|
-
FileUtils.mv
|
497
|
-
:force => true
|
490
|
+
FileUtils.mv(@quick_marshal_dir, dst_name,
|
491
|
+
:verbose => verbose, :force => true)
|
498
492
|
end
|
499
493
|
|
500
494
|
files = files.map do |path|
|
501
|
-
path.sub @directory
|
495
|
+
path.sub(/^#{Regexp.escape @directory}\/?/, '') # HACK?
|
502
496
|
end
|
503
497
|
|
504
498
|
files.each do |file|
|
@@ -506,8 +500,8 @@ class Gem::Indexer
|
|
506
500
|
dst_name = File.join @dest_directory, file
|
507
501
|
|
508
502
|
FileUtils.rm_rf dst_name, :verbose => verbose
|
509
|
-
FileUtils.mv
|
510
|
-
:force => true
|
503
|
+
FileUtils.mv(src_name, @dest_directory,
|
504
|
+
:verbose => verbose, :force => true)
|
511
505
|
end
|
512
506
|
end
|
513
507
|
|
@@ -538,10 +532,10 @@ class Gem::Indexer
|
|
538
532
|
# be replaced by their XML entity equivalent.
|
539
533
|
|
540
534
|
def sanitize(spec)
|
541
|
-
spec.summary
|
542
|
-
spec.description
|
535
|
+
spec.summary = sanitize_string(spec.summary)
|
536
|
+
spec.description = sanitize_string(spec.description)
|
543
537
|
spec.post_install_message = sanitize_string(spec.post_install_message)
|
544
|
-
spec.authors
|
538
|
+
spec.authors = spec.authors.collect { |a| sanitize_string(a) }
|
545
539
|
|
546
540
|
spec
|
547
541
|
end
|
@@ -587,14 +581,16 @@ class Gem::Indexer
|
|
587
581
|
terminate_interaction 0
|
588
582
|
end
|
589
583
|
|
590
|
-
|
584
|
+
specs = map_gems_to_specs updated_gems
|
585
|
+
prerelease, released = specs.partition { |s| s.version.prerelease? }
|
591
586
|
|
592
|
-
files = build_marshal_gemspecs
|
587
|
+
files = build_marshal_gemspecs
|
593
588
|
|
594
589
|
Gem.time 'Updated indexes' do
|
595
|
-
update_specs_index
|
596
|
-
update_specs_index
|
597
|
-
update_specs_index(
|
590
|
+
update_specs_index released, @dest_specs_index, @specs_index
|
591
|
+
update_specs_index released, @dest_latest_specs_index, @latest_specs_index
|
592
|
+
update_specs_index(prerelease,
|
593
|
+
@dest_prerelease_specs_index,
|
598
594
|
@prerelease_specs_index)
|
599
595
|
end
|
600
596
|
|
@@ -612,12 +608,12 @@ class Gem::Indexer
|
|
612
608
|
files << "#{@prerelease_specs_index}.gz"
|
613
609
|
|
614
610
|
files = files.map do |path|
|
615
|
-
path.sub @directory
|
611
|
+
path.sub(/^#{Regexp.escape @directory}\/?/, '') # HACK?
|
616
612
|
end
|
617
613
|
|
618
614
|
files.each do |file|
|
619
615
|
src_name = File.join @directory, file
|
620
|
-
dst_name = File.join @dest_directory,
|
616
|
+
dst_name = File.join @dest_directory, file # REFACTOR: duped above
|
621
617
|
|
622
618
|
FileUtils.mv src_name, dst_name, :verbose => verbose,
|
623
619
|
:force => true
|
@@ -633,7 +629,7 @@ class Gem::Indexer
|
|
633
629
|
def update_specs_index(index, source, dest)
|
634
630
|
specs_index = Marshal.load Gem.read_binary(source)
|
635
631
|
|
636
|
-
index.each do |
|
632
|
+
index.each do |spec|
|
637
633
|
platform = spec.original_platform
|
638
634
|
platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
|
639
635
|
specs_index << [spec.name, spec.version, platform]
|
@@ -645,6 +641,4 @@ class Gem::Indexer
|
|
645
641
|
Marshal.dump specs_index, io
|
646
642
|
end
|
647
643
|
end
|
648
|
-
|
649
644
|
end
|
650
|
-
|