Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
lib/jldrill/contexts/DisplayProblemContext.rb | 151 | 108 | 89.40%
|
85.19%
|
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.
1 require 'Context/Context' |
2 require 'Context/Bridge' |
3 require 'Context/View' |
4 require 'jldrill/contexts/behaviour/SearchDictionary' |
5 |
6 module JLDrill |
7 |
8 class DisplayProblemContext < Context::Context |
9 |
10 def initialize(viewBridge) |
11 super(viewBridge) |
12 end |
13 |
14 include JLDrill::Behaviour::SearchDictionary |
15 |
16 class ProblemView < Context::View |
17 |
18 # The ItemHintView displays information about the current item |
19 # that acts as hints for the user. For instance, it might |
20 # indicate that the word is intrasitive, or a suru noun, etc. |
21 class ItemHintView < Context::View |
22 def initialize(context) |
23 super(context) |
24 end |
25 |
26 def newProblem(problem) |
27 # Should be overridden in the concrete class |
28 end |
29 |
30 def updateProblem(problem) |
31 # Should be overridden in the concrete class |
32 end |
33 |
34 def differs?(problem) |
35 @context.differs?(problem) |
36 end |
37 end |
38 |
39 attr_reader :itemHints |
40 |
41 def initialize(context) |
42 super(context) |
43 @itemHints = context.viewBridge.ItemHintView.new(context) |
44 end |
45 |
46 # Modify the viewAddedTo hook to add the ItemHintView |
47 def viewAddedTo(parent) |
48 self.addView(@itemHints) |
49 end |
50 |
51 # Modify the removingViewFrom hook to remove the ItemHintView |
52 def removingViewFrom(parent) |
53 self.removeView(@itemHints) |
54 end |
55 |
56 # A new problem has been added |
57 def newProblem(problem) |
58 itemHints.newProblem(problem) |
59 # Define the rest in the concrete class |
60 end |
61 |
62 # The current problem has changed and needs updating |
63 def updateProblem(problem) |
64 itemHints.updateProblem(problem) |
65 # Define the rest in the concrete class |
66 end |
67 |
68 # Show the answer to the problem |
69 def showAnswer |
70 # Should be overridden in the concrete class |
71 end |
72 end |
73 |
74 def createViews |
75 @mainView = @viewBridge.ProblemView.new(self) |
76 end |
77 |
78 def destroyViews |
79 @mainView = nil |
80 end |
81 |
82 def enter(parent) |
83 super(parent) |
84 if !@parent.nil? |
85 if !@parent.quiz.nil? |
86 @parent.quiz.publisher.subscribe(self, "load") |
87 @parent.quiz.publisher.subscribe(self, "newProblem") |
88 @parent.quiz.publisher.subscribe(self, "problemModified") |
89 end |
90 if !@parent.reference.nil? |
91 @parent.reference.publisher.subscribe(self, "edictLoad") |
92 end |
93 newProblemUpdated(@parent.quiz.currentProblem) |
94 end |
95 end |
96 |
97 def exit |
98 if !@parent.nil? |
99 if !@parent.quiz.nil? |
100 @parent.quiz.publisher.unsubscribe(self, "load") |
101 @parent.quiz.publisher.unsubscribe(self, "newProblem") |
102 @parent.quiz.publisher.unsubscribe(self, "problemModified") |
103 end |
104 if !@parent.reference.nil? |
105 @parent.reference.publisher.unsubscribe(self, "edictLoad") |
106 end |
107 end |
108 super |
109 end |
110 |
111 def differs?(problem) |
112 exists = true |
113 if @parent.reference.loaded? && !problem.nil? |
114 exists = @parent.reference.include?(problem.item.to_o) |
115 end |
116 return !exists |
117 end |
118 |
119 def loadUpdated(quiz) |
120 # There isn't likely a new problem at this point, but this |
121 # will clear the panes and update the status for the new |
122 # quiz |
123 newProblemUpdated(quiz.currentProblem) |
124 end |
125 |
126 def newProblemUpdated(problem) |
127 @mainView.newProblem(problem) |
128 end |
129 |
130 def problemModifiedUpdated(problem) |
131 @mainView.updateProblem(problem) |
132 end |
133 |
134 def edictLoadUpdated(reference) |
135 quiz = @parent.quiz |
136 @mainView.updateProblem(quiz.currentProblem) |
137 end |
138 |
139 def showAnswer |
140 @mainView.showAnswer |
141 end |
142 |
143 def expandWithSavePath(filename) |
144 if !@parent.quiz.nil? |
145 return @parent.quiz.useSavePath(filename) |
146 else |
147 return filename |
148 end |
149 end |
150 end |
151 end |
Generated on Mon May 23 16:17:45 +0900 2011 with rcov 0.9.8