scripref 1.2.2 → 2.1.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
  SHA256:
3
- metadata.gz: 740c7e151f3f9e268593a919349a63563ae6c5abc53ebd1819ff210062e36bbc
4
- data.tar.gz: 49b5d3b12e95c7aa7df8c556f0e370f5af82b22fe8e6421d9dead148eab31881
3
+ metadata.gz: 1e8a5707b59a787a2c9d153d5664dc7089962afb7f301f381d340a54aa382fe2
4
+ data.tar.gz: 1b443da4486f615355a7eb98906228a6be744c1470396e731cb30c4ad4774189
5
5
  SHA512:
6
- metadata.gz: 17a6871933eb137c90b2187afb21cbb0398aeeab896ae080a9efb1b433876b70e6406a4d27355ed61e4710de76fd736876d42fdc613ffe0860acebdfabcda888
7
- data.tar.gz: 5d4e55dc849c3f3935d32b387deaf559090cd478fc034586f3005b4aa5dfe4f1d8e8bf2d63016936692a4974785f00afc403ebf04aa58b5eb52b9cef09a040de
6
+ metadata.gz: 91c1e585d9e956434b4806e227bd8bbc5dc1eaf1ca6f101966175bcedcdc3d4b071614c3b9e78e17ae3abc5437decc5b8e5d8978ee63a93247b923e255e71dad
7
+ data.tar.gz: 3715eee536614b2f359bd3e0ca5bf40e0d32d5d113881e1351002d91535829aa374f2115ac6f69b35e543e87e794b80fe826882fe40b41deb41cd0efd68882e4
data/Changelog CHANGED
@@ -1,3 +1,16 @@
1
+ 2.1.0
2
+ Implement correct sorting for passages with addons.
3
+
4
+ 2.0.0
5
+ Major release with following breaking changes:
6
+ Rewrite Bookorder and Bookname and adapt Formatter#format accordingly.
7
+ Remove Comparable mixin and depending methods from Passage and implement
8
+ Sorter instead.
9
+ Rename all osis_*_id names to book_id.
10
+ Rename OSIS_BOOK_ID_TO_BOOK_NAME -> BOOKNAMES_HASH
11
+
12
+ Further: Implement a lot of internal optimizations.
13
+
1
14
  1.2.2
2
15
  Extend German abbreviations.
3
16
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2018, 2020, 2024 Jan Friedrich
1
+ Copyright (c) 2010-2018, 2020, 2024-2026 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
@@ -5,6 +5,9 @@ require 'rim/version'
5
5
  Rim.setup do
6
6
  if feature_loaded? 'rim/irb'
7
7
  irb_requires %w(scripref scripref/include scripref/pipelining)
8
+ if File.exist?(fn = './.irb_init.rb')
9
+ irb_requires << fn
10
+ end
8
11
  end
9
12
  test_warning false
10
13
  end
@@ -18,17 +18,23 @@ module Scripref
18
18
  NUMBER_RE
19
19
  end
20
20
 
21
- # Regular expression to match a book.
21
+ # Regular expression to match a book
22
22
  def book_re
23
23
  return @book_re if @book_re
24
- books_res_as_strings = book_names.map do |bn|
25
- bn.names.map do |n|
26
- (n.gsub(/([^\dA-Z])/, '\1?').gsub('.', '\.'))
24
+ books_res_as_strings = []
25
+ each_bookname do |bn|
26
+ bn.each_name do |n|
27
+ books_res_as_strings << (n.gsub(/([^\dA-Z])/, '\1?').gsub('.', '\.'))
27
28
  end
28
- end.flatten
29
+ end
29
30
  @book_re = Regexp.compile(books_res_as_strings.map {|s| '(\b' << s << '\b\.?\s*)' }.join('|'), nil)
30
31
  end
31
32
 
33
+ # Enumerator over booknames
34
+ def each_bookname &blk
35
+ booknames_hash.each_value(&blk)
36
+ end
37
+
32
38
  end
33
39
 
34
40
  end
@@ -5,28 +5,106 @@ module Scripref
5
5
 
