class GitReporting::Source::Github

Attributes

branch[R]
client[R]
repo[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/git_reporting/source/github.rb, line 9
def initialize(options = {})
  if options[:repo]
    @repo = options.delete(:repo)
  else
    raise ArgumentError, "You must specify repo for GitHub source"
  end
  @branch = options.delete(:branch) || :master
  options[:auto_paginate] ||= true
  @client = Octokit::Client.new(options)
end

Public Instance Methods

fetch(period) click to toggle source
# File lib/git_reporting/source/github.rb, line 24
def fetch(period)
  extract_commits_from_array client.commits_between(repo, period.begin, period.end, sha: branch)
end
fetch_all() click to toggle source
# File lib/git_reporting/source/github.rb, line 20
def fetch_all
  extract_commits_from_array client.commits(repo, branch)
end

Private Instance Methods

extract_commits_from_array(commits_array) click to toggle source
# File lib/git_reporting/source/github.rb, line 30
def extract_commits_from_array(commits_array)
  commits_array.map do |data|
    Commit.new sha: data.sha,
               author: data.author.login,
               message: data.commit.message,
               timestamp: data.commit.author.date
  end
end