Class: UICov::CoverageData
- Inherits:
-
Object
- Object
- UICov::CoverageData
- Defined in:
- lib/uicov/coverage_data.rb
Instance Method Summary collapse
- #add_screen(name) ⇒ Object
- #add_transition(from, to, name) ⇒ Object
- #hit_screen(name) ⇒ Object
- #hit_transition(from, to, name) ⇒ Object
- #screens ⇒ Object
- #str_puml(msg = nil, nl = 1) ⇒ Object
- #to_puml(file_name = nil) ⇒ Object
- #transitions ⇒ Object
Instance Method Details
#add_screen(name) ⇒ Object
23 24 25 |
# File 'lib/uicov/coverage_data.rb', line 23 def add_screen(name) screens[name.to_sym] = ScreenInfo.new end |
#add_transition(from, to, name) ⇒ Object
33 34 35 |
# File 'lib/uicov/coverage_data.rb', line 33 def add_transition(from, to, name) transitions[TransitionInfo.key(from, to, name)] = TransitionInfo.new end |
#hit_screen(name) ⇒ Object
27 28 29 30 31 |
# File 'lib/uicov/coverage_data.rb', line 27 def hit_screen(name) name = name.to_sym info = screens.fetch(name, ScreenInfo.new(true)) screens[name] = info.hit end |
#hit_transition(from, to, name) ⇒ Object
37 38 39 40 41 |
# File 'lib/uicov/coverage_data.rb', line 37 def hit_transition(from, to, name) key = TransitionInfo.key(from, to, name) info = transitions.fetch(key, TransitionInfo.new(true)) transitions[key] = info.hit end |
#screens ⇒ Object
7 8 9 |
# File 'lib/uicov/coverage_data.rb', line 7 def screens @screens ||= {} end |
#str_puml(msg = nil, nl = 1) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/uicov/coverage_data.rb', line 15 def str_puml(msg=nil, nl=1) @str_puml ||= "" unless msg.nil? @str_puml << "#{msg}" + "\n" * nl end return @str_puml end |
#to_puml(file_name = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/uicov/coverage_data.rb', line 43 def to_puml(file_name=nil) str_puml '@startuml' str_puml SKIN_PARAMS, 0 str_puml LEGEND if Opts::Puml[:add_legend] screens.each_pair do |screen_name, screen_info| stereotype = '' stereotype = "<<#{Opts::Puml[:covered_class_stereotype]}>>" if screen_info.covered? stereotype = "<<#{Opts::Puml[:missed_class_stereotype]}>>" if screen_info.missed? str_puml "state #{screen_name}#{stereotype}" mm = transitions.map{|pair| pair if pair[0][0] == screen_name}.compact.each do |transition, transition_info| #str_puml transition str_puml "#{transition[0]} --> #{transition[1]} : #{transition[2]}" #str_puml "#{transition}" end str_puml '' end str_puml '@enduml' if file_name.nil? return str_puml else Log.unknown "Storing results in file #{File.expand_path(file_name)}" File.open(file_name, 'w') {|f| f.write str_puml} end end |
#transitions ⇒ Object
11 12 13 |
# File 'lib/uicov/coverage_data.rb', line 11 def transitions @transitions ||= {} end |