6
6
  class Bookname
7
7
 
8
- attr_reader :osis_id, :names, :abbrevs
8
+ attr_reader :book_id
9
9
 
10
- def initialize osis_id:, names:, abbrevs:
11
- @osis_id = osis_id
12
- @names = Array(names)
10
+ # @param book_id OSID-ID of the book
11
+ # @param name full name of the book
12
+ # @param abbrevs possible abbreviations for the book
13
+ # @param alternatives further Bookname instances with alternative names and abbreviations for book
14
+ def initialize book_id:, name:, abbrevs: [], alternatives: []
15
+ @book_id = book_id
16
+ @name = name
13
17
  @abbrevs = Array(abbrevs)
18
+ @alternatives = Array(alternatives)
14
19
  end
15
20
 
16
- def name
17
- @names.first
21
+ # Format the bookname (full name or abbreviation)
22
+ # @param abbrev_level if 0 full name, if >0 an abbreviation
23
+ def format abbrev_level: 0
24
+ case
25
+ when abbrev_level == 0
26
+ @name
27
+ when abbrev_level > 0
28
+ @abbrevs[abbrev_level - 1] || @abbrevs[-1] || @name
29
+ else
30
+ fail ArgumentError, 'negative values for abbrev_level are not allowed'
31
+ end
18
32
  end
19
33
 
20
- def abbrev level=0
21
- @abbrevs[level] || @abbrevs[-1]
34
+ # Enumerator over all names (name and name of alternatives)
35
+ def each_name
36
+ if block_given?
37
+ yield @name
38
+ @alternatives.each do |bn|
39
+ bn.each_name do |alt_name|
40
+ yield alt_name
41
+ end
42
+ end
43
+ else
44
+ enum_for :each_name
45
+ end
46
+ end
47
+
48
+ # Enumerator over all names and abbreviations (including alternatives)
49
+ def each_string
50
+ if block_given?
51
+ yield @name
52
+ @abbrevs.each do |a|
53
+ yield a
54
+ end
55
+ @alternatives.each do |bn|
56
+ bn.each_string do |s|
57
+ yield s
58
+ end
59
+ end
60
+ else
61
+ enum_for :each_string
62
+ end
22
63
  end
23
64
 
24
65
  def to_s
25
- @osis_id.to_s
66
+ @name
67
+ end
68
+
69
+ # Convert the instance to an equivalent string representation
70
+ def dump
71
+ s = Kernel.format('%s: %s', @book_id, [@name, @abbrevs].flatten.join('|'))
72
+ [s, @alternatives.map(&:dump).map {|s| s.sub(/^.+?: /, '')}].flatten.join(', ')
73
+ end
74
+
75
+ def inspect
76
+ Kernel.format('#<%s %s>', self.class, dump.inspect)
77
+ end
78
+
79
+ def == other
80
+ other.respond_to?(:dump) && dump == other.dump
26
81
  end
27
82
 
28
83
  alias to_str to_s
29
84
 
85
+ class << self
86
+
87
+ # Helper method to create Bookname instances from a String
88
+ # @param s string to parse
89
+ # format: [book_id]: [full name]|[abbrev1]|[abbrev2]|...(, [alternative name]|[abbrev1],...]*
90
+ # @example Format
91
+ # Zeph: Zefanja|Zef, Zephanja|Zeph
92
+ # @example Code equivalent
93
+ # Bookname.new(book_id: :Zeph, name: 'Zefanja', abbrevs: ['Zef'], alternatives: Bookname.new(book_id: :Zeph, name: 'Zephanja', abbrevs: ['Zeph']))
94
+ def parse s
95
+ book_id, rest = s.split(/:\s*/).map(&:strip)
96
+ book_id = book_id.to_sym
97
+ org, *alternatives = rest.split(/,\s*/).map(&:strip)
98
+ name, *abbrevs = org.split('|').map(&:strip)
99
+ alternatives.map! do |s|
100
+ n, *a = s.split('|').map(&:strip)
101
+ Bookname.new(book_id: book_id, name: n, abbrevs: a)
102
+ end
103
+ Bookname.new(book_id: book_id, name: name, abbrevs: abbrevs, alternatives: alternatives)
104
+ end
105
+
106
+ end
107
+
30
108
  end
