module GithubTools::Configuration

Public Instance Methods

create_token() click to toggle source
# File lib/github_tools/configuration.rb, line 11
def create_token
  print 'Username:'
  username = gets.strip
  print 'Password (never saved):'
  password = STDIN.noecho(&:gets).strip
  client = Octokit::Client.new(:login => username, :password => password)
  response = client.create_authorization(
    :scopes => [:repo],
    :note => 'github_tools',
    :note_url =>'https://github.com/ivantsepp/github_tools')
  token = response[:token]
  save_token(token)
  token
end
remote() click to toggle source
# File lib/github_tools/configuration.rb, line 30
def remote
  url = `git config --get remote.origin.url`.strip
  url = 'ssh://' + url if url.include?('@')
  url.gsub!('.git', '')
  Octokit::Repository.from_url(url)
end
save_token(token) click to toggle source
# File lib/github_tools/configuration.rb, line 26
def save_token(token)
  `git config --global githubtools.token #{token}`
end
token() click to toggle source
# File lib/github_tools/configuration.rb, line 5
def token
  token = `git config githubtools.token`.strip
  token = create_token if token.empty?
  token
end