Class: Nanoc::Core::ChecksumStore Private
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/checksum_store.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Stores checksums for objects in order to be able to detect whether a file has changed since the last site compilation.
Instance Attribute Summary collapse
- #checksums ⇒ Object writeonly private
- #objects ⇒ Object private
Attributes inherited from Store
Instance Method Summary collapse
- #[](obj) ⇒ Object private
- #add(obj) ⇒ Object private
- #attributes_checksum_for(obj) ⇒ Object private
- #content_checksum_for(obj) ⇒ Object private
-
#initialize(config:, objects:) ⇒ ChecksumStore
constructor
private
A new instance of ChecksumStore.
Methods included from ContractsSupport
enabled?, included, setup_once, warn_about_performance
Methods inherited from Store
#load, #store, tmp_path_for, tmp_path_prefix
Constructor Details
#initialize(config:, objects:) ⇒ ChecksumStore
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ChecksumStore.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nanoc/core/checksum_store.rb', line 24 def initialize(config:, objects:) super( self.class.tmp_path_for( config:, store_name: 'checksums', ), 3, ) @objects = objects @checksums = {} invalidate_memoization end |
Instance Attribute Details
#checksums=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/nanoc/core/checksum_store.rb', line 12 def checksums=(value) @checksums = value end |
#objects ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/nanoc/core/checksum_store.rb', line 13 def objects @objects end |
Instance Method Details
#[](obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/nanoc/core/checksum_store.rb', line 41 def [](obj) @checksums[obj.reference] end |
#add(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/nanoc/core/checksum_store.rb', line 46 def add(obj) if obj.is_a?(Nanoc::Core::Document) @checksums[[obj.reference, :content]] = Nanoc::Core::Checksummer.calc_for_content_of(obj) end if obj.is_a?(Nanoc::Core::Document) || obj.is_a?(Nanoc::Core::Configuration) @checksums[[obj.reference, :each_attribute]] = Nanoc::Core::Checksummer.calc_for_each_attribute_of(obj) end @checksums[obj.reference] = Nanoc::Core::Checksummer.calc(obj) self end |
#attributes_checksum_for(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 72 |
# File 'lib/nanoc/core/checksum_store.rb', line 69 def attributes_checksum_for(obj) @_attribute_checksums[obj] ||= @checksums[[obj.reference, :each_attribute]] end |
#content_checksum_for(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 |
# File 'lib/nanoc/core/checksum_store.rb', line 64 def content_checksum_for(obj) @checksums[[obj.reference, :content]] end |