class Anjou::AuthorizedKeys

Attributes

keys[R]

Public Class Methods

new(github_username) click to toggle source
# File lib/anjou/authorized_keys.rb, line 8
def initialize(github_username)
  uri = URI.parse("https://api.github.com/users/#{github_username}/keys")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  data = http.get(uri.request_uri)
  @keys = JSON.parse data.body
  raise "Response from GitHub: #{@keys['message']}" if @keys.kind_of? Hash
end

Public Instance Methods

contents() click to toggle source
# File lib/anjou/authorized_keys.rb, line 18
def contents
  @keys.map{|item| item['key']}.join("\n")
end