class Dragonfly::Cache::Storage::Local
Attributes
format[R]
root[R]
Public Class Methods
new(config)
click to toggle source
# File lib/dragonfly/cache/storage/local.rb, line 9 def initialize(config) @root = config[:server_root] @format = config[:url_format] end
Public Instance Methods
sha_size()
click to toggle source
# File lib/dragonfly/cache/storage/local.rb, line 18 def sha_size longest = Dir["#{base_dir}/*"].select { |p| File.directory?(p) }.max { |a, b| a <=> b } (longest ? File.basename(longest).size : nil) end
store(url, job)
click to toggle source
# File lib/dragonfly/cache/storage/local.rb, line 14 def store(url, job) job.to_file(path(url), mode: 0o644) end
Protected Instance Methods
base_dir()
click to toggle source
# File lib/dragonfly/cache/storage/local.rb, line 29 def base_dir @base_dir ||= begin path_format = File.join(root, format) path_format.split('/').take_while { |p| p != ':shaish' }.join('/') end end
path(url)
click to toggle source
# File lib/dragonfly/cache/storage/local.rb, line 25 def path(url) File.join(root, url) end