Sha256: fa780ba1e524b06a1639564e48f3462affcf7467e31584416e32138b078e34f7
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require 'thread' module Hanami module Assets # Store assets references when compile mode is on. # # This is expecially useful in development mode, where we want to compile # only the assets that were changed from last browser refresh. # # @since 0.1.0 # @api private class Cache # Return a new instance # # @return [Hanami::Assets::Cache] a new instance def initialize @data = Hash.new{|h,k| h[k] = 0 } @mutex = Mutex.new end # Check if the given file is fresh or changed from last check. # # @param file [String,Pathname] the file path # # @return [TrueClass,FalseClass] the result of the check # # @since 0.1.0 # @api private def fresh?(file) @mutex.synchronize do @data[file.to_s] < mtime(file) end end # Store the given file reference # # @param file [String,Pathname] the file path # # @return [TrueClass,FalseClass] the result of the check # # @since 0.1.0 # @api private def store(file) @mutex.synchronize do @data[file.to_s] = mtime(file) end end private # @since 0.1.0 # @api private def mtime(file) file.mtime.utc.to_i end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanami-assets-0.2.0 | lib/hanami/assets/cache.rb |