rubygems-update 1.0.1 → 1.1.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/ChangeLog +248 -0
- data/README +2 -0
- data/Rakefile +47 -23
- data/bin/gem +9 -4
- data/bin/update_rubygems +15 -1
- data/examples/application/bin/myapp +0 -0
- data/lib/rubygems.rb +506 -373
- data/lib/rubygems/builder.rb +14 -7
- data/lib/rubygems/command.rb +9 -9
- data/lib/rubygems/command_manager.rb +1 -0
- data/lib/rubygems/commands/cleanup_command.rb +67 -69
- data/lib/rubygems/commands/environment_command.rb +16 -10
- data/lib/rubygems/commands/fetch_command.rb +7 -9
- data/lib/rubygems/commands/install_command.rb +9 -3
- data/lib/rubygems/commands/list_command.rb +2 -4
- data/lib/rubygems/commands/mirror_command.rb +1 -1
- data/lib/rubygems/commands/query_command.rb +52 -5
- data/lib/rubygems/commands/sources_command.rb +19 -10
- data/lib/rubygems/commands/specification_command.rb +10 -6
- data/lib/rubygems/commands/uninstall_command.rb +23 -6
- data/lib/rubygems/commands/unpack_command.rb +15 -3
- data/lib/rubygems/commands/update_command.rb +27 -25
- data/lib/rubygems/custom_require.rb +1 -1
- data/lib/rubygems/defaults.rb +8 -1
- data/lib/rubygems/dependency_installer.rb +72 -104
- data/lib/rubygems/digest/digest_adapter.rb +0 -0
- data/lib/rubygems/digest/md5.rb +0 -0
- data/lib/rubygems/digest/sha1.rb +0 -0
- data/lib/rubygems/digest/sha2.rb +0 -0
- data/lib/rubygems/exceptions.rb +22 -1
- data/lib/rubygems/format.rb +16 -10
- data/lib/rubygems/indexer.rb +46 -33
- data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
- data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
- data/lib/rubygems/indexer/master_index_builder.rb +9 -8
- data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +7 -1
- data/lib/rubygems/installer.rb +8 -5
- data/lib/rubygems/package.rb +17 -774
- data/lib/rubygems/package/f_sync_dir.rb +24 -0
- data/lib/rubygems/package/tar_header.rb +245 -0
- data/lib/rubygems/package/tar_input.rb +219 -0
- data/lib/rubygems/package/tar_output.rb +143 -0
- data/lib/rubygems/package/tar_reader.rb +86 -0
- data/lib/rubygems/package/tar_reader/entry.rb +99 -0
- data/lib/rubygems/package/tar_writer.rb +180 -0
- data/lib/rubygems/remote_fetcher.rb +131 -16
- data/lib/rubygems/requirement.rb +2 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +1 -0
- data/lib/rubygems/server.rb +85 -104
- data/lib/rubygems/source_index.rb +412 -329
- data/lib/rubygems/source_info_cache.rb +232 -99
- data/lib/rubygems/source_info_cache_entry.rb +14 -4
- data/lib/rubygems/specification.rb +9 -10
- data/lib/rubygems/timer.rb +0 -0
- data/lib/rubygems/uninstaller.rb +56 -32
- data/lib/rubygems/user_interaction.rb +4 -10
- data/lib/rubygems/validator.rb +0 -0
- data/scripts/gemdoc.rb +0 -0
- data/scripts/specdoc.rb +0 -0
- data/setup.rb +56 -19
- data/test/gem_installer_test_case.rb +86 -0
- data/test/gem_installer_test_case.rbc +0 -0
- data/test/gem_package_tar_test_case.rb +146 -0
- data/test/gem_package_tar_test_case.rbc +0 -0
- data/test/gemutilities.rb +123 -38
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rb +5 -13
- data/test/mockgemui.rbc +0 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/simple_gem.rbc +0 -0
- data/test/test_config.rbc +0 -0
- data/test/test_gem.rb +46 -4
- data/test/test_gem.rbc +0 -0
- data/test/test_gem_builder.rbc +0 -0
- data/test/test_gem_command.rbc +0 -0
- data/test/test_gem_command_manager.rb +4 -2
- data/test/test_gem_command_manager.rbc +0 -0
- data/test/test_gem_commands_build_command.rbc +0 -0
- data/test/test_gem_commands_cert_command.rb +5 -1
- data/test/test_gem_commands_cert_command.rbc +0 -0
- data/test/test_gem_commands_check_command.rbc +0 -0
- data/test/test_gem_commands_contents_command.rbc +0 -0
- data/test/test_gem_commands_dependency_command.rbc +0 -0
- data/test/test_gem_commands_environment_command.rb +17 -1
- data/test/test_gem_commands_environment_command.rbc +0 -0
- data/test/test_gem_commands_fetch_command.rb +6 -5
- data/test/test_gem_commands_fetch_command.rbc +0 -0
- data/test/test_gem_commands_generate_index_command.rbc +0 -0
- data/test/test_gem_commands_install_command.rb +36 -28
- data/test/test_gem_commands_install_command.rbc +0 -0
- data/test/test_gem_commands_mirror_command.rbc +0 -0
- data/test/test_gem_commands_pristine_command.rbc +0 -0
- data/test/test_gem_commands_query_command.rb +143 -19
- data/test/test_gem_commands_query_command.rbc +0 -0
- data/test/test_gem_commands_server_command.rb +1 -1
- data/test/test_gem_commands_server_command.rbc +0 -0
- data/test/test_gem_commands_sources_command.rb +67 -9
- data/test/test_gem_commands_sources_command.rbc +0 -0
- data/test/test_gem_commands_specification_command.rb +3 -2
- data/test/test_gem_commands_specification_command.rbc +0 -0
- data/test/test_gem_commands_unpack_command.rb +46 -4
- data/test/test_gem_commands_unpack_command.rbc +0 -0
- data/test/test_gem_commands_update_command.rb +174 -0
- data/test/test_gem_commands_update_command.rbc +0 -0
- data/test/test_gem_config_file.rbc +0 -0
- data/test/test_gem_dependency.rbc +0 -0
- data/test/test_gem_dependency_installer.rb +172 -187
- data/test/test_gem_dependency_installer.rbc +0 -0
- data/test/test_gem_dependency_list.rbc +0 -0
- data/test/test_gem_digest.rb +0 -0
- data/test/test_gem_digest.rbc +0 -0
- data/test/test_gem_doc_manager.rbc +0 -0
- data/test/test_gem_ext_configure_builder.rb +9 -6
- data/test/test_gem_ext_configure_builder.rbc +0 -0
- data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
- data/test/test_gem_ext_rake_builder.rbc +0 -0
- data/test/test_gem_format.rb +1 -1
- data/test/test_gem_format.rbc +0 -0
- data/test/test_gem_gem_path_searcher.rbc +0 -0
- data/test/test_gem_gem_runner.rbc +0 -0
- data/test/test_gem_indexer.rb +7 -2
- data/test/test_gem_indexer.rbc +0 -0
- data/test/test_gem_install_update_options.rbc +0 -0
- data/test/test_gem_installer.rb +5 -84
- data/test/test_gem_installer.rbc +0 -0
- data/test/test_gem_local_remote_options.rbc +0 -0
- data/test/test_gem_outdated_command.rbc +0 -0
- data/test/test_gem_package_tar_header.rb +137 -0
- data/test/test_gem_package_tar_header.rbc +0 -0
- data/test/test_gem_package_tar_input.rb +119 -0
- data/test/test_gem_package_tar_input.rbc +0 -0
- data/test/test_gem_package_tar_output.rb +104 -0
- data/test/test_gem_package_tar_output.rbc +0 -0
- data/test/test_gem_package_tar_reader.rb +53 -0
- data/test/test_gem_package_tar_reader.rbc +0 -0
- data/test/test_gem_package_tar_reader_entry.rb +116 -0
- data/test/test_gem_package_tar_reader_entry.rbc +0 -0
- data/test/test_gem_package_tar_writer.rb +151 -0
- data/test/test_gem_package_tar_writer.rbc +0 -0
- data/test/test_gem_platform.rbc +0 -0
- data/test/test_gem_remote_fetcher.rb +189 -17
- data/test/test_gem_remote_fetcher.rbc +0 -0
- data/test/test_gem_requirement.rbc +0 -0
- data/test/test_gem_server.rb +13 -12
- data/test/test_gem_server.rbc +0 -0
- data/test/test_gem_source_index.rb +305 -56
- data/test/test_gem_source_index.rbc +0 -0
- data/test/test_gem_source_info_cache.rb +179 -53
- data/test/test_gem_source_info_cache.rbc +0 -0
- data/test/test_gem_source_info_cache_entry.rb +41 -10
- data/test/test_gem_source_info_cache_entry.rbc +0 -0
- data/test/test_gem_specification.rb +7 -7
- data/test/test_gem_specification.rbc +0 -0
- data/test/test_gem_stream_ui.rbc +0 -0
- data/test/test_gem_uninstaller.rb +43 -0
- data/test/test_gem_uninstaller.rbc +0 -0
- data/test/test_gem_validator.rbc +0 -0
- data/test/test_gem_version.rb +1 -1
- data/test/test_gem_version.rbc +0 -0
- data/test/test_gem_version_option.rbc +0 -0
- data/test/test_kernel.rb +1 -0
- data/test/test_kernel.rbc +0 -0
- metadata +85 -8
- metadata.gz.sig +0 -0
- data/lib/rubygems/gem_open_uri.rb +0 -7
- data/lib/rubygems/open-uri.rb +0 -773
- data/test/test_open_uri.rb +0 -13
- data/test/test_package.rb +0 -608
Binary file
|
Binary file
|
data/test/test_gem_server.rb
CHANGED
@@ -53,10 +53,10 @@ class TestGemServer < RubyGemTestCase
|
|
53
53
|
assert_equal 200, @res.status, @res.body
|
54
54
|
assert @res['date']
|
55
55
|
assert_equal 'text/plain', @res['content-type']
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
|
57
|
+
spec = YAML.load Zlib::Inflate.inflate(@res.body)
|
58
|
+
assert_equal 'a', spec.name
|
59
|
+
assert_equal Gem::Version.new(1), spec.version
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_quick_a_1_mswin32_gemspec_rz
|
@@ -72,10 +72,11 @@ class TestGemServer < RubyGemTestCase
|
|
72
72
|
assert_equal 200, @res.status, @res.body
|
73
73
|
assert @res['date']
|
74
74
|
assert_equal 'text/plain', @res['content-type']
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
|
76
|
+
spec = YAML.load Zlib::Inflate.inflate(@res.body)
|
77
|
+
assert_equal 'a', spec.name
|
78
|
+
assert_equal Gem::Version.new(1), spec.version
|
79
|
+
assert_equal Gem::Platform.local, spec.platform
|
79
80
|
end
|
80
81
|
|
81
82
|
def test_quick_common_substrings
|
@@ -91,10 +92,10 @@ class TestGemServer < RubyGemTestCase
|
|
91
92
|
assert_equal 200, @res.status, @res.body
|
92
93
|
assert @res['date']
|
93
94
|
assert_equal 'text/plain', @res['content-type']
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
|
96
|
+
spec = YAML.load Zlib::Inflate.inflate(@res.body)
|
97
|
+
assert_equal 'a', spec.name
|
98
|
+
assert_equal Gem::Version.new(1), spec.version
|
98
99
|
end
|
99
100
|
|
100
101
|
def test_quick_z_9_gemspec_rz
|
Binary file
|
@@ -36,7 +36,8 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
36
36
|
|
37
37
|
use_ui @ui do
|
38
38
|
fetched_index = @source_index.fetch_bulk_index @uri
|
39
|
-
assert_equal [@
|
39
|
+
assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,
|
40
|
+
@c1_2.full_name].sort,
|
40
41
|
fetched_index.gems.map { |n,s| n }.sort
|
41
42
|
end
|
42
43
|
|
@@ -82,7 +83,8 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
82
83
|
|
83
84
|
use_ui @ui do
|
84
85
|
fetched_index = @source_index.fetch_bulk_index @uri
|
85
|
-
assert_equal [@
|
86
|
+
assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,
|
87
|
+
@c1_2.full_name].sort,
|
86
88
|
fetched_index.gems.map { |n,s| n }.sort
|
87
89
|
end
|
88
90
|
|
@@ -105,7 +107,8 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
105
107
|
|
106
108
|
use_ui @ui do
|
107
109
|
fetched_index = @source_index.fetch_bulk_index @uri
|
108
|
-
assert_equal [@
|
110
|
+
assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,
|
111
|
+
@c1_2.full_name].sort,
|
109
112
|
fetched_index.gems.map { |n,s| n }.sort
|
110
113
|
end
|
111
114
|
|
@@ -123,7 +126,8 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
123
126
|
util_setup_bulk_fetch false
|
124
127
|
use_ui @ui do
|
125
128
|
fetched_index = @source_index.fetch_bulk_index @uri
|
126
|
-
assert_equal [@
|
129
|
+
assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,
|
130
|
+
@c1_2.full_name].sort,
|
127
131
|
fetched_index.gems.map { |n,s| n }.sort
|
128
132
|
end
|
129
133
|
|
@@ -136,11 +140,32 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
136
140
|
end
|
137
141
|
|
138
142
|
def test_fetch_quick_index
|
139
|
-
|
140
|
-
@
|
143
|
+
index = util_zip @gem_names
|
144
|
+
latest_index = util_zip [@a2.full_name, @b2.full_name].join("\n")
|
145
|
+
|
146
|
+
@fetcher.data["#{@gem_repo}/quick/index.rz"] = index
|
147
|
+
@fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = latest_index
|
148
|
+
|
149
|
+
quick_index = @source_index.fetch_quick_index @uri, false
|
150
|
+
assert_equal [@a2.full_name, @b2.full_name].sort,
|
151
|
+
quick_index.sort
|
152
|
+
|
153
|
+
paths = @fetcher.paths
|
154
|
+
|
155
|
+
assert_equal "#{@gem_repo}/quick/latest_index.rz", paths.shift
|
156
|
+
|
157
|
+
assert paths.empty?, paths.join(', ')
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_fetch_quick_index_all
|
161
|
+
index = util_zip @gem_names
|
162
|
+
latest_index = util_zip [@a2.full_name, @b2.full_name].join("\n")
|
163
|
+
|
164
|
+
@fetcher.data["#{@gem_repo}/quick/index.rz"] = index
|
165
|
+
@fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = latest_index
|
141
166
|
|
142
|
-
quick_index = @source_index.fetch_quick_index @uri
|
143
|
-
assert_equal [@
|
167
|
+
quick_index = @source_index.fetch_quick_index @uri, true
|
168
|
+
assert_equal [@a1.full_name, @a2.full_name, @b2.full_name].sort,
|
144
169
|
quick_index.sort
|
145
170
|
|
146
171
|
paths = @fetcher.paths
|
@@ -155,7 +180,7 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
155
180
|
proc { raise Exception }
|
156
181
|
|
157
182
|
e = assert_raise Gem::OperationNotSupportedError do
|
158
|
-
@source_index.fetch_quick_index @uri
|
183
|
+
@source_index.fetch_quick_index @uri, true
|
159
184
|
end
|
160
185
|
|
161
186
|
assert_equal 'No quick index found: Exception', e.message
|
@@ -167,41 +192,201 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
167
192
|
assert paths.empty?, paths.join(', ')
|
168
193
|
end
|
169
194
|
|
195
|
+
def test_fetch_quick_index_fallback
|
196
|
+
index = util_zip @gem_names
|
197
|
+
|
198
|
+
@fetcher.data["#{@gem_repo}/quick/index.rz"] = index
|
199
|
+
|
200
|
+
quick_index = @source_index.fetch_quick_index @uri, false
|
201
|
+
assert_equal @gem_names.split, quick_index.sort
|
202
|
+
|
203
|
+
paths = @fetcher.paths
|
204
|
+
|
205
|
+
assert_equal "#{@gem_repo}/quick/latest_index.rz", paths.shift
|
206
|
+
assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
|
207
|
+
|
208
|
+
assert paths.empty?, paths.join(', ')
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_fetch_quick_index_subdir
|
212
|
+
latest_index = util_zip [@a2.full_name, @b2.full_name].join("\n")
|
213
|
+
repo = URI.parse "#{@gem_repo}/~nobody/mirror/"
|
214
|
+
|
215
|
+
@fetcher.data["#{repo}quick/latest_index.rz"] = latest_index
|
216
|
+
|
217
|
+
quick_index = @source_index.fetch_quick_index repo, false
|
218
|
+
assert_equal [@a2.full_name, @b2.full_name].sort,
|
219
|
+
quick_index.sort
|
220
|
+
|
221
|
+
paths = @fetcher.paths
|
222
|
+
|
223
|
+
assert_equal "#{repo}quick/latest_index.rz", paths.shift
|
224
|
+
|
225
|
+
assert paths.empty?, paths.join(', ')
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_fetch_single_spec
|
229
|
+
a1_spec_url = "#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{@a1.full_name}.gemspec.rz"
|
230
|
+
@fetcher.data[a1_spec_url] = util_zip Marshal.dump(@a1)
|
231
|
+
|
232
|
+
spec = @source_index.send :fetch_single_spec, URI.parse(@gem_repo),
|
233
|
+
@a1.full_name
|
234
|
+
|
235
|
+
assert_equal @a1.full_name, spec.full_name
|
236
|
+
|
237
|
+
paths = @fetcher.paths
|
238
|
+
|
239
|
+
assert_equal a1_spec_url, paths.shift
|
240
|
+
|
241
|
+
assert paths.empty?, paths.join(', ')
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_fetch_single_spec_subdir
|
245
|
+
repo = URI.parse "#{@gem_repo}/~nobody/mirror/"
|
246
|
+
|
247
|
+
a1_spec_url = "#{repo}quick/Marshal.#{Gem.marshal_version}/#{@a1.full_name}.gemspec.rz"
|
248
|
+
@fetcher.data[a1_spec_url] = util_zip Marshal.dump(@a1)
|
249
|
+
|
250
|
+
spec = @source_index.send :fetch_single_spec, repo, @a1.full_name
|
251
|
+
|
252
|
+
assert_equal @a1.full_name, spec.full_name
|
253
|
+
|
254
|
+
paths = @fetcher.paths
|
255
|
+
|
256
|
+
assert_equal a1_spec_url, paths.shift
|
257
|
+
|
258
|
+
assert paths.empty?, paths.join(', ')
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_fetch_single_spec_yaml
|
262
|
+
a1_spec_url = "#{@gem_repo}/quick/#{@a1.full_name}.gemspec.rz"
|
263
|
+
@fetcher.data[a1_spec_url] = util_zip @a1.to_yaml
|
264
|
+
|
265
|
+
repo = URI.parse @gem_repo
|
266
|
+
|
267
|
+
spec = @source_index.send :fetch_single_spec, repo, @a1.full_name
|
268
|
+
|
269
|
+
assert_equal @a1.full_name, spec.full_name
|
270
|
+
|
271
|
+
paths = @fetcher.paths
|
272
|
+
|
273
|
+
assert_equal "#{@gem_repo}/quick/Marshal.#{Gem.marshal_version}/#{@a1.full_name}.gemspec.rz", paths.shift
|
274
|
+
assert_equal a1_spec_url, paths.shift
|
275
|
+
|
276
|
+
assert paths.empty?, paths.join(', ')
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_fetch_single_spec_yaml_subdir
|
280
|
+
repo = URI.parse "#{@gem_repo}/~nobody/mirror/"
|
281
|
+
|
282
|
+
a1_spec_url = "#{repo}quick/#{@a1.full_name}.gemspec.rz"
|
283
|
+
@fetcher.data[a1_spec_url] = util_zip @a1.to_yaml
|
284
|
+
|
285
|
+
spec = @source_index.send :fetch_single_spec, repo, @a1.full_name
|
286
|
+
|
287
|
+
assert_equal @a1.full_name, spec.full_name
|
288
|
+
|
289
|
+
paths = @fetcher.paths
|
290
|
+
|
291
|
+
assert_equal "#{repo}quick/Marshal.#{Gem.marshal_version}/#{@a1.full_name}.gemspec.rz", paths.shift
|
292
|
+
assert_equal a1_spec_url, paths.shift
|
293
|
+
|
294
|
+
assert paths.empty?, paths.join(', ')
|
295
|
+
end
|
296
|
+
|
170
297
|
def test_find_missing
|
171
|
-
missing = @source_index.find_missing [@
|
172
|
-
assert_equal [@
|
298
|
+
missing = @source_index.find_missing [@b2.full_name]
|
299
|
+
assert_equal [@b2.full_name], missing
|
173
300
|
end
|
174
301
|
|
175
302
|
def test_find_missing_none_missing
|
176
|
-
missing = @source_index.find_missing
|
303
|
+
missing = @source_index.find_missing [
|
304
|
+
@a1.full_name, @a2.full_name, @c1_2.full_name
|
305
|
+
]
|
306
|
+
|
177
307
|
assert_equal [], missing
|
178
308
|
end
|
179
309
|
|
180
310
|
def test_latest_specs
|
181
|
-
|
182
|
-
|
311
|
+
p1_ruby = quick_gem 'p', '1'
|
312
|
+
p1_platform = quick_gem 'p', '1' do |spec|
|
313
|
+
spec.platform = Gem::Platform::CURRENT
|
314
|
+
end
|
315
|
+
|
316
|
+
a1_platform = quick_gem @a1.name, (@a1.version) do |s|
|
317
|
+
s.platform = Gem::Platform.new 'x86-my_platform1'
|
318
|
+
end
|
319
|
+
|
320
|
+
a2_platform = quick_gem @a2.name, (@a2.version) do |s|
|
321
|
+
s.platform = Gem::Platform.new 'x86-my_platform1'
|
322
|
+
end
|
323
|
+
|
324
|
+
a2_platform_other = quick_gem @a2.name, (@a2.version) do |s|
|
325
|
+
s.platform = Gem::Platform.new 'x86-other_platform1'
|
326
|
+
end
|
327
|
+
|
328
|
+
a3_platform_other = quick_gem @a2.name, (@a2.version.bump) do |s|
|
329
|
+
s.platform = Gem::Platform.new 'x86-other_platform1'
|
330
|
+
end
|
331
|
+
|
332
|
+
@source_index.add_spec p1_ruby
|
333
|
+
@source_index.add_spec p1_platform
|
334
|
+
@source_index.add_spec a1_platform
|
335
|
+
@source_index.add_spec a2_platform
|
336
|
+
@source_index.add_spec a2_platform_other
|
337
|
+
@source_index.add_spec a3_platform_other
|
183
338
|
|
184
339
|
expected = [
|
185
|
-
@
|
186
|
-
|
187
|
-
|
340
|
+
@a2.full_name,
|
341
|
+
a2_platform.full_name,
|
342
|
+
a3_platform_other.full_name,
|
343
|
+
@c1_2.full_name,
|
344
|
+
@a_evil9.full_name,
|
345
|
+
p1_ruby.full_name,
|
346
|
+
p1_platform.full_name,
|
188
347
|
].sort
|
189
348
|
|
190
|
-
|
349
|
+
latest_specs = @source_index.latest_specs.map { |s| s.full_name }.sort
|
350
|
+
|
351
|
+
assert_equal expected, latest_specs
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_load_gems_in
|
355
|
+
spec_dir1 = File.join @gemhome, 'specifications'
|
356
|
+
spec_dir2 = File.join @tempdir, 'gemhome2', 'specifications'
|
357
|
+
|
358
|
+
FileUtils.rm_r spec_dir1
|
359
|
+
|
360
|
+
FileUtils.mkdir_p spec_dir1
|
361
|
+
FileUtils.mkdir_p spec_dir2
|
362
|
+
|
363
|
+
a1 = quick_gem 'a', '1' do |spec| spec.author = 'author 1' end
|
364
|
+
a2 = quick_gem 'a', '1' do |spec| spec.author = 'author 2' end
|
365
|
+
|
366
|
+
File.open File.join(spec_dir1, "#{a1.full_name}.gemspec"), 'w' do |fp|
|
367
|
+
fp.write a1.to_ruby
|
368
|
+
end
|
369
|
+
|
370
|
+
File.open File.join(spec_dir2, "#{a2.full_name}.gemspec"), 'w' do |fp|
|
371
|
+
fp.write a2.to_ruby
|
372
|
+
end
|
373
|
+
|
374
|
+
@source_index.load_gems_in spec_dir1, spec_dir2
|
375
|
+
|
376
|
+
assert_equal a1.author, @source_index.specification(a1.full_name).author
|
191
377
|
end
|
192
378
|
|
193
379
|
def test_outdated
|
194
|
-
|
195
|
-
Gem::SourceInfoCache.instance_variable_set :@cache, sic
|
380
|
+
util_setup_source_info_cache
|
196
381
|
|
197
382
|
assert_equal [], @source_index.outdated
|
198
383
|
|
199
|
-
updated = quick_gem @
|
384
|
+
updated = quick_gem @a2.name, (@a2.version.bump)
|
200
385
|
util_setup_source_info_cache updated
|
201
386
|
|
202
387
|
assert_equal [updated.name], @source_index.outdated
|
203
388
|
|
204
|
-
updated_platform = quick_gem @
|
389
|
+
updated_platform = quick_gem @a2.name, (updated.version.bump) do |s|
|
205
390
|
s.platform = Gem::Platform.new 'x86-other_platform1'
|
206
391
|
end
|
207
392
|
|
@@ -211,28 +396,36 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
211
396
|
end
|
212
397
|
|
213
398
|
def test_remove_extra
|
214
|
-
@source_index.
|
215
|
-
|
399
|
+
@source_index.add_spec @a1
|
400
|
+
@source_index.add_spec @a2
|
401
|
+
@source_index.add_spec @pl1
|
402
|
+
|
403
|
+
@source_index.remove_extra [@a1.full_name, @pl1.full_name]
|
404
|
+
|
405
|
+
assert_equal [@a1.full_name],
|
406
|
+
@source_index.gems.map { |n,s| n }.sort
|
216
407
|
end
|
217
408
|
|
218
409
|
def test_remove_extra_no_changes
|
219
|
-
gems = @
|
410
|
+
gems = [@a1.full_name, @a2.full_name]
|
411
|
+
@source_index.add_spec @a1
|
412
|
+
@source_index.add_spec @a2
|
413
|
+
|
220
414
|
@source_index.remove_extra gems
|
415
|
+
|
221
416
|
assert_equal gems, @source_index.gems.map { |n,s| n }.sort
|
222
417
|
end
|
223
418
|
|
224
419
|
def test_search
|
225
|
-
assert_equal [@
|
226
|
-
assert_equal [@
|
420
|
+
assert_equal [@a1, @a2, @a_evil9], @source_index.search('a')
|
421
|
+
assert_equal [@a2], @source_index.search('a', '= 2')
|
227
422
|
|
228
|
-
assert_equal [], @source_index.search(
|
229
|
-
assert_equal [], @source_index.search(
|
423
|
+
assert_equal [], @source_index.search('bogusstring')
|
424
|
+
assert_equal [], @source_index.search('a', '= 3')
|
230
425
|
|
231
|
-
|
232
|
-
@
|
233
|
-
|
234
|
-
source_index = Gem::SourceIndex.new @a1.full_name => @a1,
|
235
|
-
@a2.full_name => @a2
|
426
|
+
source_index = Gem::SourceIndex.new
|
427
|
+
source_index.add_spec @a1
|
428
|
+
source_index.add_spec @a2
|
236
429
|
|
237
430
|
assert_equal [@a1], source_index.search(@a1.name, '= 1')
|
238
431
|
|
@@ -276,7 +469,7 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
276
469
|
end
|
277
470
|
|
278
471
|
def test_specification
|
279
|
-
assert_equal @
|
472
|
+
assert_equal @a1, @source_index.specification(@a1.full_name)
|
280
473
|
|
281
474
|
assert_nil @source_index.specification("foo-1.2.4")
|
282
475
|
end
|
@@ -298,9 +491,11 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
298
491
|
assert_equal [], @source_index.gems.keys.sort
|
299
492
|
|
300
493
|
use_ui @ui do
|
301
|
-
@source_index.update @uri
|
494
|
+
@source_index.update @uri, true
|
302
495
|
|
303
|
-
assert_equal @
|
496
|
+
assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,
|
497
|
+
@c1_2.full_name],
|
498
|
+
@source_index.gems.keys.sort
|
304
499
|
end
|
305
500
|
|
306
501
|
paths = @fetcher.paths
|
@@ -315,15 +510,42 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
315
510
|
old_gem_conf = Gem.configuration
|
316
511
|
Gem.configuration = Gem::ConfigFile.new([])
|
317
512
|
|
513
|
+
latest_names = [@a2, @a_evil9, @b2, @c1_2].map { |s| s.full_name }
|
514
|
+
latest_index = util_zip latest_names.join("\n")
|
515
|
+
@fetcher.data["#{@gem_repo}/quick/latest_index.rz"] = latest_index
|
516
|
+
|
517
|
+
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
|
518
|
+
"#{@b2.full_name}.gemspec.rz"
|
519
|
+
@fetcher.data[marshal_uri] = util_zip Marshal.dump(@b2)
|
520
|
+
|
521
|
+
use_ui @ui do
|
522
|
+
@source_index.update @uri, false
|
523
|
+
|
524
|
+
assert_equal latest_names, @source_index.gems.keys.sort
|
525
|
+
end
|
526
|
+
|
527
|
+
paths = @fetcher.paths
|
528
|
+
assert_equal "#{@gem_repo}/quick/latest_index.rz", paths.shift
|
529
|
+
assert_equal marshal_uri, paths.shift
|
530
|
+
|
531
|
+
assert paths.empty?, paths.join(', ')
|
532
|
+
ensure
|
533
|
+
Gem.configuration = old_gem_conf
|
534
|
+
end
|
535
|
+
|
536
|
+
def test_update_incremental_all
|
537
|
+
old_gem_conf = Gem.configuration
|
538
|
+
Gem.configuration = Gem::ConfigFile.new([])
|
539
|
+
|
318
540
|
quick_index = util_zip @all_gem_names.join("\n")
|
319
541
|
@fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
|
320
542
|
|
321
543
|
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
|
322
|
-
"#{@
|
323
|
-
@fetcher.data[marshal_uri] = util_zip Marshal.dump(@
|
544
|
+
"#{@b2.full_name}.gemspec.rz"
|
545
|
+
@fetcher.data[marshal_uri] = util_zip Marshal.dump(@b2)
|
324
546
|
|
325
547
|
use_ui @ui do
|
326
|
-
@source_index.update @uri
|
548
|
+
@source_index.update @uri, true
|
327
549
|
|
328
550
|
assert_equal @all_gem_names, @source_index.gems.keys.sort
|
329
551
|
end
|
@@ -345,13 +567,13 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
345
567
|
@fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
|
346
568
|
|
347
569
|
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
|
348
|
-
"#{@
|
570
|
+
"#{@b2.full_name}.gemspec.rz"
|
349
571
|
|
350
|
-
yaml_uri = "#{@gem_repo}/quick/#{@
|
351
|
-
@fetcher.data[yaml_uri] = util_zip @
|
572
|
+
yaml_uri = "#{@gem_repo}/quick/#{@b2.full_name}.gemspec.rz"
|
573
|
+
@fetcher.data[yaml_uri] = util_zip @b2.to_yaml
|
352
574
|
|
353
575
|
use_ui @ui do
|
354
|
-
@source_index.update @uri
|
576
|
+
@source_index.update @uri, true
|
355
577
|
|
356
578
|
assert_equal @all_gem_names, @source_index.gems.keys.sort
|
357
579
|
end
|
@@ -374,16 +596,16 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
374
596
|
@fetcher.data["#{@gem_repo}/quick/index.rz"] = quick_index
|
375
597
|
|
376
598
|
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
|
377
|
-
"#{@
|
378
|
-
marshal_data = Marshal.dump(@
|
599
|
+
"#{@b2.full_name}.gemspec.rz"
|
600
|
+
marshal_data = Marshal.dump(@b2)
|
379
601
|
marshal_data[0] = (Marshal::MAJOR_VERSION - 1).chr
|
380
602
|
@fetcher.data[marshal_uri] = util_zip marshal_data
|
381
603
|
|
382
|
-
yaml_uri = "#{@gem_repo}/quick/#{@
|
383
|
-
@fetcher.data[yaml_uri] = util_zip @
|
604
|
+
yaml_uri = "#{@gem_repo}/quick/#{@b2.full_name}.gemspec.rz"
|
605
|
+
@fetcher.data[yaml_uri] = util_zip @b2.to_yaml
|
384
606
|
|
385
607
|
use_ui @ui do
|
386
|
-
@source_index.update @uri
|
608
|
+
@source_index.update @uri, true
|
387
609
|
|
388
610
|
assert_equal @all_gem_names, @source_index.gems.keys.sort
|
389
611
|
end
|
@@ -398,22 +620,48 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
398
620
|
Gem.configuration = old_gem_conf
|
399
621
|
end
|
400
622
|
|
623
|
+
def test_update_subdir
|
624
|
+
@gem_repo = @gem_repo + "/subdir"
|
625
|
+
|
626
|
+
util_setup_bulk_fetch true
|
627
|
+
|
628
|
+
@source_index.gems.replace({})
|
629
|
+
assert_equal [], @source_index.gems.keys.sort
|
630
|
+
|
631
|
+
uri = @uri.to_s + "/subdir"
|
632
|
+
|
633
|
+
use_ui @ui do
|
634
|
+
@source_index.update uri, true
|
635
|
+
|
636
|
+
assert_equal [@a1.full_name, @a2.full_name, @a_evil9.full_name,
|
637
|
+
@c1_2.full_name],
|
638
|
+
@source_index.gems.keys.sort
|
639
|
+
end
|
640
|
+
|
641
|
+
paths = @fetcher.paths
|
642
|
+
|
643
|
+
assert_equal "#{@gem_repo}/quick/index.rz", paths.shift
|
644
|
+
assert_equal "#{@gem_repo}/Marshal.#{@marshal_version}.Z", paths.shift
|
645
|
+
|
646
|
+
assert paths.empty?, paths.join(', ')
|
647
|
+
end
|
648
|
+
|
401
649
|
def test_update_with_missing
|
402
650
|
marshal_uri = File.join @gem_repo, "quick", "Marshal.#{@marshal_version}",
|
403
|
-
"#{@
|
404
|
-
dumped = Marshal.dump
|
651
|
+
"#{@c1_2.full_name}.gemspec.rz"
|
652
|
+
dumped = Marshal.dump @c1_2
|
405
653
|
@fetcher.data[marshal_uri] = util_zip(dumped)
|
406
654
|
|
407
655
|
use_ui @ui do
|
408
|
-
@source_index.update_with_missing @uri, [@
|
656
|
+
@source_index.update_with_missing @uri, [@c1_2.full_name]
|
409
657
|
end
|
410
658
|
|
411
|
-
spec = @source_index.specification(@
|
659
|
+
spec = @source_index.specification(@c1_2.full_name)
|
412
660
|
# We don't care about the equality of undumped attributes
|
413
|
-
@
|
414
|
-
@
|
661
|
+
@c1_2.files = spec.files
|
662
|
+
@c1_2.loaded_from = spec.loaded_from
|
415
663
|
|
416
|
-
assert_equal @
|
664
|
+
assert_equal @c1_2, spec
|
417
665
|
end
|
418
666
|
|
419
667
|
def util_setup_bulk_fetch(compressed)
|
@@ -427,3 +675,4 @@ class TestGemSourceIndex < RubyGemTestCase
|
|
427
675
|
end
|
428
676
|
|
429
677
|
end
|
678
|
+
|