31
109
 
32
110
  end
@@ -3,18 +3,46 @@
3
3
 
4
4
  module Scripref
5
5
 
6
- # Constants of different orderings of bible books using standardized IDs
6
+ # Module to handle differend orderings of bible books using standardized IDs
7
7
  # (see https://wiki.crosswire.org/OSIS_Book_Abbreviations)
8
8
  module Bookorder
9
9
 
10
10
  # Canonical order (the default order without any apocryphal books)
11
- CANONICAL = %i[
12
- Gen Exod Lev Num Deut Josh Judg Ruth 1Sam 2Sam 1Kgs 2Kgs 1Chr 2Chr Ezra
13
- Neh Esth Job Ps Prov Eccl Song Isa Jer Lam Ezek Dan Hos Joel Amos Obad
14
- Jonah Mic Nah Hab Zeph Hag Zech Mal Matt Mark Luke John Acts Rom 1Cor
15
- 2Cor Gal Eph Phil Col 1Thess 2Thess 1Tim 2Tim Titus Phlm Heb Jas 1Pet
16
- 2Pet 1John 2John 3John Jude Rev
17
- ]
11
+ module Canonical
12
+
13
+ BOOK_IDS = %i[
14
+ Gen Exod Lev Num Deut Josh Judg Ruth 1Sam 2Sam 1Kgs 2Kgs 1Chr 2Chr Ezra
15
+ Neh Esth Job Ps Prov Eccl Song Isa Jer Lam Ezek Dan Hos Joel Amos Obad
16
+ Jonah Mic Nah Hab Zeph Hag Zech Mal Matt Mark Luke John Acts Rom 1Cor
17
+ 2Cor Gal Eph Phil Col 1Thess 2Thess 1Tim 2Tim Titus Phlm Heb Jas 1Pet
18
+ 2Pet 1John 2John 3John Jude Rev
19
+ ]
20
+
21
+ def book2num book_id
22
+ @book2num ||= BOOK_IDS.zip(1..).to_h
23
+ @book2num[book_id]
24
+ end
25
+
26
+ end
27
+
28
+ # Luther order (without any apocryphal books)
29
+ module Luther
30
+
31
+ BOOK_IDS = %i[
32
+ Gen Exod Lev Num Deut Josh Judg Ruth 1Sam 2Sam 1Kgs 2Kgs 1Chr 2Chr Ezra
33
+ Neh Esth Job Ps Prov Eccl Song Isa Jer Lam Ezek Dan Hos Joel Amos Obad
34
+ Jonah Mic Nah Hab Zeph Hag Zech Mal Matt Mark Luke John Acts Rom 1Cor
35
+ 2Cor Gal Eph Phil Col 1Thess 2Thess 1Tim 2Tim Titus Phlm 1Pet 2Pet 1John
36
+ 2John 3John Heb Jas Jude Rev
37
+ ]
38
+
39
+ def book2num book_id
40
+ @book2num ||= BOOK_IDS.zip(1..).to_h
41
+ @book2num[book_id]
42
+ end
43
+
44
+ end
45
+
18
46
  end
19
47
 
20
48
  end
@@ -8,34 +8,81 @@ module Scripref
8
8
  # Mixin for parsing references in English.
9
9
  module English
10
10
 
