module WhatsnewStore
Constants
- CHANNEL_STATE_KEY
- ENTRIES_KEY
- MAX_ENTRIES
- PENDING_KEY
- PLUGIN
- SEEDED_KEY
Public Instance Methods
Source
# File lib/whatsnew_store.rb, line 28 def add_entry(plugin:, kind:, summary:, recorded_at: RabbotDb.iso_time, store: RabbotDb) entries = load_entries(store: store) entry = { "id" => SecureRandom.hex(4), "plugin" => plugin.to_s.strip.downcase, "kind" => kind.to_s, "summary" => summary.to_s.strip, "recorded_at" => recorded_at } save_entries([entry] + entries, store: store) entry end
Source
# File lib/whatsnew_store.rb, line 89 def clear_pending(network:, channel:, store: RabbotDb) store.set_plugin_value( plugin: PLUGIN, key: PENDING_KEY, network: network, channel: channel, value: "" ) end
Source
# File lib/whatsnew_store.rb, line 49 def load_channel_state(network:, channel:, store: RabbotDb) store.get_plugin_json( plugin: PLUGIN, key: CHANNEL_STATE_KEY, network: network, channel: channel, default: { "last_announce_at" => nil } ) end
Source
# File lib/whatsnew_store.rb, line 16 def load_entries(store: RabbotDb) Array(store.get_plugin_json(plugin: PLUGIN, key: ENTRIES_KEY, default: [])) end
Source
# File lib/whatsnew_store.rb, line 69 def load_pending(network:, channel:, store: RabbotDb) store.get_plugin_json( plugin: PLUGIN, key: PENDING_KEY, network: network, channel: channel, default: nil ) end
Source
# File lib/whatsnew_store.rb, line 45 def mark_seeded!(store: RabbotDb) store.set_plugin_value(plugin: PLUGIN, key: SEEDED_KEY, value: "1") end
Source
# File lib/whatsnew_store.rb, line 59 def save_channel_state(network:, channel:, state:, store: RabbotDb) store.set_plugin_json( plugin: PLUGIN, key: CHANNEL_STATE_KEY, network: network, channel: channel, value: state ) end
Source
# File lib/whatsnew_store.rb, line 20 def save_entries(entries, store: RabbotDb) store.set_plugin_json( plugin: PLUGIN, key: ENTRIES_KEY, value: Array(entries).first(MAX_ENTRIES) ) end
Source
# File lib/whatsnew_store.rb, line 79 def save_pending(network:, channel:, pending:, store: RabbotDb) store.set_plugin_json( plugin: PLUGIN, key: PENDING_KEY, network: network, channel: channel, value: pending ) end
Source
# File lib/whatsnew_store.rb, line 41 def seeded?(store: RabbotDb) store.get_plugin_value(plugin: PLUGIN, key: SEEDED_KEY).to_s == "1" end