Skip to content

Commit

Permalink
Refactor resetting gems to a method
Browse files Browse the repository at this point in the history
This makes it more clear what we're doing with Specification::dirs=
  • Loading branch information
drbrain committed Oct 25, 2013
1 parent 83f26eb commit fb17138
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/rubygems/server.rb
Expand Up @@ -445,7 +445,7 @@ def initialize(gem_dirs, port, daemon, launch = nil, addresses = nil)
@spec_dirs = @gem_dirs.map { |gem_dir| File.join gem_dir, 'specifications' }
@spec_dirs.reject! { |spec_dir| !File.directory? spec_dir }

Gem::Specification.dirs = @gem_dirs
reset_gems

@have_rdoc_4_plus = nil
end
Expand All @@ -470,7 +470,7 @@ def have_rdoc_4_plus?
end

def latest_specs(req, res)
Gem::Specification.dirs = @gem_dirs
reset_gems

res['content-type'] = 'application/x-gzip'

Expand Down Expand Up @@ -531,7 +531,7 @@ def listen addresses = @addresses
end

def quick(req, res)
Gem::Specification.dirs = @gem_dirs
reset_gems

res['content-type'] = 'text/plain'
add_date res
Expand Down Expand Up @@ -567,7 +567,7 @@ def quick(req, res)
end

def root(req, res)
Gem::Specification.dirs = @gem_dirs
reset_gems

add_date res

Expand Down Expand Up @@ -698,6 +698,13 @@ def rdoc(req, res)
res.body = template.result binding
end

##
# Updates the server to use the latest installed gems.

def reset_gems # :nodoc:
Gem::Specification.dirs = @gem_dirs
end

##
# Returns true and prepares http response, if rdoc for the requested gem
# name pattern was found.
Expand Down Expand Up @@ -788,7 +795,7 @@ def run
end

def specs(req, res)
Gem::Specification.dirs = @gem_dirs
reset_gems

add_date res

Expand Down

0 comments on commit fb17138

Please sign in to comment.