Sha256: def6ce080f84d8e8026f5cc52c635afa211890d902be2ab15c8e6ab50dd87e88
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
module Troo module Commands class Status class << self # @param [] # @return [String] def dispatch(klass) new(klass).report_status end end # @param [] # @return [Troo::Commands::Status] def initialize(klass) @klass = klass end # @return [String] def report_status return success if resource error end private attr_reader :klass def success label + plural + " found.\n" + resource_title end def error if count > 0 label + no_default_error + " (#{count})" else label + "No #{type}s found.\n" end end def label " #{type.capitalize}s:".ljust(10) end def resource_title ''.rjust(10) + resource.decorator.title end def no_default_error Esc.red + "No default #{type} set." + Esc.reset end def plural if count == 1 "#{count} #{type}" else "#{count} #{type}s" end end def type klass.type.to_s end def resource @resource ||= klass.default end def count @count ||= klass.count end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
troo-0.0.15 | lib/troo/cli/commands/status.rb |
troo-0.0.14 | lib/troo/cli/commands/status.rb |