Class: SilverSpurs::BootstrapRun

Inherits:
Object
  • Object
show all
Defined in:
lib/silver_spurs/client/bootstrap_run.rb

Instance Method Summary collapse

Constructor Details

#initialize(async_url, options = {}) ⇒ BootstrapRun

Returns a new instance of BootstrapRun.



6
7
8
9
# File 'lib/silver_spurs/client/bootstrap_run.rb', line 6

def initialize(async_url, options={})
  @async_url = async_url
  @timeout = options[:timeout] || 2 * 60
end

Instance Method Details

#logObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/silver_spurs/client/bootstrap_run.rb', line 28

def log
  response = RestClient.get @async_url, &method(:no_exception_for_550)
  
  case response.code
  when 201, 202, 550
    response.body
  when 404
    throw ClientException.new("the server doesn't know anything about this knife run", response)
  else
    throw ClientException.new("unexpected response", response)
  end
end

#statusObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/silver_spurs/client/bootstrap_run.rb', line 11

def status
  response = RestClient.head @async_url, &method(:no_exception_for_550)
  
  case response.code
  when 201
    :success
  when 202
    :processing
  when 550
    :failed
  when 404
    throw ClientException.new("the server doesn't know anything about this knife run", response)
  else
    throw ClientException.new("unexpected response", response)
  end
end