Class: Everlog::Dom::Module::Github

Inherits:
Everlog::Dom::Module show all
Defined in:
lib/everlog/dom/module/github.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Github

Returns a new instance of Github.



3
4
5
# File 'lib/everlog/dom/module/github.rb', line 3

def initialize config
  @config = config
end

Class Method Details

.fetch_since(date) ⇒ Object



28
29
30
31
# File 'lib/everlog/dom/module/github.rb', line 28

def fetch_since date
  instance = self.new(Dom::Entity::Config.github)
  instance.repo_names.map { |r| instance.repo_activity(r, date) }.compact
end

Instance Method Details

#api_clientObject



7
8
9
# File 'lib/everlog/dom/module/github.rb', line 7

def api_client
  @api_client ||= Inf::Api::Github.new(@config)
end

#commits(repo, date) ⇒ Object



21
22
23
24
25
# File 'lib/everlog/dom/module/github.rb', line 21

def commits(repo, date)
  response = api_client.commits_on(repo, date)
  return nil if response.empty?
  response.map { |r| Dom::Value::Github::Commit.new(r) }.reverse
end

#repo_activity(repo_name, date) ⇒ Object



15
16
17
18
19
# File 'lib/everlog/dom/module/github.rb', line 15

def repo_activity(repo_name, date)
  repo_commits = commits(repo_name.sub(/.*\//, ''), date)
  return nil if repo_commits.nil?
  Dom::Value::Github::Repository_Activity.new(repo_name, repo_commits)
end

#repo_namesObject



11
12
13
# File 'lib/everlog/dom/module/github.rb', line 11

def repo_names
  api_client.repos.map { |r| r.full_name }
end