Sha256: 9b16487250bda94acf38457cd91991a09b8f38940e7655dc675f6b2c4b8a62cf
Contents?: true
Size: 636 Bytes
Versions: 4
Compression:
Stored size: 636 Bytes
Contents
require 'thread' module Dassets; end class Dassets::FileStore attr_reader :root def initialize(root) @root = root @save_mutex = ::Mutex.new end def save(url, &block) @save_mutex.synchronize do store_path(url).tap do |path| FileUtils.mkdir_p(File.dirname(path)) File.open(path, "w"){ |f| f.write(block.call) } end end end def store_path(url) File.join(@root, url) end end class Dassets::NullFileStore < Dassets::FileStore def initialize super('') end def save(url, &block) store_path(url) # no-op, just return the store path like the base does end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dassets-0.7.0 | lib/dassets/file_store.rb |
dassets-0.6.2 | lib/dassets/file_store.rb |
dassets-0.6.1 | lib/dassets/file_store.rb |
dassets-0.6.0 | lib/dassets/file_store.rb |