Class: MyTimeline::Github::GithubScraper

Inherits:
Object
  • Object
show all
Defined in:
app/scrapers/my_timeline/github/github_scraper.rb

Constant Summary collapse

VALID_EVENTS =

IMPLEMENTED EVENTS ONLY:

%w{ForkEvent}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ GithubScraper

Returns a new instance of GithubScraper.



16
17
18
# File 'app/scrapers/my_timeline/github/github_scraper.rb', line 16

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject

Returns the value of attribute user.



14
15
16
# File 'app/scrapers/my_timeline/github/github_scraper.rb', line 14

def user
  @user
end

Instance Method Details

#scrapeObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/scrapers/my_timeline/github/github_scraper.rb', line 20

def scrape
  @count = 0

  events.each do |event|
    if should_build? event
      Rails.logger.fatal "buidling #{event.type}"
      @count = @count + 1 if "MyTimeline::Github::#{event.type}Builder".constantize.new(user, event).build_event
    end
  end

  @count
end