11
- book_names = <<-END.strip.split(/,\s*/)
12
- Genesis, Exodus, Leviticus, Numbers, Deuteronomy, Joshua, Judges,
13
- Ruth, 1 Samuel, 2 Samuel, 1 Kings, 2 Kings, 1 Chronicles,
14
- 2 Chronicles, Ezra, Nehemiah, Esther, Job, Psalms, Proverbs,
15
- Ecclesiastes, Song of Songs, Isaiah, Jeremiah, Lamentations,
16
- Ezekiel, Daniel, Hosea, Joel, Amos, Obadiah, Jonah, Micah, Nahum,
17
- Habakkuk, Zephaniah, Haggai, Zechariah, Malachi,
18
- Matthew, Mark, Luke, John, Acts, Romans, 1 Corinthians,
19
- 2 Corinthians, Galatians, Ephesians, Philippians, Colossians,
20
- 1 Thessalonians, 2 Thessalonians, 1 Timothy, 2 Timothy, Titus,
21
- Philemon, Hebrews, James, 1 Peter, 2 Peter, 1 John, 2 John, 3 John,
22
- Jude, Revelation
11
+ booknames = <<-END
12
+ Gen: Genesis|Gen
13
+ Exod: Exodus|Ex
14
+ Lev: Leviticus|Lev
15
+ Num: Numbers|Num
16
+ Deut: Deuteronomy|Deut
17
+ Josh: Joshua|Josh
18
+ Judg: Judges|Judg
19
+ Ruth: Ruth|Rth
20
+ 1Sam: 1 Samuel|1 Sam
21
+ 2Sam: 2 Samuel|2 Sam
22
+ 1Kgs: 1 Kings|1 Kgs
23
+ 2Kgs: 2 Kings|2 Kgs
24
+ 1Chr: 1 Chronicles|1 Chron
25
+ 2Chr: 2 Chronicles|2 Chron
26
+ Ezra: Ezra|Ezr
27
+ Neh: Nehemiah|Neh
28
+ Esth: Esther|Esth
29
+ Job: Job|Job
30
+ Ps: Psalms|Ps
31
+ Prov: Proverbs|Prov
32
+ Eccl: Ecclesiastes|Eccles
33
+ Song: Song of Songs|Song
34
+ Isa: Isaiah|Isa
35
+ Jer: Jeremiah|Jer
36
+ Lam: Lamentations|Lam
37
+ Ezek: Ezekiel|Ezek
38
+ Dan: Daniel|Dan
39
+ Hos: Hosea|Hos
40
+ Joel: Joel|Joel
41
+ Amos: Amos|Am
42
+ Obad: Obadiah|Obad
43
+ Jonah: Jonah|Jon
44
+ Mic: Micah|Mic
45
+ Nah: Nahum|Nah
46
+ Hab: Habakkuk|Hab
47
+ Zeph: Zephaniah|Zeph
48
+ Hag: Haggai|Hag
49
+ Zech: Zechariah|Zech
50
+ Mal: Malachi|Mal
51
+ Matt: Matthew|Matt
52
+ Mark: Mark|Mrk
53
+ Luke: Luke|Luk
54
+ John: John|John
55
+ Acts: Acts|Acts
56
+ Rom: Romans|Rom
57
+ 1Cor: 1 Corinthians|1 Cor
58
+ 2Cor: 2 Corinthians|2 Cor
59
+ Gal: Galatians|Gal
60
+ Eph: Ephesians|Eph
61
+ Phil: Philippians|Phil
62
+ Col: Colossians|Col
63
+ 1Thess: 1 Thessalonians|1 Thess
64
+ 2Thess: 2 Thessalonians|2 Thess
65
+ 1Tim: 1 Timothy|1 Tim
66
+ 2Tim: 2 Timothy|2 Tim
67
+ Titus: Titus|Tit
68
+ Phlm: Philemon|Philem
69
+ Heb: Hebrews|Heb
70
+ Jas: James|Jas
71
+ 1Pet: 1 Peter|1 Pet
72
+ 2Pet: 2 Peter|2 Pet
73
+ 1John: 1 John|1 Joh
74
+ 2John: 2 John|2 Joh
75
+ 3John: 3 John|3 Joh
76
+ Jude: Jude|Jud
77
+ Rev: Revelation|Rev
23
78
  END
24
79
 
