Sha256: 436cb25ac4f29ed7eaa5311afec750aef76c42715123323eb643532e0eb858ec
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require 'forwardable' require 'pathname' require 'yaml/store' require_relative 'signature' require_relative 'tags' module Signore class Repo class << self def default_path dir = ENV.fetch('XDG_DATA_HOME') { File.expand_path('~/.local/share') } Pathname.new(dir) / 'signore' / 'signatures.yml' end end extend Forwardable def initialize(path: self.class.default_path) @path = path convert if legacy? end def <<(signature) self.hashes = hashes + [signature.to_h] end delegate empty?: :hashes def sigs hashes.map(&Signature.method(:from_h)) end private attr_reader :path def convert self.hashes = hashes.map(&:to_h) end def legacy? path.exist? and path.read.include?('Signore::Signature') end def hashes store.transaction(true) { store.fetch('signatures', []) } end def hashes=(hashes) store.transaction { store['signatures'] = hashes } end def store @store ||= begin path.dirname.mkpath YAML::Store.new(path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
signore-0.7.0 | lib/signore/repo.rb |