class Credentials::PasswordstoreProvider

Public Class Methods

new(opts) click to toggle source
# File lib/credentials/passwordstore_provider.rb, line 4
def initialize(opts)
  
  @command = opts['command'] || '/usr/bin/pass'
  @name = opts['name'] or raise ArgumentError.new("Missing name for Provider")
end

Public Instance Methods

password() click to toggle source
# File lib/credentials/passwordstore_provider.rb, line 14
def password
  credentials[:password]
end
username() click to toggle source
# File lib/credentials/passwordstore_provider.rb, line 10
def username
  credentials[:username]
end

Private Instance Methods

credentials() click to toggle source

Parse pass output formed like

soopa_secret Username: my_user

# File lib/credentials/passwordstore_provider.rb, line 24
def credentials
  return @credentials if @credentials
  output = %x"#{@command} #{@name}".lines

  password = output.shift
  username = output.find { |line| line.start_with? 'Username:' }.split(":").pop.strip
  @credentials = {:username => username, :password => password}
end