Class: Lighthouse::Account

Inherits:
Object
  • Object
show all
Includes:
Buildmeister::JSONUtils
Defined in:
lib/lighthouse/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Buildmeister::JSONUtils

#with_json_response

Constructor Details

#initialize(name, token) ⇒ Account

Returns a new instance of Account.



9
10
11
12
13
14
15
16
# File 'lib/lighthouse/account.rb', line 9

def initialize(name, token)
  @name  = name
  @token = token

  @url = "https://#{name}.lighthouseapp.com"

  @resource = create_resource(@url, @token)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/lighthouse/account.rb', line 7

def name
  @name
end

#resourceObject

Returns the value of attribute resource.



7
8
9
# File 'lib/lighthouse/account.rb', line 7

def resource
  @resource
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/lighthouse/account.rb', line 7

def token
  @token
end

Instance Method Details

#find_projects(*names) ⇒ Object



29
30
31
# File 'lib/lighthouse/account.rb', line 29

def find_projects(*names)
  projects.select { |p| names.include?(p.name) }
end

#projectsObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/lighthouse/account.rb', line 18

def projects
  with_json_response( projects_resource.get(accept: 'json') ) do |response|
    response['projects'].map do |p|
      attrs = p['project']
      id    = attrs['id']

      Lighthouse::Project.new(resource["projects/#{id}"], attrs)
    end.tap { |p| p.extend Buildmeister::Finder }
  end
end