Class: OnePassword::Keychain

Inherits:
Object
  • Object
show all
Defined in:
lib/one_password/keychain.rb

Instance Method Summary collapse

Constructor Details

#initialize(directory = '~/Dropbox/1Password.agilekeychain') ⇒ Keychain

Returns a new instance of Keychain.



9
10
11
12
13
# File 'lib/one_password/keychain.rb', line 9

def initialize(directory = '~/Dropbox/1Password.agilekeychain')
  @directory       = Pathname(File.expand_path(directory))
  @master_password = nil
  profiles
end

Instance Method Details

#current_profileProfile

Returns:



16
17
18
# File 'lib/one_password/keychain.rb', line 16

def current_profile
  @current_profile ||= profiles['default']
end

#current_profile=(profile) ⇒ Object

Parameters:



21
22
23
24
25
26
27
# File 'lib/one_password/keychain.rb', line 21

def current_profile=(profile)
  unless profile.is_a?(Profile)
    raise UndefinedProfile.new(profile) unless profiles.key?(profile)
    profile = profiles[profile]
  end
  @profile = profile
end

#password=(password) ⇒ Object



29
30
31
# File 'lib/one_password/keychain.rb', line 29

def password=(password)
  current_profile.password = password
end