25
- book_abbrevs = <<-END.strip.split(/,\s*/)
26
- Gen, Ex, Lev, Num, Deut, Josh, Judg, Rth, 1 Sam, 2 Sam, 1 Kgs, 2 Kgs,
27
- 1 Chron, 2 Chron, Ezr, Neh, Esth, Job, Ps, Prov, Eccles, Song, Isa,
28
- Jer, Lam, Ezek, Dan, Hos, Joel, Am, Obad, Jon, Mic, Nah, Hab, Zeph, Hag,
29
- Zech, Mal, Matt, Mrk, Luk, John, Acts, Rom, 1 Cor, 2 Cor, Gal, Eph, Phil,
30
- Col, 1 Thess, 2 Thess, 1 Tim, 2 Tim, Tit, Philem, Heb, Jas, 1 Pet, 2 Pet,
31
- 1 Joh, 2 Joh, 3 Joh, Jud, Rev
32
- END
33
-
34
- # Array of book names.
35
- BOOK_NAMES = Bookorder::CANONICAL.zip(book_names, book_abbrevs).map {|osis_book_id, names, abbrevs| Bookname.new(osis_id: osis_book_id, names: names, abbrevs: abbrevs)}
36
-
37
- # Map of OSIS book ID to instance of Bookname
38
- OSIS_BOOK_ID_TO_BOOK_NAME = Bookorder::CANONICAL.zip(BOOK_NAMES).map {|id, n| [id, n]}.to_h
80
+ # Mapping of OSIS book ID to instance of Bookname
81
+ BOOKNAMES_HASH = {}
82
+ booknames.each_line do |l|
83
+ bn = Bookname.parse(l)
84
+ BOOKNAMES_HASH[bn.book_id] = bn
85
+ end
39
86
 
40
87
  # Separator between chapter and verse.
41
88
  CV_SEPARATOR = ':'
@@ -77,9 +124,9 @@ module Scripref
77
124
  POSTFIX_MORE_FOLLOWING_VERSES_RE = /ff\b\s*/o
78
125
 
79
126
  # Check if book has only one chapter
80
- # @param osis_id OSIS-ID of the book
81
- def book_has_only_one_chapter? osis_id
82
- %i[Obad Phlm 2John 3John Jude].include?(osis_id)
127
+ # @param book_id OSIS-ID of the book
128
+ def book_has_only_one_chapter? book_id
129
+ %i[Obad Phlm 2John 3John Jude].include?(book_id)
83
130
  end
84
131
 
85
132
  # Regular expression to match punctuation marks
@@ -5,14 +5,14 @@ module Scripref
5
5
 
6
6
  class Formatter
7
7
 
8
- attr_accessor :bookformat, :cv_separator, :hyphen_separator, :pass_separator
8
+ attr_accessor :abbrev_level, :cv_separator, :hyphen_separator, :pass_separator
9
9
 
10
10
  # @param mods one or more modules to include
11
- # @param bookformat (:short use abbreviations, :long use full names of books)
12
- def initialize *mods, bookformat: :name
11
+ # @param abbrev_level if 0 full name, if >0 an abbreviation
12
+ def initialize *mods, abbrev_level: 0
13
13
  @mods = mods
14
14
  mods.each {|m| extend m}
15
- @bookformat = bookformat
15
+ @abbrev_level = abbrev_level
16
16
  end
17
17
 
18
18
  # Formats a reference (array of passages and maybe separators)
@@ -28,9 +28,9 @@ module Scripref
28
28
  end
29
29
 
30
30
  # Formats a book
31
- # @param osis_book_id OSIS-ID for book
32
- def format_book osis_book_id
33
- osis_book_id_to_book_name[osis_book_id].send @bookformat
31
+ # @param book_id OSIS-ID for book
32
+ def format_book book_id
33
+ booknames_hash[book_id].format(abbrev_level: abbrev_level)
34
34
  end
35
35
 
36
36
  # Formats a chapter
@@ -8,33 +8,81 @@ module Scripref
8
8
  # Mixin for parsing references in German.
9
9
  module German
10
10
 
11
- book_names = <<-END.strip.split(/,\s*/).map {|e| e.split('|')}
12
- 1. Mose, 2. Mose, 3. Mose, 4. Mose, 5. Mose, Josua, Richter, Ruth, 1. Samuel, 2. Samuel,
13
- 1. Könige, 2. Könige, 1. Chronika, 2. Chronika, Esra, Nehemia, Esther, Hiob, Psalm|Psalmen,
14
- Sprüche, Prediger, Hohelied, Jesaja, Jeremia, Klagelieder, Hesekiel, Daniel, Hosea, Joel,
15
- Amos, Obadja, Jona, Micha, Nahum, Habakuk, Zefanja|Zephanja, Haggai, Sacharja, Maleachi,
16
- Matthäus, Markus, Lukas, Johannes, Apostelgeschichte, Römer, 1. Korinther, 2. Korinther,
17
- Galater, Epheser, Philipper, Kolosser, 1. Thessalonicher, 2. Thessalonicher, 1. Timotheus,
18
- 2. Timotheus, Titus, Philemon, Hebräer, Jakobus, 1. Petrus, 2. Petrus, 1. Johannes,
19
- 2. Johannes, 3. Johannes, Judas, Offenbarung
11
+ booknames = <<-END
12
+ Gen: 1. Mose|1. Mos|1Mo|1M
13
+ Exod: 2. Mose|2. Mos|2Mo|2M
14
+ Lev: 3. Mose|3. Mos|3Mo|3M
15
+ Num: 4. Mose|4. Mos|4Mo|4M
16
+ Deut: 5. Mose|5. Mos|5Mo|5M
17
+ Josh: Josua|Jos
18
+ Judg: Richter|Ri
19
+ Ruth: Ruth|Ruth|Rt
20
+ 1Sam: 1. Samuel|1. Sam|1Sam|1Sm
21
+ 2Sam: 2. Samuel|2. Sam|2Sam|2Sm
22
+ 1Kgs: 1. Könige|1. Kön|1Kön|1Kö
23
+ 2Kgs: 2. Könige|2. Kön|2Kön|2Kö
24
+ 1Chr: 1. Chronika|1. Chr|1Chr|1Ch
25
+ 2Chr: 2. Chronika|2. Chr|2Chr|2Ch
26
+ Ezra: Esra|Esr
27
+ Neh: Nehemia|Neh
28
+ Esth: Esther|Est
29
+ Job: Hiob|Hi
30
+ Ps: Psalm|Ps, Psalmen
31
+ Prov: Sprüche|Spr
32
+ Eccl: Prediger|Pred
33
+ Song: Hohelied|Hohel|Hoh|Hl
34
+ Isa: Jesaja|Jes
35
+ Jer: Jeremia|Jer
36
+ Lam: Klagelieder|Klag
37
+ Ezek: Hesekiel|Hes
38
+ Dan: Daniel|Dan
39
+ Hos: Hosea|Hos
40
+ Joel: Joel|Joel
41
+ Amos: Amos|Amos|Am
42
+ Obad: Obadja|Obad|Ob
43
+ Jonah: Jona|Jona|Jon
44
+ Mic: Micha|Mich|Mi
45
+ Nah: Nahum|Nah
46
+ Hab: Habakuk|Hab
47
+ Zeph: Zefanja|Zef, Zephanja|Zeph
48
+ Hag: Haggai|Hag
49
+ Zech: Sacharja|Sach
50
+ Mal: Maleachi|Mal
51
+ Matt: Matthäus|Mat|Mt
52
+ Mark: Markus|Mar|Mr
53
+ Luke: Lukas|Luk|Lk
54
+ John: Johannes|Joh|Jh
55
+ Acts: Apostelgeschichte|Apg
56
+ Rom: Römer|Röm|Rö
57
+ 1Cor: 1. Korinther|1. Kor|1Ko
58
+ 2Cor: 2. Korinther|2. Kor|2Ko
59
+ Gal: Galater|Gal
60
+ Eph: Epheser|Eph
61
+ Phil: Philipper|Phil
62
+ Col: Kolosser|Kol
63
+ 1Thess: 1. Thessalonicher|1. Thes|1.Thes|1Thes|1Th
64
+ 2Thess: 2. Thessalonicher|2. Thes|2.Thes|2Thes|2Th
65
+ 1Tim: 1. Timotheus|1. Tim|1Tim
66
+ 2Tim: 2. Timotheus|2. Tim|2Tim
67
+ Titus: Titus|Tit
68
+ Phlm: Philemon|Philem|Phm
69
+ Heb: Hebräer|Heb
70
+ Jas: Jakobus|Jak
71
+ 1Pet: 1. Petrus|1. Pet|1Pet|1Pe
72
+ 2Pet: 2. Petrus|2. Pet|2Pet|2Pe
73
+ 1John: 1. Johannes|1. Joh|1Joh|1Jo
74
+ 2John: 2. Johannes|2. Joh|2Joh|2Jo
75
+ 3John: 3. Johannes|3. Joh|3Joh|3Jo
76
+ Jude: Judas|Jud
77
+ Rev: Offenbarung|Off
20
78
  END
