Class: Buildbox::API

Inherits:
Object
  • Object
show all
Defined in:
lib/buildbox/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = Buildbox.config) ⇒ API

Returns a new instance of API.



8
9
10
# File 'lib/buildbox/api.rb', line 8

def initialize(config = Buildbox.config)
  @config  = config
end

Instance Method Details

#agent(access_token, hostname) ⇒ Object



17
18
19
# File 'lib/buildbox/api.rb', line 17

def agent(access_token, hostname)
  put("agents/#{access_token}", :hostname => hostname)
end

#authenticate(api_key) ⇒ Object



12
13
14
15
# File 'lib/buildbox/api.rb', line 12

def authenticate(api_key)
  @api_key = api_key
  get("user")
end

#scheduled_builds(project) ⇒ Object



21
22
23
# File 'lib/buildbox/api.rb', line 21

def scheduled_builds(project)
  get(project.scheduled_builds_url).map { |build| Buildbox::Build.new(build) }
end

#update_build(build) ⇒ Object



25
26
27
28
29
30
# File 'lib/buildbox/api.rb', line 25

def update_build(build)
  put(build.url, :started_at  => build.started_at,
                 :finished_at => build.finished_at,
                 :output      => build.output,
                 :exit_status => build.exit_status)
end