Sha256: 2f87346be0c67b90d0db869d841df88f6111de7cc80e57f39c815ecdbb2f21d0

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

# nodoc #
module Skunk
  module Command
    # Knows how to describe score evolution between two branches
    class CompareScore
      def initialize(base_branch, feature_branch, base_branch_score, feature_branch_score)
        @base_branch = base_branch
        @feature_branch = feature_branch
        @base_branch_score = base_branch_score
        @feature_branch_score = feature_branch_score
      end

      def message
        "Base branch (#{@base_branch}) "\
          "average skunk score: #{@base_branch_score} \n"\
          "Feature branch (#{@feature_branch}) "\
          "average skunk score: #{@feature_branch_score} \n"\
          "#{score_evolution_message}"
      end

      def score_evolution_message
        "Skunk score average is #{score_evolution} #{score_evolution_appreciation} \n"
      end

      def score_evolution_appreciation
        @feature_branch_score > @base_branch_score ? "worse" : "better"
      end

      def score_evolution
        return "Infinitely" if @base_branch_score.zero?

        precentage = (100 * (@base_branch_score - @feature_branch_score) / @base_branch_score)
        "#{precentage.round(0).abs}%"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
skunk-0.5.3 lib/skunk/commands/compare_score.rb
skunk-0.5.0 lib/skunk/cli/commands/compare_score.rb