rubygems-update 1.3.5 → 1.3.6
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 +8 -1
- data/ChangeLog +164 -0
- data/History.txt +52 -1
- data/Manifest.txt +8 -8
- data/README +3 -2
- data/Rakefile +49 -5
- data/bin/gem +2 -2
- data/bin/update_rubygems +9 -11
- data/cruise_config.rb +4 -3
- data/hide_lib_for_update/note.txt +5 -0
- data/lib/rbconfig/datadir.rb +10 -14
- data/lib/rubygems.rb +117 -140
- data/lib/rubygems/builder.rb +4 -2
- data/lib/rubygems/command.rb +51 -48
- data/lib/rubygems/command_manager.rb +2 -0
- data/lib/rubygems/commands/dependency_command.rb +10 -5
- data/lib/rubygems/commands/environment_command.rb +1 -1
- data/lib/rubygems/commands/fetch_command.rb +6 -5
- data/lib/rubygems/commands/install_command.rb +1 -0
- data/lib/rubygems/commands/mirror_command.rb +8 -8
- data/lib/rubygems/commands/owner_command.rb +75 -0
- data/lib/rubygems/commands/pristine_command.rb +1 -1
- data/lib/rubygems/commands/push_command.rb +45 -0
- data/lib/rubygems/commands/query_command.rb +4 -1
- data/lib/rubygems/commands/rdoc_command.rb +24 -9
- data/lib/rubygems/commands/server_command.rb +6 -0
- data/lib/rubygems/commands/setup_command.rb +14 -4
- data/lib/rubygems/commands/unpack_command.rb +2 -2
- data/lib/rubygems/commands/update_command.rb +2 -2
- data/lib/rubygems/commands/which_command.rb +7 -9
- data/lib/rubygems/config_file.rb +100 -26
- data/lib/rubygems/defaults.rb +1 -1
- data/lib/rubygems/dependency.rb +133 -75
- data/lib/rubygems/dependency_installer.rb +28 -10
- data/lib/rubygems/dependency_list.rb +41 -12
- data/lib/rubygems/doc_manager.rb +7 -0
- data/lib/rubygems/format.rb +16 -20
- data/lib/rubygems/gem_openssl.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +10 -12
- data/lib/rubygems/gemcutter_utilities.rb +49 -0
- data/lib/rubygems/indexer.rb +2 -2
- data/lib/rubygems/install_update_options.rb +1 -9
- data/lib/rubygems/installer.rb +35 -76
- data/lib/rubygems/local_remote_options.rb +1 -2
- data/lib/rubygems/package.rb +0 -1
- data/lib/rubygems/package/tar_input.rb +3 -1
- data/lib/rubygems/package_task.rb +16 -11
- data/lib/rubygems/remote_fetcher.rb +22 -8
- data/lib/rubygems/requirement.rb +78 -100
- data/lib/rubygems/server.rb +41 -10
- data/lib/rubygems/source_index.rb +5 -5
- data/lib/rubygems/spec_fetcher.rb +2 -2
- data/lib/rubygems/specification.rb +66 -16
- data/lib/rubygems/test_utilities.rb +33 -4
- data/lib/rubygems/uninstaller.rb +3 -3
- data/lib/rubygems/user_interaction.rb +45 -0
- data/lib/rubygems/validator.rb +6 -7
- data/lib/rubygems/version.rb +206 -149
- data/lib/rubygems/version_option.rb +16 -0
- data/test/fake_certlib/openssl.rb +1 -1
- data/test/functional.rb +0 -7
- data/test/gem_installer_test_case.rb +4 -4
- data/test/gem_package_tar_test_case.rb +1 -1
- data/test/gemutilities.rb +35 -31
- data/test/insure_session.rb +0 -8
- data/test/mockgemui.rb +0 -8
- data/test/simple_gem.rb +2 -8
- data/test/test_config.rb +3 -10
- data/test/test_gem.rb +9 -14
- data/test/test_gem_builder.rb +1 -7
- data/test/test_gem_command.rb +1 -8
- data/test/test_gem_command_manager.rb +1 -7
- data/test/test_gem_commands_build_command.rb +4 -4
- data/test/test_gem_commands_cert_command.rb +1 -2
- data/test/test_gem_commands_check_command.rb +1 -7
- data/test/test_gem_commands_contents_command.rb +1 -1
- data/test/test_gem_commands_dependency_command.rb +17 -31
- data/test/test_gem_commands_environment_command.rb +1 -1
- data/test/test_gem_commands_fetch_command.rb +14 -12
- data/test/test_gem_commands_generate_index_command.rb +1 -1
- data/test/test_gem_commands_install_command.rb +22 -20
- data/test/test_gem_commands_list_command.rb +1 -1
- data/test/test_gem_commands_lock_command.rb +1 -1
- data/test/test_gem_commands_mirror_command.rb +5 -5
- data/test/test_gem_commands_outdated_command.rb +3 -5
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +2 -2
- data/test/test_gem_commands_push_command.rb +61 -0
- data/test/test_gem_commands_query_command.rb +23 -56
- data/test/test_gem_commands_server_command.rb +1 -1
- data/test/test_gem_commands_sources_command.rb +1 -70
- data/test/test_gem_commands_specification_command.rb +3 -4
- data/test/test_gem_commands_stale_command.rb +1 -1
- data/test/test_gem_commands_uninstall_command.rb +3 -4
- data/test/test_gem_commands_unpack_command.rb +1 -1
- data/test/test_gem_commands_update_command.rb +13 -13
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +13 -7
- data/test/test_gem_dependency.rb +82 -134
- data/test/test_gem_dependency_installer.rb +55 -30
- data/test/test_gem_dependency_list.rb +28 -7
- data/test/test_gem_doc_manager.rb +1 -7
- data/test/test_gem_ext_configure_builder.rb +2 -2
- data/test/test_gem_ext_ext_conf_builder.rb +1 -1
- data/test/test_gem_ext_rake_builder.rb +1 -1
- data/test/test_gem_format.rb +14 -11
- data/test/test_gem_gem_path_searcher.rb +12 -1
- data/test/test_gem_gem_runner.rb +1 -1
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +44 -51
- data/test/test_gem_install_update_options.rb +1 -7
- data/test/test_gem_installer.rb +22 -82
- data/test/test_gem_local_remote_options.rb +1 -1
- data/test/test_gem_package_tar_header.rb +1 -8
- data/test/test_gem_package_tar_input.rb +1 -8
- data/test/test_gem_package_tar_output.rb +1 -8
- data/test/test_gem_package_tar_reader.rb +1 -8
- data/test/test_gem_package_tar_reader_entry.rb +1 -8
- data/test/test_gem_package_tar_writer.rb +1 -8
- data/test/test_gem_package_task.rb +1 -25
- data/test/test_gem_platform.rb +4 -4
- data/test/test_gem_remote_fetcher.rb +31 -21
- data/test/test_gem_requirement.rb +210 -140
- data/test/test_gem_server.rb +36 -1
- data/test/test_gem_source_index.rb +7 -13
- data/test/test_gem_spec_fetcher.rb +17 -47
- data/test/test_gem_specification.rb +7 -20
- data/test/test_gem_stream_ui.rb +21 -1
- data/test/test_gem_uninstaller.rb +1 -2
- data/test/test_gem_validator.rb +2 -8
- data/test/test_gem_version.rb +110 -254
- data/test/test_gem_version_option.rb +1 -1
- data/test/test_kernel.rb +1 -7
- data/util/CL2notes +1 -1
- data/util/gem_prelude.rb.template +64 -41
- metadata +33 -71
- metadata.gz.sig +0 -0
- data/lib/rubygems/digest/digest_adapter.rb +0 -49
- data/lib/rubygems/digest/md5.rb +0 -23
- data/lib/rubygems/digest/sha1.rb +0 -22
- data/lib/rubygems/digest/sha2.rb +0 -22
- data/lib/rubygems/timer.rb +0 -28
- data/test/test_gem_digest.rb +0 -46
- data/test/test_gem_source_info_cache.rb +0 -447
- data/test/test_gem_source_info_cache_entry.rb +0 -78
@@ -38,7 +38,7 @@ class Gem::DependencyInstaller
|
|
38
38
|
# :format_executable:: See Gem::Installer#initialize.
|
39
39
|
# :ignore_dependencies:: Don't install any dependencies.
|
40
40
|
# :install_dir:: See Gem::Installer#install.
|
41
|
-
# :prerelease:: Allow prerelease versions
|
41
|
+
# :prerelease:: Allow prerelease versions. See #install.
|
42
42
|
# :security_policy:: See Gem::Installer::new and Gem::Security.
|
43
43
|
# :user_install:: See Gem::Installer.new
|
44
44
|
# :wrappers:: See Gem::Installer::new
|
@@ -89,14 +89,18 @@ class Gem::DependencyInstaller
|
|
89
89
|
|
90
90
|
if @domain == :both or @domain == :remote then
|
91
91
|
begin
|
92
|
-
requirements = dep.
|
92
|
+
requirements = dep.requirement.requirements.map do |req, ver|
|
93
93
|
req
|
94
94
|
end
|
95
95
|
|
96
|
-
all =
|
96
|
+
all = !dep.prerelease? &&
|
97
|
+
# we only need latest if there's one requirement and it is
|
98
|
+
# guaranteed to match the newest specs
|
99
|
+
(requirements.length > 1 or
|
97
100
|
(requirements.first != ">=" and requirements.first != ">"))
|
98
101
|
|
99
|
-
found = Gem::SpecFetcher.fetcher.fetch dep, all, true,
|
102
|
+
found = Gem::SpecFetcher.fetcher.fetch dep, all, true, dep.prerelease?
|
103
|
+
|
100
104
|
gems_and_sources.push(*found)
|
101
105
|
|
102
106
|
rescue Gem::RemoteFetcher::FetchError => e
|
@@ -120,7 +124,7 @@ class Gem::DependencyInstaller
|
|
120
124
|
def gather_dependencies
|
121
125
|
specs = @specs_and_sources.map { |spec,_| spec }
|
122
126
|
|
123
|
-
dependency_list = Gem::DependencyList.new
|
127
|
+
dependency_list = Gem::DependencyList.new @development
|
124
128
|
dependency_list.add(*specs)
|
125
129
|
|
126
130
|
unless @ignore_dependencies then
|
@@ -143,7 +147,7 @@ class Gem::DependencyInstaller
|
|
143
147
|
|
144
148
|
@source_index.any? do |_, installed_spec|
|
145
149
|
dep.name == installed_spec.name and
|
146
|
-
dep.
|
150
|
+
dep.requirement.satisfied_by? installed_spec.version
|
147
151
|
end
|
148
152
|
end
|
149
153
|
|
@@ -164,7 +168,9 @@ class Gem::DependencyInstaller
|
|
164
168
|
# +version+. Returns an Array of specs and sources required for
|
165
169
|
# installation of the gem.
|
166
170
|
|
167
|
-
def find_spec_by_name_and_version
|
171
|
+
def find_spec_by_name_and_version(gem_name,
|
172
|
+
version = Gem::Requirement.default,
|
173
|
+
prerelease = false)
|
168
174
|
spec_and_source = nil
|
169
175
|
|
170
176
|
glob = if File::ALT_SEPARATOR then
|
@@ -189,6 +195,7 @@ class Gem::DependencyInstaller
|
|
189
195
|
|
190
196
|
if spec_and_source.nil? then
|
191
197
|
dep = Gem::Dependency.new gem_name, version
|
198
|
+
dep.prerelease = true if prerelease
|
192
199
|
spec_and_sources = find_gems_with_sources(dep).reverse
|
193
200
|
|
194
201
|
spec_and_source = spec_and_sources.find { |spec, source|
|
@@ -205,13 +212,24 @@ class Gem::DependencyInstaller
|
|
205
212
|
end
|
206
213
|
|
207
214
|
##
|
208
|
-
# Installs the gem and all its dependencies. Returns an Array
|
209
|
-
#
|
215
|
+
# Installs the gem +dep_or_name+ and all its dependencies. Returns an Array
|
216
|
+
# of installed gem specifications.
|
217
|
+
#
|
218
|
+
# If the +:prerelease+ option is set and there is a prerelease for
|
219
|
+
# +dep_or_name+ the prerelease version will be installed.
|
220
|
+
#
|
221
|
+
# Unless explicitly specified as a prerelease dependency, prerelease gems
|
222
|
+
# that +dep_or_name+ depend on will not be installed.
|
223
|
+
#
|
224
|
+
# If c-1.a depends on b-1 and a-1.a and there is a gem b-1.a available then
|
225
|
+
# c-1.a, b-1 and a-1.a will be installed. b-1.a will need to be installed
|
226
|
+
# separately.
|
210
227
|
|
211
228
|
def install dep_or_name, version = Gem::Requirement.default
|
212
229
|
if String === dep_or_name then
|
213
|
-
find_spec_by_name_and_version dep_or_name, version
|
230
|
+
find_spec_by_name_and_version dep_or_name, version, @prerelease
|
214
231
|
else
|
232
|
+
dep_or_name.prerelease = @prerelease
|
215
233
|
@specs_and_sources = [find_gems_with_sources(dep_or_name).last]
|
216
234
|
end
|
217
235
|
|
@@ -6,23 +6,41 @@
|
|
6
6
|
|
7
7
|
require 'tsort'
|
8
8
|
|
9
|
+
##
|
10
|
+
# Gem::DependencyList is used for installing and uninstalling gems in the
|
11
|
+
# correct order to avoid conflicts.
|
12
|
+
|
9
13
|
class Gem::DependencyList
|
10
14
|
|
11
15
|
include Enumerable
|
12
16
|
include TSort
|
13
17
|
|
14
|
-
|
15
|
-
|
18
|
+
##
|
19
|
+
# Allows enabling/disabling use of development dependencies
|
20
|
+
|
21
|
+
attr_accessor :development
|
16
22
|
|
17
|
-
|
18
|
-
|
23
|
+
##
|
24
|
+
# Creates a DependencyList from a Gem::SourceIndex +source_index+
|
25
|
+
|
26
|
+
def self.from_source_index(source_index)
|
27
|
+
list = new
|
28
|
+
|
29
|
+
source_index.each do |full_name, spec|
|
30
|
+
list.add spec
|
19
31
|
end
|
20
32
|
|
21
|
-
|
33
|
+
list
|
22
34
|
end
|
23
35
|
|
24
|
-
|
36
|
+
##
|
37
|
+
# Creates a new DependencyList. If +development+ is true, development
|
38
|
+
# dependencies will be included.
|
39
|
+
|
40
|
+
def initialize development = false
|
25
41
|
@specs = []
|
42
|
+
|
43
|
+
@development = development
|
26
44
|
end
|
27
45
|
|
28
46
|
##
|
@@ -33,8 +51,9 @@ class Gem::DependencyList
|
|
33
51
|
end
|
34
52
|
|
35
53
|
##
|
36
|
-
# Return a list of the specifications in the dependency list, sorted in
|
37
|
-
# order so that no
|
54
|
+
# Return a list of the gem specifications in the dependency list, sorted in
|
55
|
+
# order so that no gemspec in the list depends on a gemspec earlier in the
|
56
|
+
# list.
|
38
57
|
#
|
39
58
|
# This is useful when removing gems from a set of installed gems. By
|
40
59
|
# removing them in the returned order, you don't get into as many dependency
|
@@ -77,6 +96,10 @@ class Gem::DependencyList
|
|
77
96
|
@specs.find { |spec| spec.full_name == full_name }
|
78
97
|
end
|
79
98
|
|
99
|
+
def inspect # :nodoc:
|
100
|
+
"#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }]
|
101
|
+
end
|
102
|
+
|
80
103
|
##
|
81
104
|
# Are all the dependencies in the list satisfied?
|
82
105
|
|
@@ -89,10 +112,10 @@ class Gem::DependencyList
|
|
89
112
|
end
|
90
113
|
|
91
114
|
##
|
92
|
-
# Is is ok to remove a
|
115
|
+
# Is is ok to remove a gemspec from the dependency list?
|
93
116
|
#
|
94
117
|
# If removing the gemspec creates breaks a currently ok dependency, then it
|
95
|
-
# is NOT ok to remove the
|
118
|
+
# is NOT ok to remove the gemspec.
|
96
119
|
|
97
120
|
def ok_to_remove?(full_name)
|
98
121
|
gem_to_remove = find_name full_name
|
@@ -117,13 +140,16 @@ class Gem::DependencyList
|
|
117
140
|
}
|
118
141
|
end
|
119
142
|
|
143
|
+
##
|
144
|
+
# Removes the gemspec matching +full_name+ from the dependency list
|
145
|
+
|
120
146
|
def remove_by_name(full_name)
|
121
147
|
@specs.delete_if { |spec| spec.full_name == full_name }
|
122
148
|
end
|
123
149
|
|
124
150
|
##
|
125
151
|
# Return a hash of predecessors. <tt>result[spec]</tt> is an Array of
|
126
|
-
# gemspecs that have a dependency satisfied by the named
|
152
|
+
# gemspecs that have a dependency satisfied by the named gemspec.
|
127
153
|
|
128
154
|
def spec_predecessors
|
129
155
|
result = Hash.new { |h,k| h[k] = [] }
|
@@ -152,7 +178,10 @@ class Gem::DependencyList
|
|
152
178
|
def tsort_each_child(node, &block)
|
153
179
|
specs = @specs.sort.reverse
|
154
180
|
|
155
|
-
|
181
|
+
dependencies = node.runtime_dependencies
|
182
|
+
dependencies.push(*node.development_dependencies) if @development
|
183
|
+
|
184
|
+
dependencies.each do |dep|
|
156
185
|
specs.each do |spec|
|
157
186
|
if spec.satisfies_requirement? dep then
|
158
187
|
begin
|
data/lib/rubygems/doc_manager.rb
CHANGED
@@ -97,6 +97,13 @@ class Gem::DocManager
|
|
97
97
|
File.exist?(File.join(@doc_dir, "rdoc"))
|
98
98
|
end
|
99
99
|
|
100
|
+
##
|
101
|
+
# Is the RI documentation installed?
|
102
|
+
|
103
|
+
def ri_installed?
|
104
|
+
File.exist?(File.join(@doc_dir, "ri"))
|
105
|
+
end
|
106
|
+
|
100
107
|
##
|
101
108
|
# Generate the RI documents for this gem spec.
|
102
109
|
#
|
data/lib/rubygems/format.rb
CHANGED
@@ -14,25 +14,22 @@ require 'rubygems/package'
|
|
14
14
|
|
15
15
|
class Gem::Format
|
16
16
|
|
17
|
-
attr_accessor :spec
|
17
|
+
attr_accessor :spec
|
18
|
+
attr_accessor :file_entries
|
19
|
+
attr_accessor :gem_path
|
18
20
|
|
19
21
|
extend Gem::UserInteraction
|
20
22
|
|
21
23
|
##
|
22
|
-
# Constructs
|
23
|
-
|
24
|
-
#
|
25
|
-
# gem:: [String] The file name of the gem
|
26
|
-
#
|
24
|
+
# Constructs a Format representing the gem's data which came from +gem_path+
|
25
|
+
|
27
26
|
def initialize(gem_path)
|
28
27
|
@gem_path = gem_path
|
29
28
|
end
|
30
29
|
|
31
30
|
##
|
32
|
-
# Reads the
|
33
|
-
# the data
|
34
|
-
#
|
35
|
-
# file_path:: [String] Path to the gem file
|
31
|
+
# Reads the gem +file_path+ using +security_policy+ and returns a Format
|
32
|
+
# representing the data in the gem
|
36
33
|
|
37
34
|
def self.from_file_by_path(file_path, security_policy = nil)
|
38
35
|
format = nil
|
@@ -41,25 +38,24 @@ class Gem::Format
|
|
41
38
|
raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
|
42
39
|
end
|
43
40
|
|
44
|
-
|
45
|
-
|
41
|
+
start = File.read file_path, 20
|
42
|
+
|
43
|
+
if start.nil? or start.length < 20 then
|
44
|
+
nil
|
45
|
+
elsif start.include?("MD5SUM =") # old version gems
|
46
46
|
require 'rubygems/old_format'
|
47
47
|
|
48
|
-
|
48
|
+
Gem::OldFormat.from_file_by_path file_path
|
49
49
|
else
|
50
50
|
open file_path, Gem.binary_mode do |io|
|
51
|
-
|
51
|
+
from_io io, file_path, security_policy
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
return format
|
56
54
|
end
|
57
55
|
|
58
56
|
##
|
59
|
-
# Reads a gem from
|
60
|
-
# the data from the gem
|
61
|
-
#
|
62
|
-
# io:: [IO] Stream from which to read the gem
|
57
|
+
# Reads a gem from +io+ at +gem_path+ using +security_policy+ and returns a
|
58
|
+
# Format representing the data from the gem
|
63
59
|
|
64
60
|
def self.from_io(io, gem_path="(io)", security_policy = nil)
|
65
61
|
format = new gem_path
|
data/lib/rubygems/gem_openssl.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
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
1
|
##
|
8
2
|
# GemPathSearcher has the capability to find loadable files inside
|
9
3
|
# gems. It generates data up front to speed up searches later.
|
@@ -14,14 +8,16 @@ class Gem::GemPathSearcher
|
|
14
8
|
# Initialise the data we need to make searches later.
|
15
9
|
|
16
10
|
def initialize
|
17
|
-
# We want a record of all the installed gemspecs, in the order
|
18
|
-
#
|
11
|
+
# We want a record of all the installed gemspecs, in the order we wish to
|
12
|
+
# examine them.
|
19
13
|
@gemspecs = init_gemspecs
|
20
|
-
|
21
|
-
#
|
14
|
+
|
15
|
+
# Map gem spec to glob of full require_path directories. Preparing this
|
16
|
+
# information may speed up searches later.
|
22
17
|
@lib_dirs = {}
|
18
|
+
|
23
19
|
@gemspecs.each do |spec|
|
24
|
-
@lib_dirs[spec.object_id] = lib_dirs_for
|
20
|
+
@lib_dirs[spec.object_id] = lib_dirs_for spec
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
@@ -72,6 +68,7 @@ class Gem::GemPathSearcher
|
|
72
68
|
# Some of the intermediate results are cached in @lib_dirs for speed.
|
73
69
|
|
74
70
|
def matching_files(spec, path)
|
71
|
+
return [] unless @lib_dirs[spec.object_id] # case no paths
|
75
72
|
glob = File.join @lib_dirs[spec.object_id], "#{path}#{Gem.suffix_pattern}"
|
76
73
|
Dir[glob].select { |f| File.file? f.untaint }
|
77
74
|
end
|
@@ -95,7 +92,8 @@ class Gem::GemPathSearcher
|
|
95
92
|
# '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
|
96
93
|
|
97
94
|
def lib_dirs_for(spec)
|
98
|
-
"#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}"
|
95
|
+
"#{spec.full_gem_path}/{#{spec.require_paths.join(',')}}" if
|
96
|
+
spec.require_paths
|
99
97
|
end
|
100
98
|
|
101
99
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'rubygems/remote_fetcher'
|
3
|
+
|
4
|
+
module Gem::GemcutterUtilities
|
5
|
+
|
6
|
+
def sign_in
|
7
|
+
return if Gem.configuration.rubygems_api_key
|
8
|
+
|
9
|
+
say "Enter your RubyGems.org credentials."
|
10
|
+
say "Don't have an account yet? Create one at http://rubygems.org/sign_up"
|
11
|
+
|
12
|
+
email = ask " Email: "
|
13
|
+
password = ask_for_password "Password: "
|
14
|
+
say "\n"
|
15
|
+
|
16
|
+
response = rubygems_api_request :get, "api/v1/api_key" do |request|
|
17
|
+
request.basic_auth email, password
|
18
|
+
end
|
19
|
+
|
20
|
+
with_response response do |resp|
|
21
|
+
say "Signed in."
|
22
|
+
Gem.configuration.rubygems_api_key = resp.body
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def rubygems_api_request(method, path, &block)
|
27
|
+
host = ENV['RUBYGEMS_HOST'] || 'https://rubygems.org'
|
28
|
+
uri = URI.parse "#{host}/#{path}"
|
29
|
+
|
30
|
+
request_method = Net::HTTP.const_get method.to_s.capitalize
|
31
|
+
|
32
|
+
Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_response(resp)
|
36
|
+
case resp
|
37
|
+
when Net::HTTPSuccess then
|
38
|
+
if block_given? then
|
39
|
+
yield resp
|
40
|
+
else
|
41
|
+
say resp.body
|
42
|
+
end
|
43
|
+
else
|
44
|
+
say resp.body
|
45
|
+
terminate_interaction 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/rubygems/indexer.rb
CHANGED
@@ -58,7 +58,7 @@ class Gem::Indexer
|
|
58
58
|
|
59
59
|
def initialize(directory, options = {})
|
60
60
|
unless ''.respond_to? :to_xs then
|
61
|
-
|
61
|
+
raise "Gem::Indexer requires that the XML Builder library be installed:" \
|
62
62
|
"\n\tgem install builder"
|
63
63
|
end
|
64
64
|
|
@@ -350,7 +350,7 @@ class Gem::Indexer
|
|
350
350
|
end
|
351
351
|
|
352
352
|
index.sort_by { |_, spec| [-spec.date.to_i, spec] }.each do |_, spec|
|
353
|
-
gem_path = CGI.escapeHTML "http://#{@rss_gems_host}/gems/#{spec.
|
353
|
+
gem_path = CGI.escapeHTML "http://#{@rss_gems_host}/gems/#{spec.file_name}"
|
354
354
|
size = File.stat(spec.loaded_from).size rescue next
|
355
355
|
|
356
356
|
description = spec.description || spec.summary || ''
|
@@ -95,8 +95,7 @@ module Gem::InstallUpdateOptions
|
|
95
95
|
|
96
96
|
add_option(:"Install/Update", '--[no-]user-install',
|
97
97
|
'Install in user\'s home directory instead',
|
98
|
-
'of GEM_HOME.
|
99
|
-
'only if GEM_HOME is not writable.') do |value, options|
|
98
|
+
'of GEM_HOME.') do |value, options|
|
100
99
|
options[:user_install] = value
|
101
100
|
end
|
102
101
|
|
@@ -105,13 +104,6 @@ module Gem::InstallUpdateOptions
|
|
105
104
|
"dependencies") do |value, options|
|
106
105
|
options[:development] = true
|
107
106
|
end
|
108
|
-
|
109
|
-
add_option(:"Install/Update", "--prerelease",
|
110
|
-
"Install prerelease versions of a gem if",
|
111
|
-
"available. Defaults to skipping",
|
112
|
-
"prereleases.") do |value, options|
|
113
|
-
options[:prerelease] = true
|
114
|
-
end
|
115
107
|
end
|
116
108
|
|
117
109
|
##
|
data/lib/rubygems/installer.rb
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
require 'fileutils'
|
8
|
-
require 'pathname'
|
9
8
|
require 'rbconfig'
|
10
9
|
|
11
10
|
require 'rubygems/format'
|
@@ -28,6 +27,12 @@ require 'rubygems/require_paths_builder'
|
|
28
27
|
|
29
28
|
class Gem::Installer
|
30
29
|
|
30
|
+
##
|
31
|
+
# Paths where env(1) might live. Some systems are broken and have it in
|
32
|
+
# /bin
|
33
|
+
|
34
|
+
ENV_PATHS = %w[/usr/bin/env /bin/env]
|
35
|
+
|
31
36
|
##
|
32
37
|
# Raised when there is an error while building extensions.
|
33
38
|
#
|
@@ -52,16 +57,10 @@ class Gem::Installer
|
|
52
57
|
|
53
58
|
attr_reader :spec
|
54
59
|
|
55
|
-
@home_install_warning = false
|
56
60
|
@path_warning = false
|
57
61
|
|
58
62
|
class << self
|
59
63
|
|
60
|
-
##
|
61
|
-
# True if we've warned about ~/.gems install
|
62
|
-
|
63
|
-
attr_accessor :home_install_warning
|
64
|
-
|
65
64
|
##
|
66
65
|
# True if we've warned about PATH not including Gem.bindir
|
67
66
|
|
@@ -106,7 +105,7 @@ class Gem::Installer
|
|
106
105
|
@env_shebang = options[:env_shebang]
|
107
106
|
@force = options[:force]
|
108
107
|
gem_home = options[:install_dir]
|
109
|
-
@gem_home =
|
108
|
+
@gem_home = File.expand_path(gem_home)
|
110
109
|
@ignore_dependencies = options[:ignore_dependencies]
|
111
110
|
@format_executable = options[:format_executable]
|
112
111
|
@security_policy = options[:security_policy]
|
@@ -121,27 +120,6 @@ class Gem::Installer
|
|
121
120
|
raise Gem::InstallError, "invalid gem format for #{@gem}"
|
122
121
|
end
|
123
122
|
|
124
|
-
begin
|
125
|
-
FileUtils.mkdir_p @gem_home
|
126
|
-
rescue Errno::EACCES, Errno::ENOTDIR
|
127
|
-
# We'll divert to ~/.gems below
|
128
|
-
end
|
129
|
-
|
130
|
-
if not File.writable? @gem_home or
|
131
|
-
# TODO: Shouldn't have to test for existence of bindir; tests need it.
|
132
|
-
(@gem_home.to_s == Gem.dir and File.exist? Gem.bindir and
|
133
|
-
not File.writable? Gem.bindir) then
|
134
|
-
if options[:user_install] == false then # You don't want to use ~
|
135
|
-
raise Gem::FilePermissionError, @gem_home
|
136
|
-
elsif options[:user_install].nil? then
|
137
|
-
unless self.class.home_install_warning or options[:unpack] then
|
138
|
-
alert_warning "Installing to ~/.gem since #{@gem_home} and\n\t #{Gem.bindir} aren't both writable."
|
139
|
-
self.class.home_install_warning = true
|
140
|
-
end
|
141
|
-
end
|
142
|
-
options[:user_install] = true
|
143
|
-
end
|
144
|
-
|
145
123
|
if options[:user_install] and not options[:unpack] then
|
146
124
|
@gem_home = Gem.user_dir
|
147
125
|
|
@@ -152,12 +130,11 @@ class Gem::Installer
|
|
152
130
|
self.class.path_warning = true
|
153
131
|
end
|
154
132
|
end
|
155
|
-
|
156
|
-
FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
|
157
|
-
# If it's still not writable, you've got issues.
|
158
|
-
raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
|
159
133
|
end
|
160
134
|
|
135
|
+
FileUtils.mkdir_p @gem_home
|
136
|
+
raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
|
137
|
+
|
161
138
|
@spec = @format.spec
|
162
139
|
|
163
140
|
@gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint
|
@@ -183,14 +160,15 @@ class Gem::Installer
|
|
183
160
|
unless @force then
|
184
161
|
if rrv = @spec.required_ruby_version then
|
185
162
|
unless rrv.satisfied_by? Gem.ruby_version then
|
186
|
-
raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}"
|
163
|
+
raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}."
|
187
164
|
end
|
188
165
|
end
|
189
166
|
|
190
167
|
if rrgv = @spec.required_rubygems_version then
|
191
168
|
unless rrgv.satisfied_by? Gem::Version.new(Gem::RubyGemsVersion) then
|
192
169
|
raise Gem::InstallError,
|
193
|
-
|
170
|
+
"#{@spec.name} requires RubyGems version #{rrgv}. " +
|
171
|
+
"Try 'gem update --system' to update RubyGems itself."
|
194
172
|
end
|
195
173
|
end
|
196
174
|
|
@@ -229,8 +207,7 @@ class Gem::Installer
|
|
229
207
|
|
230
208
|
say @spec.post_install_message unless @spec.post_install_message.nil?
|
231
209
|
|
232
|
-
@spec.loaded_from = File.join(@gem_home, 'specifications',
|
233
|
-
"#{@spec.full_name}.gemspec")
|
210
|
+
@spec.loaded_from = File.join(@gem_home, 'specifications', @spec.spec_name)
|
234
211
|
|
235
212
|
@source_index.add_spec @spec
|
236
213
|
|
@@ -262,7 +239,7 @@ class Gem::Installer
|
|
262
239
|
# True if the gems in the source_index satisfy +dependency+.
|
263
240
|
|
264
241
|
def installation_satisfies_dependency?(dependency)
|
265
|
-
@source_index.find_name(dependency.name, dependency.
|
242
|
+
@source_index.find_name(dependency.name, dependency.requirement).size > 0
|
266
243
|
end
|
267
244
|
|
268
245
|
##
|
@@ -281,8 +258,7 @@ class Gem::Installer
|
|
281
258
|
def write_spec
|
282
259
|
rubycode = @spec.to_ruby
|
283
260
|
|
284
|
-
file_name = File.join @gem_home, 'specifications',
|
285
|
-
"#{@spec.full_name}.gemspec"
|
261
|
+
file_name = File.join @gem_home, 'specifications', @spec.spec_name
|
286
262
|
|
287
263
|
file_name.untaint
|
288
264
|
|
@@ -392,23 +368,25 @@ class Gem::Installer
|
|
392
368
|
# necessary.
|
393
369
|
|
394
370
|
def shebang(bin_file_name)
|
395
|
-
if @env_shebang
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
else
|
406
|
-
# Create a plain shebang line.
|
407
|
-
shebang = "#!#{Gem.ruby}"
|
408
|
-
end
|
371
|
+
ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
|
372
|
+
path = File.join @gem_dir, @spec.bindir, bin_file_name
|
373
|
+
first_line = File.open(path, "rb") {|file| file.gets}
|
374
|
+
|
375
|
+
if /\A#!/ =~ first_line then
|
376
|
+
# Preserve extra words on shebang line, like "-w". Thanks RPA.
|
377
|
+
shebang = first_line.sub(/\A\#!.*?ruby\S*(?=(\s+\S+))/, "#!#{Gem.ruby}")
|
378
|
+
opts = $1
|
379
|
+
shebang.strip! # Avoid nasty ^M issues.
|
380
|
+
end
|
409
381
|
|
410
|
-
|
411
|
-
|
382
|
+
if not ruby_name then
|
383
|
+
"#!#{Gem.ruby}#{opts}"
|
384
|
+
elsif opts then
|
385
|
+
"#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \"$0\" \"$@\"\n#{shebang}"
|
386
|
+
else
|
387
|
+
# Create a plain shebang line.
|
388
|
+
@env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
|
389
|
+
"#!#{@env_path} #{ruby_name}"
|
412
390
|
end
|
413
391
|
end
|
414
392
|
|
@@ -514,7 +492,7 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
|
|
514
492
|
# Ensures that files can't be installed outside the gem directory.
|
515
493
|
|
516
494
|
def extract_files
|
517
|
-
|
495
|
+
@gem_dir = File.expand_path @gem_dir
|
518
496
|
|
519
497
|
raise ArgumentError, "format required to extract from" if @format.nil?
|
520
498
|
|
@@ -558,24 +536,5 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
|
|
558
536
|
end
|
559
537
|
end
|
560
538
|
|
561
|
-
private
|
562
|
-
|
563
|
-
##
|
564
|
-
# HACK Pathname is broken on windows.
|
565
|
-
|
566
|
-
def absolute_path? pathname
|
567
|
-
pathname.absolute? or (Gem.win_platform? and pathname.to_s =~ /\A[a-z]:/i)
|
568
|
-
end
|
569
|
-
|
570
|
-
def expand_and_validate_gem_dir
|
571
|
-
@gem_dir = Pathname.new(@gem_dir).expand_path
|
572
|
-
|
573
|
-
unless absolute_path?(@gem_dir) then # HACK is this possible after #expand_path?
|
574
|
-
raise ArgumentError, "install directory %p not absolute" % @gem_dir
|
575
|
-
end
|
576
|
-
|
577
|
-
@gem_dir = @gem_dir.to_s
|
578
|
-
end
|
579
|
-
|
580
539
|
end
|
581
540
|
|