bible_ref 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7620ceecdf8eb2efd2f77531477b879276732c3
4
- data.tar.gz: e1f60d7af94a285df7f58dfb25eb408ddcfb1ab1
3
+ metadata.gz: 694d21174ea7792cbd836f0cee4a3dedf63af0bc
4
+ data.tar.gz: 4d46099efa929b7623add504ca322ff63eb0b9ad
5
5
  SHA512:
6
- metadata.gz: 12ffede23ce5079666e1740fde4706ad43d67a5e776e700991a4d5ab423985c52e4953ffd4bf6cee578074736ce2a5ea30188d6ee0c94cc24580c72aa0b3be87
7
- data.tar.gz: 96413110c682fccff792273c0e9fec29c8966ccf7b6d375e5cd348d1ac8524234dc8948fdce96d2685e27ab8f9a67efe8e5b8cb9b93b839ca001ff1fe2d1b60f
6
+ metadata.gz: 39b71a97e6bf202687a272c4c86a6310b9a55e8ffe2306f2af99b9a57574a27ba8d11b448e30568abf383fa4fc55cc521664b2b1a93d703f2c6beda4765c1d76
7
+ data.tar.gz: 11aee5b5db6cf40ec51d5796322a87996e35bf6ba9db53ffcc4aa2f649472709f92c3c794cffe5565c632a0002f359971b07166308a87f4b1ca8632bacee8377
data/README.md CHANGED
@@ -24,6 +24,10 @@ Turn "John 3:16" into:
24
24
  ]
25
25
  ```
26
26
 
27
+ (We return from/to pairs for every range so to make querying a SQL database easy peasy.)
28
+
29
+ See [the specs](https://github.com/seven1m/bible_ref/blob/master/spec/bible_ref/reference_spec.rb) for more examples.
30
+
27
31
  ## Copyright
28
32
 
29
33
  Copyright [Tim Morgan](http://timmorgan.org). See LICENSE.
@@ -190,13 +190,13 @@ module BibleRef
190
190
  unless CANONS[@canon]
191
191
  raise UnknownCanon.new("#{canon} is not known. Canons this library support are: #{CANONS.join(', ')}")
192
192
  end
193
- @book = book
193
+ @book = replace_roman_numerals(book).downcase
194
194
  end
195
195
 
196
196
  def id
197
197
  CANONS[@canon].each do |book|
198
198
  match = BOOKS[book]
199
- return book if @book.downcase =~ match
199
+ return book if @book =~ match
200
200
  end
201
201
  nil
202
202
  end
@@ -205,5 +205,14 @@ module BibleRef
205
205
  FORMATTED_BOOKS[id]
206
206
  end
207
207
 
208
+ private
209
+
210
+ def replace_roman_numerals(book)
211
+ book.sub!(/^iii/i, '3')
212
+ book.sub!(/^ii/i, '2')
213
+ book.sub!(/^i/i, '1')
214
+ book
215
+ end
216
+
208
217
  end
209
218
  end
@@ -41,6 +41,7 @@ module BibleRef
41
41
  #
42
42
  # 'JOHN 3:16&17' => 'John 3:16,17'
43
43
  def normalize
44
+ return unless book and ranges
44
45
  book.formatted + ' ' +
45
46
  ranges.map do |(ref_from, ref_to)|
46
47
  if ref_from != ref_to
@@ -1,3 +1,3 @@
1
1
  module BibleRef
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bible_ref
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan