Sha256: da6b7fd2e3b9439f3449674513963a630008c789104b49a049f095267df9c21a
Contents?: true
Size: 946 Bytes
Versions: 7
Compression:
Stored size: 946 Bytes
Contents
class RemoteTable class Request attr_accessor :url, :post_data, :username, :password # TODO: support post_data # TODO: support HTTP basic auth def initialize(bus) @url = bus[:url] or raise "need url" end def download path = ::File.join(staging_dir_path, 'REMOTE_TABLE_PACKAGE') `curl --silent \"#{url_with_google_docs_handling}\" > #{path}` path end private def staging_dir_path path = tempfile_path_from_url FileUtils.rm_f(path) FileUtils.mkdir(path) at_exit { FileUtils.rm_rf(path) } path end def tempfile_path_from_url Tempfile.open(url.gsub(/[^a-z0-9]+/i, '_')[0,100]).path end def url_with_google_docs_handling url = self.url if url.include?('spreadsheets.google.com') url = url.gsub(/\&output=.*(\&|\z)/, '') url << "&output=csv" end url end end end
Version data entries
7 entries across 7 versions & 1 rubygems