Class: GhDiff::Auth
- Inherits:
-
Object
- Object
- GhDiff::Auth
- Defined in:
- lib/gh-diff/auth.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(username: nil, password: nil, token: nil) ⇒ Auth
constructor
A new instance of Auth.
- #login ⇒ Object
Constructor Details
#initialize(username: nil, password: nil, token: nil) ⇒ Auth
Returns a new instance of Auth.
9 10 11 12 13 14 |
# File 'lib/gh-diff/auth.rb', line 9 def initialize(username:nil, password:nil, token:nil) @username = username @password = password @token = token @@login = nil end |
Class Method Details
.[](opts = {}) ⇒ Object
3 4 5 6 7 |
# File 'lib/gh-diff/auth.rb', line 3 def self.[](opts={}) new(username:opts[:username], password:opts[:password], token:opts[:token]).login end |
Instance Method Details
#login ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/gh-diff/auth.rb', line 16 def login if @token Octokit.configure { |c| c.access_token = @token } else Octokit.configure { |c| c.login = @username; c.password = @password } end @@login = Octokit.user end |