scripref 0.15.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.aspell.pws +3 -1
- data/Changelog +6 -0
- data/lib/scripref.rb +5 -2
- 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 +10 -6
- 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/scripref.gemspec +3 -3
- 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 +2 -1
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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scripref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Friedrich
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/scripref.rb
|
67
67
|
- lib/scripref/basic_methods.rb
|
68
68
|
- lib/scripref/bookname.rb
|
69
|
+
- lib/scripref/bookorder.rb
|
69
70
|
- lib/scripref/const_reader.rb
|
70
71
|
- lib/scripref/english.rb
|
71
72
|
- lib/scripref/formatter.rb
|