bible_ref 1.9.0 → 2.0.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/lib/bible_ref/languages/base.rb +3 -7
- data/lib/bible_ref/languages/cherokee.rb +0 -7
- data/lib/bible_ref/languages/chinese.rb +5 -12
- data/lib/bible_ref/languages/czech.rb +27 -33
- data/lib/bible_ref/languages/english.rb +0 -6
- data/lib/bible_ref/languages/latin.rb +0 -6
- data/lib/bible_ref/languages/portuguese.rb +2 -9
- data/lib/bible_ref/languages/romanian.rb +5 -12
- data/lib/bible_ref/languages/russian.rb +3 -9
- data/lib/bible_ref/parser.rb +2 -2
- data/lib/bible_ref/reference.rb +10 -7
- data/lib/bible_ref/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 289edfed9344b42456cd5f107d8fdd3197dbc14f3f28a7a92c8258f387fdac7a
|
4
|
+
data.tar.gz: 6f8bbaf0415d8d1d2d5d23251616f01d7f931a9e27701218cad6f4ce0b70b9dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba2f800f04d6c46f67c629780348beba179efb6c6a63072fb30a0f6afafd48b92fb1a9defd3c9cfbdda9b3f193fc7dd48c46d43fbb314d1641297a07530983f1
|
7
|
+
data.tar.gz: de3d6f6a6af1d897891b56bd44db56e4aba0f1c884d138d1ac2c23a1d561096828ffc4f2b35a7dffb7c52fc64b0e1ed23c103c0e1e97704c3944118cb87e55b1
|
@@ -5,21 +5,17 @@ module BibleRef
|
|
5
5
|
fail NotImplementedError, "You must override #books in your language class."
|
6
6
|
end
|
7
7
|
|
8
|
-
# Is it a single chapter book?
|
9
|
-
def has_single_chapter?(reference)
|
10
|
-
fail NotImplementedError, "You must override #has_single_chapter? in your language class."
|
11
|
-
end
|
12
|
-
|
13
8
|
def book_id(book_name, canon)
|
14
9
|
book_name = replace_roman_numerals(book_name)
|
15
10
|
return book_name.upcase if books[book_name.upcase] # already normalized
|
11
|
+
|
16
12
|
canon.books.each do |book|
|
17
13
|
details = books[book]
|
18
14
|
next if details.nil?
|
19
15
|
if (match = details[:match])
|
20
|
-
return book if book_name.downcase =~ match
|
16
|
+
return book if book_name.downcase =~ match || book_name =~ match
|
21
17
|
else
|
22
|
-
return book if book_name.downcase == details[:name].downcase
|
18
|
+
return book if book_name.downcase == details[:name].downcase || book_name == details[:name]
|
23
19
|
end
|
24
20
|
end
|
25
21
|
nil
|
@@ -4,13 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class Cherokee < Base
|
7
|
-
|
8
|
-
# Is it a single chapter book?
|
9
|
-
def has_single_chapter?(reference)
|
10
|
-
matches = ['ᏉᎳ ᏆᎵᎹᏂ ᎤᏬᏪᎳᏁᎸᎯ', 'ᏣᏂ ᏔᎵᏁ ᎤᏬᏪᎳᏅᎯ', 'ᏣᏂ ᏦᎢᏁ ᎤᏬᏪᎳᏅᎯ', 'ᏧᏓᏏ ᎤᏬᏪᎳᏅᎯ']
|
11
|
-
return matches.any? { |e| reference.include?(e) }
|
12
|
-
end
|
13
|
-
|
14
7
|
def books
|
15
8
|
{
|
16
9
|
'MAT' => { name: 'ᎣᏍᏛ ᎧᏃᎮᏛ ᎹᏚ ᎤᏬᏪᎳᏅᎯ' },
|
@@ -4,13 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class Chinese < Base
|
7
|
-
|
8
|
-
# Is it a single chapter book?
|
9
|
-
def has_single_chapter?(reference)
|
10
|
-
matches = [/^俄/, /^腓利門/, /^約翰貳/, /^約翰參/, /^猶/]
|
11
|
-
return Regexp.union(matches).match?(reference)
|
12
|
-
end
|
13
|
-
|
14
7
|
def books
|
15
8
|
{
|
16
9
|
'GEN' => { match: /^創/, name: '創世紀'},
|
@@ -27,7 +20,7 @@ module BibleRef
|
|
27
20
|
'2KI' => { match: /紀下$/, name: '列王紀下'},
|
28
21
|
'1CH' => { match: /志上$/, name: '歷代志上'},
|
29
22
|
'2CH' => { match: /志下$/, name: '歷代志下'},
|
30
|
-
'EZR' => { match:
|
23
|
+
'EZR' => { match: /^以斯拉/, name: '以斯拉記'},
|
31
24
|
'NEH' => { match: /^尼/, name: '尼希米記'},
|
32
25
|
'EST' => { match: /帖記$/, name: '以斯帖記'},
|
33
26
|
'JOB' => { match: /^約伯/, name: '約伯記'},
|
@@ -73,14 +66,14 @@ module BibleRef
|
|
73
66
|
'HEB' => { match: /^希/, name: '希伯來書'},
|
74
67
|
'JAS' => { match: /^雅各/, name: '雅各書'},
|
75
68
|
'1PE' => { match: /^彼得前/, name: '彼得前書'},
|
76
|
-
'2PE' => { match: /^彼得後/, name: '
|
69
|
+
'2PE' => { match: /^彼得後/, name: '彼得後書'},
|
77
70
|
'1JN' => { match: /壹書$/, name: '約翰壹書'},
|
78
|
-
'
|
79
|
-
'
|
71
|
+
'2JN' => { match: /貳書$/, name: '約翰貳書'},
|
72
|
+
'3JN' => { match: /參書$/, name: '約翰參書'},
|
80
73
|
'JUD' => { match: /^猶/, name: '猶大書'},
|
81
74
|
'REV' => { match: /^啟/, name: '啟示錄'}
|
82
75
|
}
|
83
76
|
end
|
84
77
|
end
|
85
78
|
end
|
86
|
-
end
|
79
|
+
end
|
@@ -5,12 +5,6 @@ require_relative 'base'
|
|
5
5
|
module BibleRef
|
6
6
|
module Languages
|
7
7
|
class Czech < Base
|
8
|
-
# Is it a single chapter book?
|
9
|
-
def has_single_chapter?(reference)
|
10
|
-
matches = [/^ab/, /^(jud|juda)$/, /^2 ?jan/, /^3 ?jan/, /^fil/]
|
11
|
-
Regexp.union(matches).match?(reference.downcase)
|
12
|
-
end
|
13
|
-
|
14
8
|
def books
|
15
9
|
{
|
16
10
|
'GEN' => { match: /^gen/, name: 'Genesis' },
|
@@ -20,30 +14,30 @@ module BibleRef
|
|
20
14
|
'DEU' => { match: /^d(e?ut|eu)/, name: 'Deuteronomium' },
|
21
15
|
'JOS' => { match: /^joz/, name: 'Jozue' },
|
22
16
|
'JDG' => { match: /^soud/, name: 'Soudců' },
|
23
|
-
'RUT' => { match: /^
|
24
|
-
'1SA' => { match: /^1 ?s(a?m)?/,
|
25
|
-
'2SA' => { match: /^2 ?s(a?m)?/,
|
26
|
-
'1KI' => { match: /^1 ?kr(a?l)?/,
|
27
|
-
'2KI' => { match: /^2 ?kr(a?l)?/,
|
28
|
-
'1CH' => { match: /^1 ?
|
29
|
-
'2CH' => { match: /^2 ?
|
30
|
-
'EZR' => { match: /^
|
17
|
+
'RUT' => { match: /^r[uú]/, name: 'Rút' },
|
18
|
+
'1SA' => { match: /^1\.? ?s(a?m)?/, name: '1. Samuel' },
|
19
|
+
'2SA' => { match: /^2\.? ?s(a?m)?/, name: '2. Samuel' },
|
20
|
+
'1KI' => { match: /^1\.? ?kr(a?l)?/, name: '1. Královská' },
|
21
|
+
'2KI' => { match: /^2\.? ?kr(a?l)?/, name: '2. Královská' },
|
22
|
+
'1CH' => { match: /^1\.? ?par/, name: '1. Paralipomenon' },
|
23
|
+
'2CH' => { match: /^2\.? ?par/, name: '2. Paralipomenon' },
|
24
|
+
'EZR' => { match: /^ezd/, name: 'Ezdráš' },
|
31
25
|
'NEH' => { match: /^ne/, name: 'Nehemiáš' },
|
32
26
|
'EST' => { match: /^est/, name: 'Ester' },
|
33
27
|
'JOB' => { match: /^jo?b/, name: 'Job' },
|
34
|
-
'PSA' => { match: /^
|
35
|
-
'PRO' => { match: /^
|
28
|
+
'PSA' => { match: /^zal|^žal/, name: 'Žalmy' },
|
29
|
+
'PRO' => { match: /^p[řr]/, name: 'Přísloví' },
|
36
30
|
'ECC' => { match: /^kaz/, name: 'Kazatel' },
|
37
|
-
'SNG' => { match: /^
|
31
|
+
'SNG' => { match: /^p[ií]/, name: 'Píseň písní' },
|
38
32
|
'ISA' => { match: /^iza/, name: 'Izaiáš' },
|
39
33
|
'JER' => { match: /^jer/, name: 'Jeremiáš' },
|
40
|
-
'LAM' => { match: /^
|
34
|
+
'LAM' => { match: /^pl[aá]/, name: 'Pláč' },
|
41
35
|
'EZK' => { match: /^eze/, name: 'Ezechiel' },
|
42
36
|
'DAN' => { match: /^dan/, name: 'Daniel' },
|
43
37
|
'HOS' => { match: /^oze/, name: 'Ozeáš' },
|
44
38
|
'JOL' => { match: /^joe?l/, name: 'Joel' },
|
45
39
|
'AMO' => { match: /^amo/, name: 'Amos' },
|
46
|
-
'OBA' => { match: /^
|
40
|
+
'OBA' => { match: /^abd/, name: 'Abdiáš' },
|
47
41
|
'JON' => { match: /^jona?/, name: 'Jonáš' },
|
48
42
|
'MIC' => { match: /^mi/, name: 'Micheáš' },
|
49
43
|
'NAM' => { match: /^na(h|m)/, name: 'Nahum' },
|
@@ -53,30 +47,30 @@ module BibleRef
|
|
53
47
|
'ZEC' => { match: /^zac/, name: 'Zachariáš' },
|
54
48
|
'MAL' => { match: /^mal/, name: 'Malachiáš' },
|
55
49
|
'MAT' => { match: /^ma?t/, name: 'Matouš' },
|
56
|
-
'MRK' => { match: /^ma?
|
50
|
+
'MRK' => { match: /^ma?re?k/, name: 'Marek' },
|
57
51
|
'LUK' => { match: /^lu?k/, name: 'Lukáš' },
|
58
52
|
'JHN' => { match: /^j(an|n)/, name: 'Jan' },
|
59
53
|
'ACT' => { match: /^sku/, name: 'Skutky' },
|
60
|
-
'ROM' => { match: /^rim/,
|
61
|
-
'1CO' => { match: /^1 ?kor/,
|
62
|
-
'2CO' => { match: /^2 ?kor/,
|
54
|
+
'ROM' => { match: /^rim|^řím/, name: 'Římanům' },
|
55
|
+
'1CO' => { match: /^1\.? ?kor/, name: '1. Korintským' },
|
56
|
+
'2CO' => { match: /^2\.? ?kor/, name: '2. Korintským' },
|
63
57
|
'GAL' => { match: /^gal/, name: 'Galatským' },
|
64
58
|
'EPH' => { match: /^ef/, name: 'Efeským' },
|
65
59
|
'PHP' => { match: /^filip/, name: 'Filipským' },
|
66
60
|
'COL' => { match: /^kol/, name: 'Koloským' },
|
67
|
-
'1TH' => { match: /^1 ?tes/,
|
68
|
-
'2TH' => { match: /^2 ?tes/,
|
69
|
-
'1TI' => { match: /^1 ?tim/,
|
70
|
-
'2TI' => { match: /^2 ?tim/,
|
61
|
+
'1TH' => { match: /^1\.? ?tes/, name: '1. Tesalonickým' },
|
62
|
+
'2TH' => { match: /^2\.? ?tes/, name: '2. Tesalonickým' },
|
63
|
+
'1TI' => { match: /^1\.? ?tim/, name: '1. Timoteovi' },
|
64
|
+
'2TI' => { match: /^2\.? ?tim/, name: '2. Timoteovi' },
|
71
65
|
'TIT' => { match: /^tit/, name: 'Titovi' },
|
72
66
|
'PHM' => { match: /^fil/, name: 'Filemonovi' },
|
73
|
-
'HEB' => { match: /^
|
67
|
+
'HEB' => { match: /^[žz]id/, name: 'Židům' },
|
74
68
|
'JAS' => { match: /^jak/, name: 'Jakub' },
|
75
|
-
'1PE' => { match: /^1 ?pet/,
|
76
|
-
'2PE' => { match: /^2 ?pet/,
|
77
|
-
'1JN' => { match: /^1 ?jan/,
|
78
|
-
'2JN' => { match: /^2 ?jan/,
|
79
|
-
'3JN' => { match: /^3 ?jan/,
|
69
|
+
'1PE' => { match: /^1\.? ?pet/, name: '1. Petr' },
|
70
|
+
'2PE' => { match: /^2\.? ?pet/, name: '2. Petr' },
|
71
|
+
'1JN' => { match: /^1\.? ?jan/, name: '1. Jan' },
|
72
|
+
'2JN' => { match: /^2\.? ?jan/, name: '2. Jan' },
|
73
|
+
'3JN' => { match: /^3\.? ?jan/, name: '3. Jan' },
|
80
74
|
'JUD' => { match: /^(jud|juda)$/, name: 'Juda' },
|
81
75
|
'REV' => { match: /^zj(e)?/, name: 'Zjevení' }
|
82
76
|
}
|
@@ -4,12 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class English < Base
|
7
|
-
# Is it a single chapter book?
|
8
|
-
def has_single_chapter?(reference)
|
9
|
-
matches = [/^ob/, /^(jud|jd|jude)\b/, /^2 ?jo?h?n/, /^3 ?jo?h?n/, /^(philem|phm|pm)/]
|
10
|
-
return Regexp.union(matches).match?(reference.downcase)
|
11
|
-
end
|
12
|
-
|
13
7
|
def books
|
14
8
|
{
|
15
9
|
'GEN' => { match: /^gen/, name: 'Genesis' },
|
@@ -4,12 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class Latin < Base
|
7
|
-
# Is it a single chapter book?
|
8
|
-
def has_single_chapter?(reference)
|
9
|
-
matches = ['Abdias', 'ad Philemonem', 'Joannis II', 'Joannis III', 'Judæ']
|
10
|
-
return matches.any? { |e| reference.include?(e) }
|
11
|
-
end
|
12
|
-
|
13
7
|
def books
|
14
8
|
{
|
15
9
|
'GEN' => { name: 'Genesis' },
|
@@ -4,13 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class Portuguese < Base
|
7
|
-
|
8
|
-
# Is it a single chapter book?
|
9
|
-
def has_single_chapter?(reference)
|
10
|
-
matches = [/^ob/, /^jud/, /^2 jo/, /^3 jo/, /^fil/]
|
11
|
-
return Regexp.union(matches).match?(reference.downcase)
|
12
|
-
end
|
13
|
-
|
14
7
|
def books
|
15
8
|
{
|
16
9
|
'GEN' => { match: /^g[eê]n/, name: 'Gênesis' },
|
@@ -19,7 +12,7 @@ module BibleRef
|
|
19
12
|
'NUM' => { match: /^n[uú]/, name: 'Números' },
|
20
13
|
'DEU' => { match: /^de?ut/, name: 'Deuteronômio' },
|
21
14
|
'JOS' => { match: /^jos/, name: 'Josué' },
|
22
|
-
'JDG' => { match: /^ju/,
|
15
|
+
'JDG' => { match: /^juí|^jz/, name: 'Juízes' },
|
23
16
|
'RUT' => { match: /^ru/, name: 'Rute' },
|
24
17
|
'1SA' => { match: /^1 sa?m/, name: '1 Samuel' },
|
25
18
|
'2SA' => { match: /^2 sa?m/, name: '2 Samuel' },
|
@@ -62,7 +55,7 @@ module BibleRef
|
|
62
55
|
'2CO' => { match: /^2 cor/, name: '2 Coríntios' },
|
63
56
|
'GAL' => { match: /^g[aá]l/, name: 'Gálatas' },
|
64
57
|
'EPH' => { match: /^ef[eé]/, name: 'Efésios' },
|
65
|
-
'PHP' => { match: /^
|
58
|
+
'PHP' => { match: /^fp|^filip/, name: 'Filipenses' },
|
66
59
|
'COL' => { match: /^col/, name: 'Colossenses' },
|
67
60
|
'1TH' => { match: /^1 te?s/, name: '1 Tessalonicenses' },
|
68
61
|
'2TH' => { match: /^2 te?s/, name: '2 Tessalonicenses' },
|
@@ -4,13 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class Romanian < Base
|
7
|
-
|
8
|
-
# Is it a single chapter book?
|
9
|
-
def has_single_chapter?(reference)
|
10
|
-
matches = [/^ob/, /^iud/, /^2 io/, /^3 io/, /^fil/]
|
11
|
-
return Regexp.union(matches).match?(reference.downcase)
|
12
|
-
end
|
13
|
-
|
14
7
|
def books
|
15
8
|
{
|
16
9
|
'GEN' => { match: /^gen/, name: 'Geneza' },
|
@@ -23,8 +16,8 @@ module BibleRef
|
|
23
16
|
'RUT' => { match: /^ru/, name: 'Rut' },
|
24
17
|
'1SA' => { match: /^1 sa?m/, name: '1 Samuel' },
|
25
18
|
'2SA' => { match: /^2 sa?m/, name: '2 Samuel' },
|
26
|
-
'1KI' => { match: /^1 [iîÎ]/,
|
27
|
-
'2KI' => { match: /^2 [iîÎ]/,
|
19
|
+
'1KI' => { match: /^1 [iîÎ]mp/, name: '1 Împăraţi' },
|
20
|
+
'2KI' => { match: /^2 [iîÎ]mp/, name: '2 Împăraţi' },
|
28
21
|
'1CH' => { match: /^1 cr/, name: '1 Cronici' },
|
29
22
|
'2CH' => { match: /^2 cr/, name: '2 Cronici' },
|
30
23
|
'EZR' => { match: /^ezr/, name: 'Ezra' },
|
@@ -34,7 +27,7 @@ module BibleRef
|
|
34
27
|
'PSA' => { match: /^ps/, name: 'Psalmii' },
|
35
28
|
'PRO' => { match: /^pr/, name: 'Proverbe' },
|
36
29
|
'ECC' => { match: /^ecl/, name: 'Eclesiastul' },
|
37
|
-
'SNG' => { match: /^c[aâ]n
|
30
|
+
'SNG' => { match: /^c[aâ]n/, name: 'Cântarea cântărilor' },
|
38
31
|
'ISA' => { match: /^isa/, name: 'Isaia' },
|
39
32
|
'JER' => { match: /^ier/, name: 'Ieremia' },
|
40
33
|
'LAM' => { match: /^plâ/, name: 'Plângerile lui Ieremia'},
|
@@ -62,7 +55,7 @@ module BibleRef
|
|
62
55
|
'2CO' => { match: /^2 cor/, name: '2 Corinteni' },
|
63
56
|
'GAL' => { match: /^gal/, name: 'Galateni' },
|
64
57
|
'EPH' => { match: /^ef/, name: 'Efeseni' },
|
65
|
-
'PHP' => { match: /^
|
58
|
+
'PHP' => { match: /^flp|^filip/, name: 'Filipeni' },
|
66
59
|
'COL' => { match: /^col/, name: 'Coloseni' },
|
67
60
|
'1TH' => { match: /^1 te?s/, name: '1 Tesaloniceni' },
|
68
61
|
'2TH' => { match: /^2 te?s/, name: '2 Tesaloniceni' },
|
@@ -76,7 +69,7 @@ module BibleRef
|
|
76
69
|
'2PE' => { match: /^2 pet/, name: '2 Petru' },
|
77
70
|
'1JN' => { match: /^1 io/, name: '1 Ioan' },
|
78
71
|
'2JN' => { match: /^2 io/, name: '2 Ioan' },
|
79
|
-
'3JN' => { match: /^3 io/, name: '
|
72
|
+
'3JN' => { match: /^3 io/, name: '3 Ioan' },
|
80
73
|
'JUD' => { match: /^iud/, name: 'Iuda' },
|
81
74
|
'REV' => { match: /^apo/, name: 'Apocalipsa' }
|
82
75
|
}
|
@@ -4,12 +4,6 @@ require_relative 'base'
|
|
4
4
|
module BibleRef
|
5
5
|
module Languages
|
6
6
|
class Russian < Base
|
7
|
-
# Is it a single chapter book?
|
8
|
-
def has_single_chapter?(reference)
|
9
|
-
matches = [/^авд(и[йя])?/, /^иуды?/, /^2 ?и(оа)?нн?а?/, /^3 ?и(оа)?нн?а?/, /^ф(лм|ил(имон)?у?)/]
|
10
|
-
return Regexp.union(matches).match?(reference.downcase)
|
11
|
-
end
|
12
|
-
|
13
7
|
def books
|
14
8
|
{
|
15
9
|
'GEN' => { match: /^быт(и[её])?/, name: 'Бытие' }, # Быт, Бытие
|
@@ -24,7 +18,7 @@ module BibleRef
|
|
24
18
|
'2SA' => { match: /^2 ?(цар(ств)?|сам(уила?)?)/, name: '2 Царств' }, # 2 Цар, 2 Царств, 2 Сам, 2 Самуила
|
25
19
|
'1KI' => { match: /^3 ?цар(ств)?/, name: '3 Царств' }, # 3 Цар, 3 Царств
|
26
20
|
'2KI' => { match: /^4 ?цар(ств)?/, name: '4 Царств' }, # 4 Цар, 4 Царств
|
27
|
-
'1CH' => { match: /^
|
21
|
+
'1CH' => { match: /^1 ?пар(алипоменон)/, name: '1 Паралипоменон' }, # 1 Пар, 1 Паралипоменон
|
28
22
|
'2CH' => { match: /^2 ?пар(алипоменон)/, name: '2 Паралипоменон' }, # 2 Пар, 2 Паралипоменон
|
29
23
|
'EZR' => { match: /^езд(р[аы])?/, name: 'Ездра' }, # Ездр, Ездра, Ездры
|
30
24
|
'NEH' => { match: /^неем(и[яи])?/, name: 'Неемия' }, # Неем, Неемия, Неемии
|
@@ -82,14 +76,14 @@ module BibleRef
|
|
82
76
|
'2CO' => { match: /^2 ?кор(инфянам)?/, name: '2 Коринфянам' }, # 2 Кор, 2 Коринфянам
|
83
77
|
'GAL' => { match: /^гал(атам)?/, name: 'Галатам' }, # Гал, Галатам
|
84
78
|
'EPH' => { match: /^[еэ]ф(есянам)?/, name: 'Ефесянам' }, # Еф, Ефесянам
|
85
|
-
'PHP' => { match:
|
79
|
+
'PHP' => { match: /^флп|^Филип/, name: 'Филиппийцам' }, # Флп, Филиппийцам
|
86
80
|
'COL' => { match: /^кол(оссянам)?/, name: 'Колоссянам' }, # Кол, Колоссянам
|
87
81
|
'1TH' => { match: /^1 ?фес(с(алоникийцам)?)?/,name: '1 Фессалоникийцам' }, # 1 Фес, 1 Фессалоникийцам
|
88
82
|
'2TH' => { match: /^2 ?фес(с(алоникийцам)?)?/,name: '2 Фессалоникийцам' }, # 2 Фес, 2 Фессалоникийцам
|
89
83
|
'1TI' => { match: /^1 ?тим(офею)?/, name: '1 Тимофею' }, # 1 Тим, 1 Тимофею
|
90
84
|
'2TI' => { match: /^2 ?тим(офею)?/, name: '2 Тимофею' }, # 2 Тим, 2 Тимофею
|
91
85
|
'TIT' => { match: /^титу?/, name: 'Титу' }, # Тит, Титу
|
92
|
-
'PHM' => { match:
|
86
|
+
'PHM' => { match: /^флм|^Филим/, name: 'Филимону' }, # Флм, Филимону
|
93
87
|
'HEB' => { match: /^евр(еям)?/, name: 'Евреям' }, # Евр, Евреям
|
94
88
|
'JAS' => { match: /^иак(ова?)?/, name: 'Иакова' }, # Иак, Иаков, Иакова
|
95
89
|
'1PE' => { match: /^1 ?пет(ра?)?/, name: '1 Петра' }, # 1 Пет, 1 Петра
|
data/lib/bible_ref/parser.rb
CHANGED
@@ -23,13 +23,13 @@ module BibleRef
|
|
23
23
|
rule(:ref_range) { (ref.as(:from) >> str("-") >> (ref | verse).as(:to)).as(:range) }
|
24
24
|
rule(:verse_range) { (verse.as(:from) >> str("-") >> verse.as(:to)).as(:range) }
|
25
25
|
|
26
|
-
rule(:ref) {
|
26
|
+
rule(:ref) { chapter >> str(":") >> verse }
|
27
27
|
|
28
28
|
rule(:chapters) { (chapter >> (match("[-,]") >> chapter).repeat).as(:refs) }
|
29
29
|
rule(:chapter) { num.as(:chapter) }
|
30
30
|
rule(:verse) { num.as(:verse) }
|
31
31
|
|
32
|
-
rule(:word) { (match("[
|
32
|
+
rule(:word) { (match("[1234]").maybe >> match("[^0-9]").repeat(1)).as(:word) }
|
33
33
|
rule(:separator) { (str(",") >> space.maybe) | (space.maybe >> str("&") >> space.maybe) }
|
34
34
|
rule(:num) { match("[0-9]").repeat(1).as(:num) }
|
35
35
|
rule(:space) { str(" ").repeat(1) }
|
data/lib/bible_ref/reference.rb
CHANGED
@@ -13,8 +13,8 @@ module BibleRef
|
|
13
13
|
@reference = reference
|
14
14
|
@single_chapter_book_matching = single_chapter_book_matching
|
15
15
|
raise 'expected :special or :indifferent' unless %i[special indifferent].include?(@single_chapter_book_matching)
|
16
|
-
standardize_reference
|
17
16
|
@details = parse
|
17
|
+
standardize_single_chapter_book
|
18
18
|
end
|
19
19
|
|
20
20
|
# Returns an array of pairs, each one being the from and to for a range.
|
@@ -25,11 +25,15 @@ module BibleRef
|
|
25
25
|
def ranges
|
26
26
|
return nil unless valid?
|
27
27
|
@chapter = nil
|
28
|
-
|
28
|
+
refs_as_array.map do |ref|
|
29
29
|
normalize_range(ref) || normalize_ref(ref)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def refs_as_array
|
34
|
+
[@details[:refs]].flatten
|
35
|
+
end
|
36
|
+
|
33
37
|
# Returns a USFX-compatible book id, or nil if book is unknown.
|
34
38
|
def book_id
|
35
39
|
return nil unless @details
|
@@ -77,20 +81,19 @@ module BibleRef
|
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
80
|
-
def standardize_reference
|
81
|
-
standardize_single_chapter_book if @language.has_single_chapter?(@reference)
|
82
|
-
end
|
83
|
-
|
84
84
|
def standardize_single_chapter_book
|
85
85
|
return if @single_chapter_book_matching == :indifferent
|
86
86
|
return @reference if @reference.include? ':'
|
87
|
+
return unless %w[OBA PHM 2JN 3JN JUD].include?(book_id)
|
88
|
+
return if refs_as_array.any? { |r| r[:verse] }
|
87
89
|
|
88
90
|
matches = @reference.match(/^([\d]?[\D\s]*)/)
|
89
|
-
return @reference if matches.length() == 0
|
91
|
+
#return @reference if matches.length() == 0
|
90
92
|
|
91
93
|
book = matches[0].strip
|
92
94
|
requested = @reference.sub(book, '').strip
|
93
95
|
@reference = "#{book} 1:#{requested}"
|
96
|
+
@details = parse
|
94
97
|
end
|
95
98
|
|
96
99
|
def parse
|
data/lib/bible_ref/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bible_ref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Morgan
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: parslet
|
@@ -81,7 +80,6 @@ homepage: https://github.com/seven1m/bible_ref
|
|
81
80
|
licenses:
|
82
81
|
- MIT
|
83
82
|
metadata: {}
|
84
|
-
post_install_message:
|
85
83
|
rdoc_options: []
|
86
84
|
require_paths:
|
87
85
|
- lib
|
@@ -96,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
94
|
- !ruby/object:Gem::Version
|
97
95
|
version: '0'
|
98
96
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
100
|
-
signing_key:
|
97
|
+
rubygems_version: 3.6.7
|
101
98
|
specification_version: 4
|
102
99
|
summary: Bible reference parser
|
103
100
|
test_files: []
|