# File lib/rhc/output_helpers.rb, line 138 def default_display_env_var(env_var_name, env_var_value=nil) info "#{env_var_name}#{env_var_value.nil? ? '' : '=' + env_var_value}" end
# File lib/rhc/output_helpers.rb, line 27 def display_app(app,cartridges = nil) paragraph do header [app.name, "@ #{app.app_url}", "(uuid: #{app.uuid})"] do section(:bottom => 1) do say format_table nil, get_properties( app, :domain, :creation_time, :gear_info, :git_url, :initial_git_url, :ssh_string, :aliases ), :delete => true end cartridges.each{ |c| section(:bottom => 1){ display_cart(c) } } if cartridges end end end
# File lib/rhc/output_helpers.rb, line 81 def display_cart(cart, *properties) say format_table format_cart_header(cart), get_properties(cart, *properties). concat([[:downloaded_cartridge_url, cart.url]]). 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] }). concat(cart.environment_variables.present? ? [[:environment_variables, cart.environment_variables.map{|item| "#{item[:name]}=#{item[:value]}" }.sort.join(', ')]] : []), :delete => true say format_usage_message(cart) if cart.usage_rate? end
# File lib/rhc/output_helpers.rb, line 124 def display_cart_storage_info(cart, title="Storage Info") say format_table title, get_properties(cart,:base_gear_storage,:additional_gear_storage) end
# File lib/rhc/output_helpers.rb, line 130 def display_cart_storage_list(carts) carts.each{ |cart| paragraph{ display_cart_storage_info(cart, cart.display_name) } } end
# File lib/rhc/output_helpers.rb, line 4 def display_domain(domain, applications=nil) paragraph do header ["Domain #{domain.id}", ("(owned by #{domain.owner})" if domain.owner.present?)] do section(:bottom => 1) do say format_table nil, get_properties( domain, :creation_time, :allowed_gear_sizes ), :delete => true end applications.each do |a| display_app(a,a.cartridges) end if applications.present? end end end
# File lib/rhc/output_helpers.rb, line 142 def display_env_var_list(env_vars, opts={}) if env_vars.present? if opts[:table] say table(env_vars.collect{ |item| [item.name, opts[:quotes] ? "\"#{item.value}\"" : item.value] }, :header => ['Name', 'Value']) else env_vars.sort.each do |env_var| default_display_env_var(env_var.name, opts[:quotes] ? "\"#{env_var.value}\"" : env_var.value) end end end end
# File lib/rhc/output_helpers.rb, line 94 def display_key(key, *properties) properties = [:fingerprint, :visible_to_ssh?] if properties.empty? say format_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 62 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 50 def format_cart_header(cart) [ cart.name, cart.name != cart.display_name ? "(#{cart.display_name})" : nil, ].compact end
# File lib/rhc/output_helpers.rb, line 72 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 117 def format_key_header(key) [ key.name, "(type: #{key.type})", ].compact end
# File lib/rhc/output_helpers.rb, line 57 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 134 def format_usage_message(cart) "This gear costs an additional $#{cart.usage_rate} per gear after the first 3 gears." end