Class: Suvii::Cache
- Inherits:
-
Object
- Object
- Suvii::Cache
- Defined in:
- lib/suvii/cache.rb
Overview
Class Method Summary collapse
-
.fetch(url, options = {}) {|path| ... } ⇒ String
Maps an archive URL to a path to its cached file.
Class Method Details
.fetch(url, options = {}) {|path| ... } ⇒ String
Note:
This method doesn’t write to a disk. It is a responsibility of a block implementation.
Maps an archive URL to a path to its cached file.
16 17 18 19 20 21 22 |
# File 'lib/suvii/cache.rb', line 16 def self.fetch(url, = {}) cache_path = [:cache_path] || Dir.mktmpdir escaped_url = CGI.escape(url) archive_path = File.join(cache_path, escaped_url) yield archive_path unless File.exist?(archive_path) archive_path end |