scripref 0.15.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +9 -0
- data/Rakefile +0 -10
- data/lib/scripref/basic_methods.rb +3 -1
- data/lib/scripref/bookname.rb +6 -4
- data/lib/scripref/bookorder.rb +20 -0
- data/lib/scripref/const_reader.rb +2 -1
- data/lib/scripref/english.rb +10 -6
- data/lib/scripref/formatter.rb +5 -4
- data/lib/scripref/german.rb +17 -13
- data/lib/scripref/include.rb +3 -1
- data/lib/scripref/parser.rb +17 -15
- data/lib/scripref/passage.rb +39 -45
- data/lib/scripref/pipelining.rb +2 -1
- data/lib/scripref/processor.rb +3 -2
- data/lib/scripref.rb +5 -2
- data/regtest/formatter.rb +2 -2
- data/regtest/formatter.yml +192 -192
- data/regtest/parser.yml +105 -105
- data/regtest/processor.yml +265 -265
- data/scripref.gemspec +17 -31
- data/test/test_bookname.rb +4 -2
- data/test/test_english.rb +16 -14
- data/test/test_formatter.rb +54 -52
- data/test/test_german.rb +12 -10
- data/test/test_helper.rb +3 -1
- data/test/test_integration.rb +3 -1
- data/test/test_parser.rb +66 -64
- data/test/test_passage.rb +7 -18
- data/test/test_pipelining.rb +3 -1
- data/test/test_processor.rb +20 -18
- metadata +11 -12
- data/.aspell.pws +0 -22
data/test/test_parser.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'test_helper'
|
3
5
|
|
4
6
|
class TestParser < Test::Unit::TestCase
|
@@ -12,21 +14,21 @@ class TestParser < Test::Unit::TestCase
|
|
12
14
|
|
13
15
|
def test_only_book
|
14
16
|
text = 'Ruth'
|
15
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
17
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
|
16
18
|
end
|
17
19
|
|
18
20
|
def test_book_abbrev
|
19
21
|
text = 'Ru'
|
20
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
22
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
|
21
23
|
text = 'Offb'
|
22
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
24
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Rev, b2: :Rev)], text
|
23
25
|
end
|
24
26
|
|
25
27
|
def test_book_abbrev_with_period
|
26
28
|
text = 'Ru.'
|
27
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
29
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
|
28
30
|
text = 'Offb.'
|
29
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
31
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Rev, b2: :Rev)], text
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_ambiguous_book
|
@@ -38,115 +40,115 @@ class TestParser < Test::Unit::TestCase
|
|
38
40
|
|
39
41
|
def test_book_and_chapter
|
40
42
|
text = 'Ruth 2'
|
41
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
43
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2)], text
|
42
44
|
end
|
43
45
|
|
44
46
|
def test_book_chapter_and_verse
|
45
47
|
text = 'Ruth 2,5'
|
46
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
48
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5)], text
|
47
49
|
end
|
48
50
|
|
49
51
|
def test_verse_range
|
50
52
|
text = 'Ruth 2,5-11'
|
51
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
53
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 11)], text
|
52
54
|
end
|
53
55
|
|
54
56
|
def test_chapter_verse_range
|
55
57
|
text = 'Ruth 2,5-3,7'
|
56
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
58
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 3, v2: 7)], text
|
57
59
|
end
|
58
60
|
|
59
61
|
def test_chapter_range
|
60
62
|
text = 'Ruth 2-3'
|
61
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
63
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, b2: :Ruth, c2: 3)], text
|
62
64
|
end
|
63
65
|
|
64
66
|
def test_book_range
|
65
67
|
text = '1. Mose - Offenbarung'
|
66
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
68
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Gen, b2: :Rev)], text
|
67
69
|
end
|
68
70
|
|
69
71
|
def test_book_chapter_range
|
70
72
|
text = '1. Mose 1 - Offenbarung 22'
|
71
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
73
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Gen, c1: 1, b2: :Rev, c2: 22)], text
|
72
74
|
end
|
73
75
|
|
74
76
|
def test_book_chapter_verse_range
|
75
77
|
text = '1. Mose 1,1-Offenbarung 22,21'
|
76
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
78
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Gen, c1: 1, v1: 1, b2: :Rev, c2: 22, v2: 21)], text
|
77
79
|
end
|
78
80
|
|
79
81
|
def test_one_following_verse
|
80
82
|
text = 'Ruth 2,5f'
|
81
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
83
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: :f)], text
|
82
84
|
end
|
83
85
|
|
84
86
|
def test_more_following_verse
|
85
87
|
text = 'Ruth 2,5ff'
|
86
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
88
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: :ff)], text
|
87
89
|
end
|
88
90
|
|
89
91
|
def test_first_addon
|
90
92
|
text = 'Ruth 2,5a'
|
91
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
93
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5, a1: :a)], text
|
92
94
|
end
|
93
95
|
|
94
96
|
def test_second_addon
|
95
97
|
text = 'Ruth 2,5-7a'
|
96
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
98
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 7, a2: :a)], text
|
97
99
|
end
|
98
100
|
|
99
101
|
def test_both_addons
|
100
102
|
text = 'Ruth 2,5b-7a'
|
101
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
103
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 7, a1: :b, a2: :a)], text
|
102
104
|
end
|
103
105
|
|
104
106
|
def test_reset_addons
|
105
107
|
@parser.parse 'Ruth 2,5b-7a'
|
106
108
|
text = 'Ruth'
|
107
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
109
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ruth, b2: :Ruth)], text
|
108
110
|
end
|
109
111
|
|
110
112
|
def test_book_with_only_one_chapter
|
111
113
|
text = 'Obad 3'
|
112
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
114
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 3)], text
|
113
115
|
text = 'Obad 1,3'
|
114
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
116
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 3)], text
|
115
117
|
text = 'Obad 1'
|
116
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
118
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 1)], text
|
117
119
|
text = 'Obad 1,1'
|
118
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
120
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 1)], text
|
119
121
|
end
|
120
122
|
|
121
123
|
def test_book_with_only_one_chapter_range
|
122
124
|
text = 'Obad 3-5'
|
123
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
125
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 5)], text
|
124
126
|
text = 'Obad 1,3-5'
|
125
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
127
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Obad, c2: 1, v2: 5)], text
|
126
128
|
text = 'Obad 1-4'
|
127
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
129
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 4)], text
|
128
130
|
text = 'Obad 1,1-4'
|
129
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
131
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 1, b2: :Obad, c2: 1, v2: 4)], text
|
130
132
|
end
|
131
133
|
|
132
134
|
def test_book_with_only_one_chapter_at_begin_of_range
|
133
135
|
text = 'Obad - Jona'
|
134
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
136
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, b2: :Jonah)], text
|
135
137
|
text = 'Obad 3 - Jona 2,4'
|
136
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
138
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Jonah, c2: 2, v2: 4)], text
|
137
139
|
text = 'Obad 1,3 - Jona 2,4'
|
138
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
140
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Obad, c1: 1, v1: 3, b2: :Jonah, c2: 2, v2: 4)], text
|
139
141
|
end
|
140
142
|
|
141
143
|
def test_book_with_only_one_chapter_at_end_of_range
|
142
144
|
text = 'Amos 2,4 - Obad 3'
|
143
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
145
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 3)], text
|
144
146
|
text = 'Amos 2,4 - Obad 1,3'
|
145
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
147
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 3)], text
|
146
148
|
text = 'Amos 2,4 - Obad 1'
|
147
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
149
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 1)], text
|
148
150
|
text = 'Amos 2,4 - Obad 1,1'
|
149
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
151
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Amos, c1: 2, v1: 4, b2: :Obad, c2: 1, v2: 1)], text
|
150
152
|
end
|
151
153
|
|
152
154
|
######################################################################
|
@@ -156,49 +158,49 @@ class TestParser < Test::Unit::TestCase
|
|
156
158
|
def test_two_books
|
157
159
|
text = 'Ruth; Markus'
|
158
160
|
t1, t2 = text.split(semi)
|
159
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
161
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, b2: :Ruth), semi, pass(text: t2, b1: :Mark, b2: :Mark)], text
|
160
162
|
end
|
161
163
|
|
162
164
|
def test_two_complete_refs
|
163
165
|
text = 'Ruth 2,1; Markus 4,8'
|
164
166
|
t1, t2 = text.split(semi)
|
165
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
167
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), semi, pass(text: t2, b1: :Mark, c1: 4, v1: 8, b2: :Mark, c2: 4, v2: 8)], text
|
166
168
|
end
|
167
169
|
|
168
170
|
def test_two_refs_same_book
|
169
171
|
text = 'Ruth 2,1; 5,4'
|
170
172
|
t1, t2 = text.split(semi)
|
171
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
173
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), semi, pass(text: t2, b1: :Ruth, c1: 5, v1: 4, b2: :Ruth, c2: 5, v2: 4)], text
|
172
174
|
end
|
173
175
|
|
174
176
|
def test_two_chapters_same_book
|
175
177
|
text = 'Ruth 2; 5'
|
176
178
|
t1, t2 = text.split(semi)
|
177
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
179
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Ruth, c1: 5, b2: :Ruth, c2: 5)], text
|
178
180
|
end
|
179
181
|
|
180
182
|
def test_two_chapters_different_book
|
181
183
|
text = 'Ruth 2; Markus 4'
|
182
184
|
t1, t2 = text.split(semi)
|
183
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
185
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Mark, c1: 4, b2: :Mark, c2: 4)], text
|
184
186
|
end
|
185
187
|
|
186
188
|
def test_two_verses
|
187
189
|
text = 'Ruth 2,5.11'
|
188
190
|
t1, t2 = text.split(dot)
|
189
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
191
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)], text
|
190
192
|
end
|
191
193
|
|
192
194
|
def test_partial_passage_after_full_passage
|
193
195
|
text = 'Ruth 2,5; 4'
|
194
196
|
t1, t2 = text.split(semi)
|
195
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
197
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Ruth, c1: 4, b2: :Ruth, c2: 4)], text
|
196
198
|
text = 'Ruth 2,5; Markus'
|
197
199
|
t1, t2 = text.split(semi)
|
198
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
200
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Mark, b2: :Mark)], text
|
199
201
|
text = 'Ruth 2,5; Markus 4'
|
200
202
|
t1, t2 = text.split(semi)
|
201
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
203
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 5, b2: :Ruth, c2: 2, v2: 5), semi, pass(text: t2, b1: :Mark, c1: 4, b2: :Mark, c2: 4)], text
|
202
204
|
end
|
203
205
|
|
204
206
|
######################################################################
|
@@ -208,61 +210,61 @@ class TestParser < Test::Unit::TestCase
|
|
208
210
|
def test_verse_range_and_separated_verse
|
209
211
|
text = 'Ruth 2,1-3.11'
|
210
212
|
t1, t2 = text.split(dot)
|
211
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
213
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)], text
|
212
214
|
end
|
213
215
|
|
214
216
|
def test_separate_verse_and_verse_range
|
215
217
|
text = 'Ruth 2,1.3-11'
|
216
218
|
t1, t2 = text.split(dot)
|
217
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
219
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 1), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 3, b2: :Ruth, c2: 2, v2: 11)], text
|
218
220
|
end
|
219
221
|
|
220
222
|
def test_two_verse_ranges
|
221
223
|
text = 'Ruth 2,1-3.7-11'
|
222
224
|
t1, t2 = text.split(dot)
|
223
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
225
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 7, b2: :Ruth, c2: 2, v2: 11)], text
|
224
226
|
end
|
225
227
|
|
226
228
|
def test_two_verse_range_different_books
|
227
229
|
text = 'Ruth 2,1-11; Markus 4,3-7'
|
228
230
|
t1, t2 = text.split(semi)
|
229
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
231
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), semi, pass(text: t2, b1: :Mark, c1: 4, v1: 3, b2: :Mark, c2: 4, v2: 7)], text
|
230
232
|
end
|
231
233
|
|
232
234
|
def test_two_verse_range_different_chapters
|
233
235
|
text = 'Ruth 2,1-11; 3,10-19'
|
234
236
|
t1, t2 = text.split(semi)
|
235
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
237
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), semi, pass(text: t2, b1: :Ruth, c1: 3, v1: 10, b2: :Ruth, c2: 3, v2: 19)], text
|
236
238
|
end
|
237
239
|
|
238
240
|
def test_book_range_and_following_book
|
239
241
|
text = 'Ruth-Markus; Johannes'
|
240
242
|
t1, t2 = text.split(semi)
|
241
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
243
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, b2: :Mark), semi, pass(text: t2, b1: :John, b2: :John)], text
|
242
244
|
end
|
243
245
|
|
244
246
|
def test_chapter_range_and_following_book
|
245
247
|
text = 'Ruth 1-2; Joh 4'
|
246
248
|
t1, t2 = text.split(semi)
|
247
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
249
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 1, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :John, c1: 4, b2: :John, c2: 4)], text
|
248
250
|
end
|
249
251
|
|
250
252
|
def test_chapter_range_and_following_chapter
|
251
253
|
text = 'Ruth 1-2; 4'
|
252
254
|
t1, t2 = text.split(semi)
|
253
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
255
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 1, b2: :Ruth, c2: 2), semi, pass(text: t2, b1: :Ruth, c1: 4, b2: :Ruth, c2: 4)], text
|
254
256
|
end
|
255
257
|
|
256
258
|
def test_book_only_after_full_passage
|
257
259
|
text = 'Matt 3,4; Mar; Joh 3,16'
|
258
260
|
t1, t2, t3 = text.split(semi)
|
259
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
261
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Mark, b2: :Mark), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)], text
|
260
262
|
end
|
261
263
|
|
262
264
|
def test_chapter_only_after_full_passage
|
263
265
|
text = 'Matt 3,4; 8; Joh 3,16'
|
264
266
|
t1, t2, t3 = text.split(semi)
|
265
|
-
assert_parsed_ast_for_text [pass(text: t1, b1:
|
267
|
+
assert_parsed_ast_for_text [pass(text: t1, b1: :Matt, c1: 3, v1: 4, b2: :Matt, c2: 3, v2: 4), semi, pass(text: t2, b1: :Matt, c1: 8, b2: :Matt, c2: 8), semi, pass(text: t3, b1: :John, c1: 3, v1: 16, b2: :John, c2: 3, v2: 16)], text
|
266
268
|
end
|
267
269
|
|
268
270
|
######################################################################
|
@@ -273,13 +275,13 @@ class TestParser < Test::Unit::TestCase
|
|
273
275
|
text = 'Ruth 2,1-11.15; 3,7.9-12; Markus 4; 5,3.18-21'
|
274
276
|
t1, t2, t3, t4, t5, t6, t7 = text.split(/; |\./)
|
275
277
|
ast = [
|
276
|
-
pass(text: t1, b1:
|
277
|
-
pass(text: t2, b1:
|
278
|
-
pass(text: t3, b1:
|
279
|
-
pass(text: t4, b1:
|
280
|
-
pass(text: t5, b1:
|
281
|
-
pass(text: t6, b1:
|
282
|
-
pass(text: t7, b1:
|
278
|
+
pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 11), dot,
|
279
|
+
pass(text: t2, b1: :Ruth, c1: 2, v1: 15, b2: :Ruth, c2: 2, v2: 15), semi,
|
280
|
+
pass(text: t3, b1: :Ruth, c1: 3, v1: 7, b2: :Ruth, c2: 3, v2: 7), dot,
|
281
|
+
pass(text: t4, b1: :Ruth, c1: 3, v1: 9, b2: :Ruth, c2: 3, v2: 12), semi,
|
282
|
+
pass(text: t5, b1: :Mark, c1: 4, b2: :Mark, c2: 4), semi,
|
283
|
+
pass(text: t6, b1: :Mark, c1: 5, v1: 3, b2: :Mark, c2: 5, v2: 3), dot,
|
284
|
+
pass(text: t7, b1: :Mark, c1: 5, v1: 18, b2: :Mark, c2: 5, v2: 21)
|
283
285
|
]
|
284
286
|
assert_parsed_ast_for_text ast, text
|
285
287
|
end
|
@@ -318,17 +320,17 @@ class TestParser < Test::Unit::TestCase
|
|
318
320
|
# but in German the abbrev "Phil" is generally used for "Philipper",
|
319
321
|
# so the parser should be able to support such behaviour.
|
320
322
|
text = 'Phil 4,4'
|
321
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
323
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Phil, c1: 4, v1: 4, b2: :Phil, c2: 4, v2: 4)], text
|
322
324
|
# It must also work with a dot
|
323
325
|
text = 'Phil. 4,4'
|
324
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
326
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Phil, c1: 4, v1: 4, b2: :Phil, c2: 4, v2: 4)], text
|
325
327
|
end
|
326
328
|
|
327
329
|
def test_book_abbrev_which_seems_to_be_ambiguous
|
328
330
|
# Abbreviation 'Psm' matches 'Psalm' and 'Psalmen' which is the same
|
329
331
|
# book so it is not an ambiguous error.
|
330
332
|
text = 'Psm 23,6'
|
331
|
-
assert_parsed_ast_for_text [pass(text: text, b1:
|
333
|
+
assert_parsed_ast_for_text [pass(text: text, b1: :Ps, c1: 23, v1: 6, b2: :Ps, c2: 23, v2: 6)], text
|
332
334
|
end
|
333
335
|
|
334
336
|
private
|
data/test/test_passage.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
require 'test_helper'
|
3
|
+
# frozen_string_literal: true
|
3
4
|
|
4
5
|
class TestPassage < Test::Unit::TestCase
|
5
6
|
|
@@ -12,7 +13,7 @@ class TestPassage < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def test_to_a
|
14
15
|
pass = @parser.parse('Mr 1,2-Luk 3,4').first
|
15
|
-
assert_equal [
|
16
|
+
assert_equal [:Mark, 1, 2, :Luke, 3, 4], pass.to_a
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_spaceship_operator
|
@@ -66,25 +67,13 @@ class TestPassage < Test::Unit::TestCase
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def test_start
|
69
|
-
p = pass(text: '', b1:
|
70
|
-
assert_equal [
|
70
|
+
p = pass(text: '', b1: :Gen, c1: 2, v1: 3, b2: :Num, c2: 5, v2: 6)
|
71
|
+
assert_equal [:Gen, 2, 3], p.start
|
71
72
|
end
|
72
73
|
|
73
74
|
def test_end
|
74
|
-
p = pass(text: '', b1:
|
75
|
-
assert_equal [
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_sum
|
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
|
-
assert_equal [2, 3, 4, 5, 6, 7], p1 + p2
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_differenz
|
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
|
-
assert_equal [0, 1, 2, 3, 4, 5], p2 - p1
|
75
|
+
p = pass(text: '', b1: :Gen, c1: 2, v1: 3, b2: :Num, c2: 5, v2: 6)
|
76
|
+
assert_equal [:Num, 5, 6], p.end
|
88
77
|
end
|
89
78
|
|
90
79
|
protected
|
data/test/test_pipelining.rb
CHANGED
data/test/test_processor.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'test_helper'
|
3
5
|
|
4
6
|
class TestProcessorIterators < Test::Unit::TestCase
|
@@ -8,8 +10,8 @@ class TestProcessorIterators < Test::Unit::TestCase
|
|
8
10
|
|
9
11
|
def setup
|
10
12
|
@text = 'Some text Mt 1,1 and Mr 2 and so on ...'
|
11
|
-
@mt = [pass(text: 'Mt 1,1 ', b1:
|
12
|
-
@mr = [pass(text: 'Mr 2 ', b1:
|
13
|
+
@mt = [pass(text: 'Mt 1,1 ', b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1)]
|
14
|
+
@mr = [pass(text: 'Mr 2 ', b1: :Mark, c1: 2, b2: :Mark, c2: 2)]
|
13
15
|
@processor = Processor.new(@text, German)
|
14
16
|
@chunks = ['Some text ', @mt, 'and ', @mr, 'and so on ...']
|
15
17
|
end
|
@@ -49,7 +51,7 @@ class TestProcessorVariousContexts < Test::Unit::TestCase
|
|
49
51
|
|
50
52
|
def test_reference_without_other_text
|
51
53
|
text = 'Mt 1,1'
|
52
|
-
ast = [[pass(text: 'Mt 1,1 ', b1:
|
54
|
+
ast = [[pass(text: 'Mt 1,1 ', b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1)]]
|
53
55
|
processor = Processor.new(text, German)
|
54
56
|
assert_equal ast, processor.each_ref.to_a
|
55
57
|
assert_equal ast, processor.each.to_a
|
@@ -72,46 +74,46 @@ class TestProcessorVariousContexts < Test::Unit::TestCase
|
|
72
74
|
def test_numerical_context
|
73
75
|
text = '1. Mt 1,1'
|
74
76
|
processor = Processor.new(text, German)
|
75
|
-
ast = [[pass(text: text, b1:
|
77
|
+
ast = [[pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1)]]
|
76
78
|
assert_equal ast, processor.each_ref.to_a
|
77
|
-
ast = ['1. ', [pass(text: text, b1:
|
79
|
+
ast = ['1. ', [pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1)]]
|
78
80
|
assert_equal ast, processor.each.to_a
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_verse_addon_or_postfix
|
82
84
|
text = 'Mt 1,1a'
|
83
85
|
processor = Processor.new(text, German)
|
84
|
-
ast = [[pass(text: text, b1:
|
86
|
+
ast = [[pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1, a1: 'a')]]
|
85
87
|
assert_equal ast, processor.each.to_a
|
86
88
|
text = 'Mt 1,1f'
|
87
89
|
processor = Processor.new(text, German)
|
88
|
-
ast = [[pass(text: text, b1:
|
90
|
+
ast = [[pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: :f)]]
|
89
91
|
assert_equal ast, processor.each.to_a
|
90
92
|
text = 'Mt 1,1ff'
|
91
93
|
processor = Processor.new(text, German)
|
92
|
-
ast = [[pass(text: text, b1:
|
94
|
+
ast = [[pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: :ff)]]
|
93
95
|
assert_equal ast, processor.each.to_a
|
94
96
|
end
|
95
97
|
|
96
98
|
def test_verse_addon_or_postfix_for_books_with_only_one_chapter
|
97
99
|
text = '2. Joh 5b'
|
98
100
|
processor = Processor.new(text, German)
|
99
|
-
ast = [[pass(text: text, b1:
|
101
|
+
ast = [[pass(text: text, b1: :'2John', c1: 1, v1: 5, b2: :'2John', c2: 1, v2: 5, a1: 'b')]]
|
100
102
|
assert_equal ast, processor.each.to_a
|
101
103
|
text = '2. Joh 5f'
|
102
104
|
processor = Processor.new(text, German)
|
103
|
-
ast = [[pass(text: text, b1:
|
105
|
+
ast = [[pass(text: text, b1: :'2John', c1: 1, v1: 5, b2: :'2John', c2: 1, v2: :f)]]
|
104
106
|
assert_equal ast, processor.each.to_a
|
105
107
|
text = '2. Joh 5ff'
|
106
108
|
processor = Processor.new(text, German)
|
107
|
-
ast = [[pass(text: text, b1:
|
109
|
+
ast = [[pass(text: text, b1: :'2John', c1: 1, v1: 5, b2: :'2John', c2: 1, v2: :ff)]]
|
108
110
|
assert_equal ast, processor.each.to_a
|
109
111
|
end
|
110
112
|
|
111
113
|
def test_verse_sep
|
112
114
|
text = '2. Joh 5.8'
|
113
115
|
processor = Processor.new(text, German)
|
114
|
-
ast = [[pass(text: text, b1:
|
116
|
+
ast = [[pass(text: text, b1: :'2John', c1: 1, v1: 5, b2: :'2John', c2: 1, v2: 5), '.', pass(text: text, b1: :'2John', c1: 1, v1: 8, b2: :'2John', c2: 1, v2: 8)]]
|
115
117
|
assert_equal ast, processor.each.to_a
|
116
118
|
end
|
117
119
|
|
@@ -121,9 +123,9 @@ class TestProcessorVariousContexts < Test::Unit::TestCase
|
|
121
123
|
postfix = 'nachzulesen ...'
|
122
124
|
text = prefix + ref + postfix
|
123
125
|
processor = Processor.new(text, German)
|
124
|
-
ast = [pass(text: 'Apg 2,3', b1:
|
125
|
-
pass(text: '7,55', b1:
|
126
|
-
pass(text: 'Röm 8,2-9', b1:
|
126
|
+
ast = [pass(text: 'Apg 2,3', b1: :Acts, c1: 2, v1: 3, b2: :Acts, c2: 2, v2: 3), '; ', pass(text: '4,8', b1: :Acts, c1: 4, v1: 8, b2: :Acts, c2: 4, v2: 8), '; ',
|
127
|
+
pass(text: '7,55', b1: :Acts, c1: 7, v1: 55, b2: :Acts, c2: 7, v2: 55), '; ', pass(text: '8,29-39', b1: :Acts, c1: 8, v1: 29, b2: :Acts, c2: 8, v2: 39), '; ',
|
128
|
+
pass(text: 'Röm 8,2-9', b1: :Rom, c1: 8, v1: 2, b2: :Rom, c2: 8, v2: 9), '; ', pass(text: 'Gal 6,8 ', b1: :Gal, c1: 6, v1: 8, b2: :Gal, c2: 6, v2: 8)]
|
127
129
|
assert_equal [ast], processor.each_ref.to_a
|
128
130
|
assert_equal [prefix, ast, postfix], processor.each.to_a
|
129
131
|
end
|
@@ -131,12 +133,12 @@ class TestProcessorVariousContexts < Test::Unit::TestCase
|
|
131
133
|
def test_reference_ends_with_chapter_or_verse
|
132
134
|
text = 'Joh 8.'
|
133
135
|
processor = Processor.new(text, German)
|
134
|
-
ast = [pass(text: 'Joh 8', b1:
|
136
|
+
ast = [pass(text: 'Joh 8', b1: :John, c1: 8, b2: :John, c2: 8)]
|
135
137
|
assert_equal [ast], processor.each_ref.to_a
|
136
138
|
assert_equal [ast, '.'], processor.each.to_a
|
137
139
|
text = 'Joh 8,12.'
|
138
140
|
processor = Processor.new(text, German)
|
139
|
-
ast = [pass(text: 'Joh 8,12', b1:
|
141
|
+
ast = [pass(text: 'Joh 8,12', b1: :John, c1: 8, v1: 12, b2: :John, c2: 8, v2: 12)]
|
140
142
|
assert_equal [ast], processor.each_ref.to_a
|
141
143
|
assert_equal [ast, '.'], processor.each.to_a
|
142
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scripref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
|
+
original_platform: ''
|
6
7
|
authors:
|
7
8
|
- Jan Friedrich
|
8
|
-
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: regtest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,13 +52,11 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2'
|
55
|
-
description: ''
|
56
55
|
email: janfri26@gmail.com
|
57
56
|
executables: []
|
58
57
|
extensions: []
|
59
58
|
extra_rdoc_files: []
|
60
59
|
files:
|
61
|
-
- "./.aspell.pws"
|
62
60
|
- Changelog
|
63
61
|
- LICENSE
|
64
62
|
- README.md
|
@@ -66,6 +64,7 @@ files:
|
|
66
64
|
- lib/scripref.rb
|
67
65
|
- lib/scripref/basic_methods.rb
|
68
66
|
- lib/scripref/bookname.rb
|
67
|
+
- lib/scripref/bookorder.rb
|
69
68
|
- lib/scripref/const_reader.rb
|
70
69
|
- lib/scripref/english.rb
|
71
70
|
- lib/scripref/formatter.rb
|
@@ -94,8 +93,9 @@ files:
|
|
94
93
|
- test/test_processor.rb
|
95
94
|
homepage: https://github.com/janfri/scripref
|
96
95
|
licenses: []
|
97
|
-
metadata:
|
98
|
-
|
96
|
+
metadata:
|
97
|
+
homepage_uri: https://github.com/janfri/scripref
|
98
|
+
source_code_uri: https://github.com/janfri/scripref
|
99
99
|
rdoc_options: []
|
100
100
|
require_paths:
|
101
101
|
- lib
|
@@ -103,15 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: '0'
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
114
|
-
signing_key:
|
113
|
+
rubygems_version: 3.6.0.dev
|
115
114
|
specification_version: 4
|
116
115
|
summary: Library for parsing scripture references in real texts.
|
117
116
|
test_files: []
|
data/.aspell.pws
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
personal_ws-1.1 en 21
|
2
|
-
Bookname
|
3
|
-
ParserError
|
4
|
-
PassSep
|
5
|
-
Philipper
|
6
|
-
Psalmen
|
7
|
-
Psm
|
8
|
-
Scripref
|
9
|
-
VerseSep
|
10
|
-
addons
|
11
|
-
autoload
|
12
|
-
formatter
|
13
|
-
fullref
|
14
|
-
mixins
|
15
|
-
pipelining
|
16
|
-
postfix
|
17
|
-
postfixes
|
18
|
-
refactoring
|
19
|
-
refactorings
|
20
|
-
regtest
|
21
|
-
sep
|
22
|
-
struct
|