Class: JFoundry::V2::App::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/jfoundry/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.



315
316
317
318
319
320
321
# File 'lib/jfoundry/v2/app.rb', line 315

def initialize(app, id, client, manifest = {})
  @app = app
  @id = id
  @client = client
  @manifest = manifest
  puts "-------->#{manifest}"
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



313
314
315
# File 'lib/jfoundry/v2/app.rb', line 313

def app
  @app
end

#idObject (readonly)

Returns the value of attribute id.



313
314
315
# File 'lib/jfoundry/v2/app.rb', line 313

def id
  @id
end

Instance Method Details

#consoleObject



350
351
352
353
354
355
356
# File 'lib/jfoundry/v2/app.rb', line 350

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

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

#debuggerObject



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

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

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

#file(*path) ⇒ Object



373
374
375
# File 'lib/jfoundry/v2/app.rb', line 373

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

#files(*path) ⇒ Object



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

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)


358
359
360
361
362
363
364
365
# File 'lib/jfoundry/v2/app.rb', line 358

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

#inspectObject



323
324
325
# File 'lib/jfoundry/v2/app.rb', line 323

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

#remarkObject



338
339
340
# File 'lib/jfoundry/v2/app.rb', line 338

def remark
  @manifest[:remark]
end

#sinceObject



332
333
334
335
336
# File 'lib/jfoundry/v2/app.rb', line 332

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

#stateObject Also known as: status



327
328
329
# File 'lib/jfoundry/v2/app.rb', line 327

def state
  @manifest[:state]
end

#stream_file(*path, &blk) ⇒ Object



377
378
379
# File 'lib/jfoundry/v2/app.rb', line 377

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