Issues collector collects a set of recoverable issues and steps to fix them for output at the end of a complex command
# File lib/rhc/output_helpers.rb, line 5 def add_issue(reason, commands_header, *commands) @issues ||= [] issue = {:reason => reason, :commands_header => commands_header, :commands => commands} @issues << issue end
# File lib/rhc/output_helpers.rb, line 36 def display_app(app,cartridges = nil) heading = "%s @ %s (uuid: %s)" % [app.name, app.app_url, app.uuid] paragraph do header heading do section(:bottom => 1) do display_app_properties( app, :creation_time, :gear_info, :git_url, :initial_git_url, :ssh_string, :aliases) end display_included_carts(cartridges) if cartridges end end end
# File lib/rhc/output_helpers.rb, line 55 def display_app_properties(app,*properties) say_table nil, get_properties(app,*properties), :delete => true end
# File lib/rhc/output_helpers.rb, line 99 def display_cart(cart, *properties) @table_displayed = false say_table format_cart_header(cart), get_properties(cart, *properties). concat([[cart.scalable? ? :scaling : :gears, format_cart_gears(cart)]]). concat(cart.properties.map{ |p| ["#{table_heading(p['name'])}:", p['value']] }.sort{ |a,b| a[0] <=> b[0] }), :delete => true display_no_info("cartridge") unless @table_displayed if cart.usage_rate? say "\n" say format_usage_message(cart) end end
# File lib/rhc/output_helpers.rb, line 146 def display_cart_storage_info(cart, title="Storage Info") say_table title, get_properties(cart,:base_gear_storage,:additional_gear_storage) end
# File lib/rhc/output_helpers.rb, line 152 def display_cart_storage_list(carts) carts.each do |cart| puts display_cart_storage_info(cart, cart.display_name) end end
# File lib/rhc/output_helpers.rb, line 62 def display_included_carts(carts) carts.each do |c| section(:bottom => 1) do display_cart(c) end end end
# File lib/rhc/output_helpers.rb, line 116 def display_key(key, *properties) properties = [:fingerprint, :visible_to_ssh?] if properties.empty? say_table( properties.include?(:name) ? nil : format_key_header(key), get_properties(key, *properties), { :delete => true, :color => (:green if properties.include?(:visible_to_ssh?) && key.visible_to_ssh?), } ) end
# File lib/rhc/output_helpers.rb, line 167 def display_no_info(type) say_table nil, [["This #{type} has no information to show"]] end
# File lib/rhc/output_helpers.rb, line 81 def format_cart_gears(cart) if cart.scalable? format_scaling_info(cart.scaling) elsif cart.shares_gears? "Located with #{cart.collocated_with.join(", ")}" else "%d %s" % [format_value(:current_scale, cart.current_scale), format_value(:gear_profile, cart.gear_profile)] end end
# File lib/rhc/output_helpers.rb, line 70 def format_cart_header(cart) [ cart.name, cart.name != cart.display_name ? "(#{cart.display_name})" : nil, ].compact.join(' ') end
# File lib/rhc/output_helpers.rb, line 90 def format_gear_info(info) "%d (defaults to %s)" % [:gear_count, :gear_profile].map{ |key| format_value(key, info[key]) } if info end
# File lib/rhc/output_helpers.rb, line 13 def format_issues(indent) return nil unless issues? indentation = " " * indent reasons = "" steps = "" @issues.each_with_index do |issue, i| reasons << "#{indentation}#{i+1}. #{issue[:reason].strip}\n" steps << "#{indentation}#{i+1}. #{issue[:commands_header].strip}\n" issue[:commands].each { |cmd| steps << "#{indentation} $ #{cmd}\n" } end [reasons, steps] end
# File lib/rhc/output_helpers.rb, line 139 def format_key_header(key) [ key.name, "(type: #{key.type})", ].compact.join(' ') end
# File lib/rhc/output_helpers.rb, line 77 def format_scaling_info(scaling) "x%d (minimum: %s, maximum: %s) on %s gears" % [:current_scale, :scales_from, :scales_to, :gear_profile].map{ |key| format_value(key, scaling[key]) } if scaling end
# File lib/rhc/output_helpers.rb, line 159 def format_usage_message(cart) "This gear costs an additional $#{cart.usage_rate} per gear after the first 3 gears." end
# File lib/rhc/output_helpers.rb, line 29 def issues? not @issues.nil? end