module Prawntocat

Constants

VERSION

Public Class Methods

auth() click to toggle source
# File lib/prawntocat.rb, line 31
def self.auth
  @auth ||= auth_store.transaction{ auth_store['authorization'] ||= Hash.new }
end
auth_store() click to toggle source
# File lib/prawntocat.rb, line 27
def self.auth_store
  @auth_store ||= PStore.new(File.join(ENV['HOME'], ".prawntocat.pstore"))
end
authenticate!() click to toggle source
# File lib/prawntocat.rb, line 13
def self.authenticate!
  $stdout.print("GitHub username: ")
  username = $stdin.gets.chomp
  $stdout.print("GitHub password: ")
  password = $stdin.noecho(&:gets).chomp
  authorization = Octokit::Client.new(login: username, password: password).create_authorization(scopes: ["repo"], note: "Prawntocat Issue Printer", note_url: "http://nuclearsandwich.com/prawntocat")
  auth_store.transaction do
    auth_store['authorization'] ||= Hash.new
    auth_store['authorization']['username'] = username
    auth_store['authorization']['token'] = authorization.token
  end

end
authenticated?() click to toggle source
# File lib/prawntocat.rb, line 9
def self.authenticated?
  auth.has_key?('username') and auth.has_key?('token')
end
client() click to toggle source
# File lib/prawntocat.rb, line 35
def self.client
  Octokit::Client.new login: auth['username'], oauth_token: auth['token']
end