lib/inch/cli/command/output/stats.rb in inch-0.4.10 vs lib/inch/cli/command/output/stats.rb in inch-0.5.0.rc1

- old
+ new

@@ -1,7 +1,7 @@ -require "json" -require "yaml" +require 'json' +require 'yaml' module Inch module CLI module Command module Output @@ -9,14 +9,14 @@ include SparklineHelper attr_reader :objects PRIORITY_COLORS = [ - [213, 212, 211, 210, 210, 209, 209], - [177], - [203, 203, 204, 204, 205, 206, 207] - ].flatten.map { |s| :"color#{s}" } + [213,212,211,210,210,209,209], + [177], + [203, 203, 204, 204, 205, 206, 207] + ].flatten.map { |s| :"color#{s}" } def initialize(options, objects, grade_lists) @options = options @objects = objects @grade_lists = grade_lists @@ -29,30 +29,29 @@ def display_text print_grades print_grades_by_priority print_priorities puts - puts "Try `--format json|yaml` for raw numbers.".dark + puts 'Try `--format json|yaml` for raw numbers.'.dark end def print_grades - sparkline = grade_lists_sparkline(@grade_lists).to_s(" ") + sparkline = grade_lists_sparkline(@grade_lists).to_s(' ') puts - puts "Grade distribution: (undocumented, C, B, A)" + puts 'Grade distribution: (undocumented, C, B, A)' puts - puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} " \ - "objects" + puts " Overall: #{sparkline} #{objects.size.to_s.rjust(5)} objects" puts end def print_grades_by_priority - puts "Grade distribution by priority:" + puts 'Grade distribution by priority:' puts Evaluation::PriorityRange.all.each do |priority_range| list = objects.select { |o| priority_range.include?(o.priority) } - sparkline = grades_sparkline(list).to_s(" ") - puts " #{priority_range.arrow} #{sparkline} " \ + sparkline = grades_sparkline(list).to_s(' ') + puts " #{priority_range.arrow} #{sparkline} " + "#{list.size.to_s.rjust(5)} objects" puts end end @@ -63,23 +62,23 @@ (-7..7).each do |key| priorities[key.to_s] = list.select { |p| p == key }.size end sparkline = Sparkr::Sparkline.new(priorities.values) - sparkline.format do |tick, _count, index| - tick.color(PRIORITY_COLORS[index]) + sparkline.format do |tick, count, index| + tick.color( PRIORITY_COLORS[index] ) end - puts " #{grade_list.grade}: " + sparkline.to_s(" ") + + puts " #{grade_list.grade}: " + sparkline.to_s(' ') + " #{grade_list.objects.size.to_s.rjust(5)} objects" puts end def print_priorities arrows = Evaluation::PriorityRange.all.map(&:arrow) puts "Priority distribution in grades: (low to high)" puts - puts " #{arrows.reverse.join(" ")}" + puts " #{arrows.reverse.join(' ')}" @grade_lists.reverse.each do |grade_list| print_grade_list(grade_list) end end @@ -91,13 +90,13 @@ puts YAML.dump(stats_hash) end def stats_hash { - "grade_lists" => __grade_lists, - "scores" => __scores, - "priorities" => __priorities + 'grade_lists' => __grade_lists, + 'scores' => __scores, + 'priorities' => __priorities } end def __grade_lists hash = {} @@ -122,9 +121,10 @@ hash[o.priority.to_i] ||= 0 hash[o.priority.to_i] += 1 end hash end + end end end end end