Module: Prawntocat

Defined in:
lib/prawntocat.rb,
lib/prawntocat/pdf.rb,
lib/prawntocat/issues.rb,
lib/prawntocat/version.rb

Defined Under Namespace

Classes: Issues, PDF

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.authObject



31
32
33
# File 'lib/prawntocat.rb', line 31

def self.auth
  @auth ||= auth_store.transaction{ auth_store['authorization'] ||= Hash.new }
end

.auth_storeObject



27
28
29
# File 'lib/prawntocat.rb', line 27

def self.auth_store
  @auth_store ||= PStore.new(File.join(ENV['HOME'], ".prawntocat.pstore"))
end

.authenticate!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# 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?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/prawntocat.rb', line 9

def self.authenticated?
  auth.has_key?('username') and auth.has_key?('token')
end

.clientObject



35
36
37
# File 'lib/prawntocat.rb', line 35

def self.client
  Octokit::Client.new login: auth['username'], oauth_token: auth['token']
end