summaryrefslogtreecommitdiff
path: root/lib/rubygems/server.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
commitd22130922e7842226d38d59680e4bbb48a28a5f0 (patch)
tree39594d3a14641dd5488a99a5e633239296fa5742 /lib/rubygems/server.rb
parent4752539e3f3e563d559732c52424206bd6f12dbd (diff)
Import rubygems 1.8.5 (released @ 137c80f)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/server.rb')
-rw-r--r--lib/rubygems/server.rb134
1 files changed, 67 insertions, 67 deletions
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index 76cb22f252..95ca292fa7 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -81,47 +81,47 @@ class Gem::Server
<dl>
<% values["specs"].each do |spec| %>
- <dt>
- <% if spec["first_name_entry"] then %>
- <a name="<%=spec["name"]%>"></a>
- <% end %>
-
- <b><%=spec["name"]%> <%=spec["version"]%></b>
-
- <% if spec["rdoc_installed"] then %>
- <a href="<%=spec["doc_path"]%>">[rdoc]</a>
- <% else %>
- <span title="rdoc not installed">[rdoc]</span>
- <% end %>
-
- <% if spec["homepage"] then %>
- <a href="<%=spec["homepage"]%>" title="<%=spec["homepage"]%>">[www]</a>
- <% else %>
- <span title="no homepage available">[www]</span>
- <% end %>
-
- <% if spec["has_deps"] then %>
- - depends on
- <%= spec["dependencies"].map { |v| "<a href=\"##{v["name"]}\">#{v["name"]}</a>" }.join ', ' %>.
- <% end %>
- </dt>
- <dd>
- <%=spec["summary"]%>
- <% if spec["executables"] then %>
- <br/>
-
- <% if spec["only_one_executable"] then %>
- Executable is
- <% else %>
- Executables are
- <%end%>
-
- <%= spec["executables"].map { |v| "<span class=\"context-item-name\">#{v["executable"]}</span>"}.join ', ' %>.
-
- <%end%>
- <br/>
- <br/>
- </dd>
+ <dt>
+ <% if spec["first_name_entry"] then %>
+ <a name="<%=spec["name"]%>"></a>
+ <% end %>
+
+ <b><%=spec["name"]%> <%=spec["version"]%></b>
+
+ <% if spec["rdoc_installed"] then %>
+ <a href="<%=spec["doc_path"]%>">[rdoc]</a>
+ <% else %>
+ <span title="rdoc not installed">[rdoc]</span>
+ <% end %>
+
+ <% if spec["homepage"] then %>
+ <a href="<%=spec["homepage"]%>" title="<%=spec["homepage"]%>">[www]</a>
+ <% else %>
+ <span title="no homepage available">[www]</span>
+ <% end %>
+
+ <% if spec["has_deps"] then %>
+ - depends on
+ <%= spec["dependencies"].map { |v| "<a href=\"##{v["name"]}\">#{v["name"]}</a>" }.join ', ' %>.
+ <% end %>
+ </dt>
+ <dd>
+ <%=spec["summary"]%>
+ <% if spec["executables"] then %>
+ <br/>
+
+ <% if spec["only_one_executable"] then %>
+ Executable is
+ <% else %>
+ Executables are
+ <%end%>
+
+ <%= spec["executables"].map { |v| "<span class=\"context-item-name\">#{v["executable"]}</span>"}.join ', ' %>.
+
+ <%end%>
+ <br/>
+ <br/>
+ </dd>
<% end %>
</dl>
@@ -460,15 +460,15 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
spec_dir
end
- @source_index = Gem::SourceIndex.from_gems_in(*@spec_dirs)
+ Gem::Specification.dirs = @gem_dirs
end
def Marshal(req, res)
- @source_index.refresh!
+ Gem::Specification.reset
add_date res
- index = Marshal.dump @source_index
+ index = Deprecate.skip_during { Marshal.dump Gem.source_index }
if req.request_method == 'HEAD' then
res['content-length'] = index.length
@@ -492,15 +492,16 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
def latest_specs(req, res)
- @source_index.refresh!
+ Gem::Specification.reset
res['content-type'] = 'application/x-gzip'
add_date res
- specs = @source_index.latest_specs.sort.map do |spec|
- platform = spec.original_platform
- platform = Gem::Platform::RUBY if platform.nil?
+ latest_specs = Gem::Specification.latest_specs
+
+ specs = latest_specs.sort.map do |spec|
+ platform = spec.original_platform || Gem::Platform::RUBY
[spec.name, spec.version, platform]
end
@@ -552,21 +553,20 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
def quick(req, res)
- @source_index.refresh!
+ Gem::Specification.reset
res['content-type'] = 'text/plain'
add_date res
case req.request_uri.path
when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
- dep = Gem::Dependency.new $2, $3
- specs = @source_index.search dep
- marshal_format = $1
+ marshal_format, name, version, platform = $1, $2, $3, $4
+ specs = Gem::Specification.find_all_by_name name, version
- selector = [$2, $3, $4].map { |s| s.inspect }.join ' '
+ selector = [name, version, platform].map(&:inspect).join ' '
- platform = if $4 then
- Gem::Platform.new $4.sub(/^-/, '')
+ platform = if platform then
+ Gem::Platform.new platform.sub(/^-/, '')
else
Gem::Platform::RUBY
end
@@ -589,7 +589,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
def root(req, res)
- @source_index.refresh!
+ Gem::Specification.reset
add_date res
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." unless
@@ -598,13 +598,15 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs = []
total_file_count = 0
- @source_index.each do |path, spec|
+ Gem::Specification.each do |spec|
total_file_count += spec.files.size
- deps = spec.dependencies.map do |dep|
- { "name" => dep.name,
+ deps = spec.dependencies.map { |dep|
+ {
+ "name" => dep.name,
"type" => dep.type,
- "version" => dep.requirement.to_s, }
- end
+ "version" => dep.requirement.to_s,
+ }
+ }
deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }
deps.last["is_last"] = true unless deps.empty?
@@ -798,13 +800,12 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end
def specs(req, res)
- @source_index.refresh!
+ Gem::Specification.reset
add_date res
- specs = @source_index.sort.map do |_, spec|
- platform = spec.original_platform
- platform = Gem::Platform::RUBY if platform.nil?
+ specs = Gem::Specification.sort_by(&:sort_obj).map do |spec|
+ platform = spec.original_platform || Gem::Platform::RUBY
[spec.name, spec.version, platform]
end
@@ -827,12 +828,11 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
def launch
listeners = @server.listeners.map{|l| l.addr[2] }
+ # TODO: 0.0.0.0 == any, not localhost.
host = listeners.any?{|l| l == '0.0.0.0'} ? 'localhost' : listeners.first
say "Launching browser to http://#{host}:#{@port}"
system("#{@launch} http://#{host}:#{@port}")
end
-
end
-