class GithubApi::User

Attributes

name[R]

Public Class Methods

new(user_name) click to toggle source
# File lib/unofficial-github-api/github_api.rb, line 8
def initialize(user_name)
  @name = user_name
end

Public Instance Methods

commits_size() click to toggle source
# File lib/unofficial-github-api/github_api.rb, line 33
def commits_size
  Nokogiri::HTML(open("https://github.com/#{name}")).xpath('//*[@id="contributions-calendar"]/div[3]/div[1]/span[1]').text.split(' ').first.gsub(/\,/,'').to_i
end
created_at() click to toggle source
# File lib/unofficial-github-api/github_api.rb, line 25
def created_at
  Chronic.parse(Nokogiri::HTML(open("https://github.com/#{name}")).css('span.join-date').text)
end
followers() click to toggle source
# File lib/unofficial-github-api/github_api.rb, line 12
def followers
  wq = WorkQueue.new 5
  list = {}
  pages = get_number_of_followers_pages
  (1..pages).to_a.each do |i|
    wq.enqueue_b do
      list[i] = FollowersPage.new(name, i).followers_list
    end
  end
  wq.join
  list.values.flatten
end
followers_size() click to toggle source
# File lib/unofficial-github-api/github_api.rb, line 29
def followers_size
  Nokogiri::HTML(open("https://github.com/#{name}/followers")).xpath('//*[@id="site-container"]/div[1]/div/ul/li/span/span/a[2]').text.gsub(/\,/,'').to_i
end
get_number_of_followers_pages() click to toggle source
# File lib/unofficial-github-api/github_api.rb, line 37
def get_number_of_followers_pages
  (followers_size.to_f/51).ceil
end