module WarpEngine::Storage
The storage adapter that serves build artifacts. The default is LocalAdapter (the filesystem under file_container_path); a host can set any object answering file?, directory? and locate with storage.
Constants
- Location
-
Where a stored file is served from:
kindis:file(an absolutepaththe engine sends) or:redirect(aurlthe engine redirects to).Buildone withLocation.file(path)orLocation.redirect(url);file?andredirect?tell the two apart.
Public Class Methods
Source
# File lib/warp_engine/storage.rb, line 69 def adapter configured = WarpEngine.config.storage_adapter case configured when nil, :local, "local" then local_adapter else configured end end
Returns the configured storage adapter; nil, :local or "local" give the shared LocalAdapter instance.
Source
# File lib/warp_engine/storage.rb, line 79 def local? = adapter.is_a?(LocalAdapter)
Returns true when the adapter is a LocalAdapter.
Source
# File lib/warp_engine/storage.rb, line 82 def local_adapter @local_adapter ||= LocalAdapter.new end
Returns the memoized LocalAdapter instance.
Source
# File lib/warp_engine/storage.rb, line 62 def mime_for(path) ext = File.extname(path.to_s).delete_prefix(".") Mime::Type.lookup_by_extension(ext) || "application/octet-stream" end
Returns the Mime::Type for the extension of path, or "application/octet-stream" when it is unknown.
Source
# File lib/warp_engine/storage.rb, line 87 def reset! @local_adapter = nil end
Drops the memoized LocalAdapter instance.