Class: CoreLibrary::FileHelper
- Inherits:
-
Object
- Object
- CoreLibrary::FileHelper
- Defined in:
- lib/apimatic-core/utilities/file_helper.rb
Overview
A utility for file-specific operations.
Class Method Summary collapse
-
.get_file(url) ⇒ Tempfile
Class method which takes a URL, downloads the file (if not already downloaded for this test session), and returns the file path.
Class Method Details
.get_file(url) ⇒ Tempfile
Class method which takes a URL, downloads the file (if not already downloaded for this test session), and returns the file path.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/apimatic-core/utilities/file_helper.rb', line 13 def self.get_file(url) if @cache.key?(url) @cache[url].rewind return @cache[url] end tempfile = Tempfile.new('APIMatic') tempfile.binmode tempfile.write(URI.parse(url).open(ssl_ca_cert: Certifi.where).read) tempfile.flush @cache[url] = tempfile end |