scripref 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_parser.rb CHANGED
@@ -12,21 +12,21 @@ class TestParser < Test::Unit::TestCase
12
12
 
13
13
  def test_only_book
14
14
  text = 'Ruth'
15
- assert_parsed_ast_for_text [pass(text, 8, nil, nil, 8, nil, nil)], text
15
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
16
16
  end
17
17
 
18
18
  def test_book_abbrev
19
19
  text = 'Ru'
20
- assert_parsed_ast_for_text [pass(text, 8, nil, nil, 8, nil, nil)], text
20
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
21
21
  text = 'Offb'
22
- assert_parsed_ast_for_text [pass(text, 66, nil, nil, 66, nil, nil)], text
22
+ assert_parsed_ast_for_text [pass(text: text, b1: 66, b2: 66)], text
23
23
  end
24
24
 
25
25
  def test_book_abbrev_with_period
26
26
  text = 'Ru.'
27
- assert_parsed_ast_for_text [pass(text, 8, nil, nil, 8, nil, nil)], text
27
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
28
28
  text = 'Offb.'
29
- assert_parsed_ast_for_text [pass(text, 66, nil, nil, 66, nil, nil)], text
29
+ assert_parsed_ast_for_text [pass(text: text, b1: 66, b2: 66)], text
30
30
  end
31
31
 
32
32
  def test_ambiguous_book
@@ -38,115 +38,115 @@ class TestParser < Test::Unit::TestCase
38
38
 
39
39
  def test_book_and_chapter
40
40
  text = 'Ruth 2'
41
- assert_parsed_ast_for_text [pass(text, 8, 2, nil, 8, 2, nil)], text
41
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, b2: 8, c2: 2)], text
42
42
  end
43
43
 
44
44
  def test_book_chapter_and_verse
45
45
  text = 'Ruth 2,5'
46
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, 5)], text
46
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5)], text
47
47
  end
48
48
 
49
49
  def test_verse_range
50
50
  text = 'Ruth 2,5-11'
51
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, 11)], text
51
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 11)], text
52
52
  end
53
53
 
54
54
  def test_chapter_verse_range
55
55
  text = 'Ruth 2,5-3,7'
56
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 3, 7)], text
56
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 3, v2: 7)], text
57
57
  end
58
58
 
59
59
  def test_chapter_range
60
60
  text = 'Ruth 2-3'
61
- assert_parsed_ast_for_text [pass(text, 8, 2, nil, 8, 3, nil)], text
61
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, b2: 8, c2: 3)], text
62
62
  end
63
63
 
64
64
  def test_book_range
65
65
  text = '1. Mose - Offenbarung'
66
- assert_parsed_ast_for_text [pass(text, 1, nil, nil, 66, nil, nil)], text
66
+ assert_parsed_ast_for_text [pass(text: text, b1: 1, b2: 66)], text
67
67
  end
68
68
 
69
69
  def test_book_chapter_range
70
70
  text = '1. Mose 1 - Offenbarung 22'
71
- assert_parsed_ast_for_text [pass(text, 1, 1, nil, 66, 22, nil)], text
71
+ assert_parsed_ast_for_text [pass(text: text, b1: 1, c1: 1, b2: 66, c2: 22)], text
72
72
  end
73
73
 
74
74
  def test_book_chapter_verse_range
75
75
  text = '1. Mose 1,1-Offenbarung 22,21'
76
- assert_parsed_ast_for_text [pass(text, 1, 1, 1, 66, 22, 21)], text
76
+ assert_parsed_ast_for_text [pass(text: text, b1: 1, c1: 1, v1: 1, b2: 66, c2: 22, v2: 21)], text
77
77
  end
78
78
 
79
79
  def test_one_following_verse
80
80
  text = 'Ruth 2,5f'
81
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, :f)], text
81
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: :f)], text
82
82
  end
83
83
 
84
84
  def test_more_following_verse
85
85
  text = 'Ruth 2,5ff'
86
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, :ff)], text
86
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: :ff)], text
87
87
  end
88
88
 
89
89
  def test_first_addon
90
90
  text = 'Ruth 2,5a'
91
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, 5, a1: :a)], text
91
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5, a1: :a)], text
92
92
  end
93
93
 
94
94
  def test_second_addon
95
95
  text = 'Ruth 2,5-7a'
