scripref 2.0.0 → 2.1.1
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 +4 -4
- data/Changelog +6 -0
- data/Rakefile +3 -0
- data/lib/scripref/formatter.rb +1 -1
- data/lib/scripref/passage.rb +1 -1
- data/lib/scripref/sorter.rb +35 -2
- data/lib/scripref.rb +1 -1
- data/test/test_formatter.rb +15 -0
- data/test/test_processor.rb +2 -2
- data/test/test_sorter.rb +75 -35
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b86988fd1527cd91715024994bc47a03f0b564a74c5ebf11781e00a7a9ebe82
|
|
4
|
+
data.tar.gz: cf809a65188207a7688dfe150af32d90acb038a871c93e9e250e8a200945f68c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b00eee0bf3b0126a320f1908e2312e4fbe86c99fa504ffc598fa709d887bc51fff6ecb140a16f25dc8897276f2717c28baa738e35dbb9869c31c2d44953154f9
|
|
7
|
+
data.tar.gz: aec528ec46bb8e7470c7ef06fac6411d4c36ccf3e3595541d07a611309a545e91404eb28c8de8e3189039a2b4be7ff04e437c023f170163a2558433a72f3bee6
|
data/Changelog
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
2.1.1
|
|
2
|
+
Use the verse separator between addon and verse when formatting.
|
|
3
|
+
|
|
4
|
+
2.1.0
|
|
5
|
+
Implement correct sorting for passages with addons.
|
|
6
|
+
|
|
1
7
|
2.0.0
|
|
2
8
|
Major release with following breaking changes:
|
|
3
9
|
Rewrite Bookorder and Bookname and adapt Formatter#format accordingly.
|
data/Rakefile
CHANGED
data/lib/scripref/formatter.rb
CHANGED
data/lib/scripref/passage.rb
CHANGED
data/lib/scripref/sorter.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Scripref
|
|
|
23
23
|
module SortUpDown
|
|
24
24
|
def signum pass1, pass2
|
|
25
25
|
a, b = passage2arr(pass1), passage2arr(pass2)
|
|
26
|
-
a[0,
|
|
26
|
+
a[0, 4] + b[4, 4] <=> b[0, 4] + a[4, 4]
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -43,8 +43,41 @@ module Scripref
|
|
|
43
43
|
|
|
44
44
|
def passage2arr pass
|
|
45
45
|
b1 = book2num(pass.b1)
|
|
46
|
+
c1 = pass.c1 || 1
|
|
47
|
+
v1 = pass.v1 || 1
|
|
48
|
+
a1 = case pass.a1.to_s
|
|
49
|
+
when ''
|
|
50
|
+
0
|
|
51
|
+
when 'a'
|
|
52
|
+
1
|
|
53
|
+
when 'b'
|
|
54
|
+
2
|
|
55
|
+
when 'c'
|
|
56
|
+
3
|
|
57
|
+
end
|
|
46
58
|
b2 = book2num(pass.b2)
|
|
47
|
-
|
|
59
|
+
c2 = pass.c2 || Float::INFINITY
|
|
60
|
+
v2 = case pass.v2
|
|
61
|
+
when nil
|
|
62
|
+
Float::INFINITY
|
|
63
|
+
when Integer
|
|
64
|
+
pass.v2
|
|
65
|
+
when :f
|
|
66
|
+
pass.v1.to_i + 1
|
|
67
|
+
when :ff
|
|
68
|
+
pass.v1.to_i + 3
|
|
69
|
+
end
|
|
70
|
+
a2 = case pass.a2.to_s
|
|
71
|
+
when ''
|
|
72
|
+
0
|
|
73
|
+
when 'a'
|
|
74
|
+
-3
|
|
75
|
+
when 'b'
|
|
76
|
+
-2
|
|
77
|
+
when 'c'
|
|
78
|
+
-1
|
|
79
|
+
end
|
|
80
|
+
[b1, c1, v1, a1, b2, c2, v2, a2]
|
|
48
81
|
end
|
|
49
82
|
|
|
50
83
|
end
|
data/lib/scripref.rb
CHANGED
data/test/test_formatter.rb
CHANGED
|
@@ -238,6 +238,21 @@ class TestFormatter < Test::Unit::TestCase
|
|
|
238
238
|
assert_formated_text_for_ast 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)]
|
|
239
239
|
end
|
|
240
240
|
|
|
241
|
+
def test_verse_after_addon
|
|
242
|
+
text = 'Johannes 1,1-3.1-3a.1-3b.1a-3.1b-3.1a-3a.1a-3b'
|
|
243
|
+
ast = [
|
|
244
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3), dot,
|
|
245
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a2: :a), dot,
|
|
246
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a2: :b), dot,
|
|
247
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :a), dot,
|
|
248
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :b), dot,
|
|
249
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :a, a2: :a), dot,
|
|
250
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :a, a2: :b)
|
|
251
|
+
]
|
|
252
|
+
assert_formated_text_for_ast text, ast
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
|
|
241
256
|
######################################################################
|
|
242
257
|
# complex variants of references
|
|
243
258
|
######################################################################
|
data/test/test_processor.rb
CHANGED
|
@@ -83,7 +83,7 @@ class TestProcessorVariousContexts < Test::Unit::TestCase
|
|
|
83
83
|
def test_verse_addon_or_postfix
|
|
84
84
|
text = 'Mt 1,1a'
|
|
85
85
|
processor = Processor.new(text, German)
|
|
86
|
-
ast = [[pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1, a1:
|
|
86
|
+
ast = [[pass(text: text, b1: :Matt, c1: 1, v1: 1, b2: :Matt, c2: 1, v2: 1, a1: :a)]]
|
|
87
87
|
assert_equal ast, processor.each.to_a
|
|
88
88
|
text = 'Mt 1,1f'
|
|
89
89
|
processor = Processor.new(text, German)
|
|
@@ -98,7 +98,7 @@ class TestProcessorVariousContexts < Test::Unit::TestCase
|
|
|
98
98
|
def test_verse_addon_or_postfix_for_books_with_only_one_chapter
|
|
99
99
|
text = '2. Joh 5b'
|
|
100
100
|
processor = Processor.new(text, German)
|
|
101
|
-
ast = [[pass(text: text, b1: :'2John', c1: 1, v1: 5, b2: :'2John', c2: 1, v2: 5, a1:
|
|
101
|
+
ast = [[pass(text: text, b1: :'2John', c1: 1, v1: 5, b2: :'2John', c2: 1, v2: 5, a1: :b)]]
|
|
102
102
|
assert_equal ast, processor.each.to_a
|
|
103
103
|
text = '2. Joh 5f'
|
|
104
104
|
processor = Processor.new(text, German)
|
data/test/test_sorter.rb
CHANGED
|
@@ -3,46 +3,86 @@
|
|
|
3
3
|
|
|
4
4
|
require_relative 'test_helper'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
include Scripref
|
|
9
|
-
include Test::Helper
|
|
10
|
-
|
|
11
|
-
def setup
|
|
12
|
-
@john_1 = pass(b1: :John, c1: 1, b2: :John, c2: 1)
|
|
13
|
-
@john_1_1_3 = pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3)
|
|
14
|
-
@john_1_1_18 = pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 18)
|
|
15
|
-
@john_2 = pass(b1: :John, c1: 2, b2: :John, c2: 2)
|
|
16
|
-
@heb_9 = pass(b1: :Heb, c1: 9, b2: :Heb, c2: 9)
|
|
17
|
-
@jas_1 = pass(b1: :Jas, c1: 1, b2: :Jas, c2: 1)
|
|
18
|
-
@pet_1 = pass(b1: :'1Pet', c1: 1, b2: :'1Pet', c2: 1)
|
|
19
|
-
end
|
|
6
|
+
module TestSorter
|
|
20
7
|
|
|
21
|
-
|
|
22
|
-
sorter = Sorter.new(Bookorder::Canonical)
|
|
23
|
-
assert_equal [@john_1, @heb_9, @jas_1, @pet_1], sorter.sort([@heb_9, @pet_1, @jas_1, @john_1])
|
|
24
|
-
assert_equal [@john_1_1_18, @john_1_1_3], sorter.sort([@john_1_1_3, @john_1_1_18])
|
|
25
|
-
assert_equal [@john_1, @john_1_1_18, @john_1_1_3, @john_2], sorter.sort([@john_1, @john_1_1_3, @john_2, @john_1_1_18])
|
|
26
|
-
end
|
|
8
|
+
class TestBookordering < Test::Unit::TestCase
|
|
27
9
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
include Scripref
|
|
11
|
+
include Test::Helper
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
@john_1 = pass(b1: :John, c1: 1, b2: :John, c2: 1)
|
|
15
|
+
@john_1_1_3 = pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3)
|
|
16
|
+
@john_1_1_18 = pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 18)
|
|
17
|
+
@john_2 = pass(b1: :John, c1: 2, b2: :John, c2: 2)
|
|
18
|
+
@heb_9 = pass(b1: :Heb, c1: 9, b2: :Heb, c2: 9)
|
|
19
|
+
@jas_1 = pass(b1: :Jas, c1: 1, b2: :Jas, c2: 1)
|
|
20
|
+
@pet_1 = pass(b1: :'1Pet', c1: 1, b2: :'1Pet', c2: 1)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_canonical_default
|
|
24
|
+
sorter = Sorter.new(Bookorder::Canonical)
|
|
25
|
+
assert_equal [@john_1, @heb_9, @jas_1, @pet_1], sorter.sort([@heb_9, @pet_1, @jas_1, @john_1])
|
|
26
|
+
assert_equal [@john_1_1_18, @john_1_1_3], sorter.sort([@john_1_1_3, @john_1_1_18])
|
|
27
|
+
assert_equal [@john_1, @john_1_1_18, @john_1_1_3, @john_2], sorter.sort([@john_1, @john_1_1_3, @john_2, @john_1_1_18])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_canonical_sort_up_up
|
|
31
|
+
sorter = Sorter.new(Bookorder::Canonical, Sorter::SortUpUp)
|
|
32
|
+
assert_equal [@john_1_1_3, @john_1_1_18], sorter.sort([@john_1_1_3, @john_1_1_18])
|
|
33
|
+
assert_equal [@john_1_1_3, @john_1_1_18, @john_1, @john_2], sorter.sort([@john_1, @john_1_1_3, @john_2, @john_1_1_18])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_luther_default
|
|
37
|
+
sorter = Sorter.new(Bookorder::Luther)
|
|
38
|
+
assert_equal [@john_1, @pet_1, @heb_9, @jas_1], sorter.sort([@heb_9, @pet_1, @jas_1, @john_1])
|
|
39
|
+
assert_equal [@john_1_1_18, @john_1_1_3], sorter.sort([@john_1_1_3, @john_1_1_18])
|
|
40
|
+
assert_equal [@john_1, @john_1_1_18, @john_1_1_3, @john_2], sorter.sort([@john_1, @john_1_1_3, @john_2, @john_1_1_18])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_luther_sort_up_up
|
|
44
|
+
sorter = Sorter.new(Bookorder::Luther, Sorter::SortUpUp)
|
|
45
|
+
assert_equal [@john_1, @pet_1, @heb_9, @jas_1], sorter.sort([@heb_9, @pet_1, @jas_1, @john_1])
|
|
46
|
+
assert_equal [@john_1_1_3, @john_1_1_18], sorter.sort([@john_1_1_3, @john_1_1_18])
|
|
47
|
+
assert_equal [@john_1_1_3, @john_1_1_18, @john_1, @john_2], sorter.sort([@john_1, @john_1_1_3, @john_2, @john_1_1_18])
|
|
48
|
+
end
|
|
33
49
|
|
|
34
|
-
def test_luther_default
|
|
35
|
-
sorter = Sorter.new(Bookorder::Luther)
|
|
36
|
-
assert_equal [@john_1, @pet_1, @heb_9, @jas_1], sorter.sort([@heb_9, @pet_1, @jas_1, @john_1])
|
|
37
|
-
assert_equal [@john_1_1_18, @john_1_1_3], sorter.sort([@john_1_1_3, @john_1_1_18])
|
|
38
|
-
assert_equal [@john_1, @john_1_1_18, @john_1_1_3, @john_2], sorter.sort([@john_1, @john_1_1_3, @john_2, @john_1_1_18])
|
|
39
50
|
end
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
class TestNumberordering < Test::Unit::TestCase
|
|
53
|
+
|
|
54
|
+
include Scripref
|
|
55
|
+
include Test::Helper
|
|
56
|
+
|
|
57
|
+
def setup
|
|
58
|
+
@sorter = Sorter.new(Bookorder::Canonical)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_sort_with_addons
|
|
62
|
+
f = Formatter.new(German, abbrev_level: 1)
|
|
63
|
+
ref = [
|
|
64
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3),
|
|
65
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a2: :b),
|
|
66
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a2: :a),
|
|
67
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :a),
|
|
68
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :a, a2: :b),
|
|
69
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :a, a2: :a),
|
|
70
|
+
pass(b1: :John, c1: 1, v1: 1, b2: :John, c2: 1, v2: 3, a1: :b)
|
|
71
|
+
]
|
|
72
|
+
assert_equal ref, @sorter.sort(ref)
|
|
73
|
+
assert_equal ref, @sorter.sort(ref.reverse)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_sort_with_addon_and_postfix
|
|
77
|
+
p = Parser.new(German)
|
|
78
|
+
pass1 = p.parse('Spr 25,6f').first
|
|
79
|
+
pass2 = p.parse('Spr 25,6b-7').first
|
|
80
|
+
assert_equal -1, @sorter.signum(pass1, pass2)
|
|
81
|
+
assert_equal 1, @sorter.signum(pass2, pass1)
|
|
82
|
+
assert_equal [pass1, pass2], @sorter.sort([pass1, pass2])
|
|
83
|
+
assert_equal [pass1, pass2], @sorter.sort([pass2, pass1])
|
|
84
|
+
end
|
|
85
|
+
|
|
46
86
|
end
|
|
47
87
|
|
|
48
88
|
end
|