class Application::Config
Attributes
token[R]
user[R]
Public Class Methods
new()
click to toggle source
# File lib/makegit/config.rb, line 5 def initialize() @user = git_user @token = git_token end
Public Instance Methods
login()
click to toggle source
# File lib/makegit/config.rb, line 10 def login [user, token] end
Private Instance Methods
git_token()
click to toggle source
# File lib/makegit/config.rb, line 27 def git_token token = `git config github.token`.strip if token.empty? || token.nil? STDOUT.puts "Warning: git config --global github.token not set" STDOUT.puts "Let's set it now..." STDOUT.puts "Visit https://help.github.com/articles/creating-an-access-token-for-command-line-use/" STDOUT.puts "Then create a personal access token with the \"repo\" role set" STDOUT.puts "Please enter your GitHub token:" token = STDIN.gets.strip set_git_config_token(token) end token end
git_user()
click to toggle source
# File lib/makegit/config.rb, line 15 def git_user user = `git config github.user`.strip if user.empty? || user.nil? STDOUT.puts "Warning: git config --global github.user not set" STDOUT.puts "Let's set it now..." STDOUT.puts "Please enter your GitHub username:" user = STDIN.gets.strip set_git_config_user(user) end user end
set_git_config_token(token)
click to toggle source
# File lib/makegit/config.rb, line 45 def set_git_config_token(token) system("git config --global github.token #{token}") end
set_git_config_user(user)
click to toggle source
# File lib/makegit/config.rb, line 41 def set_git_config_user(user) system("git config --global github.user #{user}") end