21
79
 
22
- book_abbrevs = <<-END.strip.split(/,\s*/).map {|e| e.split('|')}
23
- 1. Mos|1Mo|1M, 2. Mos|2Mo|2M, 3. Mos|3Mo|3M, 4. Mos|4Mo|4M, 5. Mos|5Mo|5M, Jos, Ri,
24
- Ruth|Rt, 1. Sam|1Sam|1Sm, 2. Sam|2Sam|2Sm, 1. Kön|1Kön|1Kö, 2. Kön|2Kön|2Kö,
25
- 1. Chr|1Chr|1Ch, 2. Chr|2Chr|2Ch, Esr, Neh, Est, Hi, Ps, Spr, Pred,
26
- Hohel|Hoh|Hl, Jes, Jer, Klag, Hes, Dan, Hos, Joel, Amos|Am, Obad|Ob,
27
- Jona|Jon, Mich|Mi, Nah, Hab, Zef, Hag, Sach, Mal, Mat|Mt, Mar|Mr, Luk|Lk,
28
- Joh|Jh, Apg, Röm|Rö, 1. Kor|1Ko, 2. Kor|2Ko, Gal, Eph, Phil, Kol,
29
- 1. Thes|1.Thes|1Thes|1Th, 2. Thes|2.Thes|2Thes|2Th, 1. Tim|1Tim, 2. Tim|2Tim, Tit, Philem|Phm, Heb, Jak, 1. Pet|1Pet|1Pe, 2. Pet|2Pet|2Pe,
30
- 1. Joh|1Joh|1Jo, 2. Joh|2Joh|2Jo, 3. Joh|3Joh|3Jo, Jud, Off
31
- END
32
-
33
- # Array of book names.
34
- BOOK_NAMES = Bookorder::CANONICAL.zip(book_names, book_abbrevs).map {|osis_book_id, names, abbrevs| Bookname.new(osis_id: osis_book_id, names: names, abbrevs: abbrevs)}
35
-
36
- # Map of OSIS book ID to instance of Bookname
37
- OSIS_BOOK_ID_TO_BOOK_NAME = Bookorder::CANONICAL.zip(BOOK_NAMES).map {|id, n| [id, n]}.to_h
80
+ # Mapping of OSIS book ID to instance of Bookname
81
+ BOOKNAMES_HASH = {}
82
+ booknames.each_line do |l|
83
+ bn = Bookname.parse(l)
84
+ BOOKNAMES_HASH[bn.book_id] = bn
85
+ end
38
86
 
39
87
  # Separator between chapter and verse.
40
88
  CV_SEPARATOR = ','
@@ -76,9 +124,9 @@ module Scripref
76
124
  POSTFIX_MORE_FOLLOWING_VERSES_RE = /ff\b\s*/o
77
125
 
78
126
  # Check if book has only one chapter
79
- # @param osis_id OSIS-ID of the book
80
- def book_has_only_one_chapter? osis_id
81
- %i[Obad Phlm 2John 3John Jude].include?(osis_id)
127
+ # @param book_id OSIS-ID of the book
128
+ def book_has_only_one_chapter? book_id
129
+ %i[Obad Phlm 2John 3John Jude].include?(book_id)
82
130
  end
83
131
 
84
132
  # Regular expression to match punctuation marks