Class: Upkeep::HerbSupport::ManifestCache
- Inherits:
-
Object
- Object
- Upkeep::HerbSupport::ManifestCache
- Defined in:
- lib/upkeep/herb/manifest_cache.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
- #clear ⇒ Object
- #fetch(path:, source:, parse_options: ManifestDiff::PARSE_OPTIONS) ⇒ Object
-
#initialize ⇒ ManifestCache
constructor
A new instance of ManifestCache.
- #last_update_for(path) ⇒ Object
- #summary ⇒ Object
Constructor Details
#initialize ⇒ ManifestCache
Returns a new instance of ManifestCache.
13 14 15 |
# File 'lib/upkeep/herb/manifest_cache.rb', line 13 def initialize @entries = {} end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
11 12 13 |
# File 'lib/upkeep/herb/manifest_cache.rb', line 11 def entries @entries end |
Instance Method Details
#clear ⇒ Object
44 45 46 |
# File 'lib/upkeep/herb/manifest_cache.rb', line 44 def clear entries.clear end |
#fetch(path:, source:, parse_options: ManifestDiff::PARSE_OPTIONS) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/upkeep/herb/manifest_cache.rb', line 17 def fetch(path:, source:, parse_options: ManifestDiff::PARSE_OPTIONS) source_digest = digest(source) entry = entries[path] return entry.manifest if entry&.source_digest == source_digest update = update_for(path: path, old_source: entry&.source, new_source: source, parse_options: ) manifest = update[:new_manifest] || TemplateManifest.build(path: path, source: source, parse_options: ) entries[path] = Entry.new(path, source_digest, source.dup, manifest, update_payload(update)) manifest end |
#last_update_for(path) ⇒ Object
30 31 32 |
# File 'lib/upkeep/herb/manifest_cache.rb', line 30 def last_update_for(path) entries.fetch(path).last_update end |
#summary ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/upkeep/herb/manifest_cache.rb', line 34 def summary updates = entries.values.map(&:last_update) { entries: entries.size, actions: updates.map { |update| update.fetch(:action) }.tally, topology_changes: updates.count { |update| update.fetch(:topology_changed, false) } } end |