class AgileKeychain

Constants

INVALID_KEY
INVALID_PASSWORD

Public Class Methods

new(path=nil) click to toggle source
# File lib/1pass.rb, line 8
def initialize(path=nil)
        path = path || "#{ENV["HOME"]}/Library/Application Support/1Password/1Password.agilekeychain"
        @keychain = Keychain.new(path)
end

Public Instance Methods

list() click to toggle source
# File lib/1pass.rb, line 13
def list
        @keychain.content.items.map {|i| puts i.name}
end
load(master_password, key_name, field_name=nil) click to toggle source
# File lib/1pass.rb, line 17
def load(master_password, key_name, field_name=nil) 
        inform_and_exit(INVALID_PASSWORD) unless @keychain.unlock(master_password)
        key = @keychain.get(key_name)
        inform_and_exit(INVALID_KEY) unless key
        puts field_name ? key.find(field_name) : key.fields
end

Private Instance Methods

inform_and_exit(message) click to toggle source
# File lib/1pass.rb, line 25
def inform_and_exit(message)
        puts message
        exit 1
end