96
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, 7, a2: :a)], text
96
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 7, a2: :a)], text
97
97
  end
98
98
 
99
99
  def test_both_addons
100
100
  text = 'Ruth 2,5b-7a'
101
- assert_parsed_ast_for_text [pass(text, 8, 2, 5, 8, 2, 7, a1: :b, a2: :a)], text
101
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 7, a1: :b, a2: :a)], text
102
102
  end
103
103
 
104
104
  def test_reset_addons
105
105
  @parser.parse 'Ruth 2,5b-7a'
106
106
  text = 'Ruth'
107
- assert_parsed_ast_for_text [pass(text, 8, nil, nil, 8, nil, nil)], text
107
+ assert_parsed_ast_for_text [pass(text: text, b1: 8, b2: 8)], text
108
108
  end
109
109
 
110
110
  def test_book_with_only_one_chapter
111
111
  text = 'Obad 3'
112
- assert_parsed_ast_for_text [pass(text, 31, 1, 3, 31, 1, 3)], text
112
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 3)], text
113
113
  text = 'Obad 1,3'
114
- assert_parsed_ast_for_text [pass(text, 31, 1, 3, 31, 1, 3)], text
114
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 3)], text
115
115
  text = 'Obad 1'
116
- assert_parsed_ast_for_text [pass(text, 31, 1, 1, 31, 1, 1)], text
116
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 1)], text
117
117
  text = 'Obad 1,1'
118
- assert_parsed_ast_for_text [pass(text, 31, 1, 1, 31, 1, 1)], text
118
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 1)], text
119
119
  end
120
120
 
121
121
  def test_book_with_only_one_chapter_range
122
122
  text = 'Obad 3-5'
123
- assert_parsed_ast_for_text [pass(text, 31, 1, 3, 31, 1, 5)], text
123
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 5)], text
124
124
  text = 'Obad 1,3-5'
125
- assert_parsed_ast_for_text [pass(text, 31, 1, 3, 31, 1, 5)], text
125
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 31, c2: 1, v2: 5)], text
126
126
  text = 'Obad 1-4'
127
- assert_parsed_ast_for_text [pass(text, 31, 1, 1, 31, 1, 4)], text
127
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 4)], text
128
128
  text = 'Obad 1,1-4'
129
- assert_parsed_ast_for_text [pass(text, 31, 1, 1, 31, 1, 4)], text
129
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 1, b2: 31, c2: 1, v2: 4)], text
130
130
  end
131
131
 
132
132
  def test_book_with_only_one_chapter_at_begin_of_range
133
133
  text = 'Obad - Jona'
134
- assert_parsed_ast_for_text [pass(text, 31, 1, nil, 32, nil, nil)], text
134
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, b2: 32)], text
135
135
  text = 'Obad 3 - Jona 2,4'
136
- assert_parsed_ast_for_text [pass(text, 31, 1, 3, 32, 2, 4)], text
136
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 32, c2: 2, v2: 4)], text
137
137
  text = 'Obad 1,3 - Jona 2,4'
138
- assert_parsed_ast_for_text [pass(text, 31, 1, 3, 32, 2, 4)], text
138
+ assert_parsed_ast_for_text [pass(text: text, b1: 31, c1: 1, v1: 3, b2: 32, c2: 2, v2: 4)], text
139
139
  end
140
140
 
141
141
  def test_book_with_only_one_chapter_at_end_of_range
142
142
  text = 'Amos 2,4 - Obad 3'
143
- assert_parsed_ast_for_text [pass(text, 30, 2, 4, 31, 1, 3)], text
143
+ assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 3)], text
144
144
  text = 'Amos 2,4 - Obad 1,3'
145
- assert_parsed_ast_for_text [pass(text, 30, 2, 4, 31, 1, 3)], text
145
+ assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 3)], text
146
146
  text = 'Amos 2,4 - Obad 1'
147
- assert_parsed_ast_for_text [pass(text, 30, 2, 4, 31, 1, 1)], text
147
+ assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 1)], text
148
148
  text = 'Amos 2,4 - Obad 1,1'
149
- assert_parsed_ast_for_text [pass(text, 30, 2, 4, 31, 1, 1)], text
149
+ assert_parsed_ast_for_text [pass(text: text, b1: 30, c1: 2, v1: 4, b2: 31, c2: 1, v2: 1)], text
150
150
  end
151
151
 
