lib/browse_everything/retriever.rb
def extract_download_options(options)
      url = options.fetch('url')

      # This avoids the potential for a KeyError
      headers = options.fetch('headers', {}) || {}

      file_size_value = options.fetch('file_size', 0)
      file_size = file_size_value.to_i

      output = {
        url: ::Addressable::URI.parse(url),
        headers: headers,
        file_size: file_size
      }

      output[:file_size] = get_file_size(output) if output[:file_size] < 1
      output
    end
# Extract and parse options used to download a file or resource from an HTTP API
# @param options [Hash]
# @return [Hash]
Extract and parse options used to download a file or resource from an HTTP API
Extract and parse options used to download a file or resource from an HTTP API
def extract_download_options(options)
      url = options.fetch('url')
      headers = options.fetch('headers', {}) || {}
      file_size_value = options.fetch('file_size', 0)
      file_size = file_size_value.to_i
      output = {
        url: ::Addressable::URI.parse(url),
        headers: headers,
        file_size: file_size
      }
      output[:file_size] = get_file_size(output) if output[:file_size] < 1
      output
    end
def extract_download_options ( options ) url = options . fetch ( 'url' ) headers = options . fetch ( 'headers' , { } ) || { } file_size_value = options . fetch ( 'file_size' , 0 ) file_size = file_size_value . to_i output = { url : :: Addressable :: URI . parse ( url ) , headers : headers , file_size : file_size } output [ :file_size ] = get_file_size ( output ) if output [ :file_size ] < 1 output end
Extract and parse options used to download a file or resource from an HTTP API
Extract and parse options used to download a file or resource from an HTTP API
# This avoids the potential for a KeyError
None
Hash
options
None