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 50 def display_app(app,cartridges = nil,scalable_cart = nil) heading = "%s @ %s" % [app.name, app.app_url] paragraph do header heading do display_app_properties(app,:creation_time,:uuid,:gear_profile,:git_url,:ssh_url,:aliases) display_included_carts(cartridges) if cartridges display_scaling_info(app,scalable_cart) if scalable_cart end end end
# File lib/rhc/output_helpers.rb, line 61 def display_app_properties(app,*properties) say_table "Application Info", get_properties(app,*properties), :delete => true end
# File lib/rhc/output_helpers.rb, line 99 def display_cart(cart,properties = nil) @table_displayed = false header cart.name do display_cart_properties(cart,properties) if properties display_cart_scaling_info(cart) if cart.scalable? # Commenting this out for US2438 # display_cart_storage_info(cart) if cart.additional_gear_storage > 0 display_no_info("cartridge") unless @table_displayed end end
# File lib/rhc/output_helpers.rb, line 110 def display_cart_properties(cart,properties) # We need to actually access the cart because it's not a simple hash properties = get_properties(cart,*properties.keys) do |prop| cart.property(:cart_data,prop)["value"] end say_table "Properties", properties end
# File lib/rhc/output_helpers.rb, line 121 def display_cart_scaling_info(cart) say_table "Scaling Info", get_properties(cart,:current_scale,:scales_from,:scales_to) end
This is a little different because we don't want to recreate the #display_app function
# File lib/rhc/output_helpers.rb, line 38 def display_domain(domain) say "No domain exists. You can use 'rhc domain create' to create a namespace for applications." and return unless domain header "Applications in %s" % domain.id do domain.applications.each do |a| display_app(a,a.cartridges,a.scalable_carts.first) end.blank? and say "No applications. You can use 'rhc app create' to create new applications." end end
# File lib/rhc/output_helpers.rb, line 68 def display_included_carts(carts) properties = Hash[carts.map do |cart| [cart.name,cart.connection_info] end] properties = "None" unless properties.present? say_table "Cartridges", properties, :preserve_keys => true end
# Commenting this out for US2438
def display_cart_storage_info(cart, title="Storage Info") say_table title, get_properties(cart,:base_gear_storage,:additional_gear_storage) end 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 147 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 display_scaling_info(app,cart) # Save these values for easier reuse values = [:current_scale,:scales_from,:scales_to,:scales_with] # Get the scaling properties we care about properties = get_properties(cart,*values) # Format the string for applications properties = "Scaled x%d (minimum: %s, maximum: %s) with %s on %s gears" % [properties.values_at(*values), app.gear_profile].flatten say_table "Scaling Info", properties 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 29 def issues? not @issues.nil? end