Class: GithubApi::User
- Inherits:
-
Object
- Object
- GithubApi::User
- Defined in:
- lib/unofficial-github-api/github_api.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #commits_size ⇒ Object
- #created_at ⇒ Object
- #followers ⇒ Object
- #followers_size ⇒ Object
- #get_number_of_followers_pages ⇒ Object
-
#initialize(user_name) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(user_name) ⇒ User
Returns a new instance of User.
8 9 10 |
# File 'lib/unofficial-github-api/github_api.rb', line 8 def initialize(user_name) @name = user_name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/unofficial-github-api/github_api.rb', line 7 def name @name end |
Instance Method Details
#commits_size ⇒ Object
33 34 35 |
# 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 ⇒ Object
25 26 27 |
# 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 ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# 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 ⇒ Object
29 30 31 |
# 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 ⇒ Object
37 38 39 |
# File 'lib/unofficial-github-api/github_api.rb', line 37 def get_number_of_followers_pages (followers_size.to_f/51).ceil end |