Sha256: ace05fb293ea63141bc90eccf31f4dc4d7d7d1eb3160c7b612f50fede44ce31f

Contents?: true

Size: 533 Bytes

Versions: 4

Compression:

Stored size: 533 Bytes

Contents

# blog post: http://blog.slashpoundbang.com/post/1521530410/accessing-the-os-x-keychain-from-ruby

class KeyChain
  def self.method_missing(meth, *args)
    run args.unshift(meth)
  end

  def self.find_internet_password(*args)
    # -g: Display the password for the item found
    output = quiet args.unshift('find-internet-password', '-g') 
    output[/^password: "(.*)"$/, 1]
  end

private

  def self.run(*args)
    `security #{args.join(' ')}`
  end
  
  def self.quiet(*args)
    run args.unshift('2>&1 >/dev/null')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
things-fetcher-0.1.3 lib/keychain.rb
things-fetcher-0.1.2 lib/keychain.rb
things-fetcher-0.1.1 lib/keychain.rb
things-fetcher-0.1.0 lib/keychain.rb