weft-qda 0.9.6 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/weft.rb +16 -1
- data/lib/weft/WEFT-VERSION-STRING.rb +1 -1
- data/lib/weft/application.rb +17 -74
- data/lib/weft/backend.rb +6 -32
- data/lib/weft/backend/sqlite.rb +222 -164
- data/lib/weft/backend/sqlite/category_tree.rb +52 -48
- data/lib/weft/backend/sqlite/database.rb +57 -0
- data/lib/weft/backend/sqlite/upgradeable.rb +7 -0
- data/lib/weft/broadcaster.rb +90 -0
- data/lib/weft/category.rb +139 -47
- data/lib/weft/codereview.rb +160 -0
- data/lib/weft/coding.rb +74 -23
- data/lib/weft/document.rb +23 -10
- data/lib/weft/exceptions.rb +10 -0
- data/lib/weft/filters.rb +47 -224
- data/lib/weft/filters/indexers.rb +137 -0
- data/lib/weft/filters/input.rb +118 -0
- data/lib/weft/filters/output.rb +101 -0
- data/lib/weft/filters/templates.rb +80 -0
- data/lib/weft/filters/win32backtick.rb +246 -0
- data/lib/weft/query.rb +169 -0
- data/lib/weft/wxgui.rb +349 -294
- data/lib/weft/wxgui/constants.rb +43 -0
- data/lib/weft/wxgui/controls.rb +6 -0
- data/lib/weft/wxgui/controls/category_dropdown.rb +192 -0
- data/lib/weft/wxgui/controls/category_tree.rb +314 -0
- data/lib/weft/wxgui/controls/document_list.rb +97 -0
- data/lib/weft/wxgui/controls/multitype_control.rb +37 -0
- data/lib/weft/wxgui/{inspectors → controls}/textcontrols.rb +235 -64
- data/lib/weft/wxgui/dialogs.rb +144 -41
- data/lib/weft/wxgui/error_handler.rb +116 -36
- data/lib/weft/wxgui/exceptions.rb +7 -0
- data/lib/weft/wxgui/inspectors.rb +61 -208
- data/lib/weft/wxgui/inspectors/category.rb +19 -16
- data/lib/weft/wxgui/inspectors/codereview.rb +90 -132
- data/lib/weft/wxgui/inspectors/document.rb +12 -8
- data/lib/weft/wxgui/inspectors/imagedocument.rb +56 -56
- data/lib/weft/wxgui/inspectors/query.rb +284 -0
- data/lib/weft/wxgui/inspectors/script.rb +147 -23
- data/lib/weft/wxgui/lang/en.rb +69 -0
- data/lib/weft/wxgui/sidebar.rb +90 -432
- data/lib/weft/wxgui/utilities.rb +70 -91
- data/lib/weft/wxgui/workarea.rb +150 -43
- data/share/icons/category.ico +0 -0
- data/share/icons/category.xpm +109 -0
- data/share/icons/codereview.ico +0 -0
- data/share/icons/codereview.xpm +54 -0
- data/share/icons/d_and_c.xpm +126 -0
- data/share/icons/document.ico +0 -0
- data/share/icons/document.xpm +70 -0
- data/share/icons/project.ico +0 -0
- data/share/icons/query.ico +0 -0
- data/share/icons/query.xpm +56 -0
- data/{lib/weft/wxgui → share/icons}/search.xpm +0 -0
- data/share/icons/weft.ico +0 -0
- data/share/icons/weft.xpm +62 -0
- data/share/icons/weft16.ico +0 -0
- data/share/icons/weft32.ico +0 -0
- data/share/templates/category_plain.html +18 -0
- data/share/templates/codereview_plain.html +18 -0
- data/share/templates/document_plain.html +13 -0
- data/share/templates/document_plain.txt +7 -0
- data/test/001-document.rb +55 -36
- data/test/002-category.rb +81 -6
- data/test/003-code.rb +8 -4
- data/test/004-application.rb +13 -34
- data/test/005-query_review.rb +139 -0
- data/test/006-filters.rb +54 -42
- data/test/007-output_filters.rb +113 -0
- data/test/009a-backend_sqlite_basic.rb +95 -24
- data/test/009b-backend_sqlite_complex.rb +43 -62
- data/test/009c_backend_sqlite_bench.rb +5 -10
- data/test/053-doc_inspector.rb +46 -0
- data/test/055-query_window.rb +50 -0
- data/test/all-tests.rb +1 -0
- data/test/test-common.rb +19 -0
- data/test/testdata/empty.qdp +0 -0
- data/test/testdata/simple with space.pdf +0 -0
- data/test/testdata/simple.pdf +0 -0
- data/weft-qda.rb +40 -7
- metadata +74 -14
- data/lib/weft/wxgui/category.xpm +0 -26
- data/lib/weft/wxgui/document.xpm +0 -25
- data/lib/weft/wxgui/inspectors/search.rb +0 -265
- data/lib/weft/wxgui/mondrian.xpm +0 -44
- data/lib/weft/wxgui/weft16.xpm +0 -31
Binary file
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# EXPORT_CLASS : Category
|
2
|
+
# DESCRIPTION : Category as simple HTML webpage
|
3
|
+
# CLASSNAME : CategoryHTMLOutput
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title>[% var obj.name :html %]</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h1>[% var obj.name :html %]</h1>
|
10
|
+
[% loop text.sets %]
|
11
|
+
<h2>[% var title %]
|
12
|
+
<!-- [% var length %] passages, [% var num_of_chars %] characters --></h2>
|
13
|
+
[% loop items %]
|
14
|
+
<p>[% var text :html %] (at point [% var offset %])</p>
|
15
|
+
[% end %]
|
16
|
+
[% end %]
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# EXPORT_CLASS : CodeReview
|
2
|
+
# DESCRIPTION : Code Review as HTML table
|
3
|
+
# CLASSNAME : CodeReviewHTMLOutput
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title>Code Review [% var obj.dbid %]</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h1>Code Review [% var obj.dbid %]</h1>
|
10
|
+
<table>
|
11
|
+
[% loop obj.output_rows %]
|
12
|
+
<tr>
|
13
|
+
[% loop to_a %]<td>[% var to_s %]</td>
|
14
|
+
[% end %]
|
15
|
+
</tr>[% end %]
|
16
|
+
</table>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# EXPORT_CLASS : Document
|
2
|
+
# DESCRIPTION : Document as simple HTML webpage
|
3
|
+
# CLASSNAME : DocumentHTMLOutput
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title>[% var obj.title :html %]</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h1>[% var obj.title :html %]</h1>
|
10
|
+
<p>[% var obj.memo :html %]</p>
|
11
|
+
[% var obj.text :html_paras %]
|
12
|
+
</body>
|
13
|
+
</html>
|
data/test/001-document.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
-
|
1
|
+
require 'test-common'
|
2
2
|
|
3
3
|
require 'weft/document'
|
4
|
-
require 'test/unit'
|
5
4
|
require 'weft/category'
|
6
5
|
|
7
|
-
|
8
|
-
def setup
|
6
|
+
require 'test/unit'
|
9
7
|
|
10
|
-
|
8
|
+
class TestDocument < Test::Unit::TestCase
|
9
|
+
include QDA
|
11
10
|
|
12
11
|
def test_basic
|
13
|
-
d =
|
12
|
+
d = Document.new('The Title')
|
14
13
|
assert_equal('The Title', d.title,
|
15
14
|
'Set title at initialisation')
|
16
15
|
assert_equal(0, d.length,
|
@@ -40,35 +39,44 @@ class TestDocument < Test::Unit::TestCase
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def test_fragment
|
43
|
-
d =
|
42
|
+
d = Document.new('The Title')
|
44
43
|
d.append('abc def ghi jkl')
|
45
44
|
d.append('ABC DEF GHI JKL')
|
45
|
+
|
46
|
+
# at the beginning
|
46
47
|
fr_1 = d[0,4]
|
47
48
|
assert_equal(0, fr_1.offset, 'Give offset correctly')
|
48
49
|
assert_equal(4, fr_1.end, 'Give end correctly')
|
49
50
|
assert_equal('abc ', fr_1, 'String equality')
|
51
|
+
assert_equal(d.title, fr_1.title)
|
52
|
+
assert_equal(d[fr_1.offset, fr_1.length].to_s, fr_1.to_s, 'String correct')
|
50
53
|
|
54
|
+
# in the middle
|
51
55
|
fr_2 = d[2,5]
|
52
56
|
assert_equal(2, fr_2.offset, 'Give offset correctly')
|
53
57
|
assert_equal(7, fr_2.end, 'Give end correctly')
|
58
|
+
assert_equal(d[fr_2.offset, fr_2.length].to_s, fr_2.to_s)
|
54
59
|
|
55
|
-
|
56
|
-
|
57
|
-
|
60
|
+
|
61
|
+
# past the end
|
62
|
+
fr_3 = d[25,12]
|
63
|
+
assert_equal(25, fr_3.offset, 'Give offset correctly')
|
64
|
+
assert_equal(7, fr_3.length, 'Give length correctly')
|
65
|
+
assert_equal(d[fr_3.offset, fr_3.length].to_s, fr_3.to_s, 'String correct')
|
58
66
|
|
59
67
|
fr_3.docid = 1
|
60
68
|
code = fr_3.to_code()
|
61
69
|
assert_equal(1, code.docid)
|
62
|
-
assert_equal(
|
63
|
-
assert_equal(
|
70
|
+
assert_equal(25, code.offset)
|
71
|
+
assert_equal(7, code.length)
|
64
72
|
end
|
65
73
|
|
66
74
|
def test_fragment_equivalence
|
67
|
-
c_1 =
|
68
|
-
c_2 =
|
69
|
-
c_3 =
|
70
|
-
c_4 =
|
71
|
-
c_5 =
|
75
|
+
c_1 = Fragment.new('ABC', 'title', 5)
|
76
|
+
c_2 = Fragment.new('XYZ', 'title', 0)
|
77
|
+
c_3 = Fragment.new('ABC', 'other', 5)
|
78
|
+
c_4 = Fragment.new('ABC', 'title', 50)
|
79
|
+
c_5 = Fragment.new('ABC', 'title', 5)
|
72
80
|
|
73
81
|
assert(c_1 == c_1, 'Identity Equality')
|
74
82
|
assert(c_1 == c_5, 'Equivalence Equality')
|
@@ -76,24 +84,24 @@ class TestDocument < Test::Unit::TestCase
|
|
76
84
|
assert(c_1 != c_3, 'Document inequality')
|
77
85
|
assert(c_1 != c_4, 'Offset inequality')
|
78
86
|
|
79
|
-
c_1 =
|
80
|
-
c_2 =
|
87
|
+
c_1 = Fragment.new('ABCDEF', 'title', 5)
|
88
|
+
c_2 = Fragment.new('DEFGH', 'title', 8)
|
81
89
|
|
82
90
|
assert(c_1.overlap?(c_2), 'Overlap 1/2')
|
83
91
|
assert(c_2.overlap?(c_1), 'Overlap 1/1')
|
84
92
|
assert(c_1.touch?(c_2), 'Touch 1/1')
|
85
93
|
assert(c_2.touch?(c_1), 'Touch 1/2')
|
86
94
|
|
87
|
-
c_1 =
|
88
|
-
c_2 =
|
95
|
+
c_1 = Fragment.new('ABCDEF', 'title', 5)
|
96
|
+
c_2 = Fragment.new('GHIJKL', 'title', 11)
|
89
97
|
|
90
98
|
assert(! c_1.overlap?(c_2), 'Overlap 2/2')
|
91
99
|
assert(! c_2.overlap?(c_1), 'Overlap 2/1')
|
92
100
|
assert(c_1.touch?(c_2), 'Touch 2/1')
|
93
101
|
assert(c_2.touch?(c_1), 'Touch 2/2')
|
94
102
|
|
95
|
-
c_1 =
|
96
|
-
c_2 =
|
103
|
+
c_1 = Fragment.new('ABCDEF', 'title', 5)
|
104
|
+
c_2 = Fragment.new('JKL', 'title', 14)
|
97
105
|
assert(! c_1.overlap?(c_2), 'Overlap 3/2')
|
98
106
|
assert(! c_2.overlap?(c_1), 'Overlap 3/1')
|
99
107
|
assert(! c_1.touch?(c_2), 'Touch 3/1')
|
@@ -101,27 +109,27 @@ class TestDocument < Test::Unit::TestCase
|
|
101
109
|
end
|
102
110
|
|
103
111
|
def test_fragment_comparison
|
104
|
-
c_1 =
|
105
|
-
c_2 =
|
112
|
+
c_1 = Fragment.new('ABC', 'title', 5)
|
113
|
+
c_2 = Fragment.new('XYZ', 'title', 0)
|
106
114
|
assert(c_2 < c_1, 'Offset comparison')
|
107
115
|
|
108
|
-
cs =
|
116
|
+
cs = CodeSet[ c_1, c_2 ]
|
109
117
|
cs = cs.sort { | x, y | x <=> y }
|
110
118
|
assert_equal('XYZ', cs[0],
|
111
119
|
'Sort test')
|
112
120
|
|
113
|
-
c_1 =
|
114
|
-
c_2 =
|
121
|
+
c_1 = Fragment.new('abc', 'title', 0)
|
122
|
+
c_2 = Fragment.new('xyz', 'title', 5)
|
115
123
|
assert(c_2 > c_1, 'Offset comparison')
|
116
124
|
|
117
|
-
cs =
|
125
|
+
cs = CodeSet[ c_1, c_2 ]
|
118
126
|
cs = cs.sort
|
119
127
|
assert_equal('abc', cs[0],
|
120
128
|
'Sort test')
|
121
129
|
end
|
122
130
|
|
123
131
|
def test_fragment_addition
|
124
|
-
d =
|
132
|
+
d = Document.new('The Title')
|
125
133
|
d.append('abc def ghi jkl')
|
126
134
|
d.append('ABC DEF GHI JKL')
|
127
135
|
fr_1 = d[0,4]
|
@@ -137,8 +145,8 @@ class TestDocument < Test::Unit::TestCase
|
|
137
145
|
assert_equal('abc ', fr_1 + d[1,2],
|
138
146
|
'Surrounded fragment addition')
|
139
147
|
|
140
|
-
cs_1 =
|
141
|
-
cs_2 =
|
148
|
+
cs_1 = CodeSet[ fr_1, fr_3 ]
|
149
|
+
cs_2 = CodeSet[ d[3, 11] ]
|
142
150
|
|
143
151
|
results = cs_1.union(cs_2)
|
144
152
|
assert_equal( [ d[0, 18 ] ], results,
|
@@ -150,7 +158,7 @@ class TestDocument < Test::Unit::TestCase
|
|
150
158
|
end
|
151
159
|
|
152
160
|
def test_fragment_intersect
|
153
|
-
d =
|
161
|
+
d = Document.new('The Title')
|
154
162
|
d.append('abc def ghi jkl')
|
155
163
|
d.append('ABC DEF GHI JKL')
|
156
164
|
fr_1 = d[0,4]
|
@@ -167,7 +175,7 @@ class TestDocument < Test::Unit::TestCase
|
|
167
175
|
end
|
168
176
|
|
169
177
|
def test_fragment_exclude
|
170
|
-
d =
|
178
|
+
d = Document.new('The Title')
|
171
179
|
d.append('abc def ghi jkl')
|
172
180
|
d.append('ABC DEF GHI JKL')
|
173
181
|
fr_1 = d[0,4]
|
@@ -182,8 +190,8 @@ class TestDocument < Test::Unit::TestCase
|
|
182
190
|
assert_equal([ 'a', ' ' ], fr_1 - d[1,2],
|
183
191
|
'overlapping fragment exclusion')
|
184
192
|
|
185
|
-
cs_1 =
|
186
|
-
cs_2 =
|
193
|
+
cs_1 = CodeSet[ fr_1, fr_3 ]
|
194
|
+
cs_2 = CodeSet[ d[3, 11] ]
|
187
195
|
|
188
196
|
results = cs_1.exclude(cs_2)
|
189
197
|
assert_equal( [ d[0,3], d[14, 4] ], results,
|
@@ -193,4 +201,15 @@ class TestDocument < Test::Unit::TestCase
|
|
193
201
|
assert_equal( [ d[0,3], d[14, 4] ], results,
|
194
202
|
'CodeSet subtraction')
|
195
203
|
end
|
204
|
+
|
205
|
+
def test_match
|
206
|
+
d = Document.new('')
|
207
|
+
d.append('abc def ghi jkl')
|
208
|
+
d.append('ABC DEF GHI JKL')
|
209
|
+
|
210
|
+
d.scan(/\w\w\w/) do | match |
|
211
|
+
assert_kind_of(Fragment, match)
|
212
|
+
assert_equal( match.offset, d.text.index(match.to_s) )
|
213
|
+
end
|
214
|
+
end
|
196
215
|
end
|
data/test/002-category.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
$:.push('../lib/')
|
1
|
+
require 'test-common'
|
4
2
|
|
3
|
+
require 'weft/exceptions'
|
5
4
|
require 'weft/category'
|
6
5
|
require 'test/unit'
|
7
6
|
|
8
|
-
class
|
7
|
+
class TestCategory < Test::Unit::TestCase
|
8
|
+
include QDA
|
9
9
|
def setup
|
10
10
|
|
11
11
|
end
|
@@ -16,10 +16,42 @@ class TestDocument < Test::Unit::TestCase
|
|
16
16
|
'Set title at initialisation')
|
17
17
|
assert_equal(0, c.children.length,
|
18
18
|
'Empty at initialisation')
|
19
|
-
|
20
|
-
|
19
|
+
assert_nil(c.codes)
|
20
|
+
|
21
|
+
c2 = QDA::Category.new('Child Node', c)
|
22
|
+
|
21
23
|
assert_equal(1, c.children.length,
|
22
24
|
'Added a child')
|
25
|
+
assert( c2.is_descendant_of?(c) )
|
26
|
+
assert( ! c2.is_ancestor_of?(c) )
|
27
|
+
assert( c.is_ancestor_of?(c2) )
|
28
|
+
assert( ! c.is_descendant_of?(c2) )
|
29
|
+
assert_equal( c2, c['Child Node'])
|
30
|
+
assert_equal( c2, c[/ild No/])
|
31
|
+
assert_equal( nil, c[2] )
|
32
|
+
|
33
|
+
|
34
|
+
c3 = QDA::Category.new('Child / Node',c)
|
35
|
+
assert_equal('Child / Node', c3.name)
|
36
|
+
assert_equal('Child // Node', c3.escape_name)
|
37
|
+
assert( c.is_ancestor_of?(c3) )
|
38
|
+
assert( ! c2.is_ancestor_of?(c3) )
|
39
|
+
assert( ! c2.is_descendant_of?(c3) )
|
40
|
+
|
41
|
+
assert_equal(2, c.children.length)
|
42
|
+
assert_equal([c2, c3], c.children)
|
43
|
+
|
44
|
+
assert_raises(QDA::BadNameError) { QDA::Category.new('/Bad Name', c) }
|
45
|
+
assert_raises(QDA::BadNameError) { QDA::Category.new('Bad Name/', c) }
|
46
|
+
|
47
|
+
c4 = QDA::Category.new('NAME', c)
|
48
|
+
assert_raises(QDA::NotUniqueNameError) { QDA::Category.new('NAME', c) }
|
49
|
+
assert_raises(QDA::NotUniqueNameError) { QDA::Category.new('name', c) }
|
50
|
+
rename = c.unique_name('NAME')
|
51
|
+
assert_equal('NAME (1)', rename)
|
52
|
+
c5 = QDA::Category.new(rename, c)
|
53
|
+
rename = c.unique_name('NAME')
|
54
|
+
assert_equal('NAME (2)', rename)
|
23
55
|
end
|
24
56
|
|
25
57
|
def test_memo
|
@@ -135,4 +167,47 @@ class TestDocument < Test::Unit::TestCase
|
|
135
167
|
|
136
168
|
# more tests ? ... seems to be all OK, not
|
137
169
|
end
|
170
|
+
|
171
|
+
def test_paths()
|
172
|
+
bits = Category.parse_path('foo')
|
173
|
+
assert_equal(1, bits.length)
|
174
|
+
|
175
|
+
bits = Category.parse_path('fo//o/x/c')
|
176
|
+
assert_equal(3, bits.length)
|
177
|
+
assert_equal('fo/o', bits[0])
|
178
|
+
|
179
|
+
bits = Category.parse_path('fo/o')
|
180
|
+
assert_equal(2, bits.length)
|
181
|
+
|
182
|
+
bits = Category.parse_path('//foo')
|
183
|
+
assert_equal(1, bits.length)
|
184
|
+
assert_equal('/foo', bits[0])
|
185
|
+
|
186
|
+
bits = Category.parse_path('foo//')
|
187
|
+
assert_equal(1, bits.length)
|
188
|
+
assert_equal('foo/', bits[0])
|
189
|
+
|
190
|
+
bits = Category.parse_path('///')
|
191
|
+
assert_equal(1, bits.length)
|
192
|
+
assert_equal('/', bits[0])
|
193
|
+
|
194
|
+
bits = Category.parse_path('/aaa')
|
195
|
+
assert_equal(2, bits.length)
|
196
|
+
assert_equal('', bits[0])
|
197
|
+
|
198
|
+
c1 = QDA::Category.new('The Title', nil)
|
199
|
+
assert_equal('/The Title', c1.path)
|
200
|
+
c2 = QDA::Category.new('Child Node',c1)
|
201
|
+
assert_equal('/The Title/Child Node', c2.path)
|
202
|
+
c3 = QDA::Category.new('This / That', c2)
|
203
|
+
assert_equal('/The Title/Child Node/This // That', c3.path)
|
204
|
+
|
205
|
+
desc = c1.descendants()
|
206
|
+
assert(desc.include?(c2))
|
207
|
+
assert(desc.include?(c3))
|
208
|
+
|
209
|
+
anc = c2.ancestors()
|
210
|
+
assert(anc.include?(c1))
|
211
|
+
assert(! anc.include?(c3))
|
212
|
+
end
|
138
213
|
end
|
data/test/003-code.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
$:.push('../lib/')
|
1
|
+
require 'test-common'
|
4
2
|
|
5
3
|
require 'weft'
|
6
4
|
require 'test/unit'
|
@@ -335,6 +333,9 @@ class TestCode < Test::Unit::TestCase
|
|
335
333
|
assert_equal(1, tbl.num_of_docs)
|
336
334
|
assert_equal(6, tbl.num_of_chars)
|
337
335
|
assert_equal(1, tbl.num_of_codes)
|
336
|
+
|
337
|
+
sets = tbl.sets
|
338
|
+
assert_equal(1, sets.length)
|
338
339
|
end
|
339
340
|
|
340
341
|
def test_fragment_table
|
@@ -344,12 +345,15 @@ class TestCode < Test::Unit::TestCase
|
|
344
345
|
assert_equal(1, ft.num_of_docs)
|
345
346
|
assert_equal(8, ft.num_of_chars)
|
346
347
|
assert_equal(1, ft.num_of_codes)
|
348
|
+
sets = ft.sets
|
349
|
+
assert_equal(1, sets.length)
|
350
|
+
assert_equal(1, sets[0].length)
|
351
|
+
|
347
352
|
ft.each_title do | title, codes |
|
348
353
|
assert_equal('title', title)
|
349
354
|
assert_equal(1, codes.length)
|
350
355
|
end
|
351
356
|
|
352
|
-
|
353
357
|
ct = ft.to_codingtable()
|
354
358
|
assert_equal(1, ct.num_of_docs)
|
355
359
|
assert_equal(8, ct.num_of_chars)
|
data/test/004-application.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
|
1
|
+
require 'test-common'
|
2
2
|
|
3
3
|
require 'weft/application'
|
4
|
+
require 'weft/broadcaster'
|
5
|
+
|
4
6
|
require 'test/unit'
|
5
7
|
|
6
8
|
class DummyClient
|
7
|
-
attr_reader :
|
8
|
-
|
9
|
+
attr_reader :event_log
|
10
|
+
include QDA::Subscriber
|
11
|
+
|
9
12
|
def initialize(app = nil)
|
10
|
-
|
11
|
-
|
13
|
+
@event_log
|
14
|
+
subscribe(app, :all)
|
12
15
|
end
|
13
|
-
|
14
|
-
def
|
15
|
-
|
16
|
+
|
17
|
+
def notify(evt, data)
|
18
|
+
event_log.push( :evt => evt, :data => data )
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
@@ -22,31 +25,7 @@ class TestApplication < Test::Unit::TestCase
|
|
22
25
|
end
|
23
26
|
|
24
27
|
def test_basic
|
25
|
-
app
|
28
|
+
app = QDA::Application.new()
|
26
29
|
client = DummyClient.new(app)
|
27
|
-
|
28
|
-
"Observer initially set to show clean")
|
29
|
-
app.dirty!
|
30
|
-
assert_equal("DIRTY", client.state_display,
|
31
|
-
"Observer picks up dirtying")
|
32
|
-
app.undirty!
|
33
|
-
assert_equal("CLEAN", client.state_display,
|
34
|
-
"Observer picks up saving")
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_basic_w_initializer
|
39
|
-
client = DummyClient.new()
|
40
|
-
app = QDA::Application.new(client)
|
41
|
-
|
42
|
-
assert_equal("CLEAN", client.state_display,
|
43
|
-
"Observer initially set to show clean")
|
44
|
-
app.dirty!
|
45
|
-
assert_equal("DIRTY", client.state_display,
|
46
|
-
"Observer picks up dirtying")
|
47
|
-
app.undirty!
|
48
|
-
assert_equal("CLEAN", client.state_display,
|
49
|
-
"Observer picks up saving")
|
50
|
-
|
51
|
-
end
|
30
|
+
end
|
52
31
|
end
|