Class: Octokom::Client
Constant Summary collapse
- KEY =
'api.github.com'
- URL =
'https://github.com/mjio/octokom'
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#authenticate ⇒ Object
Use the existing credentials form the ~/.netrc file to verify API requests to GitHub.
- #client ⇒ Object
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
8 9 10 |
# File 'lib/octokom/client.rb', line 8 def token @token end |
Class Method Details
.authenticate ⇒ Object
13 14 15 |
# File 'lib/octokom/client.rb', line 13 def self.authenticate new.authenticate end |
Instance Method Details
#authenticate ⇒ Object
Use the existing credentials form the ~/.netrc file to verify API requests to GitHub. When no credentials exist, ask for login and password to request a new token from GitHub.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/octokom/client.rb', line 20 def authenticate _, @token = netrc[KEY] unless token login, password = ask_for_credentials (login, password) end self end |
#client ⇒ Object
31 32 33 34 |
# File 'lib/octokom/client.rb', line 31 def client require 'octokit' Octokit::Client.new(access_token: token) end |