Class: Travis::Client::Repository::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/client/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, fingerprint) ⇒ Key

Returns a new instance of Key.



12
13
14
15
# File 'lib/travis/client/repository.rb', line 12

def initialize(data, fingerprint)
  @to_s = data
  @fingerprint = fingerprint
end

Instance Attribute Details

#fingerprintObject (readonly)

Returns the value of attribute fingerprint.



10
11
12
# File 'lib/travis/client/repository.rb', line 10

def fingerprint
  @fingerprint
end

#to_sObject (readonly)

Returns the value of attribute to_s.



10
11
12
# File 'lib/travis/client/repository.rb', line 10

def to_s
  @to_s
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/travis/client/repository.rb', line 30

def ==(other)
  other.to_s == self
end

#encrypt(value) ⇒ Object



17
18
19
20
# File 'lib/travis/client/repository.rb', line 17

def encrypt(value)
  encrypted = to_rsa.public_encrypt(value)
  Base64.encode64(encrypted).gsub(/\s+/, '')
end

#to_rsaObject



22
23
24
# File 'lib/travis/client/repository.rb', line 22

def to_rsa
  Tools::SSLKey.public_rsa_key(to_s)
end

#to_sshObject



26
27
28
# File 'lib/travis/client/repository.rb', line 26

def to_ssh
  Tools::SSLKey.rsa_ssh(to_rsa)
end