Skip to content

Instantly share code, notes, and snippets.

@universal
Created June 8, 2015 13:58
Show Gist options
  • Save universal/b619252a0cb7e8862dad to your computer and use it in GitHub Desktop.
Save universal/b619252a0cb7e8862dad to your computer and use it in GitHub Desktop.
net/http download
# encoding: UTF-8
require 'net/http'
require 'net/https'
require 'uri'
module Literature
class BibliographyDownloader
def self.download
uri = URI.parse(WebsitePrep.config.svn_url)
base = Net::HTTP.new(uri.host, uri.port)
base.ssl_version = :TLSv1
base.use_ssl = true
base.verify_mode = OpenSSL::SSL::VERIFY_NONE
base.start do |http|
request = Net::HTTP::Get.new('/svn/tex/trunk/bibtex/bib/literature.bib')
request.basic_auth WebsitePrep.config.svn_user, WebsitePrep.config.svn_pass
response = http.request(request)
open(WebsitePrep.config.bib_file, "wb") do |file|
file.write(response.body)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment