Class: StackFu::Commands::ListCommand

Inherits:
Command
  • Object
show all
Extended by:
DateHelper
Includes:
ApiHooks
Defined in:
lib/stackfu/commands/list_command.rb

Constant Summary collapse

TableAttributes =
{
  Server => [
    [:name, :key, :ip, :verified, :last_seen],
    lambda do |item| 
      last_seen = item.last_checked_in if item.respond_to?(:last_checked_in)
      
      if last_seen
        last_seen = distance_of_time_in_words(Time.now, Time.parse(last_seen))
        last_seen = "#{last_seen} ago"
        validated = "yes"
      else
        last_seen = "- never -"
        validated = ""
      end
      
      ip = item.respond_to?(:ip) ? item.ip : ""
      
      [item.slug, item._id, ip, validated, last_seen]
    end,
    "You have no servers yet. You can add new servers to your account in http://stackfu.com."
  ],
  Script => [
    [:name, :description],
    lambda { |item| [item.name, (item.description || "").truncate_words(10)] },
    "You have nothing to list yet. To generate a new script, use the 'stackfu generate' command."
  ]
}

Constants included from Rendering

Rendering::LEFT_MARGIN

Constants included from OperatingSystems

OperatingSystems::FriendlyNames, OperatingSystems::OperatingSystems

Instance Attribute Summary

Attributes inherited from Command

#errors, #options, #parameters, #subcommand

Instance Method Summary collapse

Methods included from DateHelper

display_time_in_words, distance_of_time, distance_of_time_hash, distance_of_time_in_percent, distance_of_time_in_words, distance_of_time_in_words_hash

Methods included from ApiHooks

#initialize_api

Methods inherited from Command

#command, command_for, create, inherited, #initialize, #params?, #run, #valid?

Methods included from Rendering

#done, #error, #fill_values_from_options, #menu_for, #render_target, #spinner, #table, #warning

Methods included from OperatingSystems

#convert_os, #os_name

Constructor Details

This class inherits a constructor from StackFu::Commands::Command

Instance Method Details

#default(parameters, options) ⇒ Object



50
51
52
# File 'lib/stackfu/commands/list_command.rb', line 50

def default(parameters, options)
  list [Script, Server]
end

#scripts(parameters, options) ⇒ Object



46
47
48
# File 'lib/stackfu/commands/list_command.rb', line 46

def scripts(parameters, options)
  list Script
end

#servers(parameters, options) ⇒ Object



42
43
44
# File 'lib/stackfu/commands/list_command.rb', line 42

def servers(parameters, options)
  list Server
end