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.
18 19 20 21 22 23 24 25 26 |
# File 'lib/nanoc/core/checksum_store.rb', line 18 def initialize(config:, objects:) super(Nanoc::Core::Store.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.
29 30 31 |
# File 'lib/nanoc/core/checksum_store.rb', line 29 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.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nanoc/core/checksum_store.rb', line 34 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.
54 55 56 |
# File 'lib/nanoc/core/checksum_store.rb', line 54 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.
49 50 51 |
# File 'lib/nanoc/core/checksum_store.rb', line 49 def content_checksum_for(obj) @checksums[[obj.reference, :content]] end |