class Keytaker::Item
Constants
- SERVICE_NAME
Public Class Methods
create(key:, value:)
click to toggle source
# File lib/keytaker/item.rb, line 24 def create(key:, value:) Keychain.generic_passwords.create(service: SERVICE_NAME, account: key, password: value) end
find(key)
click to toggle source
# File lib/keytaker/item.rb, line 9 def find(key) item = Keychain.generic_passwords.where(service: SERVICE_NAME, account: key).first item ? new(item) : nil end
new(item)
click to toggle source
# File lib/keytaker/item.rb, line 29 def initialize(item) @item = item end
select()
click to toggle source
# File lib/keytaker/item.rb, line 14 def select accounts = Keychain.generic_passwords.where(service: SERVICE_NAME).all.map(&:account) if accounts.empty? nil else key, _ = *PecoSelector.select_from(accounts) Keytaker::Item.find(key) end end
Public Instance Methods
copy()
click to toggle source
# File lib/keytaker/item.rb, line 33 def copy IO.popen('pbcopy', 'w') do |f| f << @item.password end end
delete()
click to toggle source
# File lib/keytaker/item.rb, line 44 def delete @item.delete end
update(value:)
click to toggle source
# File lib/keytaker/item.rb, line 39 def update(value:) @item.password = value @item.save! end