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.



343
344
345
346
347
348
# File 'lib/cfoundry/v2/app.rb', line 343

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.



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

def app
  @app
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

#consoleObject



373
374
375
376
377
378
379
# File 'lib/cfoundry/v2/app.rb', line 373

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

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

#debuggerObject



365
366
367
368
369
370
371
# File 'lib/cfoundry/v2/app.rb', line 365

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

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

#file(*path) ⇒ Object



396
397
398
# File 'lib/cfoundry/v2/app.rb', line 396

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

#files(*path) ⇒ Object



390
391
392
393
394
# File 'lib/cfoundry/v2/app.rb', line 390

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)


381
382
383
384
385
386
387
388
# File 'lib/cfoundry/v2/app.rb', line 381

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

#inspectObject



350
351
352
# File 'lib/cfoundry/v2/app.rb', line 350

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

#sinceObject



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

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

#stateObject Also known as: status



354
355
356
# File 'lib/cfoundry/v2/app.rb', line 354

def state
  @manifest[:state]
end

#stream_file(*path, &blk) ⇒ Object



400
401
402
# File 'lib/cfoundry/v2/app.rb', line 400

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