scripref 0.6.0 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0fc95082d6f8f815ac4125c0eef8b6e1c28abc9
4
- data.tar.gz: e08bde6417a5fa005412d1125ea7fa23c327af24
3
+ metadata.gz: db688b68880cd6c75e6d60c4406d830099b1306d
4
+ data.tar.gz: 5b5e59086582d1c0f34942ea3b365d68ba0c143d
5
5
  SHA512:
6
- metadata.gz: f89c7410072844ed4d09ecf4137a6168496bcfb888002219b74f864de0811c0f3a166b5f37a7513160d79266d9578832a10196b9408e8cfa3731731c5b58a6a1
7
- data.tar.gz: cf33c35be9080ba70ac85259cdd56273405eed57508cdaf75d59f2f1d444e63fe93ab0bd9c2ccfb2d6af62f909d319b641891ec11928d0449d0e27f7c95d44a8
6
+ metadata.gz: 28ae3e96d2f71bdfd418eb1416e02f4e11edc9d8696c684d055f5cc316e266ffa07cd61b4253afba44c1e408aaebbed076f3468b011dedfaaaae476a7f3ed3a9
7
+ data.tar.gz: 405d7fcb3d5a402ff89e44d7fe73c72d137d999d2707a1bccb8d6bcd21fb48512ef0385225947413fa52d1e84f0f66777d1cd79b1338ab16992e3c047e746a5b
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 0.7.0
2
+ Allow alternative book names.
3
+ Reorder formatting error messages to message, string, pointer.
4
+ Update homepage.
5
+
1
6
  0.6.0
2
7
  Use explicit classes for separators: PassSep and VerseSep.
3
8
  Refactoring: Rename class Parser::Error -> ParserError.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2015 Jan Friedrich
1
+ Copyright (c) 2010-2016 Jan Friedrich
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ require 'scripref'
8
8
  Rim.setup do
9
9
  name 'scripref'
10
10
  authors 'Jan Friedrich'
11
- homepage 'http://gitorious.org/scripref'
11
+ homepage 'https://github.com/janfri/scripref'
12
12
  version Scripref::VERSION
13
13
  summary 'Library for parsing scripture references in real texts.'
14
14
  end
@@ -21,14 +21,6 @@ module Scripref
21
21
  Jude, Revelation
22
22
  END
23
23
 
24
- # Array of regular expressions to match book names.
25
- BOOKS_RES = BOOK_NAMES.map do |bn|
26
- Regexp.new(bn.gsub(/([^1-3A-Z])/, '\1?').gsub('.', '\.') << '\b\s*')
27
- end
28
-
29
- # Regular expression to match a book.
30
- BOOK_RE = Regexp.new(BOOKS_RES.map {|re| '(^' << re.to_s << ')' }.join('|'))
31
-
32
24
  # Separator between chapter and verse.
33
25
  CV_SEPARATOR = ':'
34
26
 
@@ -32,10 +32,14 @@ module Scripref
32
32
  format_b1
33
33
  end
34
34
 
35
+ def format_book num
36
+ Array(book_names[num - 1]).first
37
+ end
38
+
35
39
  def format_b1
36
40
  b1 = @pass.b1
37
41
  if @last_b != b1
38
- @result << book_names[b1 - 1]
42
+ @result << format_book(b1)
39
43
  @last_b = b1
40
44
  @changed = true
41
45
  end
@@ -73,7 +77,7 @@ module Scripref
73
77
  b2 = @pass.b2
74
78
  if b2 && (@changed || @last_b != b2)
75
79
  @result << hyphen_separator
76
- @result << book_names[b2 - 1]
80
+ @result << format_book(b2)
77
81
  @last_b = b2
78
82
  @changed = true
79
83
  @hyphen = true
@@ -7,25 +7,17 @@ module Scripref
7
7
  module German
8
8
 
9
9
  # Array of book names.
10
- BOOK_NAMES = <<-END.strip.split(/,\s*/)
10
+ BOOK_NAMES = <<-END.strip.split(/,\s*/).map {|e| e.split('|')}
11
11
  1. Mose, 2. Mose, 3. Mose, 4. Mose, 5. Mose, Josua, Richter, Ruth, 1. Samuel, 2. Samuel,
12
12
  1. Könige, 2. Könige, 1. Chronika, 2. Chronika, Esra, Nehemia, Esther, Hiob, Psalm,
13
13
  Sprüche, Prediger, Hohelied, Jesaja, Jeremia, Klagelieder, Hesekiel, Daniel, Hosea, Joel,
