Class: GithubInfo::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/github-info/scraper.rb

Class Method Summary collapse

Class Method Details

.get_commit_history(relative_path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/github-info/scraper.rb', line 11

def self.get_commit_history(relative_path)
  commit_history = []
  document = Nokogiri::HTML(open("https://github.com#{relative_path}/commits/master"))
  document.css("div.table-list-cell").each { |commit|
    if commit.css("p a.message.js-navigation-open").text != ""
      commit_hash = {
        description: commit.css("p a.message.js-navigation-open").text,
        date: commit.css("relative-time.no-wrap").text
      }
      commit_history << commit_hash
    end
  }
  return commit_history
end

.scrape(profile_name) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/github-info/scraper.rb', line 3

def self.scrape(profile_name)
  @github_info = {
    user_info: (profile_name),
    repositories: get_repositories(profile_name)
  }
  return @github_info
end