Class: Jarbs::GithubAuth

Inherits:
Object
  • Object
show all
Includes:
Commander::UI
Defined in:
lib/jarbs/github_auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GithubAuth

Returns a new instance of GithubAuth.



7
8
9
10
11
12
# File 'lib/jarbs/github_auth.rb', line 7

def initialize(config)
  @config = config
  @client = Octokit::Client.new \
    login: @config.get('github.username') { ask('GitHub username: ') },
    password: password('Password (not saved): ')
end

Instance Method Details

#generate_token(name) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/jarbs/github_auth.rb', line 14

def generate_token(name)
  resp = @client.create_authorization scopes: ['public_repo'],
                                      note: "Jarbs error reporting",
                                      headers: { 'X-GitHub-OTP' => ask('GitHub two-factor token: ') }

  @config.set('github.token', resp.token)
end