Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zenspider committed Aug 12, 2011
1 parent 398552b commit bcd8d9b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
6 changes: 4 additions & 2 deletions lib/rubygems/remote_fetcher.rb
Expand Up @@ -131,6 +131,8 @@ def download(spec, source_uri, install_dir = Gem.dir)
# URI.parse gets confused by MS Windows paths with forward slashes.
scheme = nil if scheme =~ /^[a-z]$/i

# REFACTOR: split this up and dispatch on scheme (eg download_http)
# REFACTOR: be sure to clean up fake fetcher when you do this... cleaner
case scheme
when 'http', 'https' then
unless File.exist? local_gem_path then
Expand All @@ -140,7 +142,7 @@ def download(spec, source_uri, install_dir = Gem.dir)

remote_gem_path = source_uri + "gems/#{gem_file_name}"

gem = self.cache_update_path remote_gem_path, local_gem_path
self.cache_update_path remote_gem_path, local_gem_path
rescue Gem::RemoteFetcher::FetchError
raise if spec.original_platform == spec.platform

Expand All @@ -151,7 +153,7 @@ def download(spec, source_uri, install_dir = Gem.dir)

remote_gem_path = source_uri + "gems/#{alternate_name}"

gem = self.cache_update_path remote_gem_path, local_gem_path
self.cache_update_path remote_gem_path, local_gem_path
end
end
when 'file' then
Expand Down
9 changes: 3 additions & 6 deletions lib/rubygems/spec_fetcher.rb
Expand Up @@ -256,12 +256,9 @@ def load_specs(source_uri, file)
local_file = File.join(cache_dir, file_name)
retried = false

spec_dump = if @update_cache then
FileUtils.mkdir_p cache_dir
@fetcher.cache_update_path(spec_path, local_file)
else
@fetcher.cache_update_path(spec_path)
end
FileUtils.mkdir_p cache_dir if @update_cache

spec_dump = @fetcher.cache_update_path(spec_path, local_file)

begin
Marshal.load spec_dump
Expand Down
16 changes: 8 additions & 8 deletions test/rubygems/test_gem_commands_fetch_command.rb
Expand Up @@ -26,8 +26,8 @@ def test_execute
end
end

assert File.exist?(File.join(@tempdir, @a2.file_name)),
"#{@a2.full_name} not fetched"
assert_path_exists(File.join(@tempdir, @a2.file_name),
"#{@a2.full_name} not fetched")
end

def test_execute_prerelease
Expand All @@ -49,8 +49,8 @@ def test_execute_prerelease
end
end

assert File.exist?(File.join(@tempdir, @a2_pre.file_name)),
"#{@a2_pre.full_name} not fetched"
assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
"#{@a2_pre.full_name} not fetched")
end

def test_execute_specific_prerelease
Expand All @@ -73,8 +73,8 @@ def test_execute_specific_prerelease
end
end

assert File.exist?(File.join(@tempdir, @a2_pre.file_name)),
"#{@a2_pre.full_name} not fetched"
assert_path_exists(File.join(@tempdir, @a2_pre.file_name),
"#{@a2_pre.full_name} not fetched")
end

def test_execute_version
Expand All @@ -93,8 +93,8 @@ def test_execute_version
end
end

assert File.exist?(File.join(@tempdir, @a1.file_name)),
"#{@a1.full_name} not fetched"
assert_path_exists(File.join(@tempdir, @a1.file_name),
"#{@a1.full_name} not fetched")
end

end
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_gem_remote_fetcher.rb
Expand Up @@ -276,8 +276,8 @@ def test_download_local_read_only
inst = Gem::RemoteFetcher.fetcher
end

assert_equal File.join(@tempdir, @a1.file_name),
inst.download(@a1, local_path)
assert_equal(File.join(@tempdir, @a1.file_name),
inst.download(@a1, local_path))
ensure
FileUtils.chmod 0755, @a1.cache_dir
end
Expand Down

0 comments on commit bcd8d9b

Please sign in to comment.