Module: Prawntocat
- Defined in:
- lib/prawntocat.rb,
lib/prawntocat/pdf.rb,
lib/prawntocat/issues.rb,
lib/prawntocat/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
- .auth ⇒ Object
- .auth_store ⇒ Object
- .authenticate! ⇒ Object
- .authenticated? ⇒ Boolean
- .client ⇒ Object
Class Method Details
.auth ⇒ Object
31 32 33 |
# File 'lib/prawntocat.rb', line 31 def self.auth @auth ||= auth_store.transaction{ auth_store['authorization'] ||= Hash.new } end |
.auth_store ⇒ Object
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 = Octokit::Client.new(login: username, password: password).(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'] = .token end end |
.authenticated? ⇒ Boolean
9 10 11 |
# File 'lib/prawntocat.rb', line 9 def self.authenticated? auth.has_key?('username') and auth.has_key?('token') end |
.client ⇒ Object
35 36 37 |
# File 'lib/prawntocat.rb', line 35 def self.client Octokit::Client.new login: auth['username'], oauth_token: auth['token'] end |