Class: GhDiff::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/gh-diff/auth.rb

Class Method Summary collapse

Instance Method Summary collapse

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]).
end

Instance Method Details

#loginObject



16
17
18
19
20
21
22
23
# File 'lib/gh-diff/auth.rb', line 16

def 
  if @token
    Octokit.configure { |c| c.access_token = @token }
  else
    Octokit.configure { |c| c. = @username; c.password = @password }
  end
  @@login = Octokit.user
end