Jldrill Git C0 Coverage Information - RCov

lib/jldrill/contexts/ShowExamplesContext.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/jldrill/contexts/ShowExamplesContext.rb 82 59
56.10%
40.68%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 require 'Context/Context'
2 require 'Context/Bridge'
3 require 'Context/View'
4 
5 module JLDrill
6 
7 	class ShowExamplesContext < Context::Context
8 		
9 		def initialize(viewBridge)
10 			super(viewBridge)
11 		end
12 		
13         include JLDrill::Behaviour::SearchDictionary
14 
15         class ExampleView < Context::View
16             attr_reader :exampleWindow
17 
18             def initialize(context)
19                 super(context)
20             end
21 
22             # Destroy the window
23             def destroy
24                 # Please define in the concrete class
25             end
26 
27             # Update the examples in the UI
28             def update(examples)
29                 # Please define in the concrete class
30             end
31 
32             # This is a convenience function for the tests so that
33             # they don't have to catch the close on the context
34             def close
35                 @context.exit
36             end
37         end	
38 
39         def createViews
40             @mainView = @viewBridge.ExampleView.new(self)
41         end
42         
43         def destroyViews
44             @mainView.destroy if !@mainView.nil?
45             @mainView = nil
46         end		    
47 		
48 		def canDisplay?(parent)
49 		    !parent.nil? && parent.class.public_method_defined?(:quiz) &&
50 		        !parent.quiz.nil? && parent.tanaka.loaded?
51 		end
52 	
53 		def findExamples(problem)
54 			examples = []
55 			if !problem.nil?
56 				vocab = problem.item.to_o
57 				if !vocab.nil?
58 					examples = @parent.tanaka.search(vocab.kanji, vocab.reading)
59 				end
60 			end
61 			return examples
62 		end
63 
64 		def enter(parent)
65 		    if canDisplay?(parent)
66     		    super(parent)
67     		    @mainView.update(findExamples(@parent.quiz.currentProblem))
68     		    @parent.quiz.publisher.subscribe(self, "newProblem")
69     		end
70 		end
71 		
72 		def exit
73 		    @parent.quiz.publisher.unsubscribe(self, "newProblem")
74 		    super
75 		end
76 		
77 		def newProblemUpdated(problem)
78 		    @mainView.update(findExamples(problem)) unless @mainView.nil?
79 		end
80 
81     end
82 end

Generated on Mon May 23 16:17:46 +0900 2011 with rcov 0.9.8