Sha256: 9cba7f2ff82d7154f97440d2c5a4daa6e1f16d6d4a2b4c930fc3531b8b9fd102
Contents?: true
Size: 892 Bytes
Versions: 1
Compression:
Stored size: 892 Bytes
Contents
require 'fileutils' require 'yaml/store' require_relative 'settings' require_relative 'sig_finder' require_relative 'tags' module Signore class Database def initialize(path: Settings.new.db_path, sig_finder: SigFinder) @path = path @sig_finder = sig_finder initialise_store if path.zero? or not path.exist? @store = YAML::Store.new(path) end def <<(sig) store.transaction { store['signatures'] << sig } end def find(tags: Tags.new) sigs = store.transaction(true) { store['signatures'] } sig_finder.find(sigs, tags: tags) end attr_reader :path, :sig_finder, :store private :path, :sig_finder, :store private def initialise_store FileUtils.mkdir_p path.dirname FileUtils.touch path YAML::Store.new(path).transaction { |store| store['signatures'] = [] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
signore-0.2.4 | lib/signore/database.rb |