152
152
  ######################################################################
@@ -156,49 +156,49 @@ class TestParser < Test::Unit::TestCase
156
156
  def test_two_books
157
157
  text = 'Ruth; Markus'
158
158
  t1, t2 = text.split(semi)
159
- assert_parsed_ast_for_text [pass(t1, 8, nil, nil, 8, nil, nil), semi, pass(t2, 41, nil, nil, 41, nil, nil)], text
159
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, b2: 8), semi, pass(text: t2, b1: 41, b2: 41)], text
160
160
  end
161
161
 
162
162
  def test_two_complete_refs
163
163
  text = 'Ruth 2,1; Markus 4,8'
164
164
  t1, t2 = text.split(semi)
165
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 1), semi, pass(t2, 41, 4, 8, 41, 4, 8)], text
165
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), semi, pass(text: t2, b1: 41, c1: 4, v1: 8, b2: 41, c2: 4, v2: 8)], text
166
166
  end
167
167
 
168
168
  def test_two_refs_same_book
169
169
  text = 'Ruth 2,1; 5,4'
170
170
  t1, t2 = text.split(semi)
171
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 1), semi, pass(t2, 8, 5, 4, 8, 5, 4)], text
171
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), semi, pass(text: t2, b1: 8, c1: 5, v1: 4, b2: 8, c2: 5, v2: 4)], text
172
172
  end
173
173
 
174
174
  def test_two_chapters_same_book
175
175
  text = 'Ruth 2; 5'
176
176
  t1, t2 = text.split(semi)
177
- assert_parsed_ast_for_text [pass(t1, 8, 2, nil, 8, 2, nil), semi, pass(t2, 8, 5, nil, 8, 5, nil)], text
177
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, b2: 8, c2: 2), semi, pass(text: t2, b1: 8, c1: 5, b2: 8, c2: 5)], text
178
178
  end
179
179
 
180
180
  def test_two_chapters_different_book
181
181
  text = 'Ruth 2; Markus 4'
182
182
  t1, t2 = text.split(semi)
183
- assert_parsed_ast_for_text [pass(t1, 8, 2, nil, 8, 2, nil), semi, pass(t2, 41, 4, nil, 41, 4, nil)], text
183
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, b2: 8, c2: 2), semi, pass(text: t2, b1: 41, c1: 4, b2: 41, c2: 4)], text
184
184
  end
185
185
 
186
186
  def test_two_verses
187
187
  text = 'Ruth 2,5.11'
188
188
  t1, t2 = text.split(dot)
189
- assert_parsed_ast_for_text [pass(t1, 8, 2, 5, 8, 2, 5), dot, pass(t2, 8, 2, 11, 8, 2, 11)], text
189
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), dot, pass(text: t2, b1: 8, c1: 2, v1: 11, b2: 8, c2: 2, v2: 11)], text
190
190
  end
191
191
 
192
192
  def test_partial_passage_after_full_passage
193
193
  text = 'Ruth 2,5; 4'
194
194
  t1, t2 = text.split(semi)
195
- assert_parsed_ast_for_text [pass(t1, 8, 2, 5, 8, 2, 5), semi, pass(t2, 8, 4, nil, 8, 4, nil)], text
195
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 8, c1: 4, b2: 8, c2: 4)], text
196
196
  text = 'Ruth 2,5; Markus'
197
197
  t1, t2 = text.split(semi)
198
- assert_parsed_ast_for_text [pass(t1, 8, 2, 5, 8, 2, 5), semi, pass(t2, 41, nil, nil, 41, nil, nil)], text
198
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 41, b2: 41)], text
199
199
  text = 'Ruth 2,5; Markus 4'
200
200
  t1, t2 = text.split(semi)
201
- assert_parsed_ast_for_text [pass(t1, 8, 2, 5, 8, 2, 5), semi, pass(t2, 41, 4, nil, 41, 4, nil)], text
201
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 5, b2: 8, c2: 2, v2: 5), semi, pass(text: t2, b1: 41, c1: 4, b2: 41, c2: 4)], text
202
202
  end
203
203
 
204
204
  ######################################################################
@@ -208,61 +208,61 @@ class TestParser < Test::Unit::TestCase
208
208
  def test_verse_range_and_separated_verse
209
209
  text = 'Ruth 2,1-3.11'
210
210
  t1, t2 = text.split(dot)
211
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 3), dot, pass(t2, 8, 2, 11, 8, 2, 11)], text
211
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 3), dot, pass(text: t2, b1: 8, c1: 2, v1: 11, b2: 8, c2: 2, v2: 11)], text
212
212
  end
213
213
 
214
214
  def test_separate_verse_and_verse_range
215
215
  text = 'Ruth 2,1.3-11'
216
216
  t1, t2 = text.split(dot)
217
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 1), dot, pass(t2, 8, 2, 3, 8, 2, 11)], text
217
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 1), dot, pass(text: t2, b1: 8, c1: 2, v1: 3, b2: 8, c2: 2, v2: 11)], text
218
218
  end
219
219
 
220
220
  def test_two_verse_ranges
221
221
  text = 'Ruth 2,1-3.7-11'
222
222
  t1, t2 = text.split(dot)
223
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 3), dot, pass(t2, 8, 2, 7, 8, 2, 11)], text
223
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 3), dot, pass(text: t2, b1: 8, c1: 2, v1: 7, b2: 8, c2: 2, v2: 11)], text
224
224
  end
225
225
 
226
226
  def test_two_verse_range_different_books
227
227
  text = 'Ruth 2,1-11; Markus 4,3-7'
228
228
  t1, t2 = text.split(semi)
229
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 11), semi, pass(t2, 41, 4, 3,41, 4, 7)], text
229
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), semi, pass(text: t2, b1: 41, c1: 4, v1: 3, b2: 41, c2: 4, v2: 7)], text
230
230
  end
231
231
 
232
232
  def test_two_verse_range_different_chapters
233
233
  text = 'Ruth 2,1-11; 3,10-19'
234
234
  t1, t2 = text.split(semi)
235
- assert_parsed_ast_for_text [pass(t1, 8, 2, 1, 8, 2, 11), semi, pass(t2, 8, 3, 10, 8, 3, 19)], text
235
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), semi, pass(text: t2, b1: 8, c1: 3, v1: 10, b2: 8, c2: 3, v2: 19)], text
236
236
  end
237
237
 
238
238
  def test_book_range_and_following_book
239
239
  text = 'Ruth-Markus; Johannes'
240
240
  t1, t2 = text.split(semi)
241
- assert_parsed_ast_for_text [pass(t1, 8, nil, nil, 41, nil, nil), semi, pass(t2, 43, nil, nil, 43, nil, nil)], text
241
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, b2: 41), semi, pass(text: t2, b1: 43, b2: 43)], text
242
242
  end
243
243
 
244
244
  def test_chapter_range_and_following_book
245
245
  text = 'Ruth 1-2; Joh 4'
246
246
  t1, t2 = text.split(semi)
247
- assert_parsed_ast_for_text [pass(t1, 8, 1, nil, 8, 2, nil), semi, pass(t2, 43, 4, nil, 43, 4, nil)], text
247
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 1, b2: 8, c2: 2), semi, pass(text: t2, b1: 43, c1: 4, b2: 43, c2: 4)], text
248
248
  end
249
249
 
250
250
  def test_chapter_range_and_following_chapter
251
251
  text = 'Ruth 1-2; 4'
252
252
  t1, t2 = text.split(semi)
253
- assert_parsed_ast_for_text [pass(t1, 8, 1, nil, 8, 2, nil), semi, pass(t2, 8, 4, nil, 8, 4, nil)], text
253
+ assert_parsed_ast_for_text [pass(text: t1, b1: 8, c1: 1, b2: 8, c2: 2), semi, pass(text: t2, b1: 8, c1: 4, b2: 8, c2: 4)], text
254
254
  end
255
255
 
256
256
  def test_book_only_after_full_passage
257
257
  text = 'Matt 3,4; Mar; Joh 3,16'
258
258
  t1, t2, t3 = text.split(semi)
259
- assert_parsed_ast_for_text [pass(t1, 40, 3, 4, 40, 3, 4), semi, pass(t2, 41, nil, nil, 41, nil, nil), semi, pass(t3, 43, 3, 16, 43, 3, 16)], text
259
+ assert_parsed_ast_for_text [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 41, b2: 41), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)], text
260
260
  end
261
261
 
262
262
  def test_chapter_only_after_full_passage
263
263
  text = 'Matt 3,4; 8; Joh 3,16'
264
264
  t1, t2, t3 = text.split(semi)
