bomdb 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,359 +0,0 @@
1
- module BomDB
2
- module Import
3
- class BiblicalRefs < Import::Base
4
-
5
- def reset
6
- schema.reset(:refs)
7
- end
8
-
9
- def ref(
10
- ref_name: "Bible",
11
- book:, ref_book:,
12
- chapter:, ref_chapter:,
13
- verse: nil, ref_verse: nil,
14
- is_parallel: false, is_quotation: false)
15
- verses = @db[:verses].join(:books, :book_id => :book_id)
16
- verses.where!(:book_name => book, :verse_chapter => chapter, :verse_heading => nil)
17
- verses.where!(:verse_number => verse) if verse
18
-
19
- verses.each do |row|
20
- ref_id = @db[:refs].insert(
21
- ref_name: ref_name,
22
- verse_id: row[:verse_id],
23
- ref_book: ref_book,
24
- ref_chapter: ref_chapter,
25
- ref_verse: ref_verse || row[:verse_number],
26
- ref_is_parallel: is_parallel,
27
- ref_is_quotation: is_quotation
28
- )
29
- # puts ref_id
30
- end
31
- end
32
-
33
- def import
34
- if !schema.has_tables?(:refs)
35
- return Import::Result.new(
36
- success: false,
37
- error: "Database table 'refs' not present."
38
- )
39
- end
40
-
41
- begin
42
- # 2 Nephi 12-24 quotes Isaiah 2-14
43
- (12..24).each do |chapter|
44
- ref(ref_name: "Bible-OT", is_quotation: true,
45
- book: '2 Nephi', chapter: chapter,
46
- ref_book: 'Isaiah', ref_chapter: chapter - 10)
47
- end
48
-
49
- # 2 Nephi 27 quotes Isaiah 29
50
- ref(ref_name: "Bible-OT", is_quotation: true,
51
- book: '2 Nephi', chapter: 27,
52
- ref_book: 'Isaiah', ref_chapter: 29)
53
-
54
- # 1 Nephi 20–21 quotes Isaiah 48-49
55
- ref(ref_name: "Bible-OT", is_quotation: true,
56
- book: '1 Nephi', chapter: 20,
57
- ref_book: 'Isaiah', ref_chapter: 48)
58
- ref(ref_name: "Bible-OT", is_quotation: true,
59
- book: '1 Nephi', chapter: 21,
60
- ref_book: 'Isaiah', ref_chapter: 49)
61
-
62
- # 2 Nephi 7–8 quotes Isaiah 50–51
63
- ref(ref_name: "Bible-OT", is_quotation: true,
64
- book: '2 Nephi', chapter: 7,
65
- ref_book: 'Isaiah', ref_chapter: 50)
66
- ref(ref_name: "Bible-OT", is_quotation: true,
67
- book: '2 Nephi', chapter: 8,
68
- ref_book: 'Isaiah', ref_chapter: 51)
69
-
70
- # 3 Nephi 20 quotes Isaiah 52
71
- ref(ref_name: "Bible-OT", is_quotation: true,
72
- book: '3 Nephi', chapter: 20,
73
- ref_book: 'Isaiah', ref_chapter: 52)
74
-
75
- # Mosiah 14 quotes Isaiah 53
76
- ref(ref_name: "Bible-OT", is_quotation: true,
77
- book: 'Mosiah', chapter: 14,
78
- ref_book: 'Isaiah', ref_chapter: 53)
79
-
80
- # 3 Nephi 22 quotes Isaiah 54
81
- ref(ref_name: "Bible-OT", is_quotation: true,
82
- book: '3 Nephi', chapter: 22,
83
- ref_book: 'Isaiah', ref_chapter: 54)
84
-
85
- # 2 Nephi 29:2 parallels Isaiah 5:26
86
- ref(ref_name: "Bible-OT", is_parallel: true,
87
- book: '2 Nephi', chapter: 29, verse: 2,
88
- ref_book: 'Isaiah', ref_chapter: 5, ref_verse: 26)
89
-
90
- # 2 Nephi 28:32 quotes Isaiah 9:12-13
91
- ref(ref_name: "Bible-OT", is_parallel: true,
92
- book: '2 Nephi', chapter: 28, verse: 32,
93
- ref_book: 'Isaiah', ref_chapter: 9, ref_verse: 12)
94
-
95
- # 2 Nephi 30:9 quotes Isaiah 11:4
96
- ref(ref_name: "Bible-OT", is_quotation: true,
97
- book: '2 Nephi', chapter: 30, verse: 9,
98
- ref_book: 'Isaiah', ref_chapter: 11, ref_verse: 4)
99
-
100
- # 2 Nephi 30:11-15 quotes Isaiah 11:5-9
101
- (11..15).each do |verse|
102
- ref(ref_name: "Bible-OT", is_quotation: true,
103
- book: '2 Nephi', chapter: 30, verse: verse,
104
- ref_book: 'Isaiah', ref_chapter: 11, ref_verse: verse - 6)
105
- end
106
-
107
- # 2 Nephi 25:17; 29:1; compare 25:11 parallels Isaiah 11:11
108
- ref(ref_name: "Bible-OT", is_parallel: true,
109
- book: '2 Nephi', chapter: 25, verse: 17,
110
- ref_book: 'Isaiah', ref_chapter: 11, ref_verse: 11)
111
-
112
- ref(ref_name: "Bible-OT", is_parallel: true,
113
- book: '2 Nephi', chapter: 29, verse: 1,
114
- ref_book: 'Isaiah', ref_chapter: 11, ref_verse: 11)
115
-
116
- # 2 Nephi 28:7-8 parallels Isaiah 22:13
117
- ref(ref_name: "Bible-OT", is_parallel: true,
118
- book: '2 Nephi', chapter: 28, verse: 7,
119
- ref_book: 'Isaiah', ref_chapter: 22, ref_verse: 13)
120
-
121
- ref(ref_name: "Bible-OT", is_parallel: true,
122
- book: '2 Nephi', chapter: 28, verse: 8,
123
- ref_book: 'Isaiah', ref_chapter: 22, ref_verse: 13)
124
-
125
- # 2 Nephi 26:15 parallels Isaiah 25:12
126
- ref(ref_name: "Bible-OT", is_parallel: true,
127
- book: '2 Nephi', chapter: 26, verse: 15,
128
- ref_book: 'Isaiah', ref_chapter: 25, ref_verse: 12)
129
-
130
- # 2 Nephi 28:30 parallels Isaiah 28:10, 13
131
- ref(ref_name: "Bible-OT", is_parallel: true,
132
- book: '2 Nephi', chapter: 28, verse: 30,
133
- ref_book: 'Isaiah', ref_chapter: 28, ref_verse: 10)
134
-
135
- ref(ref_name: "Bible-OT", is_parallel: true,
136
- book: '2 Nephi', chapter: 28, verse: 30,
137
- ref_book: 'Isaiah', ref_chapter: 28, ref_verse: 13)
138
-
139
- # 2 Nephi 26:15-16 parallels Isaiah 29:3-4
140
- ref(ref_name: "Bible-OT", is_parallel: true,
141
- book: '2 Nephi', chapter: 26, verse: 15,
142
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 3)
143
-
144
- ref(ref_name: "Bible-OT", is_parallel: true,
145
- book: '2 Nephi', chapter: 26, verse: 16,
146
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 4)
147
-
148
- # 2 Nephi 26:18 parallels Isaiah 29:5
149
- ref(ref_name: "Bible-OT", is_parallel: true,
150
- book: '2 Nephi', chapter: 26, verse: 18,
151
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 5)
152
-
153
- # 2 Nephi 6:15 parallels Isaiah 29:6
154
- ref(ref_name: "Bible-OT", is_parallel: true,
155
- book: '2 Nephi', chapter: 6, verse: 15,
156
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 6)
157
-
158
- # 2 Nephi 27:2-5 parallels Isaiah 29:6-10
159
- ref(ref_name: "Bible-OT", is_parallel: true,
160
- book: '2 Nephi', chapter: 27, verse: 2,
161
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 6)
162
-
163
- ref(ref_name: "Bible-OT", is_parallel: true,
164
- book: '2 Nephi', chapter: 27, verse: 3,
165
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 7)
166
-
167
- ref(ref_name: "Bible-OT", is_parallel: true,
168
- book: '2 Nephi', chapter: 27, verse: 3,
169
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 8)
170
-
171
- ref(ref_name: "Bible-OT", is_parallel: true,
172
- book: '2 Nephi', chapter: 27, verse: 4,
173
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 9)
174
-
175
- ref(ref_name: "Bible-OT", is_parallel: true,
176
- book: '2 Nephi', chapter: 27, verse: 5,
177
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 10)
178
-
179
- # 1 Nephi 14:7; 1 Nephi 22:8; 2 Nephi 29:1 weakly parallel Isaiah 29:14
180
- # 2 Nephi 25:17 parallels Isaiah 29:14
181
- ref(ref_name: "Bible-OT", is_parallel: true,
182
- book: '2 Nephi', chapter: 25, verse: 17,
183
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 14)
184
-
185
- # 2 Nephi 28:9 parallels Isaiah 29:15
186
- ref(ref_name: "Bible-OT", is_parallel: true,
187
- book: '2 Nephi', chapter: 28, verse: 9,
188
- ref_book: 'Isaiah', ref_chapter: 29, ref_verse: 15)
189
-
190
- # 1 Nephi 10:8 parallels Isaiah 40:3
191
- ref(ref_name: "Bible-OT", is_parallel: true,
192
- book: '1 Nephi', chapter: 10, verse: 8,
193
- ref_book: 'Isaiah', ref_chapter: 40, ref_verse: 3)
194
-
195
- # 1 Nephi 17:36 parallels Isaiah 45:18
196
- ref(ref_name: "Bible-OT", is_parallel: true,
197
- book: '1 Nephi', chapter: 17, verse: 36,
198
- ref_book: 'Isaiah', ref_chapter: 45, ref_verse: 18)
199
-
200
- # Mosiah 27:31 parallels Isaiah 45:23
201
- ref(ref_name: "Bible-OT", is_parallel: true,
202
- book: 'Mosiah', chapter: 27, verse: 31,
203
- ref_book: 'Isaiah', ref_chapter: 45, ref_verse: 23)
204
-
205
- # 1 Nephi 22:6, 1 Nephi 22:8, 2 Nephi 6:6 parallel Isaiah 49:22
206
- ref(ref_name: "Bible-OT", is_parallel: true,
207
- book: '1 Nephi', chapter: 22, verse: 6,
208
- ref_book: 'Isaiah', ref_chapter: 49, ref_verse: 22)
209
-
210
- ref(ref_name: "Bible-OT", is_parallel: true,
211
- book: '1 Nephi', chapter: 22, verse: 8,
212
- ref_book: 'Isaiah', ref_chapter: 49, ref_verse: 22)
213
-
214
- ref(ref_name: "Bible-OT", is_parallel: true,
215
- book: '2 Nephi', chapter: 6, verse: 6,
216
- ref_book: 'Isaiah', ref_chapter: 49, ref_verse: 22)
217
-
218
- # 2 Nephi 6:7; 2 Nephi 10:9 parallel Isaiah 49:23
219
- ref(ref_name: "Bible-OT", is_parallel: true,
220
- book: '2 Nephi', chapter: 6, verse: 7,
221
- ref_book: 'Isaiah', ref_chapter: 49, ref_verse: 23)
222
-
223
- ref(ref_name: "Bible-OT", is_parallel: true,
224
- book: '2 Nephi', chapter: 10, verse: 9,
225
- ref_book: 'Isaiah', ref_chapter: 49, ref_verse: 23)
226
-
227
- # 2 Nephi 6:16-18 quotes Isaiah 49:24-26
228
- (16..18).each do |verse|
229
- ref(ref_name: "Bible-OT", is_quotation: true,
230
- book: '2 Nephi', chapter: 6, verse: verse,
231
- ref_book: 'Isaiah', ref_chapter: 49, ref_verse: verse + 8)
232
- end
233
-
234
- # Moroni 10:31 parallels Isaiah 52:1
235
- ref(ref_name: "Bible-OT", is_parallel: true,
236
- book: 'Moroni', chapter: 10, verse: 31,
237
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 1)
238
-
239
- # 2 Nephi 8:24-25 quotes Isaiah 52:1-2
240
- (24..25).each do |verse|
241
- ref(ref_name: "Bible-OT", is_quotation: true,
242
- book: '2 Nephi', chapter: 8, verse: verse,
243
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: verse - 23)
244
- end
245
-
246
- # 1 Nephi 13:37; Mosiah 15:14-18; 27:37 parallels Isaiah 52:7
247
- ref(ref_name: "Bible-OT", is_parallel: true,
248
- book: '1 Nephi', chapter: 13, verse: 37,
249
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 7)
250
-
251
- (14..18).each do |verse|
252
- # All 5 verses repeat a reference to Isaiah 52:7
253
- ref(ref_name: "Bible-OT", is_parallel: true,
254
- book: 'Mosiah', chapter: 15, verse: verse,
255
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 7)
256
- end
257
-
258
- ref(ref_name: "Bible-OT", is_parallel: true,
259
- book: 'Mosiah', chapter: 27, verse: 37,
260
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 7)
261
-
262
- # Mosiah 12:21-24 quotes Isaiah 52:7-10
263
- (21..24).each do |verse|
264
- ref(ref_name: "Bible-OT", is_quotation: true,
265
- book: 'Mosiah', chapter: 12, verse: verse,
266
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: verse - 14)
267
- end
268
-
269
- # Mosiah 15:29-31; 3 Nephi 16:18-20 quote Isaiah 52:8-10
270
- (29..31).each do |verse|
271
- ref(ref_name: "Bible-OT", is_quotation: true,
272
- book: 'Mosiah', chapter: 15, verse: verse,
273
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: verse - 21)
274
- end
275
-
276
- (18..20).each do |verse|
277
- # Same Isaiah quote as above, but now in 3 Nephi
278
- ref(ref_name: "Bible-OT", is_quotation: true,
279
- book: '3 Nephi', chapter: 16, verse: verse,
280
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: verse - 10)
281
- end
282
-
283
- # 3 Nephi 20:32, 34-35 parallels Isaiah 52:8-10
284
- ref(ref_name: "Bible-OT", is_parallel: true,
285
- book: '3 Nephi', chapter: 20, verse: 32,
286
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 8)
287
-
288
- ref(ref_name: "Bible-OT", is_parallel: true,
289
- book: '3 Nephi', chapter: 20, verse: 34,
290
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 9)
291
-
292
- ref(ref_name: "Bible-OT", is_parallel: true,
293
- book: '3 Nephi', chapter: 20, verse: 35,
294
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 10)
295
-
296
- # 1 Nephi 22:10, 11 each parallel Isaiah 52:10
297
- ref(ref_name: "Bible-OT", is_parallel: true,
298
- book: '1 Nephi', chapter: 22, verse: 10,
299
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 10)
300
-
301
- ref(ref_name: "Bible-OT", is_parallel: true,
302
- book: '1 Nephi', chapter: 22, verse: 11,
303
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 10)
304
-
305
- # 3 Nephi 21:29 parallels Isaiah 52:12
306
- ref(ref_name: "Bible-OT", is_parallel: true,
307
- book: '3 Nephi', chapter: 21, verse: 29,
308
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 12)
309
-
310
- # 3 Nephi 21:8 parallels Isaiah 52:15
311
- ref(ref_name: "Bible-OT", is_parallel: true,
312
- book: '3 Nephi', chapter: 21, verse: 8,
313
- ref_book: 'Isaiah', ref_chapter: 52, ref_verse: 15)
314
-
315
- # Mosiah 15:10 parallels Isaiah 53:8,10
316
- ref(ref_name: "Bible-OT", is_parallel: true,
317
- book: 'Mosiah', chapter: 15, verse: 10,
318
- ref_book: 'Isaiah', ref_chapter: 53, ref_verse: 8)
319
-
320
- ref(ref_name: "Bible-OT", is_parallel: true,
321
- book: 'Mosiah', chapter: 15, verse: 10,
322
- ref_book: 'Isaiah', ref_chapter: 53, ref_verse: 10)
323
-
324
- # Moroni 10:31 parallels Isaiah 54:2
325
- ref(ref_name: "Bible-OT", is_parallel: true,
326
- book: 'Moroni', chapter: 10, verse: 31,
327
- ref_book: 'Isaiah', ref_chapter: 54, ref_verse: 2)
328
-
329
- # 2 Nephi 26:25 parallels Isaiah 55:1
330
- ref(ref_name: "Bible-OT", is_parallel: true,
331
- book: '2 Nephi', chapter: 26, verse: 25,
332
- ref_book: 'Isaiah', ref_chapter: 55, ref_verse: 1)
333
-
334
- # 2 Nephi 9:50-51 quotes/parallels Isaiah 55:1-2
335
- ref(ref_name: "Bible-OT", is_quotation: true,
336
- book: '2 Nephi', chapter: 9, verse: 50,
337
- ref_book: 'Isaiah', ref_chapter: 55, ref_verse: 1)
338
-
339
- ref(ref_name: "Bible-OT", is_parallel: true,
340
- book: '2 Nephi', chapter: 9, verse: 51,
341
- ref_book: 'Isaiah', ref_chapter: 55, ref_verse: 2)
342
- rescue => e
343
- Import::Result.new(success: false, error: e)
344
- end
345
- Import::Result.new(success: true)
346
- end
347
-
348
- def list
349
- @db[
350
- "SELECT book_name, verse_chapter, verse_number, ref_name, ref_book, ref_chapter, ref_verse " +
351
- "FROM `verses` v " +
352
- "JOIN `books` b ON b.book_id = v.book_id " +
353
- "JOIN `refs` r ON r.verse_id = v.verse_id " +
354
- "ORDER BY ref_book, ref_chapter, ref_verse"
355
- ].map(&:inspect).join("\n")
356
- end
357
- end
358
- end
359
- end