bomdb 0.6.2 → 0.7.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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +12 -9
- data/lib/bomdb/cli/application.rb +41 -0
- data/lib/bomdb/export/books.rb +11 -1
- data/lib/bomdb/export/editions.rb +11 -1
- data/lib/bomdb/export/verses.rb +17 -5
- data/lib/bomdb/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1a4d5ae9da1a8649dc3ae897f37f0209730d128
|
4
|
+
data.tar.gz: e786dc5099a6e3a9fb8159a6c27e96095e11db78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1477bb98a8b954db1498b0f417f2e7faddf4dc27ddb7204c2945c530cd85b93b1c7ad4f07e5561718260b596d5191431d05eedfdbf0e5ff705c8cb6c9b113f02
|
7
|
+
data.tar.gz: c64bf3590944bf3eaf7d1371ac7bb2ba4da53bd3b9d1afe3eaf8696c5f1c41315ae2ea0bea01f5464faafa7fba818ab6bbafc4939eb3fff68050b48dd3887eed
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bomdb (0.
|
4
|
+
bomdb (0.7.0)
|
5
5
|
colorize (~> 0.7)
|
6
6
|
constellation (~> 0.1)
|
7
7
|
levenshtein-ffi (~> 1.1)
|
@@ -14,7 +14,7 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
activesupport (4.2.
|
17
|
+
activesupport (4.2.6)
|
18
18
|
i18n (~> 0.7)
|
19
19
|
json (~> 1.7, >= 1.7.7)
|
20
20
|
minitest (~> 5.1)
|
@@ -22,20 +22,20 @@ GEM
|
|
22
22
|
tzinfo (~> 1.1)
|
23
23
|
byebug (4.0.5)
|
24
24
|
columnize (= 0.9.0)
|
25
|
-
colorize (0.7.
|
25
|
+
colorize (0.7.7)
|
26
26
|
columnize (0.9.0)
|
27
27
|
constellation (0.1.1)
|
28
28
|
multi_json
|
29
29
|
diff-lcs (1.2.5)
|
30
|
-
ffi (1.9.
|
30
|
+
ffi (1.9.10)
|
31
31
|
i18n (0.7.0)
|
32
|
-
json (1.8.
|
32
|
+
json (1.8.3)
|
33
33
|
levenshtein-ffi (1.1.0)
|
34
34
|
ffi (~> 1.9)
|
35
35
|
mericope (0.1.1)
|
36
36
|
activesupport (~> 4.0)
|
37
|
-
minitest (5.
|
38
|
-
multi_json (1.
|
37
|
+
minitest (5.9.0)
|
38
|
+
multi_json (1.12.1)
|
39
39
|
rake (10.4.2)
|
40
40
|
rspec (3.2.0)
|
41
41
|
rspec-core (~> 3.2.0)
|
@@ -50,8 +50,8 @@ GEM
|
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
51
|
rspec-support (~> 3.2.0)
|
52
52
|
rspec-support (3.2.2)
|
53
|
-
sequel (4.
|
54
|
-
sqlite3 (1.3.
|
53
|
+
sequel (4.35.0)
|
54
|
+
sqlite3 (1.3.11)
|
55
55
|
text_clean (0.2.2)
|
56
56
|
thor (0.19.1)
|
57
57
|
thread_safe (0.3.5)
|
@@ -66,3 +66,6 @@ DEPENDENCIES
|
|
66
66
|
byebug (~> 4.0)
|
67
67
|
rake (~> 10.0)
|
68
68
|
rspec (~> 3.2)
|
69
|
+
|
70
|
+
BUNDLED WITH
|
71
|
+
1.12.5
|
@@ -8,6 +8,10 @@ module BomDB
|
|
8
8
|
class Application < Thor
|
9
9
|
|
10
10
|
|
11
|
+
desc "version", "show the version of bomdb"
|
12
|
+
def version
|
13
|
+
puts BomDB::VERSION
|
14
|
+
end
|
11
15
|
|
12
16
|
desc "import FILE", "import data from FILE into database, e.g. books.json"
|
13
17
|
option :type, :type => :string, :default => nil,
|
@@ -284,6 +288,43 @@ module BomDB
|
|
284
288
|
end
|
285
289
|
|
286
290
|
|
291
|
+
class Chapter
|
292
|
+
attr_reader :wordcount, :book, :chapter
|
293
|
+
def initialize(wordcount, book, chapter)
|
294
|
+
@wordcount, @book, @chapter = wordcount, book, chapter
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
desc "index WORDGROUP", "create an index into the books of the Book of Mormon counting by WORDGROUP"
|
299
|
+
def index(wordgroup)
|
300
|
+
wordgroup = wordgroup.to_i
|
301
|
+
|
302
|
+
chapters = BomDB::Query.new.chapters.map do |(book, chapter), content|
|
303
|
+
Chapter.new(content.split(/\s+/).size, book, chapter)
|
304
|
+
end
|
305
|
+
|
306
|
+
total_words = chapters.inject(0){ |sum, ch| sum += ch.wordcount }
|
307
|
+
|
308
|
+
idx = []
|
309
|
+
words_so_far = 0
|
310
|
+
chapter_index = 0
|
311
|
+
j = 0
|
312
|
+
|
313
|
+
(wordgroup..(total_words+wordgroup)).step(wordgroup) do |i|
|
314
|
+
while words_so_far < i && chapter_index < chapters.size
|
315
|
+
words_so_far += chapters[chapter_index].wordcount
|
316
|
+
chapter_index += 1
|
317
|
+
end
|
318
|
+
c = chapters[chapter_index-1]
|
319
|
+
idx << ["#{c.book} #{c.chapter}", j]
|
320
|
+
# puts "[#{chapters[chapter_index-1].book} #{chapters[chapter_index-1].chapter},#{j}"
|
321
|
+
j += 1
|
322
|
+
end
|
323
|
+
|
324
|
+
puts idx.to_json
|
325
|
+
end
|
326
|
+
|
327
|
+
|
287
328
|
|
288
329
|
private
|
289
330
|
|
data/lib/bomdb/export/books.rb
CHANGED
@@ -5,11 +5,21 @@ module BomDB
|
|
5
5
|
class Books < Export::Base
|
6
6
|
def export_json
|
7
7
|
books = []
|
8
|
-
|
8
|
+
select_books.each do |b|
|
9
9
|
books << JSON::generate([ b[:book_name], b[:book_group], b[:book_sort] ], array_nl: ' ')
|
10
10
|
end
|
11
11
|
Export::Result.new(success: true, body: "[\n " + books.join(",\n ") + "\n]\n")
|
12
12
|
end
|
13
|
+
|
14
|
+
def export_text
|
15
|
+
Export::Result.new(success: true, body: select_books.map{ |b| b[:book_name] }.join("\n"))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def select_books
|
21
|
+
@db[:books]
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|
@@ -5,11 +5,21 @@ module BomDB
|
|
5
5
|
class Editions < Export::Base
|
6
6
|
def export_json
|
7
7
|
editions = []
|
8
|
-
|
8
|
+
select_editions.each do |e|
|
9
9
|
editions << JSON::generate([e[:edition_year], e[:edition_name]], array_nl: ' ')
|
10
10
|
end
|
11
11
|
Export::Result.new(success: true, body: "[\n " + editions.join(",\n ") + "\n]\n")
|
12
12
|
end
|
13
|
+
|
14
|
+
def export_text
|
15
|
+
Export::Result.new(success: true, body: select_editions.map{ |e| e[:edition_name] }.join("\n"))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def select_editions
|
21
|
+
@db[:editions].order(:edition_year, :edition_name)
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|
data/lib/bomdb/export/verses.rb
CHANGED
@@ -5,11 +5,7 @@ module BomDB
|
|
5
5
|
class Verses < Export::Base
|
6
6
|
def export_json
|
7
7
|
verses = []
|
8
|
-
|
9
|
-
join(:books, :book_id => :book_id).
|
10
|
-
where(:verse_heading => nil).
|
11
|
-
order(:book_sort, :verse_chapter).
|
12
|
-
each do |v|
|
8
|
+
select_verses.each do |v|
|
13
9
|
verses << {
|
14
10
|
range_id: v[:verse_range_id],
|
15
11
|
book: v[:book_name],
|
@@ -19,6 +15,22 @@ module BomDB
|
|
19
15
|
end
|
20
16
|
Export::Result.new(success: true, body: JSON.pretty_generate(verses))
|
21
17
|
end
|
18
|
+
|
19
|
+
def export_text
|
20
|
+
verses = select_verses.map do |v|
|
21
|
+
"#{v[:book_name]} #{v[:verse_chapter]}:#{v[:verse_number]}"
|
22
|
+
end
|
23
|
+
Export::Result.new(success: true, body: verses.join("\n"))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def select_verses
|
29
|
+
@db[:verses].
|
30
|
+
join(:books, :book_id => :book_id).
|
31
|
+
where(:verse_heading => nil).
|
32
|
+
order(:book_sort, :verse_chapter)
|
33
|
+
end
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
data/lib/bomdb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bomdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duane Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -175,6 +175,7 @@ extra_rdoc_files: []
|
|
175
175
|
files:
|
176
176
|
- ".bomdb"
|
177
177
|
- ".gitignore"
|
178
|
+
- ".ruby-version"
|
178
179
|
- Gemfile
|
179
180
|
- Gemfile.lock
|
180
181
|
- LICENSE.txt
|
@@ -232,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
233
|
version: '0'
|
233
234
|
requirements: []
|
234
235
|
rubyforge_project:
|
235
|
-
rubygems_version: 2.
|
236
|
+
rubygems_version: 2.5.1
|
236
237
|
signing_key:
|
237
238
|
specification_version: 4
|
238
239
|
summary: Book of Mormon Database
|