Sha256: 53ec3629ac7dfe757d49ba56cd4a0033708d0efa22271e7b1f289476b64ea2bf

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

require 'userinput'
require 'keychain'

module Circular
  class << self
    def new(*args)
      self::API.new(*args)
    end

    def load_token(domain)
      lookup_token(domain) || UserInput.new(message: "Token for #{domain}").ask
    end
    
    private

    def lookup_token(domain)
      entry = Keychain.open(Keychain.default.path).internet_passwords.where(
        service: domain
      ).first
      return nil unless entry
      entry.password
    end
  end
end

require 'circular/api'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
circular-0.0.1 lib/circular.rb