bible 1.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.
- data/README.txt +33 -0
- data/Rakefile +41 -0
- data/bin/bible.rb +154 -0
- data/lib/bible.rb +33 -0
- data/lib/bible/bible.yml +1717 -0
- data/lib/bible/iterator.rb +80 -0
- data/lib/bible/lookup/dr.rb +42 -0
- data/lib/bible/lookup/nab.rb +40 -0
- data/lib/bible/lookup/rsv.rb +48 -0
- data/lib/bible/parser.rb +905 -0
- data/test/test_bible.rb +449 -0
- metadata +78 -0
data/test/test_bible.rb
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
|
|
3
|
+
$:.unshift File.dirname(__FILE__) + "/../lib" unless $:.include?(File.dirname(__FILE__) + "../lib")
|
|
4
|
+
puts $:
|
|
5
|
+
require 'bible'
|
|
6
|
+
|
|
7
|
+
class DRTests < Test::Unit::TestCase
|
|
8
|
+
require 'bible/lookup/dr'
|
|
9
|
+
|
|
10
|
+
def test_get_verse
|
|
11
|
+
assert((result = Bible::DRLookup.get_ref(:Genesis, 1, 1).to_s.strip) == "In the beginning God created heaven, and earth.", "Did not get verse for Genesis 1:1 as expected: #{result}")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_get_joel
|
|
15
|
+
# errors
|
|
16
|
+
assert((result = Bible["joel 4", :dr]))
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class NABTests < Test::Unit::TestCase
|
|
21
|
+
require 'bible/lookup/nab'
|
|
22
|
+
|
|
23
|
+
def test_get_verses
|
|
24
|
+
assert((result = Bible::NABLookup.get_ref(:Luke, 1, 1).to_s.strip) == "Since many have undertaken to compile a narrative of the events that have been fulfilled among us,", "Did not get verse for Luke 1:1 as expected: #{result}")
|
|
25
|
+
assert((result = Bible::NABLookup.get_ref(:Genesis, 1, 1).to_s.strip) == "In the beginning, when God created the heavens and the earth,", "Did not get verse for Genesis 1:1 as expected: #{result}")
|
|
26
|
+
assert((result = Bible::NABLookup.get_ref(:Revelation, 22, 21).to_s.strip) == "The grace of the Lord Jesus be with all.", "Did not get verse for Rev 22:21 as expected: #{result}")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_get_single_pages
|
|
30
|
+
assert((result = Bible::NABLookup.getURL("1 Samuel".to_sym, 1)) =~ /1samuel1.htm/, "Did not get URL for 1 Samuel as expected: #{result}")
|
|
31
|
+
assert((result = Bible::NABLookup.getURL("Philemon".to_sym, 1)) =~ /philemon.htm/, "Did not get URL for Philemon as expected: #{result}")
|
|
32
|
+
assert((result = Bible::NABLookup.getURL("Obadiah".to_sym, 1)) =~ /obadiah.htm/, "Did not get URL for Obadiah as expected: #{result}")
|
|
33
|
+
assert((result = Bible::NABLookup.getURL("2 John".to_sym, 1)) =~ /2john\/2john.htm/, "Did not get URL for 2 John as expected: #{result}")
|
|
34
|
+
assert((result = Bible::NABLookup.getURL("3 John".to_sym, 1)) =~ /3john\/3john.htm/, "Did not get URL for 3 John as expected: #{result}")
|
|
35
|
+
assert((result = Bible::NABLookup.getURL("Jude".to_sym, 1)) =~ /jude\/jude.htm/, "Did not get URL for Jude as expected: #{result}")
|
|
36
|
+
assert((result = Bible::NABLookup.getURL("Song of Solomon".to_sym, 1)) =~ /songs\/song1.htm/, "Did not get URL for Song of Solomon as expected: #{result}")
|
|
37
|
+
assert((result = Bible::NABLookup.getURL("Luke".to_sym, 1)) =~ /luke1.htm/, "Did not get URL for Luke as expected: #{result}")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_get_psalm2
|
|
41
|
+
assert((result = Bible::NABLookup.getURL("Psalms".to_sym, 1)) =~ /psalms\/psalm1.htm/, "Did not get URL for Pslam 1 as expected: #{result}")
|
|
42
|
+
assert((result = Bible::NABLookup.get_ref("Song of Solomon".to_sym, 1)).to_s =~ /delightful/, "Did not get text for Song of Solomon 1 as expected: #{result}")
|
|
43
|
+
assert((result = Bible["Song 1", :nab].to_s) =~ /delightful/, "Did not get text for Song of Solomon 1 as expected: #{result}")
|
|
44
|
+
result = Bible["Psalm 2", :nab].to_s
|
|
45
|
+
text = <<-EOS.split("\n").each { |line| assert(result.index(line.strip), "Line not found in text of Ps 2: #{line}") }
|
|
46
|
+
Why do the nations protest and the peoples grumble in vain?
|
|
47
|
+
Kings on earth rise up and princes plot together against the LORD and his anointed:
|
|
48
|
+
"Let us break their shackles and cast off their chains!"
|
|
49
|
+
The one enthroned in heaven laughs; the Lord derides them,
|
|
50
|
+
Then speaks to them in anger, terrifies them in wrath:
|
|
51
|
+
"I myself have installed my king on Zion, my holy mountain."
|
|
52
|
+
I will proclaim the decree of the LORD, who said to me, "You are my son; today I am your father.
|
|
53
|
+
Only ask it of me, and I will make your inheritance the nations, your possession the ends of the earth.
|
|
54
|
+
With an iron rod you shall shepherd them, like a clay pot you will shatter them."
|
|
55
|
+
And now, kings, give heed; take warning, rulers on earth.
|
|
56
|
+
Serve the LORD with fear; with trembling bow down in homage, Lest God be angry and you perish from the way in a sudden blaze of anger. Happy are all who take refuge in God!
|
|
57
|
+
EOS
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_get_joel
|
|
61
|
+
# error
|
|
62
|
+
assert((result = Bible["joel 4", :nab]))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class BibleTests < Test::Unit::TestCase
|
|
68
|
+
|
|
69
|
+
def setup
|
|
70
|
+
# Ensure that the default used is NAB
|
|
71
|
+
@old_lookup = Bible::BibleIterator.default_lookup
|
|
72
|
+
Bible::BibleIterator.default_lookup = Bible::NABLookup
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def teardown
|
|
76
|
+
Bible::BibleIterator.default_lookup = @old_lookup
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_successors
|
|
80
|
+
successors = Bible::BookInfo.all_books.collect { |b| b.book }
|
|
81
|
+
start = Bible::Books[:Genesis]
|
|
82
|
+
successors.each { |b|
|
|
83
|
+
assert(start.book == b, "Books did not match: #{start.book} != #{b}")
|
|
84
|
+
start = start.succ
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_genesis_easy
|
|
89
|
+
ref = Bible["Gen 1:1"]
|
|
90
|
+
assert(ref.book == :Genesis)
|
|
91
|
+
assert(ref.book.chapter == 1)
|
|
92
|
+
assert(ref.chapter.verse == 1)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_genesis_chapters
|
|
96
|
+
ref = Bible["Gen 1-2"]
|
|
97
|
+
assert(ref.book == :Genesis, "Book not as expected: #{ref.book.inspect}")
|
|
98
|
+
assert(ref.book.chapters == (1..2))
|
|
99
|
+
assert(ref.book.chapters[0] == 1)
|
|
100
|
+
assert(ref.book.chapters[1] == 2)
|
|
101
|
+
assert_raises(NoMethodError) { ref.book.chapter }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_genesis_chapters_indexed
|
|
105
|
+
ref = Bible["Gen 1-3"]
|
|
106
|
+
assert(ref.book == :Genesis)
|
|
107
|
+
assert(ref.book.chapters == (1..3))
|
|
108
|
+
assert(ref.book.chapters[0] == 1)
|
|
109
|
+
assert(ref.book.chapters[1] == 2, "Second book not as expected: #{ref.book.chapters[1].inspect}")
|
|
110
|
+
assert(ref.book.chapters[2] == 3)
|
|
111
|
+
assert_raises(NoMethodError) { ref.book.chapter }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_genesis_chapters_indexed_discontinuous
|
|
115
|
+
ref = Bible["Gen 1-3, 5"]
|
|
116
|
+
assert(ref.book == :Genesis)
|
|
117
|
+
assert(ref.book.chapters == [1, 2, 3, 5])
|
|
118
|
+
assert(ref.book.chapters[0] == 1)
|
|
119
|
+
assert(ref.book.chapters[1] == 2)
|
|
120
|
+
assert(ref.book.chapters[2] == 3)
|
|
121
|
+
assert(ref.book.chapters[3] == 5)
|
|
122
|
+
assert_raises(NoMethodError) { ref.book.chapter }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_genesis_discontinuous_chapters
|
|
126
|
+
ref = Bible["Gen 1, 5"]
|
|
127
|
+
assert(ref.book == :Genesis)
|
|
128
|
+
assert(ref.book.chapters == [1, 5])
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_genesis_verses
|
|
132
|
+
ref = Bible["Gen 1:1-10"]
|
|
133
|
+
assert(ref.book == :Genesis)
|
|
134
|
+
assert(ref.book.chapter == 1)
|
|
135
|
+
assert(ref.book.chapter.verses == (1..10))
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_genesis_verses_and_chapters
|
|
139
|
+
ref = Bible["Gen 1:1-2:2"]
|
|
140
|
+
assert(ref.book == :Genesis)
|
|
141
|
+
assert(ref.book.chapters == (1..2), "Chapters not as expected. Instead got #{ref.book.chapters.inspect}")
|
|
142
|
+
assert(ref.book.chapters[0] == 1)
|
|
143
|
+
assert(ref.book.chapters[0].verses == (1..31), "Verses not as expected: #{ref.book.chapters[0].verses.inspect}")
|
|
144
|
+
assert(ref.book.chapters[1] == 2)
|
|
145
|
+
assert(ref.book.chapters[1].verses == (1..2), "Verses not as expected: #{ref.book.chapters[1].verses.inspect}")
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_genesis_discontinuous_verses
|
|
149
|
+
ref = Bible["Gen 10:1, 3, 5"]
|
|
150
|
+
assert(ref.book == :Genesis)
|
|
151
|
+
assert(ref.book.chapter == 10)
|
|
152
|
+
assert(ref.book.chapter.verses == [1, 3, 5], "Verses not as expected: #{ref.book.chapter.verses.inspect}" )
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_genesis_discontinuous_verses_and_chapters
|
|
156
|
+
ref = Bible["Gen 1:1, 3:5"]
|
|
157
|
+
assert(ref.book == :Genesis)
|
|
158
|
+
assert(ref.book.chapters == [1, 3])
|
|
159
|
+
assert(ref.book.chapters[0] == 1)
|
|
160
|
+
assert(ref.book.chapters[0].verse == 1)
|
|
161
|
+
assert(ref.book.chapters[1] == 3)
|
|
162
|
+
assert(ref.book.chapters[1].verse == 5)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_genesis_discontinuous_verses_and_chapters_ranged
|
|
166
|
+
ref = Bible["Gen 1:1-10, 3:5,8"]
|
|
167
|
+
assert(ref.book == :Genesis)
|
|
168
|
+
assert(ref.book.chapters == [1, 3])
|
|
169
|
+
assert(ref.book.chapters[0] == 1)
|
|
170
|
+
assert(ref.book.chapters[0].verses == (1..10))
|
|
171
|
+
assert(ref.book.chapters[1] == 3)
|
|
172
|
+
assert(ref.book.chapters[1].verses == [5, 8])
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_two_books
|
|
176
|
+
ref = Bible["Gen 1:1, Lev 1:1"]
|
|
177
|
+
assert(ref.books == [:Genesis, :Leviticus])
|
|
178
|
+
assert(ref.books[0] == :Genesis)
|
|
179
|
+
assert(ref.books[0].chapter == 1)
|
|
180
|
+
assert(ref.books[0].chapter.verse == 1)
|
|
181
|
+
assert(ref.books[1] == :Leviticus)
|
|
182
|
+
assert(ref.books[1].chapter == 1)
|
|
183
|
+
assert(ref.books[1].chapter.verse == 1)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_two_books_with_multiple_verses
|
|
187
|
+
ref = Bible["Gen 1:1-5, Lev 1:10-12"]
|
|
188
|
+
assert(ref.books == [:Genesis, :Leviticus])
|
|
189
|
+
assert(ref.books[0] == :Genesis)
|
|
190
|
+
assert(ref.books[0].chapter == 1)
|
|
191
|
+
assert(ref.books[0].chapter.verses == (1..5))
|
|
192
|
+
assert(ref.books[1] == :Leviticus)
|
|
193
|
+
assert(ref.books[1].chapter == 1)
|
|
194
|
+
assert(ref.books[1].chapter.verses == (10..12))
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def test_multiple_books
|
|
198
|
+
["Gen 1 - Lev 1", "Gen 1-Lev 1", "Gen 1 -Lev 1"].each { |r|
|
|
199
|
+
ref = Bible[r]
|
|
200
|
+
assert(ref.books == [:Genesis, :Exodus, :Leviticus], "Books not returned as expected: #{ref.books.inspect}")
|
|
201
|
+
assert(ref.books[0] == :Genesis)
|
|
202
|
+
assert(ref.books[0].chapters == (1..50))
|
|
203
|
+
assert(ref.books[1] == :Exodus)
|
|
204
|
+
assert(ref.books[1].chapters == (1..40), "ref #{r} did not parse chapters: #{ref.books[1].chapters.inspect}")
|
|
205
|
+
assert(ref.books[2] == :Leviticus)
|
|
206
|
+
assert(ref.books[2].respond_to?(:chapter), "Chapters not as expected: #{ref.books[2].inspect}")
|
|
207
|
+
assert(ref.books[2].chapter == 1)
|
|
208
|
+
}
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def test_multiple_books_with_verses
|
|
212
|
+
ref = Bible["Gen 1:3-Lev 5:10"]
|
|
213
|
+
assert(ref.books == [:Genesis, :Exodus, :Leviticus])
|
|
214
|
+
assert(ref.books[0] == :Genesis)
|
|
215
|
+
assert(ref.books[0].chapters == (1..50))
|
|
216
|
+
assert(ref.books[0].chapters[0].verses == (3..31))
|
|
217
|
+
assert(ref.books[2] == :Leviticus)
|
|
218
|
+
assert(ref.books[2].chapters == (1..5), "Chapters not as expected: #{ref.books[1].chapters.inspect}" )
|
|
219
|
+
assert(ref.books[2].chapters[0].verses == (1..17), "Verses for chapter 1 not as expected: #{ref.books[2].chapters[0].inspect}")
|
|
220
|
+
assert(ref.books[2].chapters[1].verses == (1..16))
|
|
221
|
+
assert(ref.books[2].chapters[2].verses == (1..17))
|
|
222
|
+
assert(ref.books[2].chapters[3].verses == (1..35))
|
|
223
|
+
assert(ref.books[2].chapters[4].verses == (1..10))
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def test_multiple_books_funny
|
|
227
|
+
ref = Bible["Gen 1:3-Lev 1:10"]
|
|
228
|
+
assert(ref.books == [:Genesis, :Exodus, :Leviticus])
|
|
229
|
+
assert(ref.books[0] == :Genesis)
|
|
230
|
+
assert(ref.books[0].chapters == (1..50))
|
|
231
|
+
assert(ref.books[0].chapters[0].verses == (3..31))
|
|
232
|
+
assert(ref.books[2] == :Leviticus)
|
|
233
|
+
assert(ref.books[2].respond_to?(:chapter), "Chapter not foudn as expected: #{ref.books[2].inspect}")
|
|
234
|
+
assert(ref.books[2].chapter == 1)
|
|
235
|
+
assert(ref.books[2].chapter.verses == (1..10), "Verses not as expected: #{ref.books[2].chapter.verses.inspect}")
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_two_books
|
|
239
|
+
ref = Bible["Gen 3:1, Lev 12:1"]
|
|
240
|
+
assert(ref.books == [:Genesis, :Leviticus])
|
|
241
|
+
assert(ref.books[0].book == :Genesis)
|
|
242
|
+
assert(ref.books[0].book.chapter == 3)
|
|
243
|
+
assert(ref.books[0].book.chapter.verse == 1)
|
|
244
|
+
assert(ref.books[1].book == :Leviticus)
|
|
245
|
+
assert(ref.books[1].book.chapter == 12)
|
|
246
|
+
assert(ref.books[1].book.chapter.verse == 1)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def test_succ
|
|
250
|
+
b = Bible::Books[:Genesis]
|
|
251
|
+
assert(b.succ.book == :Exodus, "Book not as expected: #{b.succ.book}")
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def test_genesis_def
|
|
255
|
+
assert(Bible::Books[:Genesis].chapters == (1..50))
|
|
256
|
+
assert(Bible::Books[:Genesis][0].verses == (1..31))
|
|
257
|
+
assert(Bible::Books[:Genesis][1].verses == (1..25))
|
|
258
|
+
assert(Bible::Books[:Genesis][2].verses == (1..24))
|
|
259
|
+
assert(Bible::Books[:Genesis][3].verses == (1..26))
|
|
260
|
+
assert(Bible::Books[:Genesis][4].verses == (1..32))
|
|
261
|
+
assert(Bible::Books[:Genesis][5].verses == (1..22))
|
|
262
|
+
assert(Bible::Books[:Genesis][6].verses == (1..24))
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def test_1_john
|
|
266
|
+
ref = Bible["1 John 1:1"]
|
|
267
|
+
assert(ref.book == "1 John".to_sym, "ref.book not 1 John: #{ref.book}")
|
|
268
|
+
ref = Bible["1 John 1:1-10"]
|
|
269
|
+
assert(ref.book == "1 John".to_sym)
|
|
270
|
+
assert(ref.book.chapter.verses == (1..10))
|
|
271
|
+
ref = Bible["1 John 1 - 2"]
|
|
272
|
+
assert(ref.book == "1 John".to_sym)
|
|
273
|
+
assert(ref.book.chapters == (1..2))
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def test_1_john_multi_books
|
|
277
|
+
ref = Bible["1 John 1 - 2 John 1"]
|
|
278
|
+
assert(ref.books == ["1 John".to_sym, "2 John".to_sym])
|
|
279
|
+
ref = Bible["1 John 1, 2 John 1"]
|
|
280
|
+
assert(ref.books == ["1 John".to_sym, "2 John".to_sym])
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Unable to parse multiple verse-spanning references.
|
|
284
|
+
def test_multi_discontinuous_verse
|
|
285
|
+
ref = Bible["2 Sam 11:1-10, 13-17"]
|
|
286
|
+
assert(ref.book == "2 Samuel".to_sym);
|
|
287
|
+
assert(ref.book.chapter == 11);
|
|
288
|
+
assert(ref.book.chapter.verses == [(1..10), (13..17)], "Verses not as expected: #{ref.book.chapter.verses.inspect}");
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Unable to parse multiple verse-spanning references.
|
|
292
|
+
def test_multi_books
|
|
293
|
+
ref = Bible["1 Kgs - 2 Kgs"]
|
|
294
|
+
assert(ref.books == ["1 Kings".to_sym, "2 Kings".to_sym]);
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def test_alternate_format_multi
|
|
298
|
+
["James 2:14-24, 26, Mark 8:34-9:1", "James 2.14-24, 26; Mark 8.34-9.1"].each { |s|
|
|
299
|
+
ref = Bible[s]
|
|
300
|
+
assert(ref.books == [:James, :Mark], "books not as expected on #{s}: #{ref.books}")
|
|
301
|
+
assert(ref.books[0].chapter == 2, "chapters in james not as expected on #{s}: #{ref.books[0].chapter}")
|
|
302
|
+
assert(ref.books[0].chapter.verses == [14..24, 26], "verses in james not as expected on #{s}: #{ref.books[0].chapter.verses}")
|
|
303
|
+
}
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def test_period_after_book_name
|
|
307
|
+
ref = Bible["Gen. 1"]
|
|
308
|
+
assert(ref.book == :Genesis)
|
|
309
|
+
assert(ref.book.chapter == 1)
|
|
310
|
+
ref = Bible["Gen. 1.1-10"]
|
|
311
|
+
assert(ref.book == :Genesis)
|
|
312
|
+
assert(ref.book.chapter == 1)
|
|
313
|
+
assert(ref.book.chapter.verses == (1..10))
|
|
314
|
+
ref = Bible["1 Pt. 1.1-10"]
|
|
315
|
+
assert(ref.book == "1 Peter".to_sym)
|
|
316
|
+
ref = Bible["1 Pet. 1.1-10"]
|
|
317
|
+
assert(ref.book == "1 Peter".to_sym)
|
|
318
|
+
assert(ref.book.chapter == 1)
|
|
319
|
+
assert(ref.book.chapter.verses == (1..10))
|
|
320
|
+
ref = Bible["1 Peter 1.1-10"]
|
|
321
|
+
assert(ref.book == "1 Peter".to_sym)
|
|
322
|
+
assert(ref.book.chapter == 1)
|
|
323
|
+
assert(ref.book.chapter.verses == (1..10))
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def test_odd_range
|
|
327
|
+
# '20-14' should cause exception
|
|
328
|
+
assert_raises RuntimeError, "Did not get exception for bad verse reference" do
|
|
329
|
+
ref = Bible["Gen 1:1-2, 3, 20-14, 30"]
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
# Notice '20-4' which should be interpreted as 20 - 24
|
|
333
|
+
assert_nothing_raised "Exception should be caused by reference" do
|
|
334
|
+
ref = Bible["Gen 1:1-2, 3, 20-4, 30"]
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def test_sentence_references
|
|
339
|
+
ref = Bible["Acts 1:10a"]
|
|
340
|
+
assert(ref.book == :Acts, "Book is not Acts: #{ref.book}")
|
|
341
|
+
assert(ref.book.chapter == 1, "Chapter is not 1: #{ref.book.chapter}")
|
|
342
|
+
assert(ref.book.chapter.verse == 10, "Verse is not 10: #{ref.book.chapter.verse}")
|
|
343
|
+
ref = Bible["Acts 1:1a-10e"]
|
|
344
|
+
assert(ref.book == :Acts, "Book is not acts: #{ref.book}")
|
|
345
|
+
assert(ref.book.chapter == 1, "Chapter is not 1: #{ref.chapter}")
|
|
346
|
+
assert(ref.book.chapter.verses == (1 .. 10), "Verses are not 1 - 10: #{ref.book.chapter.verses}")
|
|
347
|
+
|
|
348
|
+
ref = Bible["Acts 1:2a-10:1"]
|
|
349
|
+
assert(ref.book == :Acts, "Book is not acts: #{ref.book}")
|
|
350
|
+
assert(ref.book.chapters == (1 .. 10), "Chapters are not 1 - 10: #{ref.book.chapters}")
|
|
351
|
+
assert(ref.book.chapters[0].verses == (2 .. 26), "Chapter 1 did not contain verses 2 - 26: #{ref.book.chapters[0].verses}")
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def test_open_ended_range
|
|
355
|
+
ref = Bible["Acts 1:2-"]
|
|
356
|
+
assert(ref.book == :Acts, "Book is not Acts: #{ref.book}")
|
|
357
|
+
assert(ref.chapter == 1, "Chapter is not 1: #{ref.chapter}")
|
|
358
|
+
assert_nothing_raised "Open ended range should not cause failure" do
|
|
359
|
+
assert(ref.chapter.verses)
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def test_accessors
|
|
364
|
+
# Test permutations of books, chapters, verses accessors on reference
|
|
365
|
+
|
|
366
|
+
# Single book,chapter and verse
|
|
367
|
+
ref = Bible["Acts 1:1"]
|
|
368
|
+
assert_nothing_raised("Single accessors failed") {
|
|
369
|
+
ref.book
|
|
370
|
+
ref.chapter
|
|
371
|
+
ref.verse
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
assert_raises(NoMethodError, "Multiple accessor should not be allowed") { ref.books }
|
|
375
|
+
assert_raises(NoMethodError, "Multiple accessor should not be allowed") { ref.book.chapters }
|
|
376
|
+
assert_raises(NoMethodError, "Multiple accessor should not be allowed") { ref.chapter.verses }
|
|
377
|
+
|
|
378
|
+
# Multiple verses, implicit
|
|
379
|
+
ref = Bible["Acts 1"]
|
|
380
|
+
assert_raises(NoMethodError, "Single verse access should not be allowed: #{ref.reference}") { ref.verse }
|
|
381
|
+
assert_raises(NoMethodError, "Multiple book access should not be allowed: #{ref.reference}") { ref.books }
|
|
382
|
+
assert_raises(NoMethodError, "Multiple chapter access should not be allowed: #{ref.reference}") { ref.book.chapters }
|
|
383
|
+
|
|
384
|
+
assert_nothing_raised("Expected accessors failed for ref: #{ref.reference}") do
|
|
385
|
+
ref.book
|
|
386
|
+
ref.chapter
|
|
387
|
+
ref.chapter.verses
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# Multiple verses, explicit
|
|
391
|
+
ref = Bible["Acts 1:1-10"]
|
|
392
|
+
assert_raises(NoMethodError, "Single verse access should not be allowed.") { ref.verse }
|
|
393
|
+
assert_raises(NoMethodError, "Multiple book access should not be allowed.") { ref.books }
|
|
394
|
+
assert_raises(NoMethodError, "Multiple chapter access should not be allowed.") { ref.book.chapters }
|
|
395
|
+
|
|
396
|
+
assert_nothing_raised("Expected accessors failed for ref: #{ref.reference}") do
|
|
397
|
+
ref.book
|
|
398
|
+
ref.chapter
|
|
399
|
+
ref.chapter.verses
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
# Multiple chapters, implicit
|
|
403
|
+
ref = Bible["Titus"]
|
|
404
|
+
assert_raises(NoMethodError, "Single chapter access should not be allowed.") { ref.chapter }
|
|
405
|
+
assert_raises(NoMethodError, "Single verse access should not be allowed.") { ref.verse }
|
|
406
|
+
assert_raises(NoMethodError, "Single chapter access should not be allowed.") { ref.book.chapter }
|
|
407
|
+
assert_raises(NoMethodError, "Multiple book access should not be allowed.") { ref.books }
|
|
408
|
+
|
|
409
|
+
assert_nothing_raised("Expected accessors failed: #{ref.reference}") do
|
|
410
|
+
ref.book
|
|
411
|
+
ref.book.chapters
|
|
412
|
+
ref.book.chapters[0].verses
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
# Multiple chapters, explicit
|
|
416
|
+
ref = Bible["Acts 1-2"]
|
|
417
|
+
assert_raises(NoMethodError, "Single chapter access should not be allowed.") { ref.chapter }
|
|
418
|
+
assert_raises(NoMethodError, "Single verse access should not be allowed.") { ref.verse }
|
|
419
|
+
assert_raises(NoMethodError, "Single chapter access should not be allowed.") { ref.book.chapter }
|
|
420
|
+
assert_raises(NoMethodError, "Multiple book access should not be allowed.") { ref.books }
|
|
421
|
+
|
|
422
|
+
assert_nothing_raised("Expected accessors failed: #{ref.reference}") do
|
|
423
|
+
ref.book
|
|
424
|
+
ref.book.chapters
|
|
425
|
+
ref.book.chapters[0].verses
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Multiple books
|
|
429
|
+
ref = Bible["Acts - Rom"]
|
|
430
|
+
assert_raises(NoMethodError, "Single chapter access should not be allowed.") { ref.chapter }
|
|
431
|
+
assert_raises(NoMethodError, "Single verse access should not be allowed.") { ref.verse }
|
|
432
|
+
assert_raises(NoMethodError, "Single book access should not be allowed: #{ref.reference}") { ref.book }
|
|
433
|
+
|
|
434
|
+
assert_nothing_raised("Expected accessors failed: #{ref.reference}") do
|
|
435
|
+
ref.books
|
|
436
|
+
ref.books[0].chapters
|
|
437
|
+
ref.books[0].chapters[0].verses
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
def test_philemon
|
|
443
|
+
# error
|
|
444
|
+
assert_nothing_raised "Unable to refence book of Philemon alone" do
|
|
445
|
+
ref = Bible["Phil"]
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
rubygems_version: 0.9.0
|
|
3
|
+
specification_version: 1
|
|
4
|
+
name: bible
|
|
5
|
+
version: !ruby/object:Gem::Version
|
|
6
|
+
version: 1.0.0
|
|
7
|
+
date: 2006-12-12 00:00:00 -08:00
|
|
8
|
+
summary: A library for parsing bible references and looking them up on the web.
|
|
9
|
+
require_paths:
|
|
10
|
+
- lib
|
|
11
|
+
email: jgbailey@gmail.com
|
|
12
|
+
homepage:
|
|
13
|
+
rubyforge_project:
|
|
14
|
+
description: This package implements a failry sophisticated Bible verse parser and iterator which will look up the given verse on the web. Three classes are provided for looking up different translations.
|
|
15
|
+
autorequire: bible
|
|
16
|
+
default_executable:
|
|
17
|
+
bindir: bin
|
|
18
|
+
has_rdoc: true
|
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">"
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.0.0
|
|
24
|
+
version:
|
|
25
|
+
platform: ruby
|
|
26
|
+
signing_key:
|
|
27
|
+
cert_chain:
|
|
28
|
+
post_install_message:
|
|
29
|
+
authors:
|
|
30
|
+
- Justin Bailey
|
|
31
|
+
files:
|
|
32
|
+
- lib/bible
|
|
33
|
+
- lib/bible.rb
|
|
34
|
+
- lib/bible/bible.yml
|
|
35
|
+
- lib/bible/iterator.rb
|
|
36
|
+
- lib/bible/lookup
|
|
37
|
+
- lib/bible/parser.rb
|
|
38
|
+
- lib/bible/lookup/dr.rb
|
|
39
|
+
- lib/bible/lookup/nab.rb
|
|
40
|
+
- lib/bible/lookup/rsv.rb
|
|
41
|
+
- test/test_bible.rb
|
|
42
|
+
- README.txt
|
|
43
|
+
- Rakefile
|
|
44
|
+
test_files: []
|
|
45
|
+
|
|
46
|
+
rdoc_options:
|
|
47
|
+
- --title
|
|
48
|
+
- Bible -- Verse Parser and Lookup Tool
|
|
49
|
+
- --main
|
|
50
|
+
- README.txt
|
|
51
|
+
- --line-numbers
|
|
52
|
+
extra_rdoc_files:
|
|
53
|
+
- README.txt
|
|
54
|
+
executables:
|
|
55
|
+
- bible.rb
|
|
56
|
+
extensions: []
|
|
57
|
+
|
|
58
|
+
requirements: []
|
|
59
|
+
|
|
60
|
+
dependencies:
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: highline
|
|
63
|
+
version_requirement:
|
|
64
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 1.2.1
|
|
69
|
+
version:
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: commandline
|
|
72
|
+
version_requirement:
|
|
73
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: 0.7.10
|
|
78
|
+
version:
|