Class: Xcov::Base
- Inherits:
-
Object
- Object
- Xcov::Base
- Defined in:
- lib/xcov/model/base.rb
Instance Attribute Summary collapse
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#coverage_color ⇒ Object
Returns the value of attribute coverage_color.
-
#displayable_coverage ⇒ Object
Returns the value of attribute displayable_coverage.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .create_id(name) ⇒ Object
-
.template(name) ⇒ Object
Class methods.
Instance Method Summary collapse
- #coverage_emoji ⇒ Object
- #create_coverage_color ⇒ Object
- #create_displayable_coverage ⇒ Object
- #create_summary ⇒ Object
Instance Attribute Details
#coverage ⇒ Object
Returns the value of attribute coverage.
7 8 9 |
# File 'lib/xcov/model/base.rb', line 7 def coverage @coverage end |
#coverage_color ⇒ Object
Returns the value of attribute coverage_color.
9 10 11 |
# File 'lib/xcov/model/base.rb', line 9 def coverage_color @coverage_color end |
#displayable_coverage ⇒ Object
Returns the value of attribute displayable_coverage.
8 9 10 |
# File 'lib/xcov/model/base.rb', line 8 def displayable_coverage @displayable_coverage end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/xcov/model/base.rb', line 11 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/xcov/model/base.rb', line 6 def name @name end |
Class Method Details
.create_id(name) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/xcov/model/base.rb', line 64 def self.create_id(name) char_map = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten random = (0...50).map { char_map[rand(char_map.length)] }.join pre_hash = "#{random}_#{name}" Digest::SHA1.hexdigest(pre_hash) end |
.template(name) ⇒ Object
Class methods
60 61 62 |
# File 'lib/xcov/model/base.rb', line 60 def self.template(name) ERB.new(File.read(File.join(File.dirname(__FILE__), "../../../views/", "#{name}.erb"))) end |
Instance Method Details
#coverage_emoji ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/xcov/model/base.rb', line 45 def coverage_emoji return "" if @ignored if @coverage >= 0.80 return ":white_check_mark:" elsif @coverage >= 0.50 return ":warning:" elsif @coverage >= 0.25 return ":no_entry_sign:" else return ":skull:" end end |
#create_coverage_color ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xcov/model/base.rb', line 19 def create_coverage_color return "#363636" if @ignored if @coverage > 0.8 return "#1FCB32" elsif @coverage > 0.65 return "#FCFF00" elsif @coverage > 0.5 return "#FF9C00" else return "#FF0000" end end |
#create_displayable_coverage ⇒ Object
13 14 15 16 17 |
# File 'lib/xcov/model/base.rb', line 13 def create_displayable_coverage return "-" if @ignored "%.2f%%" % [(@coverage*100)] end |
#create_summary ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xcov/model/base.rb', line 33 def create_summary if @coverage > 0.8 return "Overall coverage is good" elsif @coverage > 0.65 return "There is room for improvement" elsif @coverage > 0.5 return "Almost unmaintainable" else return "Keep calm and leave the boat" end end |