class Conjure::DigitalOcean::KeySet

Public Class Methods

new(account) click to toggle source
# File lib/conjure/digital_ocean/key_set.rb, line 7
def initialize(account)
  @account = account
end

Public Instance Methods

find_or_create(data) click to toggle source
# File lib/conjure/digital_ocean/key_set.rb, line 11
def find_or_create(data)
  find(data) || create(data)
end

Private Instance Methods

create(data) click to toggle source
# File lib/conjure/digital_ocean/key_set.rb, line 25
def create(data)
  name = "conjure_" + Digest::SHA1.hexdigest(data).slice(0, 8)
  Key.new @account.post("account/keys", :name => name, :public_key => data)["ssh_key"]
end
find(data) click to toggle source
# File lib/conjure/digital_ocean/key_set.rb, line 21
def find(data)
  keys.select { |key| key.public_key.strip == data.strip }.first
end
keys() click to toggle source
# File lib/conjure/digital_ocean/key_set.rb, line 17
def keys
  @account.get("account/keys")["ssh_keys"].map { |data| Key.new data }
end