Sha256: c8bb610f9488682196cc1aeddc1284ab4630f97c4ca34c9772de3579d114b0bc

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

module Nanoc::Int
  # Stores checksums for objects in order to be able to detect whether a file
  # has changed since the last site compilation.
  #
  # @api private
  class ChecksumStore < ::Nanoc::Int::Store
    # @option params [Nanoc::Int::Site] site The site where this checksum store
    #   belongs to
    def initialize(params = {})
      super('tmp/checksums', 1)

      @site = params[:site] if params.key?(:site)

      @checksums = {}
    end

    # Returns the old checksum for the given object. This makes sense for
    # items, layouts and code snippets.
    #
    # @param [#reference] obj The object for which to fetch the checksum
    #
    # @return [String] The checksum for the given object
    def [](obj)
      @checksums[obj.reference]
    end

    # Sets the checksum for the given object.
    #
    # @param [#reference] obj The object for which to set the checksum
    #
    # @param [String] checksum The checksum
    def []=(obj, checksum)
      @checksums[obj.reference] = checksum
    end

    # @see Nanoc::Int::Store#unload
    def unload
      @checksums = {}
    end

    protected

    def data
      @checksums
    end

    def data=(new_data)
      @checksums = new_data
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc-4.0.2 lib/nanoc/base/repos/checksum_store.rb
nanoc-4.0.1 lib/nanoc/base/repos/checksum_store.rb
nanoc-4.0.0 lib/nanoc/base/repos/checksum_store.rb
nanoc-4.0.0rc3 lib/nanoc/base/repos/checksum_store.rb
nanoc-4.0.0rc2 lib/nanoc/base/repos/checksum_store.rb
nanoc-4.0.0rc1 lib/nanoc/base/repos/checksum_store.rb
nanoc-4.0.0b4 lib/nanoc/base/compilation/checksum_store.rb
nanoc-4.0.0b3 lib/nanoc/base/compilation/checksum_store.rb