bible_passage 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1cbd230d3cc2306f39c573a30f07b236fad30fd4
4
+ data.tar.gz: 298afa89ebb98e3d873c672b28e8201180e88ab4
5
+ SHA512:
6
+ metadata.gz: 8ae6572fe238240cb1d691bef1591130aa88d0acb7885435929a72a6d83e020ffe0f1f6f1e81662757271f32483e1d6b7881fe1d6143490bf5d824f13886962d
7
+ data.tar.gz: dd9c7610bfe80d771ae4a2296ed0715836e6e651a7ce28ff48d1e61b635b7d3facdf4ae4e78b828d1f91397619dee5395e2a28c4c2f1db4d1766743b984e8077
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bible-passage (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ celluloid (0.15.2)
10
+ timers (~> 1.1.0)
11
+ coderay (1.1.0)
12
+ diff-lcs (1.2.5)
13
+ ffi (1.9.3)
14
+ formatador (0.2.5)
15
+ fuubar (1.3.3)
16
+ rspec (>= 2.14.0, < 3.1.0)
17
+ ruby-progressbar (~> 1.4)
18
+ guard (2.6.1)
19
+ formatador (>= 0.2.4)
20
+ listen (~> 2.7)
21
+ lumberjack (~> 1.0)
22
+ pry (>= 0.9.12)
23
+ thor (>= 0.18.1)
24
+ guard-rspec (4.2.10)
25
+ guard (~> 2.1)
26
+ rspec (>= 2.14, < 4.0)
27
+ listen (2.7.9)
28
+ celluloid (>= 0.15.2)
29
+ rb-fsevent (>= 0.9.3)
30
+ rb-inotify (>= 0.9)
31
+ lumberjack (1.0.9)
32
+ method_source (0.8.2)
33
+ pry (0.10.0)
34
+ coderay (~> 1.1.0)
35
+ method_source (~> 0.8.1)
36
+ slop (~> 3.4)
37
+ rb-fsevent (0.9.4)
38
+ rb-inotify (0.9.5)
39
+ ffi (>= 0.5.0)
40
+ rspec (3.0.0)
41
+ rspec-core (~> 3.0.0)
42
+ rspec-expectations (~> 3.0.0)
43
+ rspec-mocks (~> 3.0.0)
44
+ rspec-core (3.0.2)
45
+ rspec-support (~> 3.0.0)
46
+ rspec-expectations (3.0.2)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.0.0)
49
+ rspec-mocks (3.0.2)
50
+ rspec-support (~> 3.0.0)
51
+ rspec-support (3.0.2)
52
+ ruby-progressbar (1.5.1)
53
+ slop (3.5.0)
54
+ thor (0.19.1)
55
+ timers (1.1.0)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ bible-passage!
62
+ fuubar (~> 1.3)
63
+ guard (~> 2.6)
64
+ guard-rspec (~> 4.2)
65
+ rspec (~> 3.0)
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+ guard :rspec do
4
+ watch(%r{^spec/.+_spec\.rb$})
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch('spec/spec_helper.rb') { "spec" }
7
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Simon Matthew Wilkins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ bible_passage
2
+ =============
3
+
4
+ A simple library for parsing and rendering bible passages.
5
+
6
+
7
+ # Usage
8
+
9
+ The most common usage of bible_passage will be to parse a reference string, which will return a new <code>BiblePassage::Reference</code> object
10
+
11
+ ref = BiblePassage::Reference.parse "gen 1:2-3"
12
+
13
+ This <code>BiblePassage::Reference</code> object can be output as a string
14
+
15
+ > ref.to_s
16
+ => "Genesis 1:2-3"
17
+
18
+ bible_passage can handle common book name abbreviations, and will also simplify references where appropriate, eg.
19
+
20
+ > BiblePassage::Reference.parse("Genesis 1:1-50:26").to_s
21
+ => "Genesis"
22
+
23
+ It will check the validity of references and throw a <code>BiblePassage::InvalidReferenceError</code> if a reference is not valid
24
+
25
+ > BiblePassage::Reference.parse("mt 3-1")
26
+ BiblePassage::InvalidReferenceError: to_chapter cannot be before from_chapter
27
+
28
+ > BiblePassage::Reference.parse("Exudos")
29
+ BiblePassage::InvalidReferenceError: Exudos is not a valid book
30
+
31
+ > BiblePassage::Reference.parse("Ex 41")
32
+ BiblePassage::InvalidReferenceError: Exodus doesn't have a chapter 41
33
+
34
+ # License
35
+ bible_passage is distributed under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'bible_passage'
3
+ s.summary = 'A simple library for parsing and rendering bible passages'
4
+ s.version = '0.0.1'
5
+ s.authors = ["Si Wilkins"]
6
+ s.email = 'si.wilkins@gmail.com'
7
+ s.homepage = 'https://github.com/siwilkins/bible_passage'
8
+ readmes = Dir['*'].reject{ |x| x = ~ /(^|[^.a-z])[a-z]+/ || x == "TODO" || x =~ /\.gem$/ }
9
+ s.files = Dir['lib/**/*', 'spec/**/*'] + readmes
10
+ s.has_rdoc = false
11
+ s.test_files = Dir["test/**/*_test.rb"]
12
+ s.license = "MIT"
13
+ s.description = <<-END
14
+ bible_passage provides a facility for parsing a string to check its validity
15
+ as a Bible reference, and then render it in a consistent manner.
16
+ END
17
+ s.add_development_dependency 'rspec', '~> 3.0'
18
+ s.add_development_dependency 'guard', '~> 2.6'
19
+ s.add_development_dependency 'guard-rspec', '~> 4.2'
20
+ s.add_development_dependency 'fuubar', '~> 1.3'
21
+ end
@@ -0,0 +1,291 @@
1
+ module BiblePassage
2
+
3
+ class BookDataStore
4
+
5
+ BOOK_DATA = {
6
+ gen: {
7
+ name: 'Genesis',
8
+ 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, 54, 33, 20, 31, 29, 43, 36, 30, 23, 23, 57, 38, 34, 34, 28, 34, 31, 22, 33, 26],
9
+ },
10
+ exod: {
11
+ name: 'Exodus',
12
+ chapters: [22, 25, 22, 31, 23, 30, 29, 28, 35, 29, 10, 51, 22, 31, 27, 36, 16, 27, 25, 26, 37, 30, 33, 18, 40, 37, 21, 43, 46, 38, 18, 35, 23, 35, 35, 38, 29, 31, 43, 38]
13
+ },
14
+ lev: {
15
+ name: 'Leviticus',
16
+ chapters: [17, 16, 17, 35, 26, 23, 38, 36, 24, 20, 47, 8, 59, 57, 33, 34, 16, 30, 37, 27, 24, 33, 44, 23, 55, 46, 34]
17
+ },
18
+ num: {
19
+ name: 'Numbers',
20
+ chapters: [54, 34, 51, 49, 31, 27, 89, 26, 23, 36, 35, 16, 33, 45, 41, 35, 28, 32, 22, 29, 35, 41, 30, 25, 19, 65, 23, 31, 39, 17, 54, 42, 56, 29, 34, 13],
21
+ },
22
+ deut: {
23
+ name: 'Deuteronomy',
24
+ chapters: [46, 37, 29, 49, 33, 25, 26, 20, 29, 22, 32, 31, 19, 29, 23, 22, 20, 22, 21, 20, 23, 29, 26, 22, 19, 19, 26, 69, 28, 20, 30, 52, 29, 12]
25
+ },
26
+ josh: {
27
+ name: 'Joshua',
28
+ 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]
29
+ },
30
+ judg: {
31
+ name: 'Judges',
32
+ chapters: [36, 23, 31, 24, 31, 40, 25, 35, 57, 18, 40, 15, 25, 20, 20, 31, 13, 31, 30, 48, 25]
33
+ },
34
+ ruth: {
35
+ name: 'Ruth',
36
+ chapters: [22, 23, 18, 22]
37
+ },
38
+ '1sam'.to_sym => {
39
+ name: '1 Samuel',
40
+ chapters: [28, 36, 21, 22, 12, 21, 17, 22, 27, 27, 15, 25, 23, 52, 35, 23, 58, 30, 24, 42, 16, 23, 28, 23, 43, 25, 12, 25, 11, 31, 13]
41
+ },
42
+ '2sam'.to_sym => {
43
+ name: '2 Samuel',
44
+ chapters: [27, 32, 39, 12, 25, 23, 29, 18, 13, 19, 27, 31, 39, 33, 37, 23, 29, 32, 44, 26, 22, 51, 39, 25]
45
+ },
46
+ '1kings'.to_sym => {
47
+ name: '1 Kings',
48
+ chapters: [53, 46, 28, 20, 32, 38, 51, 66, 28, 29, 43, 33, 34, 31, 34, 34, 24, 46, 21, 43, 29, 54]
49
+ },
50
+ '2kings'.to_sym => {
51
+ name: '2 Kings',
52
+ chapters: [18, 25, 27, 44, 27, 33, 20, 29, 37, 36, 20, 22, 25, 29, 38, 20, 41, 37, 37, 21, 26, 20, 37, 20, 30]
53
+ },
54
+ '1chr'.to_sym => {
55
+ name: '1 Chronicles',
56
+ chapters: [54, 55, 24, 43, 41, 66, 40, 40, 44, 14, 47, 41, 14, 17, 29, 43, 27, 17, 19, 8, 30, 19, 32, 31, 31, 32, 34, 21, 30]
57
+ },
58
+ '2chr'.to_sym => {
59
+ name: '2 Chronicles',
60
+ chapters: [18, 17, 17, 22, 14, 42, 22, 18, 31, 19, 23, 16, 23, 14, 19, 14, 19, 34, 11, 37, 20, 12, 21, 27, 28, 23, 9, 27, 36, 27, 21, 33, 25, 33, 26, 23]
61
+ },
62
+ ezra: {
63
+ name: 'Ezra',
64
+ chapters: [11, 70, 13, 24, 17, 22, 28, 36, 15, 44]
65
+ },
66
+ neh: {
67
+ name: 'Nehemiah',
68
+ chapters: [11, 20, 38, 17, 19, 19, 72, 18, 37, 40, 36, 47, 31]
69
+ },
70
+ esth: {
71
+ name: 'Esther',
72
+ chapters: [22, 23, 15, 17, 14, 14, 10, 17, 32, 3]
73
+ },
74
+ job: {
75
+ name: 'Job',
76
+ 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, 21, 28, 25, 31, 40, 22, 33, 37, 16, 33, 24, 41, 30, 32, 26, 17]
77
+ },
78
+ ps: {
79
+ name: 'Psalms',
80
+ chapters: [6, 11, 9, 9, 13, 11, 18, 10, 21, 18, 7, 9, 6, 7, 5, 11, 15, 51, 15, 10, 14, 32, 6, 10, 22, 11, 14, 9, 11, 13, 25, 11, 22, 23, 28, 13, 40, 23, 14, 18, 14, 12, 5, 27, 18, 12, 10, 15, 21, 23, 21, 11, 7, 9, 24, 14, 12, 12, 18, 14, 9, 13, 12, 11, 14, 20, 8, 36, 37, 6, 24, 20, 28, 23, 11, 13, 21, 72, 13, 20, 17, 8, 19, 13, 14, 17, 7, 19, 53, 17, 16, 16, 5, 23, 11, 13, 12, 9, 9, 5, 8, 29, 22, 35, 45, 48, 43, 14, 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, 14, 10, 8, 12, 15, 21, 10, 20, 14, 9, 6]
81
+ },
82
+ prov: {
83
+ name: 'Proverbs',
84
+ 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]
85
+ },
86
+ eccl: {
87
+ name: 'Ecclesiastes',
88
+ chapters: [18, 26, 22, 17, 19, 12, 29, 17, 18, 20, 10, 14]
89
+ },
90
+ song: {
91
+ name: 'Song of Songs',
92
+ chapters: [17, 17, 11, 16, 16, 12, 14, 14]
93
+ },
94
+ isa: {
95
+ name: 'Isaiah',
96
+ chapters: [31, 22, 26, 6, 30, 13, 25, 23, 20, 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, 11, 25, 24]
97
+ },
98
+ jer: {
99
+ name: 'Jeremiah',
100
+ chapters: [19, 37, 25, 31, 31, 30, 34, 23, 25, 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]
101
+ },
102
+ lam: {
103
+ name: 'Lamentations',
104
+ chapters: [22, 22, 66, 22, 22]
105
+ },
106
+ ezek: {
107
+ name: 'Ezekiel',
108
+ chapters: [28, 10, 27, 17, 17, 14, 27, 18, 11, 22, 25, 28, 23, 23, 8, 63, 24, 32, 14, 44, 37, 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]
109
+ },
110
+ dan: {
111
+ name: 'Daniel',
112
+ chapters: [21, 49, 30, 37, 31, 28, 28, 27, 27, 21, 45, 13]
113
+ },
114
+ hos: {
115
+ name: 'Hosea',
116
+ chapters: [9, 25, 5, 19, 15, 11, 16, 14, 17, 15, 11, 15, 15, 10, ]
117
+ },
118
+ joel: {
119
+ name: 'Joel',
120
+ chapters: [20, 32, 21]
121
+ },
122
+ amos: {
123
+ name: 'Amos',
124
+ chapters: [15, 16, 15, 13, 27, 14, 17, 14, 15]
125
+ },
126
+ obad: {
127
+ name: 'Obadiah',
128
+ chapters: [21]
129
+ },
130
+ jonah: {
131
+ name: 'Jonah',
132
+ chapters: [16, 11, 10, 11]
133
+ },
134
+ mic: {
135
+ name: 'Micah',
136
+ chapters: [16, 13, 12, 14, 14, 16, 20]
137
+ },
138
+ nah: {
139
+ name: 'Nahum',
140
+ chapters: [14, 14, 19]
141
+ },
142
+ hab: {
143
+ name: 'Habakkuk',
144
+ chapters: [17, 20, 19]
145
+ },
146
+ zeph: {
147
+ name: 'Zephaniah',
148
+ chapters: [8, 15, 20]
149
+ },
150
+ hag: {
151
+ name: 'Haggai',
152
+ chapters: [15, 23]
153
+ },
154
+ zech: {
155
+ name: 'Zechariah',
156
+ chapters: [17, 17, 10, 14, 11, 15, 14, 23, 17, 12, 17, 14, 9, 21]
157
+ },
158
+ mal: {
159
+ name: 'Malachi',
160
+ chapters: [14, 17, 24, 6]
161
+ },
162
+ matt: {
163
+ name: 'Matthew',
164
+ 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]
165
+ },
166
+ mark: {
167
+ name: 'Mark',
168
+ chapters: [45, 28, 35, 41, 43, 56, 37, 38, 50, 52, 33, 44, 37, 72, 47, 20]
169
+ },
170
+ luke: {
171
+ name: 'Luke',
172
+ 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]
173
+ },
174
+ john: {
175
+ name: 'John',
176
+ chapters: [51, 25, 36, 54, 47, 71, 53, 59, 41, 42, 57, 50, 38, 31, 27, 33, 26, 40, 42, 31, 25]
177
+ },
178
+ acts: {
179
+ name: 'Acts',
180
+ chapters: [26, 47, 26, 37, 42, 15, 60, 40, 43, 48, 30, 25, 52, 28, 41, 40, 34, 28, 40, 38, 40, 30, 35, 27, 27, 32, 44, 31]
181
+ },
182
+ rom: {
183
+ name: 'Romans',
184
+ chapters: [32, 29, 31, 25, 21, 23, 25, 39, 33, 21, 36, 21, 14, 23, 33, 27]
185
+ },
186
+ '1cor'.to_sym => {
187
+ name: '1 Corinthians',
188
+ chapters: [31, 16, 23, 21, 13, 20, 40, 13, 27, 33, 34, 31, 13, 40, 58, 24]
189
+ },
190
+ '2cor'.to_sym => {
191
+ name: '2 Corinthians',
192
+ chapters: [24, 17, 18, 18, 21, 18, 16, 24, 15, 18, 33, 21, 13]
193
+ },
194
+ gal: {
195
+ name: 'Galatians',
196
+ chapters: [24, 21, 29, 31, 26, 18]
197
+ },
198
+ eph: {
199
+ name: 'Ephesians',
200
+ chapters: [23, 22, 21, 32, 33, 24]
201
+ },
202
+ phil: {
203
+ name: 'Philippians',
204
+ chapters: [30, 30, 21, 23]
205
+ },
206
+ col: {
207
+ name: 'Colossians',
208
+ chapters: [29, 23, 25, 18]
209
+ },
210
+ '1thess'.to_sym => {
211
+ name: '1 Thessalonians',
212
+ chapters: [10, 20, 13, 18, 28]
213
+ },
214
+ '2thess'.to_sym => {
215
+ name: '2 Thessalonians',
216
+ chapters: [12, 17, 18]
217
+ },
218
+ '1tim'.to_sym => {
219
+ name: '1 Timothy',
220
+ chapters: [20, 15, 16, 16, 25, 21]
221
+ },
222
+ '2tim'.to_sym => {
223
+ name: '2 Timothy',
224
+ chapters: [18, 26, 17, 22]
225
+ },
226
+ titus: {
227
+ name: 'Titus',
228
+ chapters: [16, 15, 15, ]
229
+ },
230
+ phlm: {
231
+ name: 'Philemon',
232
+ chapters: [25]
233
+ },
234
+ heb: {
235
+ name: 'Hebrews',
236
+ chapters: [14, 18, 19, 16, 14, 20, 28, 13, 28, 39, 40, 29, 25]
237
+ },
238
+ jas: {
239
+ name: 'James',
240
+ chapters: [27, 26, 18, 17, 20]
241
+ },
242
+ '1pet'.to_sym => {
243
+ name: '1 Peter',
244
+ chapters: [25, 25, 22, 19, 14]
245
+ },
246
+ '2pet'.to_sym => {
247
+ name: '2 Peter',
248
+ chapters: [21, 22, 18, ]
249
+ },
250
+ '1john'.to_sym => {
251
+ name: '1 John',
252
+ chapters: [10, 29, 24, 21, 21]
253
+ },
254
+ '2john'.to_sym => {
255
+ name: '2 John',
256
+ chapters: [13]
257
+ },
258
+ '3john'.to_sym => {
259
+ name: '3 John',
260
+ chapters: [15]
261
+ },
262
+ jude: {
263
+ name: 'Jude',
264
+ chapters: [25]
265
+ },
266
+ rev: {
267
+ name: 'Revelation',
268
+ chapters: [20, 29, 22, 11, 14, 17, 17, 13, 21, 11, 19, 17, 18, 20, 8, 21, 18, 24, 21, 15, 27, 21]
269
+ }
270
+ }
271
+
272
+ def book_name(key)
273
+ book = BOOK_DATA[key]
274
+ if book
275
+ book[:name]
276
+ else
277
+ raise(InvalidReferenceError.new("#{key} is not a valid book key"))
278
+ end
279
+ end
280
+
281
+ def number_of_chapters(key)
282
+ BOOK_DATA[key][:chapters].size
283
+ end
284
+
285
+ def number_of_verses(key, chapter)
286
+ BOOK_DATA[key][:chapters][chapter - 1]
287
+ end
288
+
289
+ end
290
+
291
+ end