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.



252
253
254
255
256
257
# File 'lib/cfoundry/v2/app.rb', line 252

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.



250
251
252
# File 'lib/cfoundry/v2/app.rb', line 250

def app
  @app
end

#idObject (readonly)

Returns the value of attribute id.



250
251
252
# File 'lib/cfoundry/v2/app.rb', line 250

def id
  @id
end

Instance Method Details

#consoleObject



280
281
282
283
284
285
286
# File 'lib/cfoundry/v2/app.rb', line 280

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

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

#debuggerObject



272
273
274
275
276
277
278
# File 'lib/cfoundry/v2/app.rb', line 272

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

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

#file(*path) ⇒ Object



303
304
305
# File 'lib/cfoundry/v2/app.rb', line 303

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

#files(*path) ⇒ Object



297
298
299
300
301
# File 'lib/cfoundry/v2/app.rb', line 297

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)


288
289
290
291
292
293
294
295
# File 'lib/cfoundry/v2/app.rb', line 288

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

#inspectObject



259
260
261
# File 'lib/cfoundry/v2/app.rb', line 259

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

#sinceObject



268
269
270
# File 'lib/cfoundry/v2/app.rb', line 268

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

#stateObject Also known as: status



263
264
265
# File 'lib/cfoundry/v2/app.rb', line 263

def state
  @manifest[:state]
end