Class: Skunk::Command::CompareScore

Inherits:
Object
  • Object
show all
Defined in:
lib/skunk/commands/compare_score.rb

Overview

Knows how to describe score evolution between two branches

Instance Method Summary collapse

Constructor Details

#initialize(base_branch, feature_branch, base_branch_score, feature_branch_score) ⇒ CompareScore

Returns a new instance of CompareScore.



8
9
10
11
12
13
# File 'lib/skunk/commands/compare_score.rb', line 8

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

Instance Method Details

#messageObject



15
16
17
18
19
20
21
# File 'lib/skunk/commands/compare_score.rb', line 15

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

#score_evolutionObject



31
32
33
34
35
36
# File 'lib/skunk/commands/compare_score.rb', line 31

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

#score_evolution_appreciationObject



27
28
29
# File 'lib/skunk/commands/compare_score.rb', line 27

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

#score_evolution_messageObject



23
24
25
# File 'lib/skunk/commands/compare_score.rb', line 23

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