Class: CoreLibrary::FileHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/apimatic-core/utilities/file_helper.rb

Overview

A utility for file specific operations.

Class Method Summary collapse

Class Method Details

.get_file(url) ⇒ Object

Class method which takes a URL, downloads the file (if not already downloaded. for this test session) and returns the path of the file.

Parameters:

  • url (String)

    The URL of the required file.



11
12
13
14
15
16
17
18
19
# File 'lib/apimatic-core/utilities/file_helper.rb', line 11

def self.get_file(url)
  unless @cache.keys.include? url
    @cache[url] = Tempfile.new('APIMatic')
    @cache[url].binmode
    @cache[url].write(URI.parse(url).open({ ssl_ca_cert: Certifi.where }).read)
  end
  @cache[url].rewind
  @cache[url].path
end