265
- assert_parsed_ast_for_text [pass(t1, 40, 3, 4, 40, 3, 4), semi, pass(t2, 40, 8, nil, 40, 8, nil), semi, pass(t3, 43, 3, 16, 43, 3, 16)], text
265
+ assert_parsed_ast_for_text [pass(text: t1, b1: 40, c1: 3, v1: 4, b2: 40, c2: 3, v2: 4), semi, pass(text: t2, b1: 40, c1: 8, b2: 40, c2: 8), semi, pass(text: t3, b1: 43, c1: 3, v1: 16, b2: 43, c2: 3, v2: 16)], text
266
266
  end
267
267
 
268
268
  ######################################################################
@@ -273,13 +273,13 @@ class TestParser < Test::Unit::TestCase
273
273
  text = 'Ruth 2,1-11.15; 3,7.9-12; Markus 4; 5,3.18-21'
274
274
  t1, t2, t3, t4, t5, t6, t7 = text.split(/; |\./)
275
275
  ast = [
276
- pass(t1, 8, 2, 1, 8, 2, 11), dot,
277
- pass(t2, 8, 2, 15, 8, 2, 15), semi,
278
- pass(t3, 8, 3, 7, 8, 3, 7), dot,
279
- pass(t4, 8, 3, 9, 8, 3, 12), semi,
280
- pass(t5, 41, 4, nil, 41, 4, nil), semi,
281
- pass(t6, 41, 5, 3, 41, 5, 3), dot,
282
- pass(t7, 41, 5, 18, 41, 5, 21)
276
+ pass(text: t1, b1: 8, c1: 2, v1: 1, b2: 8, c2: 2, v2: 11), dot,
277
+ pass(text: t2, b1: 8, c1: 2, v1: 15, b2: 8, c2: 2, v2: 15), semi,
278
+ pass(text: t3, b1: 8, c1: 3, v1: 7, b2: 8, c2: 3, v2: 7), dot,
279
+ pass(text: t4, b1: 8, c1: 3, v1: 9, b2: 8, c2: 3, v2: 12), semi,
280
+ pass(text: t5, b1: 41, c1: 4, b2: 41, c2: 4), semi,
281
+ pass(text: t6, b1: 41, c1: 5, v1: 3, b2: 41, c2: 5, v2: 3), dot,
282
+ pass(text: t7, b1: 41, c1: 5, v1: 18, b2: 41, c2: 5, v2: 21)
283
283
  ]
284
284
  assert_parsed_ast_for_text ast, text
285
285
  end
@@ -288,22 +288,20 @@ class TestParser < Test::Unit::TestCase
288
288
  # malformed references
289
289
  ######################################################################
290
290
 
291
- def test_error_message
291
+ def test_exception_and_error_message
292
292
  text = 'Ruth 2,x'
293
- begin
293
+ assert_raise ParserError do
294
294
  @parser.parse text
295
- rescue ParserError
296
295
  end
297
296
  assert_equal 'Verse expected!', @parser.error
298
297
  formated_error = "Verse expected!\nRuth 2,x\n ^"
299
298
  assert_equal formated_error, @parser.format_error
300
299
  end
301
300
 
302
- def test_error_message_for_unambiguous_book
301
+ def test_exception_and_error_message_for_ambiguous_book
303
302
  text = 'Ruth 2,4; M 3,8'
304
- begin
303
+ assert_raise ParserError do
305
304
  @parser.parse text
306
- rescue ParserError
307
305
  end
308
306
  assert_match /^Abbreviation M is ambiguous/, @parser.error
309
307
  formated_error = "Abbreviation M is ambiguous it matches Micha, Maleachi, Matthäus, Markus!\nRuth 2,4; M 3,8\n ^"
@@ -315,12 +313,22 @@ class TestParser < Test::Unit::TestCase
315
313
  ######################################################################
316
314
 
317
315
  def test_special_book_abbrev
318
- # Abbrev "Phil" would technical match "Philipper" and "Philemon"
316
+ # Abbreviation "Phil" would technical match "Philipper" and "Philemon"
319
317
  # and therefore throw a ParserError because it's ambiguous,
320
318
  # but in German the abbrev "Phil" is generally used for "Philipper",
321
319
  # so the parser should be able to support such behaviour.
322
320
  text = 'Phil 4,4'
