Module: CC::Service::QualityHelper
- Included in:
- Slack
- Defined in:
- lib/cc/helpers/quality_helper.rb
Instance Method Summary collapse
- #constant_basename(name) ⇒ Object
- #constant_name ⇒ Object
- #improved? ⇒ Boolean
- #previous_rating ⇒ Object
- #previous_remediation_cost ⇒ Object
- #quality_title ⇒ Object
- #rating ⇒ Object
- #remediation_cost ⇒ Object
- #with_article(letter, bold = false) ⇒ Object
Instance Method Details
#constant_basename(name) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/cc/helpers/quality_helper.rb', line 45 def constant_basename(name) if name.include?(".") File.basename(name) else name end end |
#constant_name ⇒ Object
6 7 8 |
# File 'lib/cc/helpers/quality_helper.rb', line 6 def constant_name payload["constant_name"] end |
#improved? ⇒ Boolean
2 3 4 |
# File 'lib/cc/helpers/quality_helper.rb', line 2 def improved? remediation_cost < previous_remediation_cost end |
#previous_rating ⇒ Object
22 23 24 |
# File 'lib/cc/helpers/quality_helper.rb', line 22 def with_article(payload["previous_rating"]) end |
#previous_remediation_cost ⇒ Object
30 31 32 |
# File 'lib/cc/helpers/quality_helper.rb', line 30 def previous_remediation_cost payload.fetch("previous_remediation_cost", 0) end |
#quality_title ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cc/helpers/quality_helper.rb', line 10 def quality_title if payload["rating"].present? "Refactor #{constant_name} from #{} on Code Climate" else "Refactor #{constant_name} on Code Climate" end end |
#rating ⇒ Object
18 19 20 |
# File 'lib/cc/helpers/quality_helper.rb', line 18 def with_article(payload["rating"]) end |
#remediation_cost ⇒ Object
26 27 28 |
# File 'lib/cc/helpers/quality_helper.rb', line 26 def remediation_cost payload.fetch("remediation_cost", 0) end |
#with_article(letter, bold = false) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cc/helpers/quality_helper.rb', line 34 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 |