Class: Nanoc::Core::Checksummer
- Inherits:
-
Object
- Object
- Nanoc::Core::Checksummer
- Defined in:
- lib/nanoc/core/checksummer.rb
Overview
Creates checksums for given objects.
A checksum is a string, such as “mL+TaqNsEeiPkWloPgCtAofT1yg=”, that is used to determine whether a piece of data has changed.
Defined Under Namespace
Classes: BinaryContentUpdateBehavior, CollectionUpdateBehavior, CompactDigest, ContextUpdateBehavior, DataUpdateBehavior, DocumentUpdateBehavior, HashUpdateBehavior, ItemRepUpdateBehavior, NoUpdateBehavior, PathnameUpdateBehavior, RawUpdateBehavior, RescueUpdateBehavior, RuleContextUpdateBehavior, SetUpdateBehavior, StringUpdateBehavior, ToIToSUpdateBehavior, ToSUpdateBehavior, UnwrapUpdateBehavior, UpdateBehavior, VerboseDigest
Class Method Summary collapse
-
.calc(obj, digest_class = CompactDigest) ⇒ String
The digest.
- .calc_for_content_of(obj) ⇒ Object
- .calc_for_each_attribute_of(obj, digest_class = CompactDigest) ⇒ Object
- .define_behavior(klass, behavior) ⇒ Object
Class Method Details
.calc(obj, digest_class = CompactDigest) ⇒ String
Returns The digest.
42 43 44 45 46 |
# File 'lib/nanoc/core/checksummer.rb', line 42 def calc(obj, digest_class = CompactDigest) digest = digest_class.new update(obj, digest) digest.to_s end |
.calc_for_content_of(obj) ⇒ Object
48 49 50 |
# File 'lib/nanoc/core/checksummer.rb', line 48 def calc_for_content_of(obj) obj.content_checksum_data || obj.checksum_data || Nanoc::Core::Checksummer.calc(obj.content) end |
.calc_for_each_attribute_of(obj, digest_class = CompactDigest) ⇒ Object
52 53 54 55 56 |
# File 'lib/nanoc/core/checksummer.rb', line 52 def calc_for_each_attribute_of(obj, digest_class = CompactDigest) obj.attributes.transform_values do |value| Nanoc::Core::Checksummer.calc(value, digest_class) end end |
.define_behavior(klass, behavior) ⇒ Object
58 59 60 |
# File 'lib/nanoc/core/checksummer.rb', line 58 def define_behavior(klass, behavior) behaviors[klass] = behavior end |