Sha256: bd7012ba203cf275134f3e31ecd500f6e78ffb7af58e3d8c60cf566973ca9011
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'ostruct' module Keychain class << self def generic_passwords KeychainFile.new.generic_passwords end def internet_passwords KeychainFile.new.internet_passwords end def open(path) KeychainFile.new(path) end def nuke_list @nuke_list ||= [] end def empty_nuke_list! @nuke_list = [] end end class KeychainFile def initialize(path = nil) @keychain = path end def generic_passwords Passwords.new(@keychain) end def internet_passwords InternetPasswords.new(@keychain) end end class Passwords def initialize(keychain = nil) @keychain = keychain end def where(params) cache.find_all do |x| hash = x.marshal_dump params.all? { |k, v| hash[k] == v } end end def create(params) struct = OpenStruct.new(params) struct.keychain = @keychain cache << struct end private def cache @cache ||= [] @cache.reject! { |x| Keychain.nuke_list.include? x.hash } Keychain.empty_nuke_list! @cache end end class InternetPasswords < Passwords end end class OpenStruct def delete Keychain.nuke_list << hash super end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
keylime-0.0.1-x86_64-darwin-15 | spec/stub/keychain.rb |