class Aeternitas::Source
Sources can store polling results in a write once - read many fashion. Each source, by default, hereby stores it's raw_content
in a compressed file on disk if it has not been saved yet (determined by the raw_contents MD5 Hash) The 'aeternitas_sources' table holds all source metadata in a quite space-efficient way. For instance the compressed file's location is determined from the sources fingerprint which at the same time is it's database ID.
Attributes
raw_content[W]
Public Instance Methods
generate_fingerprint()
click to toggle source
Generates the entries fingerprint. @return [String] the entries fingerprint.
# File lib/aeternitas/source.rb, line 38 def generate_fingerprint Digest::MD5.hexdigest(@raw_content.to_s) end
raw_content()
click to toggle source
Get the sources raw content. @return [String] the sources raw content
# File lib/aeternitas/source.rb, line 44 def raw_content @raw_content ||= Aeternitas.config.get_storage_adapter.retrieve(self.fingerprint) end
Private Instance Methods
create_file()
click to toggle source
# File lib/aeternitas/source.rb, line 50 def create_file Aeternitas.config.get_storage_adapter.store(self.fingerprint, raw_content) end
delete_file()
click to toggle source
# File lib/aeternitas/source.rb, line 54 def delete_file Aeternitas.config.get_storage_adapter.delete(self.fingerprint) end
ensure_fingerprint()
click to toggle source
# File lib/aeternitas/source.rb, line 58 def ensure_fingerprint self.fingerprint ||= generate_fingerprint end