14
- Amos, Obadja, Jona, Micha, Nahum, Habakuk, Zephanja, Haggai, Sacharja, Maleachi,
14
+ Amos, Obadja, Jona, Micha, Nahum, Habakuk, Zefanja|Zephanja, Haggai, Sacharja, Maleachi,
15
15
  Matthäus, Markus, Lukas, Johannes, Apostelgeschichte, Römer, 1. Korinther, 2. Korinther,
16
16
  Galater, Epheser, Philipper, Kolosser, 1. Thessalonicher, 2. Thessalonicher, 1. Timotheus,
17
17
  2. Timotheus, Titus, Philemon, Hebräer, Jakobus, 1. Petrus, 2. Petrus, 1. Johannes,
18
18
  2. Johannes, 3. Johannes, Judas, Offenbarung
19
19
  END
20
20
 
21
- # Array of regular expressions to match book names.
22
- BOOKS_RES = BOOK_NAMES.map do |bn|
23
- Regexp.new(bn.gsub(/([^1-5A-Z])/, '\1?').gsub('.', '\.') << '\b\s*')
24
- end
25
-
26
- # Regular expression to match a book.
27
- BOOK_RE = Regexp.new(BOOKS_RES.map {|re| '(^' << re.to_s << ')' }.join('|'))
28
-
29
21
  # Separator between chapter and verse.
30
22
  CV_SEPARATOR = ','
31
23
 
@@ -227,12 +227,21 @@ module Scripref
227
227
  @a1 = @a2 = nil
228
228
  end
229
229
 
230
+ # Regular expression to match a book.
231
+ def book_re
232
+ return @book_re if @book_re
233
+ books_res_as_strings = book_names.flatten.map do |bn|
234
+ (bn.gsub(/([^\dA-Z])/, '\1?').gsub('.', '\.')) << '\b\s*'
235
+ end
236
+ @book_re = Regexp.compile(books_res_as_strings.map {|s| '(^' << s << ')' }.join('|'), nil)
237
+ end
238
+
230
239
  def abbrev2num str
231
240
  book2num(abbrev2book(str))
232
241
  end
233
242
 
234
243
  def abbrev2book str
235
- @books_str ||= ('#' << book_names.join('#') << '#')
244
+ @books_str ||= ('#' << book_names.flatten.join('#') << '#')
236
245
  pattern = str.strip.chars.map {|c| Regexp.escape(c) << '[^#]*'}.join
