Class: Lighthouse::Account
- Inherits:
-
Object
- Object
- Lighthouse::Account
- Includes:
- Buildmeister::JSONUtils
- Defined in:
- lib/lighthouse/account.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #find_projects(*names) ⇒ Object
-
#initialize(name, token) ⇒ Account
constructor
A new instance of Account.
- #projects ⇒ Object
Methods included from Buildmeister::JSONUtils
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
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/lighthouse/account.rb', line 7 def name @name end |
#resource ⇒ Object
Returns the value of attribute resource.
7 8 9 |
# File 'lib/lighthouse/account.rb', line 7 def resource @resource end |
#token ⇒ Object
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 |
#projects ⇒ Object
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 |