Class: CFoundry::V2::App::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/cfoundry/v2/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, id, client, manifest = {}) ⇒ Instance

Returns a new instance of Instance.



330
331
332
333
334
335
# File 'lib/cfoundry/v2/app.rb', line 330

def initialize(app, id, client, manifest = {})
  @app = app
  @id = id
  @client = client
  @manifest = manifest
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



328
329
330
# File 'lib/cfoundry/v2/app.rb', line 328

def app
  @app
end

#idObject (readonly)

Returns the value of attribute id.



328
329
330
# File 'lib/cfoundry/v2/app.rb', line 328

def id
  @id
end

Instance Method Details

#consoleObject



360
361
362
363
364
365
366
# File 'lib/cfoundry/v2/app.rb', line 360

def console
  return unless @manifest[:console_ip] and @manifest[:console_port]

  { :ip => @manifest[:console_ip],
    :port => @manifest[:console_port]
  }
end

#debuggerObject



352
353
354
355
356
357
358
# File 'lib/cfoundry/v2/app.rb', line 352

def debugger
  return unless @manifest[:debug_ip] and @manifest[:debug_port]

  { :ip => @manifest[:debug_ip],
    :port => @manifest[:debug_port]
  }
end

#file(*path) ⇒ Object



383
384
385
# File 'lib/cfoundry/v2/app.rb', line 383

def file(*path)
  @client.base.files(@app.guid, @id, *path)
end

#files(*path) ⇒ Object



377
378
379
380
381
# File 'lib/cfoundry/v2/app.rb', line 377

def files(*path)
  @client.base.files(@app.guid, @id, *path).split("\n").collect do |entry|
    path + [entry.split(/\s+/, 2)[0]]
  end
end

#healthy?Boolean

Returns:

  • (Boolean)


368
369
370
371
372
373
374
375
# File 'lib/cfoundry/v2/app.rb', line 368

def healthy?
  case state
  when "STARTING", "RUNNING"
    true
  when "DOWN", "FLAPPING"
    false
  end
end

#inspectObject



337
338
339
# File 'lib/cfoundry/v2/app.rb', line 337

def inspect
  "#<App::Instance '#{@app.name}' \##@id>"
end

#sinceObject



346
347
348
349
350
# File 'lib/cfoundry/v2/app.rb', line 346

def since
  if since = @manifest[:since]
    Time.at(@manifest[:since])
  end
end

#stateObject Also known as: status



341
342
343
# File 'lib/cfoundry/v2/app.rb', line 341

def state
  @manifest[:state]
end

#stream_file(*path, &blk) ⇒ Object



387
388
389
# File 'lib/cfoundry/v2/app.rb', line 387

def stream_file(*path, &blk)
  @client.base.stream_file(@app.guid, @id, *path, &blk)
end