Class: GitReporting::Source::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/git_reporting/source/github.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Github

Returns a new instance of Github.



9
10
11
12
13
14
15
16
17
18
# 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

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



7
8
9
# File 'lib/git_reporting/source/github.rb', line 7

def branch
  @branch
end

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/git_reporting/source/github.rb', line 7

def client
  @client
end

#repoObject (readonly)

Returns the value of attribute repo.



7
8
9
# File 'lib/git_reporting/source/github.rb', line 7

def repo
  @repo
end

Instance Method Details

#fetch(period) ⇒ Object



24
25
26
# 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_allObject



20
21
22
# File 'lib/git_reporting/source/github.rb', line 20

def fetch_all
  extract_commits_from_array client.commits(repo, branch)
end