Class: UICov::ScreenData
- Inherits:
-
Object
- Object
- UICov::ScreenData
- Defined in:
- lib/uicov/coverage/screen_data.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#checks ⇒ Object
readonly
Returns the value of attribute checks.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#transitions ⇒ Object
readonly
Returns the value of attribute transitions.
Instance Method Summary collapse
- #add_action(name) ⇒ Object
- #add_check(name) ⇒ Object
- #add_covered_action(name) ⇒ Object
- #add_covered_check(name) ⇒ Object
- #add_covered_element(name) ⇒ Object
- #add_covered_transition(name, to) ⇒ Object
- #add_element(name) ⇒ Object
- #add_transition(name, to) ⇒ Object
- #get_count(members_name, hitted = false) ⇒ Object
- #get_coverage(members_name) ⇒ Object
- #hit ⇒ Object
-
#initialize(name) ⇒ ScreenData
constructor
A new instance of ScreenData.
- #report ⇒ Object
Constructor Details
#initialize(name) ⇒ ScreenData
Returns a new instance of ScreenData.
8 9 10 11 12 13 14 15 |
# File 'lib/uicov/coverage/screen_data.rb', line 8 def initialize(name) @name = name @hits = 0 @elements = {} @transitions = {} @actions = {} @checks = {} end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
7 8 9 |
# File 'lib/uicov/coverage/screen_data.rb', line 7 def actions @actions end |
#checks ⇒ Object (readonly)
Returns the value of attribute checks.
7 8 9 |
# File 'lib/uicov/coverage/screen_data.rb', line 7 def checks @checks end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
7 8 9 |
# File 'lib/uicov/coverage/screen_data.rb', line 7 def elements @elements end |
#transitions ⇒ Object (readonly)
Returns the value of attribute transitions.
7 8 9 |
# File 'lib/uicov/coverage/screen_data.rb', line 7 def transitions @transitions end |
Instance Method Details
#add_action(name) ⇒ Object
30 31 32 |
# File 'lib/uicov/coverage/screen_data.rb', line 30 def add_action(name) actions[name] ||= ActionData.new name end |
#add_check(name) ⇒ Object
38 39 40 |
# File 'lib/uicov/coverage/screen_data.rb', line 38 def add_check(name) checks[name] ||= CheckData.new name end |
#add_covered_action(name) ⇒ Object
34 35 36 |
# File 'lib/uicov/coverage/screen_data.rb', line 34 def add_covered_action(name) add_action(name).hit end |
#add_covered_check(name) ⇒ Object
42 43 44 |
# File 'lib/uicov/coverage/screen_data.rb', line 42 def add_covered_check(name) add_check(name).hit end |
#add_covered_element(name) ⇒ Object
50 51 52 |
# File 'lib/uicov/coverage/screen_data.rb', line 50 def add_covered_element(name) add_element(name).hit end |
#add_covered_transition(name, to) ⇒ Object
26 27 28 |
# File 'lib/uicov/coverage/screen_data.rb', line 26 def add_covered_transition(name, to) add_transition(name, to).hit end |
#add_element(name) ⇒ Object
46 47 48 |
# File 'lib/uicov/coverage/screen_data.rb', line 46 def add_element(name) elements[name] ||= ElementData.new name end |
#add_transition(name, to) ⇒ Object
21 22 23 24 |
# File 'lib/uicov/coverage/screen_data.rb', line 21 def add_transition(name, to) tr_key = TransitionData.get_key(name, to) transitions[tr_key] ||= TransitionData.new name, to end |
#get_count(members_name, hitted = false) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/uicov/coverage/screen_data.rb', line 78 def get_count(members_name, hitted=false) members = instance_variable_get("@#{members_name}") if hitted members.values.keep_if{ |e| 0 < e.hits}.size else members.size end end |
#get_coverage(members_name) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/uicov/coverage/screen_data.rb', line 71 def get_coverage(members_name) members = instance_variable_get("@#{members_name}") uncovered = members.values.select{|e| e.hits == 0} cov = ((members.size.to_f - uncovered.size) / members.size) * 100 return cov.nan? ? 100.0 : cov.round(2) end |
#hit ⇒ Object
17 18 19 |
# File 'lib/uicov/coverage/screen_data.rb', line 17 def hit @hits += 1 end |
#report ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/uicov/coverage/screen_data.rb', line 54 def report %Q^ <h2>Screen: <span>#{@name}</span></h2> <h3>Coverage summary</h3> #{report_members_summary 'elements' unless elements.empty?} #{report_members_summary 'transitions' unless transitions.empty?} #{report_members_summary 'actions' unless actions.empty?} #{report_members_summary 'checks' unless checks.empty?} <h3>Coverage details</h3> #{report_members 'elements' unless elements.empty?} #{report_members 'transitions' unless transitions.empty?} #{report_members 'actions' unless actions.empty?} #{report_members 'checks' unless checks.empty?} <hr/> ^ end |