Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
---|---|---|---|---|
lib/jldrill/contexts/SetOptionsContext.rb | 105 | 73 | 94.29%
|
91.78%
|
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/GetFilenameContext' |
5 |
6 module JLDrill |
7 |
8 class SetOptionsContext < Context::Context |
9 |
10 attr_reader :filename, :quiz |
11 |
12 def initialize(viewBridge) |
13 super(viewBridge) |
14 @quiz = nil |
15 end |
16 |
17 class OptionsView < Context::View |
18 attr_reader :options |
19 |
20 def initialize(context) |
21 super(context) |
22 @optionsSet = false |
23 @options = Options.new(nil) |
24 end |
25 |
26 # Destroy the options window |
27 def destroy |
28 # Please define in the concrete class |
29 end |
30 |
31 # Indicate that the options have been modified or not. |
32 def optionsSet=(bool) |
33 @optionsSet = bool |
34 end |
35 |
36 # Returns true if the options have been modified |
37 def optionsSet? |
38 return @optionsSet |
39 end |
40 |
41 # Update the UI with the options passed in |
42 def update(options) |
43 @options.assign(options) |
44 # Call super() first and then write UI specific code |
45 end |
46 |
47 # Update the UI with the filename of the dictionary |
48 def setDictionaryFilename(filename) |
49 # Please override in the concrete class |
50 end |
51 |
52 # Display the options dialog and get input from the user |
53 def run |
54 # Please write the code for the concrete class and then |
55 # call super(). This will simply exit the context. |
56 exit |
57 end |
58 |
59 # This is a convenience method for the tests so that they |
60 # have something to catch rather than the exit() on the context. |
61 def exit |
62 @context.exit |
63 end |
64 end |
65 |
66 def createViews |
67 @mainView = @viewBridge.OptionsView.new(self) |
68 end |
69 |
70 def destroyViews |
71 @mainView.destroy |
72 @mainView = nil |
73 end |
74 |
75 def hasQuiz?(parent) |
76 !parent.nil? && parent.class.public_method_defined?(:quiz) && |
77 !parent.quiz.nil? |
78 end |
79 |
80 def getDictionaryFilename |
81 context = GetFilenameContext.new(@viewBridge, GetFilenameContext::OPEN) |
82 filename = context.enter(self) |
83 if !filename.nil? |
84 @mainView.setDictionaryFilename(filename) |
85 end |
86 end |
87 |
88 def enter(parent) |
89 if hasQuiz?(parent) |
90 super(parent) |
91 @quiz = parent.quiz |
92 @mainView.update(@quiz.options) |
93 @mainView.run |
94 end |
95 end |
96 |
97 def exit |
98 if @mainView.optionsSet? |
99 @quiz.options.assign(@mainView.options) |
100 @quiz.strategy.reschedule |
101 end |
102 super |
103 end |
104 end |
105 end |
Generated on Mon May 23 16:17:46 +0900 2011 with rcov 0.9.8