scriptura 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scriptura/scripture.rb +4 -3
- data/lib/scriptura/scripture_book.rb +2 -2
- data/lib/scriptura/scripture_verse.rb +14 -7
- data/lib/scriptura/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0044ece919fa1f8adacbf9692fc1466bb5467d8
|
4
|
+
data.tar.gz: f96700adfc6c802c81bed1ba6fdf1e6b6c90a6cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 034c0937de8ffcf99bbe5a96d73533f540f74150d1e79fb997f23bd01373d80325847b49f5f57291cb7aa1f355b0ec60b3aedf83d0d05888e729b60cc884e126
|
7
|
+
data.tar.gz: 9c833b5ecad6d4ee8bbe1434c0598e907b7f24f1316e7e565252515b304e85333a57a7cf9eaaeb7f27b9826b231e7e70452629cd1827cf586fc4385875d7ec4b
|
data/lib/scriptura/scripture.rb
CHANGED
@@ -2,6 +2,9 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Scriptura
|
4
4
|
module Scripture
|
5
|
+
HOME_PATH = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
|
6
|
+
METADATA_FILE = File.join(HOME_PATH, 'lib', 'scriptura', 'metadata.yml')
|
7
|
+
|
5
8
|
def self.old_testament_books
|
6
9
|
books = []
|
7
10
|
(1..39).each do |book_number|
|
@@ -27,9 +30,7 @@ module Scriptura
|
|
27
30
|
end
|
28
31
|
|
29
32
|
def self.metadata
|
30
|
-
@metadata ||=
|
31
|
-
YAML.load_file('lib/scriptura/metadata.yml')
|
32
|
-
end
|
33
|
+
@metadata ||= YAML.load_file(METADATA_FILE)
|
33
34
|
end
|
34
35
|
|
35
36
|
def self.find_book_hash attribute, value
|
@@ -13,13 +13,13 @@ module Scriptura
|
|
13
13
|
|
14
14
|
def self.find_by_name(name)
|
15
15
|
hash = Scripture.find_book_hash(:name, name)
|
16
|
-
fail "Book by the name #{name} was not found! Check if there was a spelling error.. or try initializing it with a book number" if hash.nil?
|
16
|
+
fail DoesNotExist, "Book by the name #{name} was not found! Check if there was a spelling error.. or try initializing it with a book number" if hash.nil?
|
17
17
|
new(hash['number'])
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.find(string_id)
|
21
21
|
hash = Scripture.find_book_hash(:string_id, string_id)
|
22
|
-
fail "Book by the string_id #{string_id} was not found! Check if there was a spelling error.. or try initializing it with a book number" if hash.nil?
|
22
|
+
fail DoesNotExist, "Book by the string_id #{string_id} was not found! Check if there was a spelling error.. or try initializing it with a book number" if hash.nil?
|
23
23
|
new(hash['number'])
|
24
24
|
end
|
25
25
|
|
@@ -8,13 +8,8 @@ module Scriptura
|
|
8
8
|
alias_method :number, :verse_number
|
9
9
|
|
10
10
|
def initialize(*args)
|
11
|
-
|
12
|
-
|
13
|
-
fail ArgumentError, 'normalized value of scripture verse cannot be converted to an integer' unless args[0].respond_to?(:to_i)
|
14
|
-
book_number, chapter_number, verse_number = de_normalize(args[0])
|
15
|
-
when args.count == 3
|
16
|
-
book_number, chapter_number, verse_number = args
|
17
|
-
end
|
11
|
+
book_number, chapter_number, verse_number = extract_arguments(args)
|
12
|
+
|
18
13
|
@scripture_chapter = ScriptureChapter.new(book_number, chapter_number)
|
19
14
|
@scripture_book = @scripture_chapter.scripture_book
|
20
15
|
fail ArgumentError, 'verse number cannot be converted to an integer' unless verse_number.respond_to?(:to_i)
|
@@ -39,6 +34,18 @@ module Scriptura
|
|
39
34
|
|
40
35
|
private
|
41
36
|
|
37
|
+
def extract_arguments args
|
38
|
+
case args.count
|
39
|
+
when 1
|
40
|
+
fail ArgumentError, 'normalized value of scripture verse cannot be converted to an integer' unless args[0].respond_to?(:to_i)
|
41
|
+
book_number, chapter_number, verse_number = de_normalize(args[0].to_i)
|
42
|
+
when 3
|
43
|
+
book_number, chapter_number, verse_number = args
|
44
|
+
else
|
45
|
+
fail ArgumentError, 'wrong number of arguments! The arguments should either be one normalized value for the verse or 3 separate book, chapter, verse numbers'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
42
49
|
def de_normalize(number)
|
43
50
|
quotient, verse_number = number.divmod(1000)
|
44
51
|
book_number, chapter_number = quotient.divmod(1000)
|
data/lib/scriptura/version.rb
CHANGED