323
- assert_parsed_ast_for_text [pass(text, 50, 4, 4, 50, 4, 4)], text
321
+ assert_parsed_ast_for_text [pass(text: text, b1: 50, c1: 4, v1: 4, b2: 50, c2: 4, v2: 4)], text
322
+ # It must also work with a dot
323
+ text = 'Phil. 4,4'
324
+ assert_parsed_ast_for_text [pass(text: text, b1: 50, c1: 4, v1: 4, b2: 50, c2: 4, v2: 4)], text
325
+ end
326
+
327
+ def test_book_abbrev_which_seems_to_be_ambiguous
328
+ # Abbreviation 'Psm' matches 'Psalm' and 'Psalmen' which is the same
329
+ # book so it is not an ambiguous error.
330
+ text = 'Psm 23,6'
331
+ assert_parsed_ast_for_text [pass(text: text, b1: 19, c1: 23, v1: 6, b2: 19, c2: 23, v2: 6)], text
324
332
  end
325
333
 
326
334
  private
data/test/test_passage.rb CHANGED
@@ -66,24 +66,24 @@ class TestPassage < Test::Unit::TestCase
66
66
  end
67
67
 
68
68
  def test_start
69
- p = pass('', 1, 2, 3, 4, 5, 6)
69
+ p = pass(text: '', b1: 1, c1: 2, v1: 3, b2: 4, c2: 5, v2: 6)
70
70
  assert_equal [1, 2, 3], p.start
71
71
  end
72
72
 
73
73
  def test_end
74
- p = pass('', 1, 2, 3, 4, 5, 6)
74
+ p = pass(text: '', b1: 1, c1: 2, v1: 3, b2: 4, c2: 5, v2: 6)
75
75
  assert_equal [4, 5, 6], p.end
76
76
  end
77
77
 
78
78
  def test_sum
79
- p1 = pass('', 1, 2, 3, 4, 5, 6)
80
- p2 = pass('', 1, 1, 1, 1, 1, 1)
79
+ p1 = pass(text: '', b1: 1, c1: 2, v1: 3, b2: 4, c2: 5, v2: 6)
80
+ p2 = pass(text: '', b1: 1, c1: 1, v1: 1, b2: 1, c2: 1, v2: 1)
81
81
  assert_equal [2, 3, 4, 5, 6, 7], p1 + p2
82
82
  end
83
83
 
84
84
  def test_differenz
85
- p1 = pass('', 1, 2, 3, 4, 5, 6)
86
- p2 = pass('', 1, 1, 1, 1, 1, 1)
85
+ p1 = pass(text: '', b1: 1, c1: 2, v1: 3, b2: 4, c2: 5, v2: 6)
86
+ p2 = pass(text: '', b1: 1, c1: 1, v1: 1, b2: 1, c2: 1, v2: 1)
87
87
  assert_equal [0, 1, 2, 3, 4, 5], p2 - p1
88
88
  end
89
89
 
@@ -1,35 +1,32 @@
1
1
  # - encoding: utf-8 -
2
2
  require 'test_helper'
3
3
 
4
- class TestProcessor < Test::Unit::TestCase
4
+ class TestProcessorIterators < Test::Unit::TestCase
5
5
 
6
6
  include Scripref
7
7
  include Test::Helper
8
8
 
9
- def setup1
9
+ def setup
10
10
  @text = 'Some text Mt 1,1 and Mr 2 and so on ...'
11
- @mt = [pass('Mt 1,1 ', 40, 1, 1, 40, 1, 1)]
12
- @mr = [pass('Mr 2 ', 41, 2, nil, 41, 2, nil)]
11
+ @mt = [pass(text: 'Mt 1,1 ', b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: 1)]
12
+ @mr = [pass(text: 'Mr 2 ', b1: 41, c1: 2, b2: 41, c2: 2)]
13
13
  @processor = Processor.new(@text, German)
14
14
  @chunks = ['Some text ', @mt, 'and ', @mr, 'and so on ...']
15
15
  end
16
16
 
17
17
  def test_each_with_block
18
- setup1
19
18
  @processor.each do |chunk|
20
19
  assert_equal @chunks.shift, chunk
21
20
  end
22
21
  end
23
22
 
24
23
  def test_each_without_block
25
- setup1
26
24
  enum = @processor.each
27
25
  assert_kind_of Enumerator, enum
28
26
  assert_equal @chunks, enum.to_a
