module SystemKeychain::Store::Mac
Public Class Methods
get(url)
click to toggle source
# File lib/system_keychain/store/mac.rb, line 10 def self.get(url) match = `security find-generic-password -s #{Shellwords.escape(url)} -g 2>&1`.match(/password: "([^"]*)".*acct"<blob>="([^"]*)"/m) return nil unless match pass, user = match.captures return [user, pass] end
is_valid()
click to toggle source
# File lib/system_keychain/store/mac.rb, line 6 def self.is_valid `which security` == "/usr/bin/security\n" end
remove(url)
click to toggle source
# File lib/system_keychain/store/mac.rb, line 17 def self.remove(url) `security delete-generic-password -s #{Shellwords.escape(url)}` end
save(url, user, pass, description = url)
click to toggle source
# File lib/system_keychain/store/mac.rb, line 21 def self.save(url, user, pass, description = url) `security add-generic-password -l #{Shellwords.escape(description)} -s #{Shellwords.escape(url)} -a #{Shellwords.escape(user)} -p #{Shellwords.escape(pass)}` end