bible_bot 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 104716fdd025941b40d6626690048a72109da1b23fd6e68a5918d193e3d46839
4
+ data.tar.gz: 8ba2af722b2c14327f9d2e708f5b103727b44e50a891c6117fb66f393f3e757d
5
+ SHA512:
6
+ metadata.gz: d32d3e5e490afc029508a8514485cbef3db87ff783f8eeb8384fbd531385cd97f61e1b165e454bc6b02db2497a6a89d566b63f55b79b7e1c53d8f9bbe04933f1
7
+ data.tar.gz: faa5c83aff4c9ec81f197147cf30d5c86d2e3b81c0c772fba6ffdcb299ce21f70275dcba01410c7dbde665057afcb67db1b6561b28912003485bf7b0c398a095
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - name: Set up Ruby
12
+ uses: actions/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.6
15
+ - name: Install dependencies
16
+ run: bundle install
17
+ - name: Run tests
18
+ run: bundle exec rspec
@@ -0,0 +1,2 @@
1
+ .git
2
+ .yardoc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bible_bot (1.4.4)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ method_source (1.0.0)
12
+ pry (0.13.1)
13
+ coderay (~> 1.1)
14
+ method_source (~> 1.0)
15
+ rspec (3.5.0)
16
+ rspec-core (~> 3.5.0)
17
+ rspec-expectations (~> 3.5.0)
18
+ rspec-mocks (~> 3.5.0)
19
+ rspec-core (3.5.4)
20
+ rspec-support (~> 3.5.0)
21
+ rspec-expectations (3.5.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.5.0)
24
+ rspec-mocks (3.5.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.5.0)
27
+ rspec-support (3.5.0)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bible_bot!
34
+ pry
35
+ rspec (~> 3.5.0)
36
+
37
+ BUNDLED WITH
38
+ 1.17.2
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2017 Lightstock, LLC
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ Originally ported from https://github.com/davisd/python-scriptures by David Davis <davisd@davisd.com>
@@ -0,0 +1,144 @@
1
+ # bible_bot
2
+
3
+ Gem for parsing and working with bible verse references.
4
+
5
+ ## Getting Started
6
+
7
+ ```ruby
8
+ # Gemfile
9
+ gem 'bible_bot', github: 'LittleLea/bible_bot'
10
+ ```
11
+
12
+ ```bash
13
+ $ bundle install
14
+ ```
15
+
16
+ ```ruby
17
+ require 'bible_bot'
18
+
19
+ # Parsing
20
+ references = BibleBot::Reference.parse( "John 1:1 is the first but Rom 8:9-10 is another." )
21
+
22
+ # Formatting
23
+ references.map(&:formatted).join( ", " ) #=> "John 1:1, Romans 8:9-10"
24
+ reference = references.last
25
+ reference.start_verse.formatted #=> "Romans 8:9"
26
+ reference.end_verse.formatted #=> "Romans 8:10"
27
+
28
+ # Invalid references are skipped by default
29
+ BibleBot::Reference.parse( "Genesis 100:1" ) #=> []
30
+
31
+ # Optionally include invalid references
32
+ references = BibleBot::Reference.parse( "Genesis 100:1", validate: false )
33
+ references.first.valid? #=> false
34
+
35
+ # Optionally raise on errors
36
+ BibleBot::Reference.parse( "Genesis 100:1", validate: :raise_errors )
37
+ # => BibleBot::InvalidVerseError:
38
+ # Verse is not valid: {:book=>"Genesis", :chapter_number=>100, :verse_number=>1}
39
+
40
+ # Find Books
41
+ book = BibleBot::Book.find_by_name("1 John")
42
+ book.reference.inspect #=> {:start_verse=>"1 John 1:1", :end_verse=>"1 John 5:21"}
43
+ ```
44
+
45
+ ## Terms
46
+
47
+ * `Verse` - A single verse in the bible.
48
+ * `Reference` - A range of two verses. Start and end verse may be equal, in which case it is a single verse reference.
49
+ * `ReferenceMatch` - A lower level wrapper around regular expression `Match` results. This class contains all the parsing logic. Except for advanced use cases, use `Reference.parse` instead.
50
+ * `Book` - One of the 66 books in the bible.
51
+ * `Bible` - A wrapper containing all 66 books and the regular expressions used for parsing.
52
+
53
+ ## Supported Abbreviation Rules
54
+
55
+ * May abbreviate the book title. See `BibleBot::Bible` for which book abbreviations are supported.
56
+
57
+ ```ruby
58
+ "Gen 1:1"
59
+ ```
60
+
61
+ * May omit the end book if it is the same as the start book.
62
+
63
+ ```ruby
64
+ "Genesis 1:1-2:3" #=> Genesis 1:1 - Genesis 2:3
65
+ ```
66
+
67
+ * May omit the end chapter if it is the same as the start chapter.
68
+
69
+ ```ruby
70
+ "Genesis 1:1-3" #=> Genesis 1:1 - Genesis 1:3
71
+ ```
72
+
73
+ * May omit the verse number if the reference includes the entire chapter.
74
+
75
+ ```ruby
76
+ "Genesis 1" #=> Genesis 1:1 - Genesis 1:31
77
+ "Genesis 1-2" #=> Genesis 1:1 - Genesis 2:25
78
+ ```
79
+
80
+ * May omit the chapter number if the book is only a single chapter book.
81
+
82
+ ```ruby
83
+ "Jude 5" #=> Jude 1:5 - Jude 1:5
84
+ ```
85
+
86
+ ## Persisting References and Verses
87
+
88
+ A `Reference` is made up of two `Verse` objects.
89
+
90
+ ```ruby
91
+ reference.start_verse
92
+ reference.end_verse
93
+ ```
94
+
95
+ Each verse is represented by an integer ID that can be stored in your database.
96
+
97
+ ```ruby
98
+ # |- book.id
99
+ # | |- chapter_number
100
+ # | | |- verse_number
101
+ # XX_XXX_XXX
102
+
103
+ reference.start_verse.id #=> 1_001_001 (Genesis 1:1)
104
+ reference.end_verse.id #=> 2_010_020 (Exodus 10:20)
105
+ ```
106
+
107
+ How you store the `start_verse` and `end_verse` is up to you.
108
+
109
+ To re-instantiate a reference, you can use `Reference.from_verse_ids(:start_verse_id, :end_verse_id)`.
110
+
111
+ ```ruby
112
+ Reference.from_verse_ids(1_001_001, 2_010_020)
113
+
114
+ # Which is shorthand for
115
+ Reference.new(
116
+ start_verse: Verse.from_id(1_001_001),
117
+ end_verse: Verse.from_id(2_010_020)
118
+ )
119
+ ```
120
+
121
+
122
+ ## Comparing References
123
+
124
+ If you want to see if a `Reference` intersects any you have stored in your database, you might do something like:
125
+
126
+ ```ruby
127
+ Foo.where("start_verse_id <= ?", reference.end_verse.id)
128
+ .where("end_verse_id >= ?", reference.start_verse.id)
129
+ ```
130
+
131
+ `Reference` and `Verse` also have built in methods for comparing against each other.
132
+
133
+ ```ruby
134
+ reference.intersects_reference?(other_reference)
135
+ reference.includes_verse?(verse)
136
+ verse < other_verse
137
+ verse == other_verse
138
+ verse > other_verse
139
+ ```
140
+
141
+
142
+ ## History
143
+
144
+ Originally ported from [https://github.com/davisd/python-scriptures](https://github.com/davisd/python-scriptures)
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bible_bot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bible_bot"
8
+ spec.version = BibleBot::VERSION
9
+ spec.authors = ["Jeff McFadden"]
10
+ spec.email = ["jeff@littlelea.co"]
11
+ spec.summary = %q{Bible Verse Parsing, etc.}
12
+ spec.homepage = "https://github.com/lightstock/bible_bot"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency 'rspec', '~> 3.5.0'
21
+ spec.add_development_dependency 'pry'
22
+ end
@@ -0,0 +1,7 @@
1
+ require "bible_bot/version"
2
+ require "bible_bot/book"
3
+ require "bible_bot/bible"
4
+ require "bible_bot/errors"
5
+ require "bible_bot/verse"
6
+ require "bible_bot/reference"
7
+ require "bible_bot/reference_match"
@@ -0,0 +1,568 @@
1
+ module BibleBot
2
+ # Defines Books and Regular Expressions used for parsing and other logic in this gem.
3
+ class Bible
4
+
5
+ # Using this list to inform some of the Abbreviation decisions: https://www.logos.com/bible-book-abbreviations
6
+ @@books = [
7
+ Book.new(
8
+ id: 1,
9
+ name: "Genesis",
10
+ abbreviation: "Gen",
11
+ regex: "(?:Gen|Ge)(?:esis)?",
12
+ testament: "Old",
13
+ chapters: [31, 25, 24, 26, 32, 22, 24, 22, 29, 32, 32, 20, 18, 24, 21, 16, 27, 33, 38, 18, 34, 24, 20, 67, 34, 35, 46, 22, 35, 43, 55, 32, 20, 31, 29, 43, 36, 30, 23, 23, 57, 38, 34, 34, 28, 34, 31, 22, 33, 26]
14
+ ),
15
+ Book.new(
16
+ id: 2,
17
+ name: "Exodus",
18
+ abbreviation: "Exod",
19
+ regex: "Ex(?:odus|od)?",
20
+ testament: "Old",
21
+ chapters: [22, 25, 22, 31, 23, 30, 25, 32, 35, 29, 10, 51, 22, 31, 27, 36, 16, 27, 25, 26, 36, 31, 33, 18, 40, 37, 21, 43, 46, 38, 18, 35, 23, 35, 35, 38, 29, 31, 43, 38]
22
+ ),
23
+ Book.new(
24
+ id: 3,
25
+ name: "Leviticus",
26
+ abbreviation: "Lev",
27
+ regex: "Lev(?:iticus)?",
28
+ testament: "Old",
29
+ chapters: [17, 16, 17, 35, 19, 30, 38, 36, 24, 20, 47, 8, 59, 57, 33, 34, 16, 30, 37, 27, 24, 33, 44, 23, 55, 46, 34]
30
+ ),
31
+ Book.new(
32
+ id: 4,
33
+ name: "Numbers",
34
+ abbreviation: "Num",
35
+ regex: "Num(?:bers)?",
36
+ testament: "Old",
37
+ chapters: [54, 34, 51, 49, 31, 27, 89, 26, 23, 36, 35, 16, 33, 45, 41, 50, 13, 32, 22, 29, 35, 41, 30, 25, 18, 65, 23, 31, 40, 16, 54, 42, 56, 29, 34, 13]
38
+ ),
39
+ Book.new(
40
+ id: 5,
41
+ name: "Deuteronomy",
42
+ abbreviation: "Deut",
43
+ regex: "Deut(?:eronomy)?",
44
+ testament: "Old",
45
+ chapters: [46, 37, 29, 49, 33, 25, 26, 20, 29, 22, 32, 32, 18, 29, 23, 22, 20, 22, 21, 20, 23, 30, 25, 22, 19, 19, 26, 68, 29, 20, 30, 52, 29, 12]
46
+ ),
47
+ Book.new(
48
+ id: 6,
49
+ name: "Joshua",
50
+ abbreviation: "Josh",
51
+ regex: "Josh(?:ua)?",
52
+ testament: "Old",
53
+ chapters: [18, 24, 17, 24, 15, 27, 26, 35, 27, 43, 23, 24, 33, 15, 63, 10, 18, 28, 51, 9, 45, 34, 16, 33]
54
+ ),
55
+ Book.new(
56
+ id: 7,
57
+ name: "Judges",
58
+ abbreviation: "Judg",
59
+ regex: "Judg(?:es)?",
60
+ testament: "Old",
61
+ chapters: [36, 23, 31, 24, 31, 40, 25, 35, 57, 18, 40, 15, 25, 20, 20, 31, 13, 31, 30, 48, 25]
62
+ ),
63
+ Book.new(
64
+ id: 8,
65
+ name: "Ruth",
66
+ abbreviation: "Ruth",
67
+ regex: "Ruth",
68
+ testament: "Old",
69
+ chapters: [22, 23, 18, 22]
70
+ ),
71
+ Book.new(
72
+ id: 9,
73
+ name: "1 Samuel",
74
+ abbreviation: "1Sam",
75
+ regex: "(?:1|I)(?:\\s)?Sam(?:uel)?",
76
+ testament: "Old",
77
+ chapters: [28, 36, 21, 22, 12, 21, 17, 22, 27, 27, 15, 25, 23, 52, 35, 23, 58, 30, 24, 42, 15, 23, 29, 22, 44, 25, 12, 25, 11, 31, 13]
78
+ ),
79
+ Book.new(
80
+ id: 10,
81
+ name: "2 Samuel",
82
+ abbreviation: "2Sam",
83
+ regex: "(?:2|II)(?:\\s)?Sam(?:uel)?",
84
+ testament: "Old",
85
+ chapters: [27, 32, 39, 12, 25, 23, 29, 18, 13, 19, 27, 31, 39, 33, 37, 23, 29, 33, 43, 26, 22, 51, 39, 25]
86
+ ),
87
+ Book.new(
88
+ id: 11,
89
+ name: "1 Kings",
90
+ abbreviation: "1Kgs",
91
+ regex: "(?:1|I)(?:\\s)?K(?:in)?gs",
92
+ testament: "Old",
93
+ chapters: [53, 46, 28, 34, 18, 38, 51, 66, 28, 29, 43, 33, 34, 31, 34, 34, 24, 46, 21, 43, 29, 53]
94
+ ),
95
+ Book.new(
96
+ id: 12,
97
+ name: "2 Kings",
98
+ abbreviation: "2Kgs",
99
+ regex: "(?:2|II)(?:\\s)?K(?:in)?gs",
100
+ testament: "Old",
101
+ chapters: [18, 25, 27, 44, 27, 33, 20, 29, 37, 36, 21, 21, 25, 29, 38, 20, 41, 37, 37, 21, 26, 20, 37, 20, 30]
102
+ ),
103
+ Book.new(
104
+ id: 13,
105
+ name: "1 Chronicles",
106
+ abbreviation: "1Chr",
107
+ regex: "(?:1|I)(?:\\s)?Chr(?:on)?(?:icles)?",
108
+ testament: "Old",
109
+ chapters: [54, 55, 24, 43, 26, 81, 40, 40, 44, 14, 47, 40, 14, 17, 29, 43, 27, 17, 19, 8, 30, 19, 32, 31, 31, 32, 34, 21, 30]
110
+ ),
111
+ Book.new(
112
+ id: 14,
113
+ name: "2 Chronicles",
114
+ abbreviation: "2Chr",
115
+ regex: "(?:2|II)(?:\\s)?Chr(?:on)?(?:icles)?",
116
+ testament: "Old",
117
+ chapters: [17, 18, 17, 22, 14, 42, 22, 18, 31, 19, 23, 16, 22, 15, 19, 14, 19, 34, 11, 37, 20, 12, 21, 27, 28, 23, 9, 27, 36, 27, 21, 33, 25, 33, 27, 23]
118
+ ),
119
+ Book.new(
120
+ id: 15,
121
+ name: "Ezra",
122
+ abbreviation: "Ezra",
123
+ regex: "Ezra",
124
+ testament: "Old",
125
+ chapters: [11, 70, 13, 24, 17, 22, 28, 36, 15, 44]
126
+ ),
127
+ Book.new(
128
+ id: 16,
129
+ name: "Nehemiah",
130
+ abbreviation: "Neh",
131
+ regex: "Neh(?:emiah)?",
132
+ testament: "Old",
133
+ chapters: [11, 20, 32, 23, 19, 19, 73, 18, 38, 39, 36, 47, 31]
134
+ ),
135
+ Book.new(
136
+ id: 17,
137
+ name: "Esther",
138
+ abbreviation: "Esth",
139
+ regex: "Esth(?:er)?",
140
+ testament: "Old",
141
+ chapters: [22, 23, 15, 17, 14, 14, 10, 17, 32, 3]
142
+ ),
143
+ Book.new(
144
+ id: 18,
145
+ name: "Job",
146
+ abbreviation: "Job",
147
+ regex: "Job",
148
+ testament: "Old",
149
+ chapters: [22, 13, 26, 21, 27, 30, 21, 22, 35, 22, 20, 25, 28, 22, 35, 22, 16, 21, 29, 29, 34, 30, 17, 25, 6, 14, 23, 28, 25, 31, 40, 22, 33, 37, 16, 33, 24, 41, 30, 24, 34, 17]
150
+ ),
151
+ Book.new(
152
+ id: 19,
153
+ name: "Psalms",
154
+ abbreviation: "Ps",
155
+ regex: "Ps(?:a)?(?:lm)?(?:s)?",
156
+ testament: "Old",
157
+ chapters: [6, 12, 8, 8, 12, 10, 17, 9, 20, 18, 7, 8, 6, 7, 5, 11, 15, 50, 14, 9, 13, 31, 6, 10, 22, 12, 14, 9, 11, 12, 24, 11, 22, 22, 28, 12, 40, 22, 13, 17, 13, 11, 5, 26, 17, 11, 9, 14, 20, 23, 19, 9, 6, 7, 23, 13, 11, 11, 17, 12, 8, 12, 11, 10, 13, 20, 7, 35, 36, 5, 24, 20, 28, 23, 10, 12, 20, 72, 13, 19, 16, 8, 18, 12, 13, 17, 7, 18, 52, 17, 16, 15, 5, 23, 11, 13, 12, 9, 9, 5, 8, 28, 22, 35, 45, 48, 43, 13, 31, 7, 10, 10, 9, 8, 18, 19, 2, 29, 176, 7, 8, 9, 4, 8, 5, 6, 5, 6, 8, 8, 3, 18, 3, 3, 21, 26, 9, 8, 24, 13, 10, 7, 12, 15, 21, 10, 20, 14, 9, 6]
158
+ ),
159
+ Book.new(
160
+ id: 20,
161
+ name: "Proverbs",
162
+ abbreviation: "Prov",
163
+ regex: "Prov(?:erbs)?",
164
+ testament: "Old",
165
+ chapters: [33, 22, 35, 27, 23, 35, 27, 36, 18, 32, 31, 28, 25, 35, 33, 33, 28, 24, 29, 30, 31, 29, 35, 34, 28, 28, 27, 28, 27, 33, 31]
166
+ ),
167
+ Book.new(
168
+ id: 21,
169
+ name: "Ecclesiastes",
170
+ abbreviation: "Eccl",
171
+ regex: "Ecc(?:l)?(?:esiastes)?",
172
+ testament: "Old",
173
+ chapters: [18, 26, 22, 16, 20, 12, 29, 17, 18, 20, 10, 14]
174
+ ),
175
+ Book.new(
176
+ id: 22,
177
+ name: "Song of Solomon",
178
+ abbreviation: "Song",
179
+ regex: "Song(?: of )?(?:Solomon|Songs)?",
180
+ testament: "Old",
181
+ chapters: [17, 17, 11, 16, 16, 13, 13, 14]
182
+ ),
183
+ Book.new(
184
+ id: 23,
185
+ name: "Isaiah",
186
+ abbreviation: "Isa",
187
+ regex: "Isa(?:iah)?",
188
+ testament: "Old",
189
+ chapters: [31, 22, 26, 6, 30, 13, 25, 22, 21, 34, 16, 6, 22, 32, 9, 14, 14, 7, 25, 6, 17, 25, 18, 23, 12, 21, 13, 29, 24, 33, 9, 20, 24, 17, 10, 22, 38, 22, 8, 31, 29, 25, 28, 28, 25, 13, 15, 22, 26, 11, 23, 15, 12, 17, 13, 12, 21, 14, 21, 22, 11, 12, 19, 12, 25, 24]
190
+ ),
191
+ Book.new(
192
+ id: 24,
193
+ name: "Jeremiah",
194
+ abbreviation: "Jer",
195
+ regex: "Jer(?:emiah)?",
196
+ testament: "Old",
197
+ chapters: [19, 37, 25, 31, 31, 30, 34, 22, 26, 25, 23, 17, 27, 22, 21, 21, 27, 23, 15, 18, 14, 30, 40, 10, 38, 24, 22, 17, 32, 24, 40, 44, 26, 22, 19, 32, 21, 28, 18, 16, 18, 22, 13, 30, 5, 28, 7, 47, 39, 46, 64, 34]
198
+ ),
199
+ Book.new(
200
+ id: 25,
201
+ name: "Lamentations",
202
+ abbreviation: "Lam",
203
+ regex: "Lam(?:entations)?",
204
+ testament: "Old",
205
+ chapters: [22, 22, 66, 22, 22]
206
+ ),
207
+ Book.new(
208
+ id: 26,
209
+ name: "Ezekiel",
210
+ abbreviation: "Ezek",
211
+ regex: "Ezek(?:iel)?",
212
+ testament: "Old",
213
+ chapters: [28, 10, 27, 17, 17, 14, 27, 18, 11, 22, 25, 28, 23, 23, 8, 63, 24, 32, 14, 49, 32, 31, 49, 27, 17, 21, 36, 26, 21, 26, 18, 32, 33, 31, 15, 38, 28, 23, 29, 49, 26, 20, 27, 31, 25, 24, 23, 35]
214
+ ),
215
+ Book.new(
216
+ id: 27,
217
+ name: "Daniel",
218
+ abbreviation: "Dan",
219
+ regex: "Dan(?:iel)?",
220
+ testament: "Old",
221
+ chapters: [21, 49, 30, 37, 31, 28, 28, 27, 27, 21, 45, 13]
222
+ ),
223
+ Book.new(
224
+ id: 28,
225
+ name: "Hosea",
226
+ abbreviation: "Hos",
227
+ regex: "Hos(?:ea)?",
228
+ testament: "Old",
229
+ chapters: [11, 23, 5, 19, 15, 11, 16, 14, 17, 15, 12, 14, 16, 9]
230
+ ),
231
+ Book.new(
232
+ id: 29,
233
+ name: "Joel",
234
+ abbreviation: "Joel",
235
+ regex: "Joel",
236
+ testament: "Old",
237
+ chapters: [20, 32, 21]
238
+ ),
239
+ Book.new(
240
+ id: 30,
241
+ name: "Amos",
242
+ abbreviation: "Amos",
243
+ regex: "Amos",
244
+ testament: "Old",
245
+ chapters: [15, 16, 15, 13, 27, 14, 17, 14, 15]
246
+ ),
247
+ Book.new(
248
+ id: 31,
249
+ name: "Obadiah",
250
+ abbreviation: "Obad",
251
+ regex: "Obad(?:iah)?",
252
+ testament: "Old",
253
+ chapters: [21]
254
+ ),
255
+ Book.new(
256
+ id: 32,
257
+ name: "Jonah",
258
+ abbreviation: "Jonah",
259
+ regex: "Jonah",
260
+ testament: "Old",
261
+ chapters: [17, 10, 10, 11]
262
+ ),
263
+ Book.new(
264
+ id: 33,
265
+ name: "Micah",
266
+ abbreviation: "Mic",
267
+ regex: "Mic(?:ah)?",
268
+ testament: "Old",
269
+ chapters: [16, 13, 12, 13, 15, 16, 20]
270
+ ),
271
+ Book.new(
272
+ id: 34,
273
+ name: "Nahum",
274
+ abbreviation: "Nah",
275
+ regex: "Nah(?:um)?",
276
+ testament: "Old",
277
+ chapters: [15, 13, 19]
278
+ ),
279
+ Book.new(
280
+ id: 35,
281
+ name: "Habakkuk",
282
+ abbreviation: "Hab",
283
+ regex: "Hab(?:akkuk)?",
284
+ testament: "Old",
285
+ chapters: [17, 20, 19]
286
+ ),
287
+ Book.new(
288
+ id: 36,
289
+ name: "Zephaniah",
290
+ abbreviation: "Zeph",
291
+ regex: "Zeph(?:aniah)?",
292
+ testament: "Old",
293
+ chapters: [18, 15, 20]
294
+ ),
295
+ Book.new(
296
+ id: 37,
297
+ name: "Haggai",
298
+ abbreviation: "Hag",
299
+ regex: "Hag(?:gai)?",
300
+ testament: "Old",
301
+ chapters: [15, 23]
302
+ ),
303
+ Book.new(
304
+ id: 38,
305
+ name: "Zechariah",
306
+ abbreviation: "Zech",
307
+ regex: "Zech(?:ariah)?",
308
+ testament: "Old",
309
+ chapters: [21, 13, 10, 14, 11, 15, 14, 23, 17, 12, 17, 14, 9, 21]
310
+ ),
311
+ Book.new(
312
+ id: 39,
313
+ name: "Malachi",
314
+ abbreviation: "Mal",
315
+ regex: "Mal(?:achi)?",
316
+ testament: "Old",
317
+ chapters: [14, 17, 18, 6]
318
+ ),
319
+ Book.new(
320
+ id: 40,
321
+ name: "Matthew",
322
+ abbreviation: "Matt",
323
+ regex: "M(?:at)?t(?:hew)?",
324
+ testament: "New",
325
+ chapters: [25, 23, 17, 25, 48, 34, 29, 34, 38, 42, 30, 50, 58, 36, 39, 28, 27, 35, 30, 34, 46, 46, 39, 51, 46, 75, 66, 20]
326
+ ),
327
+ Book.new(
328
+ id: 41,
329
+ name: "Mark",
330
+ abbreviation: "Mark",
331
+ regex: "M(?:ar)?k",
332
+ testament: "New",
333
+ chapters: [45, 28, 35, 41, 43, 56, 37, 38, 50, 52, 33, 44, 37, 72, 47, 20]
334
+ ),
335
+ Book.new(
336
+ id: 42,
337
+ name: "Luke",
338
+ abbreviation: "Luke",
339
+ regex: "(?:Luke|Lk)",
340
+ testament: "New",
341
+ chapters: [80, 52, 38, 44, 39, 49, 50, 56, 62, 42, 54, 59, 35, 35, 32, 31, 37, 43, 48, 47, 38, 71, 56, 53]
342
+ ),
343
+ Book.new(
344
+ id: 43,
345
+ name: "John",
346
+ abbreviation: "John",
347
+ regex: "(?<!(?:1|2|3|I)\\s)(?<!(?:1|2|3|I))(?:John|Jn)",
348
+ testament: "New",
349
+ chapters: [51, 25, 36, 54, 47, 71, 53, 59, 41, 42, 57, 50, 38, 31, 27, 33, 26, 40, 42, 31, 25]
350
+ ),
351
+ Book.new(
352
+ id: 44,
353
+ name: "Acts",
354
+ abbreviation: "Acts",
355
+ regex: "Acts",
356
+ testament: "New",
357
+ chapters: [26, 47, 26, 37, 42, 15, 60, 40, 43, 48, 30, 25, 52, 28, 41, 40, 34, 28, 41, 38, 40, 30, 35, 27, 27, 32, 44, 31]
358
+ ),
359
+ Book.new(
360
+ id: 45,
361
+ name: "Romans",
362
+ abbreviation: "Rom",
363
+ regex: "(?:Rom|Rm)(?:ans)?",
364
+ testament: "New",
365
+ chapters: [32, 29, 31, 25, 21, 23, 25, 39, 33, 21, 36, 21, 14, 23, 33, 27]
366
+ ),
367
+ Book.new(
368
+ id: 46,
369
+ name: "1 Corinthians",
370
+ abbreviation: "1Cor",
371
+ regex: "(?:1|I)(?:\\s)?Cor(?:inthians)?",
372
+ testament: "New",
373
+ chapters: [31, 16, 23, 21, 13, 20, 40, 13, 27, 33, 34, 31, 13, 40, 58, 24]
374
+ ),
375
+ Book.new(
376
+ id: 47,
377
+ name: "2 Corinthians",
378
+ abbreviation: "2Cor",
379
+ regex: "(?:2|II)(?:\\s)?Cor(?:inthians)?",
380
+ testament: "New",
381
+ chapters: [24, 17, 18, 18, 21, 18, 16, 24, 15, 18, 33, 21, 14]
382
+ ),
383
+ Book.new(
384
+ id: 48,
385
+ name: "Galatians",
386
+ abbreviation: "Gal",
387
+ regex: "Gal(?:atians)?",
388
+ testament: "New",
389
+ chapters: [24, 21, 29, 31, 26, 18]
390
+ ),
391
+ Book.new(
392
+ id: 49,
393
+ name: "Ephesians",
394
+ abbreviation: "Eph",
395
+ regex: "Eph(?:esians)?",
396
+ testament: "New",
397
+ chapters: [23, 22, 21, 32, 33, 24]
398
+ ),
399
+ Book.new(
400
+ id: 50,
401
+ name: "Philippians",
402
+ abbreviation: "Phil",
403
+ regex: "Phil(?!e)(?:ippians)?",
404
+ testament: "New",
405
+ chapters: [30, 30, 21, 23]
406
+ ),
407
+ Book.new(
408
+ id: 51,
409
+ name: "Colossians",
410
+ abbreviation: "Col",
411
+ regex: "Col(?:ossians)?",
412
+ testament: "New",
413
+ chapters: [29, 23, 25, 18]
414
+ ),
415
+ Book.new(
416
+ id: 52,
417
+ name: "1 Thessalonians",
418
+ abbreviation: "1Thess",
419
+ regex: "(?:1|I)(?:\\s)?Thess(?:alonians)?",
420
+ testament: "New",
421
+ chapters: [10, 20, 13, 18, 28]
422
+ ),
423
+ Book.new(
424
+ id: 53,
425
+ name: "2 Thessalonians",
426
+ abbreviation: "2Thess",
427
+ regex: "(?:2|II)(?:\\s)?Thess(?:alonians)?",
428
+ testament: "New",
429
+ chapters: [12, 17, 18]
430
+ ),
431
+ Book.new(
432
+ id: 54,
433
+ name: "1 Timothy",
434
+ abbreviation: "1Tim",
435
+ regex: "(?:1|I)(?:\\s)?Tim(?:othy)?",
436
+ testament: "New",
437
+ chapters: [20, 15, 16, 16, 25, 21]
438
+ ),
439
+ Book.new(
440
+ id: 55,
441
+ name: "2 Timothy",
442
+ abbreviation: "2Tim",
443
+ regex: "(?:2|II)(?:\\s)?Tim(?:othy)?",
444
+ testament: "New",
445
+ chapters: [18, 26, 17, 22]
446
+ ),
447
+ Book.new(
448
+ id: 56,
449
+ name: "Titus",
450
+ abbreviation: "Titus",
451
+ regex: "Tit(?:us)?",
452
+ testament: "New",
453
+ chapters: [16, 15, 15]
454
+ ),
455
+ Book.new(
456
+ id: 57,
457
+ name: "Philemon",
458
+ abbreviation: "Philem",
459
+ regex: "Philem(?:on)?",
460
+ testament: "New",
461
+ chapters: [25]
462
+ ),
463
+ Book.new(
464
+ id: 58,
465
+ name: "Hebrews",
466
+ abbreviation: "Heb",
467
+ regex: "Heb(?:rews)?",
468
+ testament: "New",
469
+ chapters: [14, 18, 19, 16, 14, 20, 28, 13, 28, 39, 40, 29, 25]
470
+ ),
471
+ Book.new(
472
+ id: 59,
473
+ name: "James",
474
+ abbreviation: "Jas",
475
+ regex: "Ja(?:me)?s",
476
+ testament: "New",
477
+ chapters: [27, 26, 18, 17, 20]
478
+ ),
479
+ Book.new(
480
+ id: 60,
481
+ name: "1 Peter",
482
+ abbreviation: "1Pet",
483
+ regex: "(?:1|I)(?:\\s)?Pet(?:er)?",
484
+ testament: "New",
485
+ chapters: [25, 25, 22, 19, 14]
486
+ ),
487
+ Book.new(
488
+ id: 61,
489
+ name: "2 Peter",
490
+ abbreviation: "2Pet",
491
+ regex: "(?:2|II)(?:\\s)?Pet(?:er)?",
492
+ testament: "New",
493
+ chapters: [21, 22, 18]
494
+ ),
495
+ Book.new(
496
+ id: 62,
497
+ name: "1 John",
498
+ abbreviation: "1John",
499
+ regex: "(?:(?:1|I)(?:\\s)?)(?:John|Jn)",
500
+ testament: "New",
501
+ chapters: [10, 29, 24, 21, 21]
502
+ ),
503
+ Book.new(
504
+ id: 63,
505
+ name: "2 John",
506
+ abbreviation: "2John",
507
+ regex: "(?:(?:2|II)(?:\\s)?)(?:John|Jn)",
508
+ testament: "New",
509
+ chapters: [13]
510
+ ),
511
+ Book.new(
512
+ id: 64,
513
+ name: "3 John",
514
+ abbreviation: "3John",
515
+ regex: "(?:(?:3|III)(?:\\s)?)(?:John|Jn)",
516
+ testament: "New",
517
+ chapters: [15]
518
+ ),
519
+ Book.new(
520
+ id: 65,
521
+ name: "Jude",
522
+ abbreviation: "Jude",
523
+ regex: "Jude",
524
+ testament: "New",
525
+ chapters: [25]
526
+ ),
527
+ Book.new(
528
+ id: 66,
529
+ name: "Revelation",
530
+ abbreviation: "Rev",
531
+ regex: "Rev(?:elation)?(?:\\sof Jesus Christ)?",
532
+ testament: "New",
533
+ chapters: [20, 29, 22, 11, 14, 17, 17, 13, 21, 11, 19, 17, 18, 20, 8, 21, 18, 24, 21, 15, 27, 21]
534
+ )
535
+ ]
536
+
537
+ def self.books
538
+ @@books
539
+ end
540
+
541
+ # assemble the book regex
542
+ def self.book_re_string
543
+ @@book_re_string ||= Bible.books.map(&:regex).join('|')
544
+ end
545
+
546
+ # compiled book regular expression
547
+ def self.book_re
548
+ @@book_re ||= Regexp.new(book_re_string, Regexp::IGNORECASE)
549
+ end
550
+
551
+ # compiled scripture reference regular expression
552
+ def self.scripture_re
553
+ @@scripture_re ||= Regexp.new(
554
+ sprintf('\b' +
555
+ '(?<BookTitle>%s)' +
556
+ '[\s\.]*' +
557
+ '(?<ChapterNumber>\d{1,3})' +
558
+ '(?:\s*[:\.]\s*' +
559
+ '(?<VerseNumber>\d{1,3}))?' +
560
+ '(?:\s*-\s*' +
561
+ '(?<EndBookTitle>%s)?[\s\.]*' +
562
+ '(?<EndChapterNumber>\d{1,3})?' +
563
+ '(?:\s*[:\.]\s*)?' +
564
+ '(?<EndVerseNumber>\d{1,3})?' +
565
+ ')?', book_re_string, book_re_string), Regexp::IGNORECASE)
566
+ end
567
+ end
568
+ end