Module: CC::Service::QualityHelper

Included in:
Slack
Defined in:
lib/cc/helpers/quality_helper.rb

Instance Method Summary collapse

Instance Method Details

#constant_basename(name) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/cc/helpers/quality_helper.rb', line 37

def constant_basename(name)
  if name.include?(".")
    File.basename(name)
  else
    name
  end
end

#constant_nameObject



6
7
8
# File 'lib/cc/helpers/quality_helper.rb', line 6

def constant_name
  payload["constant_name"]
end

#improved?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/cc/helpers/quality_helper.rb', line 2

def improved?
  remediation_cost < previous_remediation_cost
end

#previous_ratingObject



14
15
16
# File 'lib/cc/helpers/quality_helper.rb', line 14

def previous_rating
  with_article(payload["previous_rating"])
end

#previous_remediation_costObject



22
23
24
# File 'lib/cc/helpers/quality_helper.rb', line 22

def previous_remediation_cost
  payload.fetch("previous_remediation_cost", 0)
end

#ratingObject



10
11
12
# File 'lib/cc/helpers/quality_helper.rb', line 10

def rating
  with_article(payload["rating"])
end

#remediation_costObject



18
19
20
# File 'lib/cc/helpers/quality_helper.rb', line 18

def remediation_cost
  payload.fetch("remediation_cost", 0)
end

#with_article(letter, bold = false) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/cc/helpers/quality_helper.rb', line 26

def with_article(letter, bold = false)
  letter ||= '?'

  text = bold ? "*#{letter}*" : letter
  if %w( A F ).include?(letter.to_s)
    "an #{text}"
  else
    "a #{text}"
  end
end