class GithubInfo::CLI
Public Instance Methods
call()
click to toggle source
# File lib/github-info/cli.rb, line 2 def call menu end
Private Instance Methods
format_date(date)
click to toggle source
# File lib/github-info/cli.rb, line 58 def format_date(date) if date.split(' ')[1].split(',')[0].to_i < 10 date_pieces = date.split(' ') date = "#{date_pieces[0]} 0#{date_pieces[1]} #{date_pieces[2]}" end return date end
print_commit_history(index)
click to toggle source
# File lib/github-info/cli.rb, line 49 def print_commit_history(index) puts "commit history:" @github_profile.commit_history(index).each { |commit| print "\t" print "#{format_date(commit[:date])}: " puts commit[:description] } end
print_contributions()
click to toggle source
# File lib/github-info/cli.rb, line 31 def print_contributions puts "#{@github_profile.contributions} contributions in the last year" end
print_help()
click to toggle source
# File lib/github-info/cli.rb, line 8 def print_help print "\tgit: [profile] -> " puts "Retrieves information from a github profile." print "\tname -> " puts "Outputs the name of the user if one is provided." print "\tcontributions -> " puts "Outputs the contributions commited by the user within the last year." print "\trepos -> " puts "Outputs an indexed list of the user's repositories." print "\thistory: [repository_index] -> " puts "Outputs a list of a repository's commit history." print "\texit -> " puts "Exit the program." end
print_name()
click to toggle source
# File lib/github-info/cli.rb, line 23 def print_name if @github_profile.name != "" puts @github_profile.name else puts "name unavailable" end end
print_repositories()
click to toggle source
# File lib/github-info/cli.rb, line 35 def print_repositories if @github_profile.repositories.size != 0 puts "repositories:" i = 0 @github_profile.repositories.each do |repository| print "\t" print '0' if i < 9 puts "#{i += 1}. #{repository[:name]}" end else puts "no repositories" end end