29
27
  end
30
28
 
31
29
  def test_each_ref_with_block
32
- setup1
33
30
  refs = @chunks.select {|c| c.kind_of? Array}
34
31
  @processor.each_ref do |ref|
35
32
  assert_equal refs.shift, ref
@@ -37,16 +34,22 @@ class TestProcessor < Test::Unit::TestCase
37
34
  end
38
35
 
39
36
  def test_each_ref_without_block
40
- setup1
41
37
  enum = @processor.each_ref
42
38
  refs = @chunks.select {|c| c.kind_of? Array}
43
39
  assert_kind_of Enumerator, enum
44
40
  assert_equal refs, enum.to_a
45
41
  end
46
42
 
43
+ end
44
+
45
+ class TestProcessorVariousContexts < Test::Unit::TestCase
46
+
47
+ include Scripref
48
+ include Test::Helper
49
+
47
50
  def test_reference_without_other_text
48
51
  text = 'Mt 1,1'
49
- ast = [[pass('Mt 1,1 ', 40, 1, 1, 40, 1, 1)]]
52
+ ast = [[pass(text: 'Mt 1,1 ', b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: 1)]]
50
53
  processor = Processor.new(text, German)
51
54
  assert_equal ast, processor.each_ref.to_a
52
55
  assert_equal ast, processor.each.to_a
@@ -69,47 +72,73 @@ class TestProcessor < Test::Unit::TestCase
69
72
  def test_numerical_context
70
73
  text = '1. Mt 1,1'
71
74
  processor = Processor.new(text, German)
72
- ast = [[pass(text, 40, 1, 1, 40, 1, 1)]]
75
+ ast = [[pass(text: text, b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: 1)]]
73
76
  assert_equal ast, processor.each_ref.to_a
74
- ast = ['1. ', [pass(text, 40, 1, 1, 40, 1, 1)]]
77
+ ast = ['1. ', [pass(text: text, b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: 1)]]
75
78
  assert_equal ast, processor.each.to_a
76
79
  end
77
80
 
78
81
  def test_verse_addon_or_postfix
79
82
  text = 'Mt 1,1a'
80
83
  processor = Processor.new(text, German)
81
- ast = [[pass(text, 40, 1, 1, 40, 1, 1, a1: 'a')]]
84
+ ast = [[pass(text: text, b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: 1, a1: 'a')]]
82
85
  assert_equal ast, processor.each.to_a
83
86
  text = 'Mt 1,1f'
84
87
  processor = Processor.new(text, German)
85
- ast = [[pass(text, 40, 1, 1, 40, 1, :f)]]
88
+ ast = [[pass(text: text, b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: :f)]]
86
89
  assert_equal ast, processor.each.to_a
87
90
  text = 'Mt 1,1ff'
88
91
  processor = Processor.new(text, German)
89
- ast = [[pass(text, 40, 1, 1, 40, 1, :ff)]]
92
+ ast = [[pass(text: text, b1: 40, c1: 1, v1: 1, b2: 40, c2: 1, v2: :ff)]]
90
93
  assert_equal ast, processor.each.to_a
91
94
  end
92
95
 
93
96
  def test_verse_addon_or_postfix_for_books_with_only_one_chapter
94
97
  text = '2. Joh 5b'
95
98
  processor = Processor.new(text, German)
96
- ast = [[pass(text, 63, 1, 5, 63, 1, 5, a1: 'b')]]
99
+ ast = [[pass(text: text, b1: 63, c1: 1, v1: 5, b2: 63, c2: 1, v2: 5, a1: 'b')]]
97
100
  assert_equal ast, processor.each.to_a
98
101
  text = '2. Joh 5f'
99
102
  processor = Processor.new(text, German)
100
- ast = [[pass(text, 63, 1, 5, 63, 1, :f)]]
103
+ ast = [[pass(text: text, b1: 63, c1: 1, v1: 5, b2: 63, c2: 1, v2: :f)]]
101
104
  assert_equal ast, processor.each.to_a
102
105
  text = '2. Joh 5ff'
103
106
  processor = Processor.new(text, German)
104
- ast = [[pass(text, 63, 1, 5, 63, 1, :ff)]]
107
+ ast = [[pass(text: text, b1: 63, c1: 1, v1: 5, b2: 63, c2: 1, v2: :ff)]]
105
108
  assert_equal ast, processor.each.to_a
