Class: Microclimate::Repository

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/microclimate/repository.rb

Direct Known Subclasses

Branch

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#connection, #host

Constructor Details

#initialize(client, options) ⇒ Repository

Returns a new instance of Repository.

Parameters:

  • options (Hash)

    An option hash of: repo_id: The SHA identifier of the repository on Code Climate.



11
12
13
14
# File 'lib/microclimate/repository.rb', line 11

def initialize(client, options)
  @client = client
  @repo_id = options[:repo_id]
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/microclimate/repository.rb', line 5

def client
  @client
end

#repo_idObject

Returns the value of attribute repo_id.



5
6
7
# File 'lib/microclimate/repository.rb', line 5

def repo_id
  @repo_id
end

Instance Method Details

#branch_for(branch_name) ⇒ Object



39
40
41
# File 'lib/microclimate/repository.rb', line 39

def branch_for(branch_name)
  Branch.new(client, self, branch_name)
end

#ready?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/microclimate/repository.rb', line 29

def ready?
  !last_snapshot.nil?
end

#refresh!Object

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



23
24
25
26
27
# File 'lib/microclimate/repository.rb', line 23

def refresh!
  output = connection.post resource_refresh_url, :api_token => api_token
  json = output.body
  Response.new JSON.parse(json)
end

#statusObject



33
34
35
36
37
# File 'lib/microclimate/repository.rb', line 33

def status
  output = connection.get resource_url, :api_token => api_token
  json = output.body
  Response.new JSON.parse(json)
end

#www_urlObject



43
44
45
# File 'lib/microclimate/repository.rb', line 43

def www_url
  "https://codeclimate.com/repos/#{repo_id}"
end