class Microclimate::Repository

Attributes

client[RW]
repo_id[RW]

Public Class Methods

new(client, options) click to toggle source

@param [Hash] options An option hash of:

+repo_id+: The SHA identifier of the repository on Code Climate.
# File lib/microclimate/repository.rb, line 11
def initialize(client, options)
  @client = client
  @repo_id = options[:repo_id]
end

Public Instance Methods

branch_for(branch_name) click to toggle source
# File lib/microclimate/repository.rb, line 36
def branch_for(branch_name)
  Branch.new(client, self, branch_name)
end
last_snapshot() click to toggle source
# File lib/microclimate/repository.rb, line 44
def last_snapshot
  snapshot = status.last_snapshot
  return nil if snapshot.nil?
  Snapshot.new(snapshot)
end
previous_snapshot() click to toggle source
# File lib/microclimate/repository.rb, line 50
def previous_snapshot
  snapshot = status.previous_snapshot
  return nil if snapshot.nil?

  Snapshot.new(snapshot)
end
ready?() click to toggle source
# File lib/microclimate/repository.rb, line 26
def ready?
  !last_snapshot.nil?
end
refresh!() click to toggle source

Force Code Climate to refresh this repository (at the master branch)

# File lib/microclimate/repository.rb, line 21
def refresh!
  output = connection.post resource_refresh_url, :api_token => api_token
  output.success?
end
status() click to toggle source
# File lib/microclimate/repository.rb, line 30
def status
  output = connection.get resource_url, :api_token => api_token
  json = output.body
  Response.new JSON.parse(json)
end
www_url() click to toggle source
# File lib/microclimate/repository.rb, line 40
def www_url
  "https://codeclimate.com/repos/#{repo_id}"
end

Protected Instance Methods

resource_refresh_url() click to toggle source
# File lib/microclimate/repository.rb, line 59
def resource_refresh_url
  "#{resource_url}/refresh"
end
resource_url() click to toggle source
# File lib/microclimate/repository.rb, line 63
def resource_url
  "/api/repos/#{repo_id}"
end