lib/dassets/file_store.rb in dassets-0.7.0 vs lib/dassets/file_store.rb in dassets-0.8.0
- old
+ new
@@ -1,35 +1,38 @@
require 'thread'
-module Dassets; end
-class Dassets::FileStore
- attr_reader :root
+module Dassets
- def initialize(root)
- @root = root
- @save_mutex = ::Mutex.new
- end
+ class FileStore
+ attr_reader :root
- 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) }
+ 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
- end
- def store_path(url)
- File.join(@root, url)
- end
+ def store_path(url)
+ File.join(@root, url)
+ end
-end
+ class NullStore < FileStore
+ def initialize
+ super('')
+ 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
- def save(url, &block)
- store_path(url) # no-op, just return the store path like the base does
end
+
end