cskit-biblekjv 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/Gemfile +7 -4
- data/History.txt +7 -1
- data/Rakefile +6 -14
- data/cskit-biblekjv.gemspec +9 -11
- data/lib/cskit/bible/kjv.rb +38 -12
- data/lib/cskit/bible/kjv/splitter.rb +101 -0
- data/lib/cskit/bible/kjv/version.rb +9 -0
- data/lib/cskit/bible/kjv/volume.rb +57 -0
- metadata +20 -35
- data/lib/cskit-biblekjv.rb +0 -7
- data/lib/cskit-biblekjv/bible_splitter.rb +0 -91
- data/lib/cskit-biblekjv/version.rb +0 -5
- data/lib/cskit-biblekjv/volume.rb +0 -49
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ODFlMDVkNTcxYzViYmRmY2Q1YTU5ZjQ2ZDAyMDBhODNjNjg0OWQwNjQ4MWQx
|
10
|
-
OGU3YWZmNDlkZjdkNjdkMWRhZGNjM2NhYmFlYWVlNmJhM2U3MDRjN2ZmMzVm
|
11
|
-
M2JmYWNlMjk0M2ZjZDEzZjJkYzljNDM4MmE2OGFlNTE0ZGMxMzM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Yjg2YTJkZmE5YTczMTk5YWZlNDliNDE3NzRiMzdiYTE2MzA1ZGU5Y2ExM2Nm
|
14
|
-
OTdmMTg5NGE1N2NjNzAxOTBiNzM5MzliMWQxNTA4NWJhNDAyY2IzMWJlYmY1
|
15
|
-
MjUwNjgxZWM2NWY0Mjg1NjQzMGJjNjEwYWJjYjRmMzMxYThiZDI=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d57ec30684d441c976498a92ff53efbe7f3443eb
|
4
|
+
data.tar.gz: 9ef19012c522e30f867734b0730e38efe3e91c2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a7e0930fe5ee3247d9dc54bb8a4df0e8f339e13850c4bb5071d2cd36f654d42658ed849b0ac194a129f2bdd7fe578ff5cae58f5a49926288cada7732604edff3
|
7
|
+
data.tar.gz: 96d2b7411a2afc580c752eb20b62e7919dd2b394e4bd92f3acd7d0de3d87b89759dc1cd503edd9cd57159527a4c358d79a642da7eb995033e786896b8354b96d
|
data/Gemfile
CHANGED
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,35 +1,27 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
# Copyright 2012 Twitter, Inc
|
4
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
5
|
-
|
6
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
7
|
-
|
8
3
|
require 'bundler'
|
9
4
|
require 'digest'
|
10
5
|
|
11
6
|
require 'rubygems/package_task'
|
12
7
|
|
13
|
-
require '
|
8
|
+
require 'cskit/bible/kjv'
|
14
9
|
|
15
10
|
Bundler::GemHelper.install_tasks
|
16
11
|
|
17
12
|
task :update do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
input_file = File.join(File.dirname(__FILE__), "vendor/biblekjv.txt")
|
22
|
-
output_dir = File.join(File.dirname(__FILE__), "resources/bible/kjv")
|
23
|
-
splitter = CSKit::Splitters::BibleSplitter.new(input_file)
|
13
|
+
input_file = File.join(File.dirname(__FILE__), 'vendor', 'biblekjv.txt')
|
14
|
+
output_dir = CSKit::Bible::Kjv.resource_root
|
15
|
+
splitter = CSKit::Bible::Kjv::Splitter.new(input_file)
|
24
16
|
|
25
17
|
FileUtils.mkdir_p(output_dir)
|
26
18
|
|
27
19
|
splitter.each_chapter do |chapter, book|
|
28
|
-
book_name = book.name.downcase.gsub(
|
20
|
+
book_name = book.name.downcase.gsub(' ', '_')
|
29
21
|
book_output_dir = File.join(output_dir, book_name)
|
30
22
|
FileUtils.mkdir_p(book_output_dir)
|
31
23
|
|
32
|
-
File.open(File.join(book_output_dir, "#{chapter.number}.json"),
|
24
|
+
File.open(File.join(book_output_dir, "#{chapter.number}.json"), 'w+') do |f|
|
33
25
|
puts "Writing #{book.name}, chapter #{chapter.number} ..."
|
34
26
|
f.write(chapter.to_hash.to_json)
|
35
27
|
end
|
data/cskit-biblekjv.gemspec
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
4
|
-
require 'cskit
|
4
|
+
require 'cskit/bible/kjv/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = ::
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.homepage =
|
7
|
+
s.name = 'cskit-biblekjv'
|
8
|
+
s.version = ::CSKit::Bible::Kjv::VERSION
|
9
|
+
s.authors = ['Cameron Dutro']
|
10
|
+
s.email = ['camertron@gmail.com']
|
11
|
+
s.homepage = 'http://github.com/camertron'
|
12
12
|
|
13
|
-
s.description = s.summary =
|
13
|
+
s.description = s.summary = 'Bible resources for CSKit, King James Version.'
|
14
14
|
|
15
15
|
s.platform = Gem::Platform::RUBY
|
16
16
|
s.has_rdoc = true
|
17
17
|
|
18
18
|
s.add_dependency 'json'
|
19
|
-
s.add_dependency 'cskit', '~> 1.
|
20
|
-
|
21
|
-
s.add_development_dependency 'rake'
|
19
|
+
s.add_dependency 'cskit', '~> 1.1.0'
|
22
20
|
|
23
21
|
s.require_path = 'lib'
|
24
|
-
s.files = Dir[
|
22
|
+
s.files = Dir['{lib,spec,resources}/**/*', 'Gemfile', 'History.txt', 'LICENSE', 'README.md', 'Rakefile', 'cskit-biblekjv.gemspec']
|
25
23
|
end
|
data/lib/cskit/bible/kjv.rb
CHANGED
@@ -1,17 +1,43 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'cskit'
|
4
|
-
require '
|
5
|
-
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module CSKit
|
7
|
+
module Bible
|
8
|
+
module Kjv
|
9
|
+
autoload :Splitter, 'cskit/bible/kjv/splitter'
|
10
|
+
autoload :Volume, 'cskit/bible/kjv/volume'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def resource_dir
|
14
|
+
@resource_dir ||= resource_pathname.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource_root
|
18
|
+
@resource_root ||= resource_pathname.join('bible', 'kjv').to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def resource_pathname
|
24
|
+
@resource_dir ||= Pathname(__FILE__)
|
25
|
+
.dirname.dirname.dirname.dirname
|
26
|
+
.join('resources')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
6
32
|
|
7
33
|
CSKit.register_volume({
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
})
|
34
|
+
type: :bible,
|
35
|
+
id: :bible_kjv,
|
36
|
+
name: 'The Holy Bible, King James Version',
|
37
|
+
author: '',
|
38
|
+
language: 'English',
|
39
|
+
resource_path: CSKit::Bible::Kjv.resource_root,
|
40
|
+
volume: CSKit::Bible::Kjv::Volume,
|
41
|
+
parser: CSKit::Parsers::Bible::BibleParser,
|
42
|
+
reader: CSKit::Readers::BibleReader
|
43
|
+
})
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module CSKit
|
6
|
+
module Bible
|
7
|
+
module Kjv
|
8
|
+
|
9
|
+
# Splits the kjv bible text (from Project Gutenberg) in the vendor directory.
|
10
|
+
# Mainly designed to be used by the 'update' rake task.
|
11
|
+
class Splitter
|
12
|
+
|
13
|
+
VERSE_REGEX = /\d{1,3}:\d{1,3}/
|
14
|
+
BOOK_TRIGGERS = [
|
15
|
+
'Jonah',
|
16
|
+
'The Epistle of Paul the Apostle to the Hebrews',
|
17
|
+
'The Third Epistle General of John',
|
18
|
+
'The General Epistle of Jude',
|
19
|
+
'The Revelation of Saint John the Devine'
|
20
|
+
]
|
21
|
+
|
22
|
+
include Enumerable
|
23
|
+
attr_reader :input_file
|
24
|
+
|
25
|
+
def initialize(input_file)
|
26
|
+
@input_file = input_file
|
27
|
+
end
|
28
|
+
|
29
|
+
def each
|
30
|
+
verse_buffer = ''
|
31
|
+
chapter = CSKit::Volumes::Bible::Chapter.new(1, [])
|
32
|
+
book = CSKit::Volumes::Bible::Book.new(book_data.first['name'], [chapter])
|
33
|
+
book_count = 1
|
34
|
+
|
35
|
+
File.open(input_file).each_line do |line|
|
36
|
+
if line.strip.empty?
|
37
|
+
if verse_buffer =~ /\A#{VERSE_REGEX}/
|
38
|
+
split_verses(verse_buffer).each do |verse_data|
|
39
|
+
chapter_num, verse_num, text = verse_data
|
40
|
+
|
41
|
+
if chapter_num != chapter.number
|
42
|
+
yield chapter, book
|
43
|
+
new_chapter = CSKit::Volumes::Bible::Chapter.new(chapter_num, [])
|
44
|
+
end
|
45
|
+
|
46
|
+
if chapter_num > chapter.number
|
47
|
+
book.chapters << new_chapter
|
48
|
+
chapter = new_chapter
|
49
|
+
elsif chapter_num != chapter.number
|
50
|
+
book = CSKit::Volumes::Bible::Book.new(book_data[book_count]['name'], [new_chapter])
|
51
|
+
book_count += 1
|
52
|
+
chapter = new_chapter
|
53
|
+
end
|
54
|
+
|
55
|
+
chapter.verses << CSKit::Volumes::Bible::Verse.new(text.strip)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
verse_buffer.clear
|
60
|
+
elsif
|
61
|
+
# Jonah (and Hebrews) is special because Obadiah (the book before Jonah)
|
62
|
+
# only has one chapter and therefore breaks the assumption that all
|
63
|
+
# books have more than one chapter, which this script uses to avoid
|
64
|
+
# having to identify book headers. Yes, it's ugly.
|
65
|
+
if BOOK_TRIGGERS.include?(line.strip)
|
66
|
+
yield chapter, book
|
67
|
+
chapter = CSKit::Volumes::Bible::Chapter.new(1, [])
|
68
|
+
book = CSKit::Volumes::Bible::Book.new(book_data[book_count]['name'], [chapter])
|
69
|
+
book_count += 1
|
70
|
+
end
|
71
|
+
else
|
72
|
+
verse_buffer << "#{line.strip} "
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
yield chapter, book
|
77
|
+
end
|
78
|
+
|
79
|
+
alias_method :each_chapter, :each
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def book_data
|
84
|
+
@book_data ||= JSON.parse(
|
85
|
+
File.read(
|
86
|
+
File.join(CSKit::Bible::Kjv.resource_root, 'books.json')
|
87
|
+
)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
def split_verses(text)
|
92
|
+
verses = text.split(/(#{VERSE_REGEX})/)
|
93
|
+
verses[1..-1].each_slice(2).map do |verse_parts|
|
94
|
+
verse_parts.first.split(":").map(&:to_i) + [verse_parts.last]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module CSKit
|
6
|
+
module Bible
|
7
|
+
module Kjv
|
8
|
+
class Volume < CSKit::Volume
|
9
|
+
|
10
|
+
def get_book(book_name)
|
11
|
+
if File.directory?(book_resource_path(book_name))
|
12
|
+
glob_path = File.join(book_resource_path, '**')
|
13
|
+
|
14
|
+
chapters = Dir.glob(glob_path).map.with_index do |resource_file, index|
|
15
|
+
get_chapter(index + 1, book_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
CSKit::Volumes::Bible::Book.new(book_name, chapters)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_chapter(chapter_number, book_name)
|
23
|
+
resource_file = File.join(book_resource_path(book_name), "#{chapter_number}.json")
|
24
|
+
chapter_cache[resource_file] ||= CSKit::Volumes::Bible::Chapter.from_hash(
|
25
|
+
JSON.parse(File.read(resource_file))
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def unabbreviate_book_name(orig_book_name)
|
30
|
+
book_name = orig_book_name.strip.chomp('.') # remove trailing period
|
31
|
+
regex = /^#{book_name}\w*/i
|
32
|
+
|
33
|
+
found_book = books.find do |book|
|
34
|
+
book['name'] =~ regex
|
35
|
+
end
|
36
|
+
|
37
|
+
found_book ? found_book['name'] : orig_book_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def books
|
41
|
+
@books ||= JSON.parse(File.read(File.join(resource_path, 'books.json')))
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def book_resource_path(book_name)
|
47
|
+
File.join(resource_path, book_name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def chapter_cache
|
51
|
+
@chapter_cache ||= {}
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,57 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cskit-biblekjv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cskit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
40
|
+
version: 1.1.0
|
55
41
|
description: Bible resources for CSKit, King James Version.
|
56
42
|
email:
|
57
43
|
- camertron@gmail.com
|
@@ -59,11 +45,16 @@ executables: []
|
|
59
45
|
extensions: []
|
60
46
|
extra_rdoc_files: []
|
61
47
|
files:
|
48
|
+
- Gemfile
|
49
|
+
- History.txt
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- cskit-biblekjv.gemspec
|
62
54
|
- lib/cskit/bible/kjv.rb
|
63
|
-
- lib/cskit
|
64
|
-
- lib/cskit
|
65
|
-
- lib/cskit
|
66
|
-
- lib/cskit-biblekjv.rb
|
55
|
+
- lib/cskit/bible/kjv/splitter.rb
|
56
|
+
- lib/cskit/bible/kjv/version.rb
|
57
|
+
- lib/cskit/bible/kjv/volume.rb
|
67
58
|
- resources/bible/kjv/acts/1.json
|
68
59
|
- resources/bible/kjv/acts/10.json
|
69
60
|
- resources/bible/kjv/acts/11.json
|
@@ -1254,12 +1245,6 @@ files:
|
|
1254
1245
|
- resources/bible/kjv/zephaniah/1.json
|
1255
1246
|
- resources/bible/kjv/zephaniah/2.json
|
1256
1247
|
- resources/bible/kjv/zephaniah/3.json
|
1257
|
-
- Gemfile
|
1258
|
-
- History.txt
|
1259
|
-
- LICENSE
|
1260
|
-
- README.md
|
1261
|
-
- Rakefile
|
1262
|
-
- cskit-biblekjv.gemspec
|
1263
1248
|
homepage: http://github.com/camertron
|
1264
1249
|
licenses: []
|
1265
1250
|
metadata: {}
|
@@ -1269,17 +1254,17 @@ require_paths:
|
|
1269
1254
|
- lib
|
1270
1255
|
required_ruby_version: !ruby/object:Gem::Requirement
|
1271
1256
|
requirements:
|
1272
|
-
- -
|
1257
|
+
- - ">="
|
1273
1258
|
- !ruby/object:Gem::Version
|
1274
1259
|
version: '0'
|
1275
1260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1276
1261
|
requirements:
|
1277
|
-
- -
|
1262
|
+
- - ">="
|
1278
1263
|
- !ruby/object:Gem::Version
|
1279
1264
|
version: '0'
|
1280
1265
|
requirements: []
|
1281
1266
|
rubyforge_project:
|
1282
|
-
rubygems_version: 2.
|
1267
|
+
rubygems_version: 2.2.3
|
1283
1268
|
signing_key:
|
1284
1269
|
specification_version: 4
|
1285
1270
|
summary: Bible resources for CSKit, King James Version.
|
data/lib/cskit-biblekjv.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
include CSKit::Books
|
4
|
-
|
5
|
-
module CSKit
|
6
|
-
module Splitters
|
7
|
-
class BibleSplitter
|
8
|
-
|
9
|
-
VERSE_REGEX = /\d{1,3}:\d{1,3}/
|
10
|
-
BOOK_TRIGGERS = [
|
11
|
-
"Jonah",
|
12
|
-
"The Epistle of Paul the Apostle to the Hebrews",
|
13
|
-
"The Third Epistle General of John",
|
14
|
-
"The General Epistle of Jude",
|
15
|
-
"The Revelation of Saint John the Devine"
|
16
|
-
]
|
17
|
-
|
18
|
-
include Enumerable
|
19
|
-
attr_reader :input_file
|
20
|
-
|
21
|
-
def initialize(input_file)
|
22
|
-
@input_file = input_file
|
23
|
-
end
|
24
|
-
|
25
|
-
def each
|
26
|
-
verse_buffer = ""
|
27
|
-
chapter = Bible::Chapter.new(1, [])
|
28
|
-
book = Bible::Book.new(book_data.first["name"], [chapter])
|
29
|
-
book_count = 1
|
30
|
-
|
31
|
-
File.open(input_file).each_line do |line|
|
32
|
-
if line.strip.empty?
|
33
|
-
if verse_buffer =~ /\A#{VERSE_REGEX}/
|
34
|
-
split_verses(verse_buffer).each do |verse_data|
|
35
|
-
chapter_num, verse_num, text = verse_data
|
36
|
-
|
37
|
-
if chapter_num != chapter.number
|
38
|
-
yield chapter, book
|
39
|
-
new_chapter = Bible::Chapter.new(chapter_num, [])
|
40
|
-
end
|
41
|
-
|
42
|
-
if chapter_num > chapter.number
|
43
|
-
book.chapters << new_chapter
|
44
|
-
chapter = new_chapter
|
45
|
-
elsif chapter_num != chapter.number
|
46
|
-
book = Bible::Book.new(book_data[book_count]["name"], [new_chapter])
|
47
|
-
book_count += 1
|
48
|
-
chapter = new_chapter
|
49
|
-
end
|
50
|
-
|
51
|
-
chapter.verses << Bible::Verse.new(text.strip)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
verse_buffer.clear
|
56
|
-
elsif
|
57
|
-
# Jonah (and Hebrews) is special because Obadiah (the book before Jonah) only has one chapter
|
58
|
-
# and therefore breaks the assumption that all books have more than one chapter, which this
|
59
|
-
# script uses to avoid having to identify book headers. Yes, it's ugly.
|
60
|
-
if BOOK_TRIGGERS.include?(line.strip)
|
61
|
-
yield chapter, book
|
62
|
-
chapter = Bible::Chapter.new(1, [])
|
63
|
-
book = Bible::Book.new(book_data[book_count]["name"], [chapter])
|
64
|
-
book_count += 1
|
65
|
-
end
|
66
|
-
else
|
67
|
-
verse_buffer << "#{line.strip} "
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
yield chapter, book
|
72
|
-
end
|
73
|
-
|
74
|
-
alias :each_chapter :each
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def book_data
|
79
|
-
@book_data ||= JSON.parse(File.read(File.join(CSKitBibleKJV.resource_dir, "bible", "kjv", "books.json")))
|
80
|
-
end
|
81
|
-
|
82
|
-
def split_verses(text)
|
83
|
-
verses = text.split(/(#{VERSE_REGEX})/)
|
84
|
-
verses[1..-1].each_slice(2).map do |verse_parts|
|
85
|
-
verse_parts.first.split(":").map(&:to_i) + [verse_parts.last]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module CSKitBibleKJV
|
6
|
-
class Volume < CSKit::Volume
|
7
|
-
|
8
|
-
def get_book(book_name)
|
9
|
-
if File.directory?(book_resource_path(book_name))
|
10
|
-
CSKit::Volumes::Bible::Book.new(book_name, Dir.glob(File.join(book_resource_path, "**")).map.with_index do |resource_file, index|
|
11
|
-
get_chapter(index + 1, book_name)
|
12
|
-
end)
|
13
|
-
else
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_chapter(chapter_number, book_name)
|
19
|
-
resource_file = File.join(book_resource_path(book_name), "#{chapter_number}.json")
|
20
|
-
chapter_cache[resource_file] ||= CSKit::Volumes::Bible::Chapter.from_hash(JSON.parse(File.read(resource_file)))
|
21
|
-
end
|
22
|
-
|
23
|
-
def unabbreviate_book_name(orig_book_name)
|
24
|
-
book_name = orig_book_name.strip.chomp(".") # remove trailing period
|
25
|
-
regex = /^#{book_name}\w*/i
|
26
|
-
|
27
|
-
found_book = books.find do |book|
|
28
|
-
book["name"] =~ regex
|
29
|
-
end
|
30
|
-
|
31
|
-
found_book ? found_book["name"] : orig_book_name
|
32
|
-
end
|
33
|
-
|
34
|
-
def books
|
35
|
-
@books ||= JSON.parse(File.read(File.join(resource_path, "books.json")))
|
36
|
-
end
|
37
|
-
|
38
|
-
protected
|
39
|
-
|
40
|
-
def book_resource_path(book_name)
|
41
|
-
File.join(resource_path, book_name)
|
42
|
-
end
|
43
|
-
|
44
|
-
def chapter_cache
|
45
|
-
@chapter_cache ||= {}
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|