Class: CodecovApi::Api::Commits

Inherits:
Base
  • Object
show all
Defined in:
lib/codecov_api/api/commits.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, repo) ⇒ Commits

Returns a new instance of Commits.



6
7
8
9
# File 'lib/codecov_api/api/commits.rb', line 6

def initialize(owner, repo)
  @owner = owner
  @repo = repo
end

Instance Method Details

#folder_totals(path, branch = 'master') ⇒ Object



28
29
30
# File 'lib/codecov_api/api/commits.rb', line 28

def folder_totals(path, branch = 'master')
  get_request("/tree/#{branch}/#{path}")
end

#get(sha) ⇒ Object



24
25
26
# File 'lib/codecov_api/api/commits.rb', line 24

def get(sha)
  get_request("/commit/#{sha}")
end

#list(from = nil, to = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/codecov_api/api/commits.rb', line 11

def list(from = nil, to = nil)
  uri = '/commits'
  params = { from: from, to: to }.map do |key, value|
    if value.instance_of?(Time)
      "#{key}=#{value.utc.strftime('%F %T')}"
    elsif !value.nil?
      raise 'not a valid time'
    end
  end.compact
  uri = "#{uri}/?#{params.join('&')}" unless params.empty?
  get_request(uri)
end