106
109
  end
107
110
 
108
111
  def test_verse_sep
109
112
  text = '2. Joh 5.8'
110
113
  processor = Processor.new(text, German)
111
- ast = [[pass(text, 63, 1, 5, 63, 1, 5), '.', pass(text, 63, 1, 8, 63, 1, 8)]]
114
+ ast = [[pass(text: text, b1: 63, c1: 1, v1: 5, b2: 63, c2: 1, v2: 5), '.', pass(text: text, b1: 63, c1: 1, v1: 8, b2: 63, c2: 1, v2: 8)]]
112
115
  assert_equal ast, processor.each.to_a
113
116
  end
114
117
 
118
+ def test_complex_reference
119
+ prefix = 'Wie in den Stellen '
120
+ ref = 'Apg 2,3; 4,8; 7,55; 8,29-39; Röm 8,2-9; Gal 6,8 '
121
+ postfix = 'nachzulesen ...'
122
+ text = prefix + ref + postfix
123
+ processor = Processor.new(text, German)
124
+ ast = [pass(text: 'Apg 2,3', b1: 44, c1: 2, v1: 3, b2: 44, c2: 2, v2: 3), '; ', pass(text: '4,8', b1: 44, c1: 4, v1: 8, b2: 44, c2: 4, v2: 8), '; ',
125
+ pass(text: '7,55', b1: 44, c1: 7, v1: 55, b2: 44, c2: 7, v2: 55), '; ', pass(text: '8,29-39', b1: 44, c1: 8, v1: 29, b2: 44, c2: 8, v2: 39), '; ',
126
+ pass(text: 'Röm 8,2-9', b1: 45, c1: 8, v1: 2, b2: 45, c2: 8, v2: 9), '; ', pass(text: 'Gal 6,8 ', b1: 48, c1: 6, v1: 8, b2: 48, c2: 6, v2: 8)]
127
+ assert_equal [ast], processor.each_ref.to_a
128
+ assert_equal [prefix, ast, postfix], processor.each.to_a
129
+ end
130
+
131
+ def test_reference_ends_with_chapter_or_verse
132
+ text = 'Joh 8.'
133
+ processor = Processor.new(text, German)
134
+ ast = [pass(text: 'Joh 8', b1: 43, c1: 8, b2: 43, c2: 8)]
135
+ assert_equal [ast], processor.each_ref.to_a
136
+ assert_equal [ast, '.'], processor.each.to_a
137
+ text = 'Joh 8,12.'
138
+ processor = Processor.new(text, German)
139
+ ast = [pass(text: 'Joh 8,12', b1: 43, c1: 8, v1: 12, b2: 43, c2: 8, v2: 12)]
140
+ assert_equal [ast], processor.each_ref.to_a
141
+ assert_equal [ast, '.'], processor.each.to_a
142
+ end
143
+
115
144
  end
metadata CHANGED
@@ -1,49 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scripref
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rim
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '2.9'
33
+ version: '2.17'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '2.9'
40
+ version: '2.17'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: regtest
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0.4'
47
+ version: '2'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0.4'
54
+ version: '2'
41
55
  description: ''
42
56
  email: janfri26@gmail.com
43
57
  executables: []
44
58
  extensions: []
45
59
  extra_rdoc_files: []
46
60
  files:
61
+ - "./.aspell.pws"
47
62
  - Changelog
48
63
  - LICENSE
49
64
  - README.md
@@ -66,6 +81,7 @@ files:
66
81
  - regtest/parser.yml
67
82
  - regtest/processor.rb
68
83
  - regtest/processor.yml
84
+ - scripref.gemspec
69
85
  - test/test_bookname.rb
70
86
  - test/test_english.rb
71
87
  - test/test_formatter.rb
@@ -87,15 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
103
  requirements:
88
104
  - - ">="
89
105
  - !ruby/object:Gem::Version
90
- version: '0'
106
+ version: 2.5.0
91
107
  required_rubygems_version: !ruby/object:Gem::Requirement
92
108
  requirements:
93
109
  - - ">="
94
110
  - !ruby/object:Gem::Version
95
111
  version: '0'
96
112
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.6.10
113
+ rubygems_version: 3.1.2
99
114
  signing_key:
100
115
  specification_version: 4
101
116
  summary: Library for parsing scripture references in real texts.