237
246
  re = /(?<=#)#{pattern}(?=#)/
238
247
  names = @books_str.scan(re)
@@ -243,7 +252,11 @@ module Scripref
243
252
  def book2num str
244
253
  unless @book2num
245
254
  @book2num = {}
246
- book_names.each_with_index {|s, i| @book2num[s] = i+1}
255
+ book_names.each_with_index do |bns, i|
256
+ Array(bns).each do |bn|
257
+ @book2num[bn] = i+1
258
+ end
259
+ end
247
260
  end
248
261
  @book2num[str]
249
262
  end
@@ -259,7 +272,7 @@ module Scripref
259
272
 
260
273
  def format_error
261
274
  if error
262
- format("%s\n%s^\n%s", string, ' ' * pointer, error)
275
+ format("%s\n%s\n%s^", error, string, ' ' * pointer)
263
276
  else
264
277
  ''
265
278
  end
data/lib/scripref.rb CHANGED
@@ -8,7 +8,7 @@ require 'scripref/german'
8
8
 
9
9
  module Scripref
10
10
 
11
- VERSION = '0.6.0'
11
+ VERSION = '0.7.0'
12
12
 
13
13
  Passage = Struct.new(:text, :b1, :c1, :v1, :b2, :c2, :v2, :a1, :a2) do
14
14
 
@@ -0,0 +1,26 @@
1
+ require 'ostruct'
2
+ require 'regtest'
3
+ require 'scripref'
4
+
5
+ include Regtest
6
+ include Scripref
7
+
8
+ o = OpenStruct.new
9
+ o.b1 = [42]
10
+ o.c1 = [1, nil]
11
+ o.v1 = [2, nil]
12
+ o.b2 = [43, nil]
13
+ o.c2 = [3, nil]
14
+ o.v2 = [4, nil]
15
+
16
+ formatter = Formatter.new(German)
17
+
18
+ combinations(o).each do |c|
19
+ a = [c.b1, c.c1, c.v1, c.b2, c.c2, c.v2]
20
+ pass = Passage.new('', *a)
21
+ h = pass.to_h
22
+ h.shift
23
+ sample h do
24
+ formatter.format([pass])
25
+ end
26
+ end
@@ -0,0 +1,352 @@
1
+ ---
2
+ sample:
3
+ :b1: 42
4
+ :c1: 1
5
+ :v1: 2
6
+ :b2: 43
7
+ :c2: 3
8
+ :v2: 4
9
+ :a1:
10
+ :a2:
11
+ result: Lukas 1,2-Johannes 3,4
12
+ ---
13
+ sample:
14
+ :b1: 42
15
+ :c1: 1
16
+ :v1: 2
17
+ :b2: 43
18
+ :c2: 3
19
+ :v2:
20
+ :a1:
21
+ :a2:
22
+ result: Lukas 1,2-Johannes 3
23
+ ---
24
+ sample:
25
+ :b1: 42
26
+ :c1: 1
27
+ :v1: 2
28
+ :b2: 43
29
+ :c2:
30
+ :v2: 4
31
+ :a1:
32
+ :a2:
33
+ result: Lukas 1,2-Johannes,4
34
+ ---
35
+ sample:
36
+ :b1: 42
37
+ :c1: 1
38
+ :v1: 2
39
+ :b2: 43
40
+ :c2:
41
+ :v2:
42
+ :a1:
43
+ :a2:
44
+ result: Lukas 1,2-Johannes
45
+ ---
46
+ sample:
47
+ :b1: 42
48
+ :c1: 1
49
+ :v1: 2
50
+ :b2:
51
+ :c2: 3
52
+ :v2: 4
53
+ :a1:
54
+ :a2:
55
+ result: Lukas 1,2-3,4
56
+ ---
57
+ sample:
58
+ :b1: 42
59
+ :c1: 1
60
+ :v1: 2
61
+ :b2:
62
+ :c2: 3
63
+ :v2:
64
+ :a1:
65
+ :a2:
66
+ result: Lukas 1,2-3
67
+ ---
68
+ sample:
69
+ :b1: 42
70
+ :c1: 1
71
+ :v1: 2
72
+ :b2:
73
+ :c2:
74
+ :v2: 4
75
+ :a1:
76
+ :a2:
77
+ result: Lukas 1,2-4
78
+ ---
79
+ sample:
80
+ :b1: 42
81
+ :c1: 1
82
+ :v1: 2
83
+ :b2:
84
+ :c2:
85
+ :v2:
86
+ :a1:
87
+ :a2:
88
+ result: Lukas 1,2
89
+ ---
90
+ sample:
91
+ :b1: 42
92
+ :c1: 1
93
+ :v1:
94
+ :b2: 43
95
+ :c2: 3
96
+ :v2: 4
97
+ :a1:
98
+ :a2:
99
+ result: Lukas 1-Johannes 3,4
100
+ ---
101
+ sample:
102
+ :b1: 42
103
+ :c1: 1
104
+ :v1:
105
+ :b2: 43
106
+ :c2: 3
107
+ :v2:
108
+ :a1:
109
+ :a2:
110
+ result: Lukas 1-Johannes 3
111
+ ---
112
+ sample:
113
+ :b1: 42
114
+ :c1: 1
115
+ :v1:
116
+ :b2: 43
117
+ :c2:
118
+ :v2: 4
119
+ :a1:
120
+ :a2:
121
+ result: Lukas 1-Johannes,4
122
+ ---
123
+ sample:
124
+ :b1: 42
125
+ :c1: 1
126
+ :v1:
127
+ :b2: 43
128
+ :c2:
129
+ :v2:
130
+ :a1:
131
+ :a2:
132
+ result: Lukas 1-Johannes
133
+ ---
134
+ sample:
135
+ :b1: 42
136
+ :c1: 1
137
+ :v1:
138
+ :b2:
139
+ :c2: 3
140
+ :v2: 4
141
+ :a1:
142
+ :a2:
143
+ result: Lukas 1-3,4
144
+ ---
145
+ sample:
146
+ :b1: 42
147
+ :c1: 1
148
+ :v1:
149
+ :b2:
150
+ :c2: 3
151
+ :v2:
152
+ :a1:
153
+ :a2:
154
+ result: Lukas 1-3
155
+ ---
156
+ sample:
157
+ :b1: 42
158
+ :c1: 1
159
+ :v1:
160
+ :b2:
161
+ :c2:
162
+ :v2: 4
163
+ :a1:
164
+ :a2:
165
+ result: Lukas 1-4
166
+ ---
167
+ sample:
168
+ :b1: 42
169
+ :c1: 1
170
+ :v1:
171
+ :b2:
172
+ :c2:
173
+ :v2:
174
+ :a1:
175
+ :a2:
176
+ result: Lukas 1
177
+ ---
178
+ sample:
179
+ :b1: 42
180
+ :c1:
181
+ :v1: 2
182
+ :b2: 43
183
+ :c2: 3
184
+ :v2: 4
185
+ :a1:
186
+ :a2:
187
+ result: Lukas,2-Johannes 3,4
188
+ ---
189
+ sample:
190
+ :b1: 42
191
+ :c1:
192
+ :v1: 2
193
+ :b2: 43
194
+ :c2: 3
195
+ :v2:
196
+ :a1:
197
+ :a2:
198
+ result: Lukas,2-Johannes 3
199
+ ---
200
+ sample:
201
+ :b1: 42
202
+ :c1:
203
+ :v1: 2
204
+ :b2: 43
205
+ :c2:
206
+ :v2: 4
207
+ :a1:
208
+ :a2:
209
+ result: Lukas,2-Johannes,4
210
+ ---
211
+ sample:
212
+ :b1: 42
213
+ :c1:
214
+ :v1: 2
215
+ :b2: 43
216
+ :c2:
217
+ :v2:
218
+ :a1:
219
+ :a2:
220
+ result: Lukas,2-Johannes
221
+ ---
222
+ sample:
223
+ :b1: 42
224
+ :c1:
225
+ :v1: 2
226
+ :b2:
227
+ :c2: 3
228
+ :v2: 4
229
+ :a1:
230
+ :a2:
231
+ result: Lukas,2-3,4
232
+ ---
233
+ sample:
234
+ :b1: 42
235
+ :c1:
236
+ :v1: 2
237
+ :b2:
238
+ :c2: 3
239
+ :v2:
240
+ :a1:
241
+ :a2:
242
+ result: Lukas,2-3
243
+ ---
244
+ sample:
245
+ :b1: 42
246
+ :c1:
247
+ :v1: 2
248
+ :b2:
249
+ :c2:
250
+ :v2: 4
251
+ :a1:
252
+ :a2:
253
+ result: Lukas,2-4
254
+ ---
255
+ sample:
256
+ :b1: 42
257
+ :c1:
258
+ :v1: 2
259
+ :b2:
260
+ :c2:
261
+ :v2:
262
+ :a1:
263
+ :a2:
264
+ result: Lukas,2
265
+ ---
266
+ sample:
267
+ :b1: 42
268
+ :c1:
269
+ :v1:
270
+ :b2: 43
271
+ :c2: 3
272
+ :v2: 4
273
+ :a1:
274
+ :a2:
275
+ result: Lukas-Johannes 3,4
276
+ ---
277
+ sample:
278
+ :b1: 42
279
+ :c1:
280
+ :v1:
281
+ :b2: 43
282
+ :c2: 3
283
+ :v2:
284
+ :a1:
285
+ :a2:
286
+ result: Lukas-Johannes 3
287
+ ---
288
+ sample:
289
+ :b1: 42
290
+ :c1:
291
+ :v1:
292
+ :b2: 43
293
+ :c2:
294
+ :v2: 4
295
+ :a1:
296
+ :a2:
297
+ result: Lukas-Johannes,4
298
+ ---
299
+ sample:
300
+ :b1: 42
301
+ :c1:
302
+ :v1:
303
+ :b2: 43
304
+ :c2:
305
+ :v2:
306
+ :a1:
307
+ :a2:
308
+ result: Lukas-Johannes
309
+ ---
310
+ sample:
311
+ :b1: 42
312
+ :c1:
313
+ :v1:
314
+ :b2:
315
+ :c2: 3
316
+ :v2: 4
317
+ :a1:
318
+ :a2:
319
+ result: Lukas-3,4
320
+ ---
321
+ sample:
322
+ :b1: 42
323
+ :c1:
324
+ :v1:
325
+ :b2:
326
+ :c2: 3
327
+ :v2:
328
+ :a1:
329
+ :a2:
330
+ result: Lukas-3
331
+ ---
332
+ sample:
333
+ :b1: 42
334
+ :c1:
335
+ :v1:
336
+ :b2:
337
+ :c2:
338
+ :v2: 4
339
+ :a1:
340
+ :a2:
341
+ result: Lukas-4
342
+ ---
343
+ sample:
344
+ :b1: 42
345
+ :c1:
346
+ :v1:
347
+ :b2:
348
+ :c2:
349
+ :v2:
350
+ :a1:
351
+ :a2:
352
+ result: Lukas
@@ -0,0 +1,478 @@
1
+ ---
2
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
3
+ result:
4
+ - :text: Ruth 2,1a-11
5
+ :b1: 8
6
+ :c1: 2
7
+ :v1: 1
8
+ :b2: 8
9
+ :c2: 2
10
+ :v2: 11
11
+ :a1: :a
12
+ :a2:
13
+ - "."
14
+ - :text: 15a
15
+ :b1: 8
16
+ :c1: 2
17
+ :v1: 15
18
+ :b2: 8
19
+ :c2: 2
20
+ :v2: 15
21
+ :a1: :a
22
+ :a2:
23
+ - "; "
24
+ - :text: 3,7b
25
+ :b1: 8
26
+ :c1: 3
27
+ :v1: 7
28
+ :b2: 8
29
+ :c2: 3
30
+ :v2: 7
31
+ :a1: :b
32
+ :a2:
33
+ - "."
34
+ - :text: 9-12b
35
+ :b1: 8
36
+ :c1: 3
37
+ :v1: 9
38
+ :b2: 8
39
+ :c2: 3
40
+ :v2: 12
41
+ :a1:
42
+ :a2: :b
43
+ - "; "
44
+ - :text: Markus 4
45
+ :b1: 41
46
+ :c1: 4
47
+ :v1:
48
+ :b2: 41
49
+ :c2: 4
50
+ :v2:
51
+ :a1:
52
+ :a2:
53
+ - "; "
54
+ - :text: 5,3a
55
+ :b1: 41
56
+ :c1: 5
57
+ :v1: 3
58
+ :b2: 41
59
+ :c2: 5
60
+ :v2: 3
61
+ :a1: :a
62
+ :a2:
63
+ - "."
64
+ - :text: 18b-21a
65
+ :b1: 41
66
+ :c1: 5
67
+ :v1: 18
68
+ :b2: 41
69
+ :c2: 5
70
+ :v2: 21
71
+ :a1: :b
72
+ :a2: :a
73
+ ---
74
+ sample: " 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a"
75
+ exception: |-
76
+ Book expected!
77
+ 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
78
+ ^
79
+ ---
80
+ sample: Ruth ,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
81
+ exception: |-
82
+ EOS or hyphen and book or chapter expected!
83
+ Ruth ,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
84
+ ^
85
+ ---
86
+ sample: Ruth 21a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
87
+ exception: |-
88
+ EOS or chapter verse separator or hyphen and book or hyphen and chapter or passage separator and book or passage separator and chapter expected!
89
+ Ruth 21a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
90
+ ^
91
+ ---
92
+ sample: Ruth 2,-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
93
+ exception: |-
94
+ Verse expected!
95
+ Ruth 2,-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
96
+ ^
97
+ ---
98
+ sample: Ruth 2,1a11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
99
+ exception: |-
100
+ EOS or passage separator or verse separator or hyphen expected!
101
+ Ruth 2,1a11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
102
+ ^
103
+ ---
104
+ sample: Ruth 2,1a-.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
105
+ exception: |-
106
+ Chapter or verse expected!
107
+ Ruth 2,1a-.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
108
+ ^
109
+ ---
110
+ sample: Ruth 2,1a-1115a; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
111
+ result:
112
+ - :text: Ruth 2,1a-1115a
113
+ :b1: 8
114
+ :c1: 2
115
+ :v1: 1
116
+ :b2: 8
117
+ :c2: 2
118
+ :v2: 1115
119
+ :a1: :a
120
+ :a2: :a
121
+ - "; "
122
+ - :text: 3,7b
123
+ :b1: 8
124
+ :c1: 3
125
+ :v1: 7
126
+ :b2: 8
127
+ :c2: 3
128
+ :v2: 7
129
+ :a1: :b
130
+ :a2:
131
+ - "."
132
+ - :text: 9-12b
133
+ :b1: 8
134
+ :c1: 3
135
+ :v1: 9
136
+ :b2: 8
137
+ :c2: 3
138
+ :v2: 12
139
+ :a1:
140
+ :a2: :b
141
+ - "; "
142
+ - :text: Markus 4
143
+ :b1: 41
144
+ :c1: 4
145
+ :v1:
146
+ :b2: 41
147
+ :c2: 4
148
+ :v2:
149
+ :a1:
150
+ :a2:
151
+ - "; "
152
+ - :text: 5,3a
153
+ :b1: 41
154
+ :c1: 5
155
+ :v1: 3
156
+ :b2: 41
157
+ :c2: 5
158
+ :v2: 3
159
+ :a1: :a
160
+ :a2:
161
+ - "."
162
+ - :text: 18b-21a
163
+ :b1: 41
164
+ :c1: 5
165
+ :v1: 18
166
+ :b2: 41
167
+ :c2: 5
168
+ :v2: 21
169
+ :a1: :b
170
+ :a2: :a
171
+ ---
172
+ sample: Ruth 2,1a-11.; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
173
+ exception: |-
174
+ Verse expected!
175
+ Ruth 2,1a-11.; 3,7b.9-12b; Markus 4; 5,3a.18b-21a
176
+ ^
177
+ ---
178
+ sample: Ruth 2,1a-11.15a3,7b.9-12b; Markus 4; 5,3a.18b-21a
179
+ exception: |-
180
+ EOS or passage separator or verse separator or hyphen expected!
181
+ Ruth 2,1a-11.15a3,7b.9-12b; Markus 4; 5,3a.18b-21a
182
+ ^
183
+ ---
184
+ sample: Ruth 2,1a-11.15a; ,7b.9-12b; Markus 4; 5,3a.18b-21a
185
+ exception: |-
186
+ Book or chapter expected!
187
+ Ruth 2,1a-11.15a; ,7b.9-12b; Markus 4; 5,3a.18b-21a
188
+ ^
189
+ ---
190
+ sample: Ruth 2,1a-11.15a; 37b.9-12b; Markus 4; 5,3a.18b-21a
191
+ exception: |-
192
+ EOS or chapter verse separator or hyphen and book or hyphen and chapter or passage separator and book or passage separator and chapter expected!
193
+ Ruth 2,1a-11.15a; 37b.9-12b; Markus 4; 5,3a.18b-21a
194
+ ^
195
+ ---
196
+ sample: Ruth 2,1a-11.15a; 3,.9-12b; Markus 4; 5,3a.18b-21a
197
+ exception: |-
198
+ Verse expected!
199
+ Ruth 2,1a-11.15a; 3,.9-12b; Markus 4; 5,3a.18b-21a
200
+ ^
201
+ ---
202
+ sample: Ruth 2,1a-11.15a; 3,7b9-12b; Markus 4; 5,3a.18b-21a
203
+ exception: |-
204
+ EOS or passage separator or verse separator or hyphen expected!
205
+ Ruth 2,1a-11.15a; 3,7b9-12b; Markus 4; 5,3a.18b-21a
206
+ ^
207
+ ---
208
+ sample: Ruth 2,1a-11.15a; 3,7b.-12b; Markus 4; 5,3a.18b-21a
209
+ exception: |-
210
+ Verse expected!
211
+ Ruth 2,1a-11.15a; 3,7b.-12b; Markus 4; 5,3a.18b-21a
212
+ ^
213
+ ---
214
+ sample: Ruth 2,1a-11.15a; 3,7b.912b; Markus 4; 5,3a.18b-21a
215
+ result:
216
+ - :text: Ruth 2,1a-11
217
+ :b1: 8
218
+ :c1: 2
219
+ :v1: 1
220
+ :b2: 8
221
+ :c2: 2
222
+ :v2: 11
223
+ :a1: :a
224
+ :a2:
225
+ - "."
226
+ - :text: 15a
227
+ :b1: 8
228
+ :c1: 2
229
+ :v1: 15
230
+ :b2: 8
231
+ :c2: 2
232
+ :v2: 15
233
+ :a1: :a
234
+ :a2:
235
+ - "; "
236
+ - :text: 3,7b
237
+ :b1: 8
238
+ :c1: 3
239
+ :v1: 7
240
+ :b2: 8
241
+ :c2: 3
242
+ :v2: 7
243
+ :a1: :b
244
+ :a2:
245
+ - "."
246
+ - :text: 912b
247
+ :b1: 8
248
+ :c1: 3
249
+ :v1: 912
250
+ :b2: 8
251
+ :c2: 3
252
+ :v2: 912
253
+ :a1: :b
254
+ :a2:
255
+ - "; "
256
+ - :text: Markus 4
257
+ :b1: 41
258
+ :c1: 4
259
+ :v1:
260
+ :b2: 41
261
+ :c2: 4
262
+ :v2:
263
+ :a1:
264
+ :a2:
265
+ - "; "
266
+ - :text: 5,3a
267
+ :b1: 41
268
+ :c1: 5
269
+ :v1: 3
270
+ :b2: 41
271
+ :c2: 5
272
+ :v2: 3
273
+ :a1: :a
274
+ :a2:
275
+ - "."
276
+ - :text: 18b-21a
277
+ :b1: 41
278
+ :c1: 5
279
+ :v1: 18
280
+ :b2: 41
281
+ :c2: 5
282
+ :v2: 21
283
+ :a1: :b
284
+ :a2: :a
285
+ ---
286
+ sample: Ruth 2,1a-11.15a; 3,7b.9-; Markus 4; 5,3a.18b-21a
287
+ exception: |-
288
+ Chapter or verse expected!
289
+ Ruth 2,1a-11.15a; 3,7b.9-; Markus 4; 5,3a.18b-21a
290
+ ^
291
+ ---
292
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12bMarkus 4; 5,3a.18b-21a
293
+ exception: |-
294
+ EOS or verse separator or passage separator expected!
295
+ Ruth 2,1a-11.15a; 3,7b.9-12bMarkus 4; 5,3a.18b-21a
296
+ ^
297
+ ---
298
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; 4; 5,3a.18b-21a
299
+ result:
300
+ - :text: Ruth 2,1a-11
301
+ :b1: 8
302
+ :c1: 2
303
+ :v1: 1
304
+ :b2: 8
305
+ :c2: 2
306
+ :v2: 11
307
+ :a1: :a
308
+ :a2:
309
+ - "."
310
+ - :text: 15a
311
+ :b1: 8
312
+ :c1: 2
313
+ :v1: 15
314
+ :b2: 8
315
+ :c2: 2
316
+ :v2: 15
317
+ :a1: :a
318
+ :a2:
319
+ - "; "
320
+ - :text: 3,7b
321
+ :b1: 8
322
+ :c1: 3
323
+ :v1: 7
324
+ :b2: 8
325
+ :c2: 3
326
+ :v2: 7
327
+ :a1: :b
328
+ :a2:
329
+ - "."
330
+ - :text: 9-12b
331
+ :b1: 8
332
+ :c1: 3
333
+ :v1: 9
334
+ :b2: 8
335
+ :c2: 3
336
+ :v2: 12
337
+ :a1:
338
+ :a2: :b
339
+ - "; "
340
+ - :text: '4'
341
+ :b1: 8
342
+ :c1: 4
343
+ :v1: 9
344
+ :b2: 8
345
+ :c2: 4
346
+ :v2: 12
347
+ :a1:
348
+ :a2:
349
+ - "; "
350
+ - :text: 5,3a
351
+ :b1: 8
352
+ :c1: 5
353
+ :v1: 3
354
+ :b2: 8
355
+ :c2: 5
356
+ :v2: 3
357
+ :a1: :a
358
+ :a2:
359
+ - "."
360
+ - :text: 18b-21a
361
+ :b1: 8
362
+ :c1: 5
363
+ :v1: 18
364
+ :b2: 8
365
+ :c2: 5
366
+ :v2: 21
367
+ :a1: :b
368
+ :a2: :a
369
+ ---
370
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus ; 5,3a.18b-21a
371
+ exception: |-
372
+ EOS or hyphen and book or chapter expected!
373
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus ; 5,3a.18b-21a
374
+ ^
375
+ ---
376
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 45,3a.18b-21a
377
+ result:
378
+ - :text: Ruth 2,1a-11
379
+ :b1: 8
380
+ :c1: 2
381
+ :v1: 1
382
+ :b2: 8
383
+ :c2: 2
384
+ :v2: 11
385
+ :a1: :a
386
+ :a2:
387
+ - "."
388
+ - :text: 15a
389
+ :b1: 8
390
+ :c1: 2
391
+ :v1: 15
392
+ :b2: 8
393
+ :c2: 2
394
+ :v2: 15
395
+ :a1: :a
396
+ :a2:
397
+ - "; "
398
+ - :text: 3,7b
399
+ :b1: 8
400
+ :c1: 3
401
+ :v1: 7
402
+ :b2: 8
403
+ :c2: 3
404
+ :v2: 7
405
+ :a1: :b
406
+ :a2:
407
+ - "."
408
+ - :text: 9-12b
409
+ :b1: 8
410
+ :c1: 3
411
+ :v1: 9
412
+ :b2: 8
413
+ :c2: 3
414
+ :v2: 12
415
+ :a1:
416
+ :a2: :b
417
+ - "; "
418
+ - :text: Markus 45,3a
419
+ :b1: 41
420
+ :c1: 45
421
+ :v1: 3
422
+ :b2: 41
423
+ :c2: 45
424
+ :v2: 3
425
+ :a1: :a
426
+ :a2:
427
+ - "."
428
+ - :text: 18b-21a
429
+ :b1: 41
430
+ :c1: 45
431
+ :v1: 18
432
+ :b2: 41
433
+ :c2: 45
434
+ :v2: 21
435
+ :a1: :b
436
+ :a2: :a
437
+ ---
438
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; ,3a.18b-21a
439
+ exception: |-
440
+ Book or chapter expected!
441
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; ,3a.18b-21a
442
+ ^
443
+ ---
444
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 53a.18b-21a
445
+ exception: |-
446
+ EOS or chapter verse separator or hyphen and book or hyphen and chapter or passage separator and book or passage separator and chapter expected!
447
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 53a.18b-21a
448
+ ^
449
+ ---
450
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,.18b-21a
451
+ exception: |-
452
+ Verse expected!
453
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,.18b-21a
454
+ ^
455
+ ---
456
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a18b-21a
457
+ exception: |-
458
+ EOS or passage separator or verse separator or hyphen expected!
459
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a18b-21a
460
+ ^
461
+ ---
462
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.-21a
463
+ exception: |-
464
+ Verse expected!
465
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.-21a
466
+ ^
467
+ ---
468
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b21a
469
+ exception: |-
470
+ EOS or passage separator or verse separator or hyphen expected!
471
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b21a
472
+ ^
473
+ ---
474
+ sample: Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-
475
+ exception: |-
476
+ Chapter or verse expected!
477
+ Ruth 2,1a-11.15a; 3,7b.9-12b; Markus 4; 5,3a.18b-
478
+ ^
data/test/test_english.rb CHANGED
@@ -6,9 +6,14 @@ require 'scripref/english'
6
6
  class TestEnglish < Test::Unit::TestCase
7
7
 
8
8
  include Test::Helper
9
- include Scripref::English
9
+ include Scripref
10
+
11
+ def setup
12
+ @parser = Parser.new(English)
13
+ end
10
14
 
11
15
  def test_book_re
16
+ book_re = @parser.book_re
12
17
  assert_match book_re, 'Genesis'
13
18
  assert_match book_re, 'Exodus'
14
19
  assert_match book_re, 'Matthew'
@@ -37,7 +42,6 @@ class TestEnglish < Test::Unit::TestCase
37
42
  end
38
43
 
39
44
  def assert_book_num num, str
40
- @parser ||= Scripref::Parser.new(Scripref::English)
41
45
  assert_equal num, @parser.parse(str).first.b1
42
46
  end
43
47
 
@@ -97,6 +97,11 @@ class TestFormatter < Test::Unit::TestCase
97
97
  check_formatting
98
98
  end
99
99
 
100
+ def test_alternative_booknames
101
+ ast = @parser.parse('Zephanja 1,8')
102
+ assert_equal 'Zefanja 1,8', @german_formatter.format(ast)
103
+ end
104
+
100
105
  private
101
106
 
102
107
  def check_formatting
data/test/test_german.rb CHANGED
@@ -6,9 +6,14 @@ require 'scripref/german'
6
6
  class TestGerman < Test::Unit::TestCase
7
7
 
8
8
  include Test::Helper
9
- include Scripref::German
9
+ include Scripref
10
+
11
+ def setup
12
+ @parser = Parser.new(German)
13
+ end
10
14
 
11
15
  def test_book_re
16
+ book_re = @parser.book_re
12
17
  assert_match book_re, '1. Mose'
13
18
  assert_match book_re, '2. Mose'
14
19
  assert_match book_re, 'Matthäus'
data/test/test_parser.rb CHANGED
@@ -225,7 +225,7 @@ class TestParser < Test::Unit::TestCase
225
225
  rescue Scripref::ParserError
226
226
  end
227
227
  assert_equal 'Verse expected!', @parser.error
228
- formated_error = "Ruth 2,x\n ^\nVerse expected!"
228
+ formated_error = "Verse expected!\nRuth 2,x\n ^"
229
229
  assert_equal formated_error, @parser.format_error
230
230
  end
231
231
 
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: 0.6.0
4
+ version: 0.7.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: 2016-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -56,7 +56,10 @@ files:
56
56
  - lib/scripref/parser.rb
57
57
  - lib/scripref/pipelining.rb
58
58
  - lib/scripref/processor.rb
59
+ - regtest/formatter.rb
60
+ - regtest/formatter.yml
59
61
  - regtest/parser.rb
62
+ - regtest/parser.yml
60
63
  - test/test_english.rb
61
64
  - test/test_formatter.rb
62
65
  - test/test_german.rb
@@ -65,7 +68,7 @@ files:
65
68
  - test/test_passage.rb
66
69
  - test/test_pipelining.rb
67
70
  - test/test_processor.rb
68
- homepage: http://gitorious.org/scripref
71
+ homepage: https://github.com/janfri/scripref
69
72
  licenses: []
70
73
  metadata: {}
71
74
  post_install_message: