Sha256: 20325fbc39205dce9cc4875bc3a2ced4905e408fa673427d625ffa1fd22100b9
Contents?: true
Size: 687 Bytes
Versions: 1
Compression:
Stored size: 687 Bytes
Contents
# encoding: UTF-8 module Signore class Database def self.db @db end def self.find opts = {} opts = {tags: [], no_tags: []}.merge opts @db .select { |sig| opts[:tags].all? { |tag| sig.tagged_with? tag } } .reject { |sig| opts[:no_tags].any? { |tag| sig.tagged_with? tag } } .shuffle.first end def self.load path @path = path @db = File.exists?(@path) ? YAML.load_file(@path) : [] end def self.min_yaml @db.to_yaml.gsub /^ (author|source|subject|tags): !!null \n/, '' end def self.save sig @db << sig FileUtils.mkpath File.dirname @path File.open(@path, 'w') { |file| file << self.min_yaml } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
signore-0.0.0 | lib/signore/database.rb |