module Lighthouse

Ruby lib for working with the Lighthouse API's XML interface.

The first thing you need to set is the account name. This is the same as the web address for your account.

Lighthouse.account = 'activereload'

Then, you should set the authentication. You can either use your login credentials with HTTP Basic Authentication or with an API Tokens. You can find more info on tokens at lighthouseapp.com/help/using-beacons.

# with basic authentication
Lighthouse.authenticate('rick@techno-weenie.net', 'spacemonkey')

# or, use a token
Lighthouse.token = 'abcdefg'

If no token or authentication info is given, you'll only be granted public access.

This library is a small wrapper around the REST interface. You should read the docs at lighthouseapp.com/api.

Attributes

account[RW]
domain_format[RW]
email[RW]
host_format[RW]
password[RW]
port[RW]
protocol[RW]
token[R]

Public Class Methods

authenticate(email, password) click to toggle source

Sets up basic authentication credentials for all the resources.

# File lib/lighthouse.rb, line 58
def authenticate(email, password)
  self.email    = email
  self.password = password
  
  resources.each do |klass|
    update_auth(klass)
  end
end
resources() click to toggle source
# File lib/lighthouse.rb, line 75
def resources
  @resources ||= []
end
token=(value) click to toggle source

Sets the API token for all the resources.

# File lib/lighthouse.rb, line 68
def token=(value)
  @token = value
  resources.each do |klass|
    update_token_header(klass)
  end
end
update_auth(resource) click to toggle source
# File lib/lighthouse.rb, line 87
def update_auth(resource)
  return unless email && password
  resource.user     = email
  resource.password = password
end
update_site(resource) click to toggle source
# File lib/lighthouse.rb, line 79
def update_site(resource)
  resource.site = resource.site_format % (host_format % [protocol, domain_format % account, ":#{port}"])
end
update_token_header(resource) click to toggle source
# File lib/lighthouse.rb, line 83
def update_token_header(resource)
  resource.headers['X-LighthouseToken'] = token if token
end