lib/hu/scale.rb in hu-1.5.11 vs lib/hu/scale.rb in hu-1.5.12

- old
+ new

@@ -10,56 +10,68 @@ sleeps: true, pro: false, ram: 512, cpu: 1, dedicated: false, - usd: 0 + usd: 0, + letter: 'f', + color: "\e[0;32;1m", }, { id: 'hobby', sleeps: false, pro: false, ram: 512, cpu: 1, dedicated: false, - usd: 7 + usd: 7, + letter: 'H', + color: "\e[0;32m", }, { id: 'standard-1x', sleeps: false, pro: true, ram: 512, cpu: 1, dedicated: false, - usd: 25 + usd: 25, + letter: '1', + color: "\e[0;33m", }, { id: 'standard-2x', sleeps: false, pro: true, ram: 1024, cpu: 4, dedicated: false, - usd: 50 + usd: 50, + letter: '2', + color: "\e[0;33;1m", }, { id: 'performance-m', sleeps: false, pro: true, ram: 2560, cpu: 11, dedicated: true, - usd: 250 + usd: 250, + letter: 'M', + color: "\e[0;31;1m", }, { id: 'performance-l', sleeps: false, pro: true, ram: 14_336, cpu: 46, dedicated: true, - usd: 500 + usd: 500, + letter: 'L', + color: "\e[0;35;1m", } ].freeze DYNO_TYPES.each_with_index do |dt, i| dt[:index] = i @@ -106,11 +118,11 @@ total_cost = 0 max_app_name_len = state.keys.reduce(0) { |a, e| [a, e.length].max } state.sort.each do |app_name, dyno_types| next if ignored_app?(app_name) - row = { 'app' => app_name, 'fH12ML' => '......', 'formation' => "heroku ps:scale -a #{app_name.ljust(max_app_name_len).color(:green).bright}" } + row = { 'app' => app_name, 'fH12ML' => '......', 'formation' => "\e[0mheroku ps:scale -a #{app_name.ljust(max_app_name_len).color(:green).bright}" } cost = 0 dyno_types.each do |dyno_type, dynos| dynos.each do |dyno| row = Marshal.load(Marshal.dump(row)) dyno_type_str = dyno[:type] @@ -119,15 +131,21 @@ dyno_type_str = dyno_type_str.color(:black).bright quant_colon_type = quant_colon_type.color(:black).bright else dyno_type_str = dyno_type_str.color(:yellow) quant_colon_type = quant_colon_type.color(:yellow) - row['fH12ML'][DYNO_TYPES.find { |e| e[:id] == dyno_type }[:index]] = '*' + idx = DYNO_TYPES.find { |e| e[:id] == dyno_type }[:index] + row['fH12ML'][idx] = 'fH12ML'[idx] end row['formation'] += " #{dyno_type_str}" + '='.color(:black).bright + quant_colon_type.to_s cost += DYNO_TYPES.find { |e| e[:id] == dyno_type }[:usd] * dyno[:quantity] end end + new_row = ''.dup + row['fH12ML'].each_char do |l| + new_row << (DYNO_TYPES.find {|dt| dt[:letter] == l}[:color] + l + "\e[0;30;1m" rescue '.') + end + row['fH12ML'] = "\e[0;30;1m"+new_row total_cost += cost row['$/mo'] = format '%4d', cost rows << row end