rubygems-update 0.9.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +135 -0
- data/Rakefile +3 -1
- data/lib/rubygems.rb +27 -38
- data/lib/rubygems/commands/install_command.rb +2 -0
- data/lib/rubygems/commands/mirror_command.rb +8 -2
- data/lib/rubygems/commands/query_command.rb +3 -1
- data/lib/rubygems/commands/server_command.rb +3 -3
- data/lib/rubygems/commands/unpack_command.rb +11 -4
- data/lib/rubygems/commands/update_command.rb +114 -108
- data/lib/rubygems/defaults.rb +46 -0
- data/lib/rubygems/dependency_installer.rb +13 -2
- data/lib/rubygems/indexer.rb +1 -1
- data/lib/rubygems/install_update_options.rb +7 -0
- data/lib/rubygems/installer.rb +66 -11
- data/lib/rubygems/package.rb +2 -1
- data/lib/rubygems/platform.rb +24 -30
- data/lib/rubygems/remote_fetcher.rb +7 -3
- data/lib/rubygems/require_paths_builder.rb +15 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +18 -3
- data/lib/rubygems/source_index.rb +20 -23
- data/lib/rubygems/source_info_cache.rb +3 -3
- data/lib/rubygems/specification.rb +64 -31
- data/lib/rubygems/uninstaller.rb +1 -1
- data/lib/rubygems/validator.rb +3 -2
- data/lib/rubygems/version.rb +10 -3
- data/setup.rb +30 -6
- data/test/gemutilities.rb +23 -13
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rbc +0 -0
- data/test/test_gem.rb +46 -76
- data/test/test_gem.rbc +0 -0
- data/test/test_gem_commands_build_command.rb +12 -12
- data/test/test_gem_commands_dependency_command.rb +10 -10
- data/test/test_gem_commands_mirror_command.rb +9 -4
- data/test/test_gem_commands_query_command.rb +7 -3
- data/test/test_gem_commands_server_command.rb +27 -0
- data/test/test_gem_commands_unpack_command.rb +20 -2
- data/test/test_gem_format.rb +1 -1
- data/test/test_gem_indexer.rb +5 -5
- data/test/test_gem_install_update_options.rb +1 -1
- data/test/test_gem_installer.rb +149 -60
- data/test/test_gem_platform.rb +19 -0
- data/test/test_gem_remote_fetcher.rb +19 -2
- data/test/test_gem_server.rb +44 -1
- data/test/test_gem_source_index.rb +2 -2
- data/test/test_gem_specification.rb +300 -168
- data/test/test_gem_version.rb +15 -0
- data/test/test_kernel.rb +19 -19
- metadata +46 -42
- data/lib/rubygems/remote_installer.rb +0 -195
- data/test/test_gem_remote_installer.rb +0 -161
data/test/test_gem_version.rb
CHANGED
@@ -55,6 +55,11 @@ class TestGemVersion < RubyGemTestCase
|
|
55
55
|
assert_inadequate( "1.0.0.1", "= 1.0")
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_bump_trailing_zeros
|
59
|
+
v = Gem::Version.new("5.0.0")
|
60
|
+
assert_equal "5.1", v.bump.to_s
|
61
|
+
end
|
62
|
+
|
58
63
|
def test_bump
|
59
64
|
v = Gem::Version.new("5.2.4")
|
60
65
|
assert_equal "5.3", v.bump.to_s
|
@@ -65,6 +70,16 @@ class TestGemVersion < RubyGemTestCase
|
|
65
70
|
assert_equal "6", v.bump.to_s
|
66
71
|
end
|
67
72
|
|
73
|
+
def test_eql_eh
|
74
|
+
v = Gem::Version.new("1.2")
|
75
|
+
|
76
|
+
assert_equal true, v.eql?(@v1_2)
|
77
|
+
assert_equal true, @v1_2.eql?(v)
|
78
|
+
|
79
|
+
assert_equal false, @v1_2.eql?(@v1_3)
|
80
|
+
assert_equal false, @v1_3.eql?(@v1_2)
|
81
|
+
end
|
82
|
+
|
68
83
|
def test_equals2
|
69
84
|
v = Gem::Version.new("1.2")
|
70
85
|
|
data/test/test_kernel.rb
CHANGED
@@ -25,39 +25,39 @@ class TestKernel < RubyGemTestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_gem
|
28
|
-
assert gem('a', '=
|
29
|
-
assert $:.any? { |p| %r{a-
|
30
|
-
assert $:.any? { |p| %r{a-
|
28
|
+
assert gem('a', '= 1'), "Should load"
|
29
|
+
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
30
|
+
assert $:.any? { |p| %r{a-1/bin} =~ p }
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_gem_redundent
|
34
|
-
assert gem('a', '=
|
35
|
-
assert ! gem('a', '=
|
36
|
-
assert_equal 1, $:.select { |p| %r{a-
|
37
|
-
assert_equal 1, $:.select { |p| %r{a-
|
34
|
+
assert gem('a', '= 1'), "Should load"
|
35
|
+
assert ! gem('a', '= 1'), "Should not load"
|
36
|
+
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
|
37
|
+
assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_gem_overlapping
|
41
|
-
assert gem('a', '=
|
42
|
-
assert ! gem('a', '>=
|
43
|
-
assert_equal 1, $:.select { |p| %r{a-
|
44
|
-
assert_equal 1, $:.select { |p| %r{a-
|
41
|
+
assert gem('a', '= 1'), "Should load"
|
42
|
+
assert ! gem('a', '>= 1'), "Should not load"
|
43
|
+
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
|
44
|
+
assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_gem_conflicting
|
48
|
-
assert gem('a', '=
|
48
|
+
assert gem('a', '= 1'), "Should load"
|
49
49
|
|
50
50
|
ex = assert_raise Gem::Exception do
|
51
|
-
gem 'a', '=
|
51
|
+
gem 'a', '= 2'
|
52
52
|
end
|
53
53
|
|
54
|
-
assert_match(/activate a \(=
|
55
|
-
assert_match(/activated a-
|
54
|
+
assert_match(/activate a \(= 2\)/, ex.message)
|
55
|
+
assert_match(/activated a-1/, ex.message)
|
56
56
|
|
57
|
-
assert $:.any? { |p| %r{a-
|
58
|
-
assert $:.any? { |p| %r{a-
|
59
|
-
assert ! $:.any? { |p| %r{a-
|
60
|
-
assert ! $:.any? { |p| %r{a-
|
57
|
+
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
58
|
+
assert $:.any? { |p| %r{a-1/bin} =~ p }
|
59
|
+
assert ! $:.any? { |p| %r{a-2/lib} =~ p }
|
60
|
+
assert ! $:.any? { |p| %r{a-2/bin} =~ p }
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
metadata
CHANGED
@@ -1,41 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4.6
|
3
|
-
specification_version: 2
|
4
2
|
name: rubygems-update
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-11-19 00:00:00 -08:00
|
8
|
-
summary: RubyGems Update GEM
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: rubygems-developers@rubyforge.org
|
12
|
-
homepage: http://rubygems.rubyforge.org
|
13
|
-
rubyforge_project: rubygems
|
14
|
-
description: RubyGems is a package management framework for Ruby. This Gem is a update for the base RubyGems software. You must have a base installation of RubyGems before this update can be applied.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: "0"
|
30
|
-
version:
|
4
|
+
version: 1.0.0
|
31
5
|
platform: ruby
|
32
|
-
signing_key:
|
33
|
-
cert_chain: []
|
34
|
-
|
35
|
-
post_install_message:
|
36
6
|
authors:
|
37
7
|
- Jim Weirich
|
38
8
|
- Chad Fowler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2007-12-19 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: RubyGems is a package management framework for Ruby. This Gem is a update for the base RubyGems software. You must have a base installation of RubyGems before this update can be applied.
|
18
|
+
email: rubygems-developers@rubyforge.org
|
19
|
+
executables:
|
20
|
+
- update_rubygems
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
39
25
|
files:
|
40
26
|
- Rakefile
|
41
27
|
- ChangeLog
|
@@ -101,6 +87,7 @@ files:
|
|
101
87
|
- lib/rubygems/commands/which_command.rb
|
102
88
|
- lib/rubygems/config_file.rb
|
103
89
|
- lib/rubygems/custom_require.rb
|
90
|
+
- lib/rubygems/defaults.rb
|
104
91
|
- lib/rubygems/dependency.rb
|
105
92
|
- lib/rubygems/dependency_installer.rb
|
106
93
|
- lib/rubygems/dependency_list.rb
|
@@ -133,7 +120,7 @@ files:
|
|
133
120
|
- lib/rubygems/package.rb
|
134
121
|
- lib/rubygems/platform.rb
|
135
122
|
- lib/rubygems/remote_fetcher.rb
|
136
|
-
- lib/rubygems/
|
123
|
+
- lib/rubygems/require_paths_builder.rb
|
137
124
|
- lib/rubygems/requirement.rb
|
138
125
|
- lib/rubygems/rubygems_version.rb
|
139
126
|
- lib/rubygems/security.rb
|
@@ -168,11 +155,14 @@ files:
|
|
168
155
|
- test/fake_certlib/openssl.rb
|
169
156
|
- test/functional.rb
|
170
157
|
- test/gemutilities.rb
|
158
|
+
- test/gemutilities.rbc
|
171
159
|
- test/insure_session.rb
|
172
160
|
- test/mockgemui.rb
|
161
|
+
- test/mockgemui.rbc
|
173
162
|
- test/simple_gem.rb
|
174
163
|
- test/test_config.rb
|
175
164
|
- test/test_gem.rb
|
165
|
+
- test/test_gem.rbc
|
176
166
|
- test/test_gem_builder.rb
|
177
167
|
- test/test_gem_command.rb
|
178
168
|
- test/test_gem_command_manager.rb
|
@@ -188,6 +178,7 @@ files:
|
|
188
178
|
- test/test_gem_commands_mirror_command.rb
|
189
179
|
- test/test_gem_commands_pristine_command.rb
|
190
180
|
- test/test_gem_commands_query_command.rb
|
181
|
+
- test/test_gem_commands_server_command.rb
|
191
182
|
- test/test_gem_commands_sources_command.rb
|
192
183
|
- test/test_gem_commands_specification_command.rb
|
193
184
|
- test/test_gem_commands_unpack_command.rb
|
@@ -210,7 +201,6 @@ files:
|
|
210
201
|
- test/test_gem_outdated_command.rb
|
211
202
|
- test/test_gem_platform.rb
|
212
203
|
- test/test_gem_remote_fetcher.rb
|
213
|
-
- test/test_gem_remote_installer.rb
|
214
204
|
- test/test_gem_requirement.rb
|
215
205
|
- test/test_gem_server.rb
|
216
206
|
- test/test_gem_source_index.rb
|
@@ -225,17 +215,31 @@ files:
|
|
225
215
|
- test/test_open_uri.rb
|
226
216
|
- test/test_package.rb
|
227
217
|
- .document
|
228
|
-
|
229
|
-
|
218
|
+
has_rdoc: false
|
219
|
+
homepage: http://rubygems.rubyforge.org
|
220
|
+
post_install_message:
|
230
221
|
rdoc_options: []
|
231
222
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
223
|
+
require_paths:
|
224
|
+
- lib
|
225
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: "0"
|
230
|
+
version:
|
231
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - ">="
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: "0"
|
236
|
+
version:
|
238
237
|
requirements: []
|
239
238
|
|
240
|
-
|
239
|
+
rubyforge_project: rubygems
|
240
|
+
rubygems_version: 0.9.5
|
241
|
+
signing_key:
|
242
|
+
specification_version: 2
|
243
|
+
summary: RubyGems Update GEM
|
244
|
+
test_files: []
|
241
245
|
|
@@ -1,195 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
-
# All rights reserved.
|
4
|
-
# See LICENSE.txt for permissions.
|
5
|
-
#++
|
6
|
-
|
7
|
-
require 'fileutils'
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'rubygems/installer'
|
11
|
-
require 'rubygems/source_info_cache'
|
12
|
-
|
13
|
-
module Gem
|
14
|
-
|
15
|
-
class RemoteInstaller
|
16
|
-
|
17
|
-
include UserInteraction
|
18
|
-
|
19
|
-
# <tt>options[:http_proxy]</tt>::
|
20
|
-
# * [String]: explicit specification of proxy; overrides any
|
21
|
-
# environment variable setting
|
22
|
-
# * nil: respect environment variables (HTTP_PROXY, HTTP_PROXY_USER, HTTP_PROXY_PASS)
|
23
|
-
# * <tt>:no_proxy</tt>: ignore environment variables and _don't_
|
24
|
-
# use a proxy
|
25
|
-
#
|
26
|
-
# * <tt>:cache_dir</tt>: override where downloaded gems are cached.
|
27
|
-
def initialize(options={})
|
28
|
-
@options = options
|
29
|
-
@source_index_hash = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
# This method will install package_name onto the local system.
|
33
|
-
#
|
34
|
-
# gem_name::
|
35
|
-
# [String] Name of the Gem to install
|
36
|
-
#
|
37
|
-
# version_requirement::
|
38
|
-
# [default = ">= 0"] Gem version requirement to install
|
39
|
-
#
|
40
|
-
# Returns::
|
41
|
-
# an array of Gem::Specification objects, one for each gem installed.
|
42
|
-
#
|
43
|
-
def install(gem_name, version_requirement = Gem::Requirement.default,
|
44
|
-
force = false, install_dir = Gem.dir)
|
45
|
-
unless version_requirement.respond_to?(:satisfied_by?)
|
46
|
-
version_requirement = Gem::Requirement.new [version_requirement]
|
47
|
-
end
|
48
|
-
installed_gems = []
|
49
|
-
begin
|
50
|
-
spec, source = find_gem_to_install(gem_name, version_requirement)
|
51
|
-
dependencies = find_dependencies_not_installed(spec.dependencies)
|
52
|
-
|
53
|
-
installed_gems << install_dependencies(dependencies, force, install_dir)
|
54
|
-
|
55
|
-
cache_dir = @options[:cache_dir] || File.join(install_dir, "cache")
|
56
|
-
destination_file = File.join(cache_dir, spec.full_name + ".gem")
|
57
|
-
|
58
|
-
download_gem(destination_file, source, spec)
|
59
|
-
|
60
|
-
installer = new_installer(destination_file)
|
61
|
-
installed_gems.unshift installer.install(force, install_dir)
|
62
|
-
rescue RemoteInstallationSkipped => e
|
63
|
-
alert_error e.message
|
64
|
-
end
|
65
|
-
installed_gems.flatten
|
66
|
-
end
|
67
|
-
|
68
|
-
# Return a hash mapping the available source names to the source
|
69
|
-
# index of that source.
|
70
|
-
def source_index_hash
|
71
|
-
return @source_index_hash if @source_index_hash
|
72
|
-
@source_index_hash = {}
|
73
|
-
Gem::SourceInfoCache.cache_data.each do |source_uri, sic_entry|
|
74
|
-
@source_index_hash[source_uri] = sic_entry.source_index
|
75
|
-
end
|
76
|
-
@source_index_hash
|
77
|
-
end
|
78
|
-
|
79
|
-
# Finds the Gem::Specification objects and the corresponding source URI
|
80
|
-
# for gems matching +gem_name+ and +version_requirement+
|
81
|
-
def specs_n_sources_matching(gem_name, version_requirement)
|
82
|
-
specs_n_sources = []
|
83
|
-
|
84
|
-
source_index_hash.each do |source_uri, source_index|
|
85
|
-
specs = source_index.search(/^#{Regexp.escape gem_name}$/i,
|
86
|
-
version_requirement)
|
87
|
-
# TODO move to SourceIndex#search?
|
88
|
-
ruby_version = Gem::Version.new RUBY_VERSION
|
89
|
-
specs = specs.select do |spec|
|
90
|
-
spec.required_ruby_version.nil? or
|
91
|
-
spec.required_ruby_version.satisfied_by? ruby_version
|
92
|
-
end
|
93
|
-
specs.each { |spec| specs_n_sources << [spec, source_uri] }
|
94
|
-
end
|
95
|
-
|
96
|
-
if specs_n_sources.empty? then
|
97
|
-
raise GemNotFoundException, "Could not find #{gem_name} (#{version_requirement}) in any repository"
|
98
|
-
end
|
99
|
-
|
100
|
-
specs_n_sources = specs_n_sources.sort_by { |gs,| gs.version }.reverse
|
101
|
-
|
102
|
-
specs_n_sources
|
103
|
-
end
|
104
|
-
|
105
|
-
# Find a gem to be installed by interacting with the user.
|
106
|
-
def find_gem_to_install(gem_name, version_requirement)
|
107
|
-
specs_n_sources = specs_n_sources_matching gem_name, version_requirement
|
108
|
-
|
109
|
-
top_3_versions = specs_n_sources.map{|gs| gs.first.version}.uniq[0..3]
|
110
|
-
specs_n_sources.reject!{|gs| !top_3_versions.include?(gs.first.version)}
|
111
|
-
|
112
|
-
binary_gems = specs_n_sources.reject { |item|
|
113
|
-
item[0].platform.nil? || item[0].platform==Platform::RUBY
|
114
|
-
}
|
115
|
-
|
116
|
-
# only non-binary gems...return latest
|
117
|
-
return specs_n_sources.first if binary_gems.empty?
|
118
|
-
|
119
|
-
list = specs_n_sources.collect { |spec, source_uri|
|
120
|
-
"#{spec.name} #{spec.version} (#{spec.platform})"
|
121
|
-
}
|
122
|
-
|
123
|
-
list << "Skip this gem"
|
124
|
-
list << "Cancel installation"
|
125
|
-
|
126
|
-
string, index = choose_from_list(
|
127
|
-
"Select which gem to install for your platform (#{RUBY_PLATFORM})",
|
128
|
-
list)
|
129
|
-
|
130
|
-
if index.nil? or index == (list.size - 1) then
|
131
|
-
raise RemoteInstallationCancelled, "Installation of #{gem_name} cancelled."
|
132
|
-
end
|
133
|
-
|
134
|
-
if index == (list.size - 2) then
|
135
|
-
raise RemoteInstallationSkipped, "Installation of #{gem_name} skipped."
|
136
|
-
end
|
137
|
-
|
138
|
-
specs_n_sources[index]
|
139
|
-
end
|
140
|
-
|
141
|
-
def find_dependencies_not_installed(dependencies)
|
142
|
-
to_install = []
|
143
|
-
dependencies.each do |dependency|
|
144
|
-
srcindex = Gem::SourceIndex.from_installed_gems
|
145
|
-
matches = srcindex.find_name(dependency.name, dependency.requirement_list)
|
146
|
-
to_install.push dependency if matches.empty?
|
147
|
-
end
|
148
|
-
to_install
|
149
|
-
end
|
150
|
-
|
151
|
-
# Install all the given dependencies. Returns an array of
|
152
|
-
# Gem::Specification objects, one for each dependency installed.
|
153
|
-
#
|
154
|
-
# TODO: For now, we recursively install, but this is not the right
|
155
|
-
# way to do things (e.g. if a package fails to download, we
|
156
|
-
# shouldn't install anything).
|
157
|
-
def install_dependencies(dependencies, force, install_dir)
|
158
|
-
return if @options[:ignore_dependencies]
|
159
|
-
installed_gems = []
|
160
|
-
dependencies.each do |dep|
|
161
|
-
if @options[:include_dependencies] ||
|
162
|
-
ask_yes_no("Install required dependency #{dep.name}?", true)
|
163
|
-
remote_installer = RemoteInstaller.new @options
|
164
|
-
installed_gems << remote_installer.install(dep.name,
|
165
|
-
dep.version_requirements,
|
166
|
-
force, install_dir)
|
167
|
-
elsif force then
|
168
|
-
# ignore
|
169
|
-
else
|
170
|
-
raise DependencyError, "Required dependency #{dep.name} not installed"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
installed_gems
|
174
|
-
end
|
175
|
-
|
176
|
-
def download_gem(destination_file, source, spec)
|
177
|
-
return if File.exist? destination_file
|
178
|
-
uri = source + "/gems/#{spec.full_name}.gem"
|
179
|
-
response = Gem::RemoteFetcher.fetcher.fetch_path uri
|
180
|
-
write_gem_to_file response, destination_file
|
181
|
-
end
|
182
|
-
|
183
|
-
def write_gem_to_file(body, destination_file)
|
184
|
-
FileUtils.mkdir_p(File.dirname(destination_file)) unless File.exist?(destination_file)
|
185
|
-
File.open(destination_file, 'wb') do |out|
|
186
|
-
out.write(body)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
def new_installer(gem)
|
191
|
-
return Installer.new(gem, @options)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
-
# All rights reserved.
|
4
|
-
# See LICENSE.txt for permissions.
|
5
|
-
#++
|
6
|
-
|
7
|
-
require 'test/unit'
|
8
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
9
|
-
require 'rubygems/remote_installer'
|
10
|
-
|
11
|
-
class MockFetcher
|
12
|
-
def initialize(uri, proxy)
|
13
|
-
@uri = uri
|
14
|
-
@proxy = proxy
|
15
|
-
end
|
16
|
-
|
17
|
-
def size
|
18
|
-
1000
|
19
|
-
end
|
20
|
-
|
21
|
-
def source_index
|
22
|
-
if @uri =~ /non.existent.url/
|
23
|
-
fail Gem::RemoteSourceException,
|
24
|
-
"Error fetching remote gem cache: Mock Socket Exception"
|
25
|
-
end
|
26
|
-
result = {
|
27
|
-
'foo-1.2.3' => Gem::Specification.new do |s|
|
28
|
-
s.name = 'foo'
|
29
|
-
s.version = "1.2.3"
|
30
|
-
s.summary = "This is a cool package"
|
31
|
-
end,
|
32
|
-
'foo-tools-2.0.0' => Gem::Specification.new do |s|
|
33
|
-
s.name = 'foo-tools'
|
34
|
-
s.version = "2.0.0"
|
35
|
-
s.summary = "This is an even cooler package"
|
36
|
-
end,
|
37
|
-
'foo-2-2.0.0' => Gem::Specification.new do |s|
|
38
|
-
s.name = 'foo-2'
|
39
|
-
s.version = "2.0.0"
|
40
|
-
s.summary = "This is the coolest package evar!~!"
|
41
|
-
end,
|
42
|
-
}
|
43
|
-
result
|
44
|
-
end
|
45
|
-
|
46
|
-
def fetch_path(path)
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.finish
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class TestGemRemoteInstaller < RubyGemTestCase
|
54
|
-
|
55
|
-
def setup
|
56
|
-
super
|
57
|
-
|
58
|
-
util_setup_fake_fetcher
|
59
|
-
|
60
|
-
util_setup_source_info_cache @gem1, @gem4
|
61
|
-
|
62
|
-
@installer = Gem::RemoteInstaller.new
|
63
|
-
@installer.instance_variable_set("@fetcher_class", MockFetcher)
|
64
|
-
end
|
65
|
-
|
66
|
-
def teardown
|
67
|
-
FileUtils.rm "dest_file" rescue nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_find_gem_to_install
|
71
|
-
future_gem = quick_gem @gem1.name, '9.9.9' do |spec|
|
72
|
-
spec.required_ruby_version = '> 999.999.999' # HACK
|
73
|
-
end
|
74
|
-
|
75
|
-
util_setup_source_info_cache @gem1, future_gem
|
76
|
-
version = Gem::Version::Requirement.new "> 0.0.0"
|
77
|
-
gems = @installer.find_gem_to_install(@gem1.name, version)
|
78
|
-
|
79
|
-
assert_equal @gem1.full_name, gems.first.full_name
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_source_index_hash
|
83
|
-
source_hash = @installer.source_index_hash
|
84
|
-
|
85
|
-
assert_equal 1, source_hash.size
|
86
|
-
assert source_hash.has_key?('http://gems.example.com')
|
87
|
-
assert_equal [@gem1, @gem4],
|
88
|
-
source_hash['http://gems.example.com'].search(@gem1.name)
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_specs_n_sources_matching
|
92
|
-
version = Gem::Version::Requirement.new "> 0.0.0"
|
93
|
-
specs_n_sources = @installer.specs_n_sources_matching @gem1.name, version
|
94
|
-
|
95
|
-
gems = specs_n_sources.map { |g,| g.full_name }
|
96
|
-
|
97
|
-
assert_equal [@gem1.full_name], gems,
|
98
|
-
"Gems with longer names and higher versions must not match"
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
# This test suite has a number of TODOs in the test cases. The
|
104
|
-
# TestRemoteInstaller test suite is a reworking of this class from
|
105
|
-
# scratch.
|
106
|
-
class RemoteInstallerTest #< RubyGemTestCase # HACK disabled
|
107
|
-
class RInst < Gem::RemoteInstaller
|
108
|
-
include Test::Unit::Assertions
|
109
|
-
|
110
|
-
attr_accessor :expected_destination_files
|
111
|
-
attr_accessor :expected_bodies
|
112
|
-
attr_accessor :caches
|
113
|
-
attr_accessor :responses
|
114
|
-
|
115
|
-
def source_index_hash
|
116
|
-
@caches
|
117
|
-
end
|
118
|
-
|
119
|
-
def fetch(uri)
|
120
|
-
@reponses ||= {}
|
121
|
-
@responses[uri]
|
122
|
-
end
|
123
|
-
|
124
|
-
def write_gem_to_file(body, destination_file)
|
125
|
-
expected_destination_file = expected_destination_files.pop
|
126
|
-
expected_body = expected_bodies.pop
|
127
|
-
assert_equal expected_body, body, "Unexpected body"
|
128
|
-
assert_equal expected_destination_file, destination_file, "Unexpected destination file"
|
129
|
-
end
|
130
|
-
|
131
|
-
def new_installer(gem)
|
132
|
-
return MockInstaller.new(gem)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def setup
|
137
|
-
Gem.clear_paths
|
138
|
-
@remote_installer = Gem::RemoteInstaller.new
|
139
|
-
@remote_installer.instance_eval { @fetcher_class = MockFetcher }
|
140
|
-
end
|
141
|
-
|
142
|
-
SAMPLE_SPEC = Gem::Specification.new do |s|
|
143
|
-
s.name = 'foo'
|
144
|
-
s.version = "1.2.3"
|
145
|
-
s.platform = Gem::Platform::RUBY
|
146
|
-
s.summary = "This is a cool package"
|
147
|
-
s.files = []
|
148
|
-
end
|
149
|
-
SAMPLE_CACHE = { 'foo-1.2.3' => SAMPLE_SPEC }
|
150
|
-
SAMPLE_CACHE_YAML = SAMPLE_CACHE.to_yaml
|
151
|
-
|
152
|
-
FOO_GEM = '' # TODO
|
153
|
-
CACHE_DIR = File.join(Gem.dir, 'cache')
|
154
|
-
|
155
|
-
def test_install
|
156
|
-
result = @remote_installer.install('foo')
|
157
|
-
assert_equal [nil], result
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
161
|
-
|