Sha256: 37d82f48fcdc8966984f017868c0fa7da6a65c1751fb294db1ecbfd24c2d0b38

Contents?: true

Size: 1.2 KB

Versions: 23

Compression:

Stored size: 1.2 KB

Contents

# encoding: utf-8

module Nanoc

  # 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::Store

    # @option params [Nanoc::Site] site The site where this checksum store
    #   belongs to
    def initialize(params={})
      super('tmp/checksums', 1)

      @site = params[:site] if params.has_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::Store#unload
    def unload
      @checksums = {}
    end

  protected

    def data
      @checksums
    end

    def data=(new_data)
      @checksums = new_data
    end

  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
nanoc-3.6.7 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.6 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.5 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.4 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.3 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.2 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.1 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.6.0 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.5.0 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.5.0b2 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.5.0b1 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.4.3 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.4.2 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.4.1 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.4.0 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.3.7 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.3.6 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.3.5 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.3.4 lib/nanoc/base/compilation/checksum_store.rb
nanoc-3.3.3 lib/nanoc/base/compilation/checksum_store.rb