Sha256: 4a30200fc23c15726efaf070501673868535467ab33a4eddb488bc78cbff925f

Contents?: true

Size: 885 Bytes

Versions: 34

Compression:

Stored size: 885 Bytes

Contents

module Inch
  module CLI
    module SparklineHelper
      def grade_lists_sparkline(grade_lists)
        new_grade_lists = grade_lists.reverse
        list = new_grade_lists.map { |r| r.objects.size }
        __sparkline(list, new_grade_lists)
      end

      def grades_sparkline(objects)
        grades = {}
        objects.each do |o|
          grades[o.grade.to_sym] ||= 0
          grades[o.grade.to_sym] += 1
        end
        grade_lists = Evaluation.new_grade_lists.reverse
        order = grade_lists.map(&:to_sym)
        list = order.map { |g| grades[g] }
        __sparkline(list, grade_lists)
      end

      def __sparkline(list, grade_lists)
        sparkline = Sparkr::Sparkline.new(list)
        sparkline.format do |tick, _count, index|
          t = tick.color(grade_lists[index].color)
          index == 0 ? t + ' ' : t
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
inch-0.9.0.rc1 lib/inch/cli/sparkline_helper.rb
inch-0.8.0 lib/inch/cli/sparkline_helper.rb
inch-0.8.0.rc2 lib/inch/cli/sparkline_helper.rb
inch-0.8.0.rc1 lib/inch/cli/sparkline_helper.rb
inch-0.7.1 lib/inch/cli/sparkline_helper.rb
inch-0.7.0 lib/inch/cli/sparkline_helper.rb
inch-0.6.4 lib/inch/cli/sparkline_helper.rb
inch-0.6.3 lib/inch/cli/sparkline_helper.rb
inch-0.6.2 lib/inch/cli/sparkline_helper.rb
inch-0.6.1 lib/inch/cli/sparkline_helper.rb
inch-0.6.0 lib/inch/cli/sparkline_helper.rb
inch-0.6.0.rc6 lib/inch/cli/sparkline_helper.rb
inch-0.6.0.rc5 lib/inch/cli/sparkline_helper.rb
inch-0.6.0.rc4 lib/inch/cli/sparkline_helper.rb
inch-0.6.0.rc3 lib/inch/cli/sparkline_helper.rb
inch-0.6.0.rc2 lib/inch/cli/sparkline_helper.rb
inch-0.6.0.rc1 lib/inch/cli/sparkline_helper.rb
inch-0.5.10 lib/inch/cli/sparkline_helper.rb
inch-0.5.9 lib/inch/cli/sparkline_helper.rb
inch-0.5.8 lib/inch/cli/sparkline_helper.rb