class CfScript::Command::Apps::AppsCommand

Constants

APPS_TABLE
NO_APPS_FOUND

Public Class Methods

new() click to toggle source
Calls superclass method CfScript::Command::Base::new
# File lib/cf_script/command/cf/apps/apps.rb, line 14
def initialize
  super(:apps, :apps)
end

Public Instance Methods

run(options = {}) { |list| ... } click to toggle source
# File lib/cf_script/command/cf/apps/apps.rb, line 18
def run(options = {}, &block)
  run_cf self do |output|
    blank_list = CfScript::AppList.new

    return blank_list unless good_run?(output)
    return blank_list if output.contains? NO_APPS_FOUND

    if rows = output.table(APPS_TABLE)
      list = build_app_list(rows)

      block_given? ? yield(list) : list
    else
      error 'rows is nil'
      return blank_list
    end
  end
end

Private Instance Methods

build_app_list(rows) click to toggle source
# File lib/cf_script/command/cf/apps/apps.rb, line 38
def build_app_list(rows)
  apps = rows.map do |row|
    CfScript::AppInfo.new(row[:name].value, row)
  end

  CfScript::AppList.new(apps)
end