scripref 0.8.0 → 0.9.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 +4 -4
- data/CHANGELOG +5 -0
- data/lib/scripref/english.rb +13 -1
- data/lib/scripref/formatter.rb +8 -0
- data/lib/scripref/german.rb +13 -1
- data/lib/scripref/parser.rb +18 -11
- data/lib/scripref.rb +1 -1
- data/test/test_formatter.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7969fae6655c502970897c3a7c75e5542e35f70
|
4
|
+
data.tar.gz: 4a71db57ad05ad5be040812473904d8db8dfa712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f273d53bf3e1ebdab926508c7763ad97542088fdaa9a3b65e5d6fefe29c4e577fd3da6931be41e646c84cf87729347ad27be84d5e8790a71ad9794b607409f
|
7
|
+
data.tar.gz: 6ce53ebcd0a65466877bbc57c22c7d0e663522402f30dea5950df31fbfa0ab2debb37afd111b88653cacf30a8d01fe66929313d9ea1b7fe856380452ae368ff8
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.9.0
|
2
|
+
Differentiate between verse addons and postfixes for one ore more following verses.
|
3
|
+
New methods Parser#postfix_one_following_verse and Parser#postfix_more_following_verses.
|
4
|
+
|
5
|
+
|
1
6
|
0.8.0
|
2
7
|
Formatting of verse addons implemented.
|
3
8
|
Refactoring: Rename methods in Formatter to distinguish between format_* and process_*.
|
data/lib/scripref/english.rb
CHANGED
@@ -43,7 +43,19 @@ module Scripref
|
|
43
43
|
VERSE_SEP_RE = /,\s*/o
|
44
44
|
|
45
45
|
# Regular expression to match addons for a verse.
|
46
|
-
VERSE_ADDON_RE = /
|
46
|
+
VERSE_ADDON_RE = /[ab]\s*/o
|
47
|
+
|
48
|
+
# Postfix for one following verse
|
49
|
+
POSTFIX_ONE_FOLLOWING_VERSE = 'f'
|
50
|
+
|
51
|
+
# Regular expression to match postfix for one following verse
|
52
|
+
POSTFIX_ONE_FOLLOWING_VERSE_RE = /f\b\s*/o
|
53
|
+
|
54
|
+
# Postfix for more following verses
|
55
|
+
POSTFIX_MORE_FOLLOWING_VERSES = 'ff'
|
56
|
+
|
57
|
+
# Regular expression to match postfix for more following verses
|
58
|
+
POSTFIX_MORE_FOLLOWING_VERSES_RE = /ff\b\s*/o
|
47
59
|
|
48
60
|
pass = '([1-3]\s*)?[A-Z][a-z]+\.?\s*(\d+\s*[,.\-]\s*)*\d+\s*'
|
49
61
|
|
data/lib/scripref/formatter.rb
CHANGED
@@ -110,6 +110,14 @@ module Scripref
|
|
110
110
|
|
111
111
|
def process_v2
|
112
112
|
v2 = @pass.v2
|
113
|
+
case v2
|
114
|
+
when :f
|
115
|
+
@result << postfix_one_following_verse
|
116
|
+
return
|
117
|
+
when :ff
|
118
|
+
@result << postfix_more_following_verses
|
119
|
+
return
|
120
|
+
end
|
113
121
|
if v2 && (@changed || @last_v != v2)
|
114
122
|
if @hyphen
|
115
123
|
if ! book_has_only_one_chapter?(@pass.b2)
|
data/lib/scripref/german.rb
CHANGED
@@ -40,7 +40,19 @@ module Scripref
|
|
40
40
|
VERSE_SEP_RE = /\.\s*/o
|
41
41
|
|
42
42
|
# Regular expression to match addons for a verse.
|
43
|
-
VERSE_ADDON_RE = /
|
43
|
+
VERSE_ADDON_RE = /[ab]\s*/o
|
44
|
+
|
45
|
+
# Postfix for one following verse
|
46
|
+
POSTFIX_ONE_FOLLOWING_VERSE = 'f'
|
47
|
+
|
48
|
+
# Regular expression to match postfix for one following verse
|
49
|
+
POSTFIX_ONE_FOLLOWING_VERSE_RE = /f\b\s*/o
|
50
|
+
|
51
|
+
# Postfix for more following verses
|
52
|
+
POSTFIX_MORE_FOLLOWING_VERSES = 'ff'
|
53
|
+
|
54
|
+
# Regular expression to match postfix for more following verses
|
55
|
+
POSTFIX_MORE_FOLLOWING_VERSES_RE = /ff\b\s*/o
|
44
56
|
|
45
57
|
pass = '([1-5]\.?\s*)?[A-Z][a-zäöü]+\.?\s*(\d+\s*[,.\-]\s*)*\d+\s*'
|
46
58
|
|
data/lib/scripref/parser.rb
CHANGED
@@ -29,7 +29,7 @@ module Scripref
|
|
29
29
|
# for example {'Phil' => 'Philipper'}
|
30
30
|
# usual overwritten in Mixins
|
31
31
|
def special_abbrev_mapping
|
32
|
-
|
32
|
+
@special_abbrev_mapping ||= {}
|
33
33
|
end
|
34
34
|
|
35
35
|
# Parsing a string of a scripture reference
|
@@ -93,12 +93,11 @@ module Scripref
|
|
93
93
|
@v1 = @v2 = s.to_i
|
94
94
|
|
95
95
|
if addon = verse_addon
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
96
|
+
@a1 = addon
|
97
|
+
end
|
98
|
+
|
99
|
+
if postfix = verse_postfix
|
100
|
+
@v2 = postfix
|
102
101
|
end
|
103
102
|
|
104
103
|
if hyphen
|
@@ -156,10 +155,7 @@ module Scripref
|
|
156
155
|
@v2 = s.to_i
|
157
156
|
|
158
157
|
if addon = verse_addon
|
159
|
-
|
160
|
-
when :a, :b, :c
|
161
|
-
@a2 = addon
|
162
|
-
end
|
158
|
+
@a2 = addon
|
163
159
|
end
|
164
160
|
|
165
161
|
if verse_sep
|
@@ -232,6 +228,17 @@ module Scripref
|
|
232
228
|
end
|
233
229
|
end
|
234
230
|
|
231
|
+
# try to parse postfixes for verse
|
232
|
+
def verse_postfix
|
233
|
+
s = (scan(postfix_one_following_verse_re) or scan(postfix_more_following_verses_re))
|
234
|
+
if s
|
235
|
+
@text << s
|
236
|
+
s.to_sym
|
237
|
+
else
|
238
|
+
nil
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
235
242
|
def push_passage
|
236
243
|
@result << Passage.new(@text, @b1, @c1, @v1, @b2, @c2, @v2, a1: @a1, a2: @a2)
|
237
244
|
@text = ''
|
data/lib/scripref.rb
CHANGED
data/test/test_formatter.rb
CHANGED
@@ -120,6 +120,18 @@ class TestFormatter < Test::Unit::TestCase
|
|
120
120
|
check_formatting
|
121
121
|
end
|
122
122
|
|
123
|
+
def test_postfix_one_following_verse
|
124
|
+
@german = 'Markus 2,2f'
|
125
|
+
@english = 'Mark 2:2f'
|
126
|
+
check_formatting
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_postfix_more_following_verses
|
130
|
+
@german = 'Markus 2,2ff'
|
131
|
+
@english = 'Mark 2:2ff'
|
132
|
+
check_formatting
|
133
|
+
end
|
134
|
+
|
123
135
|
private
|
124
136
|
|
125
137
|
def check_formatting
|
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.
|
4
|
+
version: 0.9.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-
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rim
|