rubygems-update 1.3.6 → 1.3.7
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 +86 -0
- data/History.txt +34 -1
- data/Manifest.txt +6 -1
- data/Rakefile +79 -34
- data/lib/rubygems.rb +52 -30
- data/lib/rubygems/builder.rb +2 -0
- data/lib/rubygems/command.rb +12 -0
- data/lib/rubygems/command_manager.rb +17 -12
- data/lib/rubygems/commands/contents_command.rb +1 -1
- data/lib/rubygems/commands/dependency_command.rb +3 -1
- data/lib/rubygems/commands/environment_command.rb +3 -2
- data/lib/rubygems/commands/fetch_command.rb +7 -3
- data/lib/rubygems/commands/install_command.rb +2 -1
- data/lib/rubygems/commands/query_command.rb +16 -3
- data/lib/rubygems/commands/server_command.rb +5 -3
- data/lib/rubygems/commands/setup_command.rb +1 -1
- data/lib/rubygems/commands/unpack_command.rb +35 -23
- data/lib/rubygems/commands/update_command.rb +1 -1
- data/lib/rubygems/defaults.rb +4 -6
- data/lib/rubygems/dependency.rb +32 -6
- data/lib/rubygems/dependency_installer.rb +10 -3
- data/lib/rubygems/doc_manager.rb +5 -2
- data/lib/rubygems/errors.rb +35 -0
- data/lib/rubygems/exceptions.rb +10 -1
- data/lib/rubygems/indexer.rb +1 -1
- data/lib/rubygems/installer.rb +6 -5
- data/lib/rubygems/package.rb +6 -3
- data/lib/rubygems/package/f_sync_dir.rb +4 -3
- data/lib/rubygems/package/tar_header.rb +4 -3
- data/lib/rubygems/package/tar_output.rb +4 -3
- data/lib/rubygems/package/tar_reader.rb +4 -3
- data/lib/rubygems/package/tar_writer.rb +4 -3
- data/lib/rubygems/package_task.rb +4 -3
- data/lib/rubygems/platform.rb +4 -1
- data/lib/rubygems/remote_fetcher.rb +9 -3
- data/lib/rubygems/requirement.rb +5 -0
- data/lib/rubygems/security.rb +3 -3
- data/lib/rubygems/server.rb +33 -18
- data/lib/rubygems/source_index.rb +4 -4
- data/lib/rubygems/source_info_cache.rb +4 -2
- data/lib/rubygems/spec_fetcher.rb +33 -11
- data/lib/rubygems/specification.rb +40 -32
- data/lib/rubygems/test_utilities.rb +2 -2
- data/lib/rubygems/validator.rb +3 -4
- data/lib/rubygems/version.rb +1 -1
- data/test/gem_package_tar_test_case.rb +2 -2
- data/test/gemutilities.rb +15 -9
- data/test/insure_session.rb +1 -1
- data/test/plugin/exception/rubygems_plugin.rb +2 -0
- data/test/plugin/load/rubygems_plugin.rb +1 -0
- data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
- data/test/rubygems/commands/crash_command.rb +5 -0
- data/test/rubygems_plugin.rb +5 -0
- data/test/simple_gem.rb +15 -15
- data/test/test_gem.rb +45 -2
- data/test/test_gem_command_manager.rb +14 -0
- data/test/test_gem_commands_contents_command.rb +7 -5
- data/test/test_gem_commands_environment_command.rb +3 -1
- data/test/test_gem_commands_fetch_command.rb +21 -1
- data/test/test_gem_commands_install_command.rb +2 -4
- data/test/test_gem_commands_query_command.rb +33 -6
- data/test/test_gem_commands_server_command.rb +9 -2
- data/test/test_gem_commands_uninstall_command.rb +4 -2
- data/test/test_gem_commands_unpack_command.rb +46 -2
- data/test/test_gem_config_file.rb +2 -0
- data/test/test_gem_dependency.rb +11 -0
- data/test/test_gem_doc_manager.rb +1 -1
- data/test/test_gem_indexer.rb +2 -2
- data/test/test_gem_installer.rb +1 -1
- data/test/test_gem_package_tar_input.rb +1 -1
- data/test/test_gem_package_tar_writer.rb +3 -3
- data/test/test_gem_platform.rb +19 -0
- data/test/test_gem_server.rb +11 -0
- data/test/test_gem_source_index.rb +2 -2
- data/test/test_gem_spec_fetcher.rb +42 -0
- data/test/test_gem_specification.rb +46 -7
- data/util/{gem_prelude.rb.template → gem_prelude.rb} +53 -23
- metadata +16 -6
- metadata.gz.sig +0 -0
@@ -69,6 +69,10 @@ class Gem::DependencyInstaller
|
|
69
69
|
|
70
70
|
@install_dir = options[:install_dir] || Gem.dir
|
71
71
|
@cache_dir = options[:cache_dir] || @install_dir
|
72
|
+
|
73
|
+
# Set with any errors that SpecFetcher finds while search through
|
74
|
+
# gemspecs for a dep
|
75
|
+
@errors = nil
|
72
76
|
end
|
73
77
|
|
74
78
|
##
|
@@ -78,6 +82,8 @@ class Gem::DependencyInstaller
|
|
78
82
|
# local gems preferred over remote gems.
|
79
83
|
|
80
84
|
def find_gems_with_sources(dep)
|
85
|
+
# Reset the errors
|
86
|
+
@errors = nil
|
81
87
|
gems_and_sources = []
|
82
88
|
|
83
89
|
if @domain == :both or @domain == :local then
|
@@ -99,7 +105,7 @@ class Gem::DependencyInstaller
|
|
99
105
|
(requirements.length > 1 or
|
100
106
|
(requirements.first != ">=" and requirements.first != ">"))
|
101
107
|
|
102
|
-
found = Gem::SpecFetcher.fetcher.
|
108
|
+
found, @errors = Gem::SpecFetcher.fetcher.fetch_with_errors dep, all, true, dep.prerelease?
|
103
109
|
|
104
110
|
gems_and_sources.push(*found)
|
105
111
|
|
@@ -204,8 +210,9 @@ class Gem::DependencyInstaller
|
|
204
210
|
end
|
205
211
|
|
206
212
|
if spec_and_source.nil? then
|
207
|
-
raise Gem::GemNotFoundException
|
208
|
-
"
|
213
|
+
raise Gem::GemNotFoundException.new(
|
214
|
+
"Could not find a valid gem '#{gem_name}' (#{version}) locally or in a repository",
|
215
|
+
gem_name, version, @errors)
|
209
216
|
end
|
210
217
|
|
211
218
|
@specs_and_sources = [spec_and_source]
|
data/lib/rubygems/doc_manager.rb
CHANGED
@@ -179,7 +179,10 @@ class Gem::DocManager
|
|
179
179
|
r = RDoc::RDoc.new
|
180
180
|
|
181
181
|
old_pwd = Dir.pwd
|
182
|
-
Dir.chdir
|
182
|
+
Dir.chdir @spec.full_gem_path
|
183
|
+
|
184
|
+
say "rdoc #{args.join ' '}" if Gem.configuration.really_verbose
|
185
|
+
|
183
186
|
begin
|
184
187
|
r.document args
|
185
188
|
rescue Errno::EACCES => e
|
@@ -193,7 +196,7 @@ class Gem::DocManager
|
|
193
196
|
Gem.configuration.backtrace
|
194
197
|
ui.errs.puts "(continuing with the rest of the installation)"
|
195
198
|
ensure
|
196
|
-
Dir.chdir
|
199
|
+
Dir.chdir old_pwd
|
197
200
|
end
|
198
201
|
end
|
199
202
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Gem::ErrorReason; end
|
2
|
+
|
3
|
+
# Generated when trying to lookup a gem to indicate that the gem
|
4
|
+
# was found, but that it isn't usable on the current platform.
|
5
|
+
#
|
6
|
+
# fetch and install read these and report them to the user to aid
|
7
|
+
# in figuring out why a gem couldn't be installed.
|
8
|
+
#
|
9
|
+
class Gem::PlatformMismatch < Gem::ErrorReason
|
10
|
+
|
11
|
+
attr_reader :name
|
12
|
+
attr_reader :version
|
13
|
+
attr_reader :platforms
|
14
|
+
|
15
|
+
def initialize(name, version)
|
16
|
+
@name = name
|
17
|
+
@version = version
|
18
|
+
@platforms = []
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_platform(platform)
|
22
|
+
@platforms << platform
|
23
|
+
end
|
24
|
+
|
25
|
+
def wordy
|
26
|
+
prefix = "Found #{@name} (#{@version})"
|
27
|
+
|
28
|
+
if @platforms.size == 1
|
29
|
+
"#{prefix}, but was for platform #{@platforms[0]}"
|
30
|
+
else
|
31
|
+
"#{prefix}, but was for platforms #{@platforms.join(' ,')}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/lib/rubygems/exceptions.rb
CHANGED
@@ -37,7 +37,16 @@ class Gem::FormatException < Gem::Exception
|
|
37
37
|
attr_accessor :file_path
|
38
38
|
end
|
39
39
|
|
40
|
-
class Gem::GemNotFoundException < Gem::Exception
|
40
|
+
class Gem::GemNotFoundException < Gem::Exception
|
41
|
+
def initialize(msg, name=nil, version=nil, errors=nil)
|
42
|
+
super msg
|
43
|
+
@name = name
|
44
|
+
@version = version
|
45
|
+
@errors = errors
|
46
|
+
end
|
47
|
+
|
48
|
+
attr_reader :name, :version, :errors
|
49
|
+
end
|
41
50
|
|
42
51
|
class Gem::InstallError < Gem::Exception; end
|
43
52
|
|
data/lib/rubygems/indexer.rb
CHANGED
@@ -320,7 +320,7 @@ class Gem::Indexer
|
|
320
320
|
<title>#{rss_title}</title>
|
321
321
|
<link>http://#{rss_host}</link>
|
322
322
|
<description>Recently released gems from http://#{rss_host}</description>
|
323
|
-
<generator>RubyGems v#{Gem::
|
323
|
+
<generator>RubyGems v#{Gem::VERSION}</generator>
|
324
324
|
<docs>http://cyber.law.harvard.edu/rss/rss.html</docs>
|
325
325
|
HEADER
|
326
326
|
|
data/lib/rubygems/installer.rb
CHANGED
@@ -133,7 +133,8 @@ class Gem::Installer
|
|
133
133
|
end
|
134
134
|
|
135
135
|
FileUtils.mkdir_p @gem_home
|
136
|
-
raise Gem::FilePermissionError, @gem_home unless
|
136
|
+
raise Gem::FilePermissionError, @gem_home unless
|
137
|
+
options[:unpack] or File.writable? @gem_home
|
137
138
|
|
138
139
|
@spec = @format.spec
|
139
140
|
|
@@ -165,7 +166,7 @@ class Gem::Installer
|
|
165
166
|
end
|
166
167
|
|
167
168
|
if rrgv = @spec.required_rubygems_version then
|
168
|
-
unless rrgv.satisfied_by? Gem::Version.new(Gem::
|
169
|
+
unless rrgv.satisfied_by? Gem::Version.new(Gem::VERSION) then
|
169
170
|
raise Gem::InstallError,
|
170
171
|
"#{@spec.name} requires RubyGems version #{rrgv}. " +
|
171
172
|
"Try 'gem update --system' to update RubyGems itself."
|
@@ -270,7 +271,7 @@ class Gem::Installer
|
|
270
271
|
##
|
271
272
|
# Creates windows .bat files for easy running of commands
|
272
273
|
|
273
|
-
def generate_windows_script(
|
274
|
+
def generate_windows_script(filename, bindir)
|
274
275
|
if Gem.win_platform? then
|
275
276
|
script_name = filename + ".bat"
|
276
277
|
script_path = File.join bindir, File.basename(script_name)
|
@@ -295,7 +296,7 @@ class Gem::Installer
|
|
295
296
|
|
296
297
|
@spec.executables.each do |filename|
|
297
298
|
filename.untaint
|
298
|
-
bin_path = File.expand_path
|
299
|
+
bin_path = File.expand_path "#{@spec.bindir}/#{filename}", @gem_dir
|
299
300
|
mode = File.stat(bin_path).mode | 0111
|
300
301
|
File.chmod mode, bin_path
|
301
302
|
|
@@ -329,7 +330,7 @@ class Gem::Installer
|
|
329
330
|
|
330
331
|
say bin_script_path if Gem.configuration.really_verbose
|
331
332
|
|
332
|
-
generate_windows_script
|
333
|
+
generate_windows_script filename, bindir
|
333
334
|
#else
|
334
335
|
# FileUtils.rm_f bin_script_path
|
335
336
|
# FileUtils.cp exec_path, bin_script_path,
|
data/lib/rubygems/package.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
|
3
|
-
# See LICENSE.txt for additional licensing information.
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
#--
|
3
|
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
|
4
|
+
# See LICENSE.txt for additional licensing information.
|
5
|
+
#++
|
5
6
|
|
6
7
|
require 'fileutils'
|
7
8
|
require 'find'
|
@@ -12,8 +13,10 @@ require 'zlib'
|
|
12
13
|
require 'rubygems/security'
|
13
14
|
require 'rubygems/specification'
|
14
15
|
|
16
|
+
##
|
15
17
|
# Wrapper for FileUtils meant to provide logging and additional operations if
|
16
18
|
# needed.
|
19
|
+
|
17
20
|
class Gem::FileOperations
|
18
21
|
|
19
22
|
def initialize(logger = nil)
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
|
3
|
-
# See LICENSE.txt for additional licensing information.
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
#--
|
3
|
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
|
4
|
+
# See LICENSE.txt for additional licensing information.
|
5
|
+
#++
|
5
6
|
|
6
7
|
module Gem::Package::FSyncDir
|
7
8
|
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
|
3
|
-
# See LICENSE.txt for additional licensing information.
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
#--
|
3
|
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
|
4
|
+
# See LICENSE.txt for additional licensing information.
|
5
|
+
#++
|
5
6
|
|
6
7
|
##
|
7
8
|
#--
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
|
3
|
-
# See LICENSE.txt for additional licensing information.
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
#--
|
3
|
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
|
4
|
+
# See LICENSE.txt for additional licensing information.
|
5
|
+
#++
|
5
6
|
|
6
7
|
##
|
7
8
|
# TarOutput is a wrapper to TarWriter that builds gem-format tar file.
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
|
3
|
-
# See LICENSE.txt for additional licensing information.
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
#--
|
3
|
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
|
4
|
+
# See LICENSE.txt for additional licensing information.
|
5
|
+
#++
|
5
6
|
|
6
7
|
##
|
7
8
|
# TarReader reads tar files and allows iteration over their items
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
|
3
|
-
# See LICENSE.txt for additional licensing information.
|
1
|
+
# -*- coding: utf-8 -*-
|
4
2
|
#--
|
3
|
+
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
|
4
|
+
# See LICENSE.txt for additional licensing information.
|
5
|
+
#++
|
5
6
|
|
6
7
|
##
|
7
8
|
# Allows writing of tar files
|
@@ -41,7 +41,7 @@ require 'rake/packagetask'
|
|
41
41
|
#
|
42
42
|
# require 'rubygems'
|
43
43
|
# require 'rubygems/package_task'
|
44
|
-
#
|
44
|
+
#
|
45
45
|
# spec = Gem::Specification.new do |s|
|
46
46
|
# s.platform = Gem::Platform::RUBY
|
47
47
|
# s.summary = "Ruby based make-like utility."
|
@@ -56,7 +56,7 @@ require 'rake/packagetask'
|
|
56
56
|
# and dependencies are specified in standard Ruby syntax.
|
57
57
|
# EOF
|
58
58
|
# end
|
59
|
-
#
|
59
|
+
#
|
60
60
|
# Gem::PackageTask.new(spec) do |pkg|
|
61
61
|
# pkg.need_zip = true
|
62
62
|
# pkg.need_tar = true
|
@@ -102,6 +102,7 @@ class Gem::PackageTask < Rake::PackageTask
|
|
102
102
|
|
103
103
|
gem_file = gem_spec.file_name
|
104
104
|
gem_path = File.join package_dir, gem_file
|
105
|
+
gem_dir = File.join package_dir, gem_spec.full_name
|
105
106
|
|
106
107
|
desc "Build the gem file #{gem_file}"
|
107
108
|
task :gem => [gem_path]
|
@@ -109,7 +110,7 @@ class Gem::PackageTask < Rake::PackageTask
|
|
109
110
|
trace = Rake.application.options.trace
|
110
111
|
Gem.configuration.verbose = trace
|
111
112
|
|
112
|
-
file gem_path => [package_dir] + @gem_spec.files do
|
113
|
+
file gem_path => [package_dir, gem_dir] + @gem_spec.files do
|
113
114
|
when_writing "Creating #{gem_spec.file_name}" do
|
114
115
|
Gem::Builder.new(gem_spec).build
|
115
116
|
verbose trace do
|
data/lib/rubygems/platform.rb
CHANGED
@@ -70,6 +70,8 @@ class Gem::Platform
|
|
70
70
|
when /hpux(\d+)/ then [ 'hpux', $1 ]
|
71
71
|
when /^java$/, /^jruby$/ then [ 'java', nil ]
|
72
72
|
when /^java([\d.]*)/ then [ 'java', $1 ]
|
73
|
+
when /^dotnet$/ then [ 'dotnet', nil ]
|
74
|
+
when /^dotnet([\d.]*)/ then [ 'dotnet', $1 ]
|
73
75
|
when /linux/ then [ 'linux', $1 ]
|
74
76
|
when /mingw32/ then [ 'mingw32', nil ]
|
75
77
|
when /(mswin\d+)(\_(\d+))?/ then
|
@@ -103,7 +105,7 @@ class Gem::Platform
|
|
103
105
|
def to_s
|
104
106
|
to_a.compact.join '-'
|
105
107
|
end
|
106
|
-
|
108
|
+
|
107
109
|
def empty?
|
108
110
|
to_s.empty?
|
109
111
|
end
|
@@ -148,6 +150,7 @@ class Gem::Platform
|
|
148
150
|
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
|
149
151
|
when /^i\d86-linux/ then ['x86', 'linux', nil ]
|
150
152
|
when 'java', 'jruby' then [nil, 'java', nil ]
|
153
|
+
when /dotnet(\-(\d+\.\d+))?/ then ['universal','dotnet', $2 ]
|
151
154
|
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
|
152
155
|
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
|
153
156
|
when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ]
|
@@ -88,7 +88,9 @@ class Gem::RemoteFetcher
|
|
88
88
|
|
89
89
|
# Always escape URI's to deal with potential spaces and such
|
90
90
|
unless URI::Generic === source_uri
|
91
|
-
source_uri = URI.parse(URI.
|
91
|
+
source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ?
|
92
|
+
URI::DEFAULT_PARSER.escape(source_uri) :
|
93
|
+
URI.escape(source_uri))
|
92
94
|
end
|
93
95
|
|
94
96
|
scheme = source_uri.scheme
|
@@ -252,6 +254,8 @@ class Gem::RemoteFetcher
|
|
252
254
|
connection.start unless connection.started?
|
253
255
|
|
254
256
|
connection
|
257
|
+
rescue Errno::EHOSTDOWN => e
|
258
|
+
raise FetchError.new(e.message, uri)
|
255
259
|
end
|
256
260
|
|
257
261
|
##
|
@@ -309,7 +313,7 @@ class Gem::RemoteFetcher
|
|
309
313
|
request.basic_auth uri.user, uri.password
|
310
314
|
end
|
311
315
|
|
312
|
-
ua = "RubyGems/#{Gem::
|
316
|
+
ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}"
|
313
317
|
ua << " Ruby/#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
|
314
318
|
ua << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
315
319
|
ua << ")"
|
@@ -351,7 +355,9 @@ class Gem::RemoteFetcher
|
|
351
355
|
# HACK work around EOFError bug in Net::HTTP
|
352
356
|
# NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
|
353
357
|
# to install gems.
|
354
|
-
rescue EOFError,
|
358
|
+
rescue EOFError, Timeout::Error,
|
359
|
+
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
|
360
|
+
|
355
361
|
requests = @requests[connection.object_id]
|
356
362
|
say "connection reset after #{requests} requests, retrying" if
|
357
363
|
Gem.configuration.really_verbose
|
data/lib/rubygems/requirement.rb
CHANGED
@@ -93,9 +93,14 @@ class Gem::Requirement
|
|
93
93
|
requirements.uniq!
|
94
94
|
|
95
95
|
requirements << ">= 0" if requirements.empty?
|
96
|
+
@none = (requirements == ">= 0")
|
96
97
|
@requirements = requirements.map! { |r| self.class.parse r }
|
97
98
|
end
|
98
99
|
|
100
|
+
def none?
|
101
|
+
@none ||= (to_s == ">= 0")
|
102
|
+
end
|
103
|
+
|
99
104
|
def as_list # :nodoc:
|
100
105
|
requirements.map { |op, version| "#{op} #{version}" }
|
101
106
|
end
|
data/lib/rubygems/security.rb
CHANGED
@@ -218,7 +218,7 @@ require 'rubygems/gem_openssl'
|
|
218
218
|
#
|
219
219
|
# # signing key (still kept in an undisclosed location!)
|
220
220
|
# s.signing_key = '/mnt/floppy/alf-private_key.pem'
|
221
|
-
#
|
221
|
+
#
|
222
222
|
# # certificate chain (includes the issuer certificate now too)
|
223
223
|
# s.cert_chain = ['/home/alf/doc/seattlerb-public_cert.pem',
|
224
224
|
# '/home/alf/doc/alf_at_seattle-public_cert.pem']
|
@@ -274,7 +274,7 @@ require 'rubygems/gem_openssl'
|
|
274
274
|
# # convert a PEM format X509 certificate into DER format:
|
275
275
|
# # (note: Windows .cer files are X509 certificates in DER format)
|
276
276
|
# $ openssl x509 -in input.pem -outform der -out output.der
|
277
|
-
#
|
277
|
+
#
|
278
278
|
# # print out the certificate in a human-readable format:
|
279
279
|
# $ openssl x509 -in input.pem -noout -text
|
280
280
|
#
|
@@ -282,7 +282,7 @@ require 'rubygems/gem_openssl'
|
|
282
282
|
#
|
283
283
|
# # convert a PEM format RSA key into DER format:
|
284
284
|
# $ openssl rsa -in input_key.pem -outform der -out output_key.der
|
285
|
-
#
|
285
|
+
#
|
286
286
|
# # print out the key in a human readable format:
|
287
287
|
# $ openssl rsa -in input_key.pem -noout -text
|
288
288
|
#
|
data/lib/rubygems/server.rb
CHANGED
@@ -33,6 +33,8 @@ require 'rubygems/doc_manager'
|
|
33
33
|
|
34
34
|
class Gem::Server
|
35
35
|
|
36
|
+
attr_reader :spec_dirs
|
37
|
+
|
36
38
|
include ERB::Util
|
37
39
|
include Gem::UserInteraction
|
38
40
|
|
@@ -430,29 +432,36 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
430
432
|
options[:addresses]).run
|
431
433
|
end
|
432
434
|
|
433
|
-
|
435
|
+
##
|
436
|
+
# Only the first directory in gem_dirs is used for serving gems
|
437
|
+
|
438
|
+
def initialize(gem_dirs, port, daemon, addresses = nil)
|
434
439
|
Socket.do_not_reverse_lookup = true
|
435
440
|
|
436
|
-
@
|
441
|
+
@gem_dirs = Array gem_dirs
|
437
442
|
@port = port
|
438
443
|
@daemon = daemon
|
439
444
|
@addresses = addresses
|
440
445
|
logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
|
441
446
|
@server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
|
442
447
|
|
443
|
-
@
|
448
|
+
@spec_dirs = @gem_dirs.map do |gem_dir|
|
449
|
+
spec_dir = File.join gem_dir, 'specifications'
|
444
450
|
|
445
|
-
|
446
|
-
|
451
|
+
unless File.directory? spec_dir then
|
452
|
+
raise ArgumentError, "#{gem_dir} does not appear to be a gem repository"
|
453
|
+
end
|
454
|
+
|
455
|
+
spec_dir
|
447
456
|
end
|
448
457
|
|
449
|
-
@source_index = Gem::SourceIndex.from_gems_in
|
458
|
+
@source_index = Gem::SourceIndex.from_gems_in(*@spec_dirs)
|
450
459
|
end
|
451
460
|
|
452
461
|
def Marshal(req, res)
|
453
462
|
@source_index.refresh!
|
454
463
|
|
455
|
-
res
|
464
|
+
add_date res
|
456
465
|
|
457
466
|
index = Marshal.dump @source_index
|
458
467
|
|
@@ -471,12 +480,18 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
471
480
|
res.body << index
|
472
481
|
end
|
473
482
|
|
483
|
+
def add_date res
|
484
|
+
res['date'] = @spec_dirs.map do |spec_dir|
|
485
|
+
File.stat(spec_dir).mtime
|
486
|
+
end.max
|
487
|
+
end
|
488
|
+
|
474
489
|
def latest_specs(req, res)
|
475
490
|
@source_index.refresh!
|
476
491
|
|
477
492
|
res['content-type'] = 'application/x-gzip'
|
478
493
|
|
479
|
-
res
|
494
|
+
add_date res
|
480
495
|
|
481
496
|
specs = @source_index.latest_specs.sort.map do |spec|
|
482
497
|
platform = spec.original_platform
|
@@ -535,7 +550,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
535
550
|
@source_index.refresh!
|
536
551
|
|
537
552
|
res['content-type'] = 'text/plain'
|
538
|
-
res
|
553
|
+
add_date res
|
539
554
|
|
540
555
|
case req.request_uri.path
|
541
556
|
when '/quick/index' then
|
@@ -586,7 +601,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
586
601
|
|
587
602
|
def root(req, res)
|
588
603
|
@source_index.refresh!
|
589
|
-
res
|
604
|
+
add_date res
|
590
605
|
|
591
606
|
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." unless
|
592
607
|
req.path == '/'
|
@@ -630,16 +645,16 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
630
645
|
specs << {
|
631
646
|
"authors" => "Chad Fowler, Rich Kilmer, Jim Weirich, Eric Hodel and others",
|
632
647
|
"dependencies" => [],
|
633
|
-
"doc_path" => "/doc_root/rubygems-#{Gem::
|
648
|
+
"doc_path" => "/doc_root/rubygems-#{Gem::VERSION}/rdoc/index.html",
|
634
649
|
"executables" => [{"executable" => 'gem', "is_last" => true}],
|
635
650
|
"only_one_executable" => true,
|
636
|
-
"full_name" => "rubygems-#{Gem::
|
651
|
+
"full_name" => "rubygems-#{Gem::VERSION}",
|
637
652
|
"has_deps" => false,
|
638
653
|
"homepage" => "http://docs.rubygems.org/",
|
639
654
|
"name" => 'rubygems',
|
640
655
|
"rdoc_installed" => true,
|
641
656
|
"summary" => "RubyGems itself",
|
642
|
-
"version" => Gem::
|
657
|
+
"version" => Gem::VERSION,
|
643
658
|
}
|
644
659
|
|
645
660
|
specs = specs.sort_by { |spec| [spec["name"].downcase, spec["version"]] }
|
@@ -718,7 +733,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
718
733
|
# documentation - just put it underneath the main doc folder.
|
719
734
|
|
720
735
|
def show_rdoc_for_pattern(pattern, res)
|
721
|
-
found_gems = Dir.glob("#{@
|
736
|
+
found_gems = Dir.glob("{#{@gem_dirs.join ','}}/doc/#{pattern}").select {|path|
|
722
737
|
File.exist? File.join(path, 'rdoc/index.html')
|
723
738
|
}
|
724
739
|
case found_gems.length
|
@@ -771,7 +786,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
771
786
|
|
772
787
|
@server.mount_proc("/gem-server-rdoc-style.css") do |req, res|
|
773
788
|
res['content-type'] = 'text/css'
|
774
|
-
res
|
789
|
+
add_date res
|
775
790
|
res.body << RDOC_CSS
|
776
791
|
end
|
777
792
|
|
@@ -782,7 +797,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
782
797
|
paths = { "/gems" => "/cache/", "/doc_root" => "/doc/" }
|
783
798
|
paths.each do |mount_point, mount_dir|
|
784
799
|
@server.mount(mount_point, WEBrick::HTTPServlet::FileHandler,
|
785
|
-
File.join(@
|
800
|
+
File.join(@gem_dirs.first, mount_dir), true)
|
786
801
|
end
|
787
802
|
|
788
803
|
trap("INT") { @server.shutdown; exit! }
|
@@ -794,7 +809,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
794
809
|
def specs(req, res)
|
795
810
|
@source_index.refresh!
|
796
811
|
|
797
|
-
res
|
812
|
+
add_date res
|
798
813
|
|
799
814
|
specs = @source_index.sort.map do |_, spec|
|
800
815
|
platform = spec.original_platform
|
@@ -821,7 +836,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
821
836
|
def yaml(req, res)
|
822
837
|
@source_index.refresh!
|
823
838
|
|
824
|
-
res
|
839
|
+
add_date res
|
825
840
|
|
826
841
|
index = @source_index.to_yaml
|
827
842
|
|