bomdb 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -26
- data/Rakefile +4 -1
- data/lib/bomdb/cli/application.rb +1 -1
- data/lib/bomdb/export/contents.rb +4 -4
- data/lib/bomdb/query.rb +12 -8
- data/lib/bomdb/version.rb +1 -1
- data/spec/bomdb/query_spec.rb +28 -7
- data/spec/spec_helper.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef43d46210651b66ea43b74d7c839eb46016fb0
|
4
|
+
data.tar.gz: d31dc13344a3dc942ff850f368d7879819440ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8edfd7c1df4ed59bba75cf4f7688429a0ec4776cb199ed43f3fb0ef6749123e9ee9d4284516ba4492fb877937690e04cf9ae21a22eb11462a61c42c4bf09ae
|
7
|
+
data.tar.gz: 7be412d55eb0d296467807f163501acb5cf88ed1d37b8c728f8364df8def4b9610114b2263aaae1bf75e09ac9f4f0a99cf09a221c39dabb7e44146d9f63a8fa3
|
data/Gemfile.lock
CHANGED
@@ -14,48 +14,48 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
activesupport (4.2.
|
17
|
+
activesupport (4.2.10)
|
18
18
|
i18n (~> 0.7)
|
19
|
-
json (~> 1.7, >= 1.7.7)
|
20
19
|
minitest (~> 5.1)
|
21
20
|
thread_safe (~> 0.3, >= 0.3.4)
|
22
21
|
tzinfo (~> 1.1)
|
23
22
|
byebug (4.0.5)
|
24
23
|
columnize (= 0.9.0)
|
25
|
-
colorize (0.
|
24
|
+
colorize (0.8.1)
|
26
25
|
columnize (0.9.0)
|
26
|
+
concurrent-ruby (1.0.5)
|
27
27
|
constellation (0.1.1)
|
28
28
|
multi_json
|
29
|
-
diff-lcs (1.
|
30
|
-
ffi (1.9.
|
31
|
-
i18n (0.
|
32
|
-
|
29
|
+
diff-lcs (1.3)
|
30
|
+
ffi (1.9.23)
|
31
|
+
i18n (0.9.5)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
33
|
levenshtein-ffi (1.1.0)
|
34
34
|
ffi (~> 1.9)
|
35
35
|
mericope (0.2.0)
|
36
36
|
activesupport (~> 4.0)
|
37
|
-
minitest (5.
|
38
|
-
multi_json (1.
|
39
|
-
rake (10.
|
40
|
-
rspec (3.
|
41
|
-
rspec-core (~> 3.
|
42
|
-
rspec-expectations (~> 3.
|
43
|
-
rspec-mocks (~> 3.
|
44
|
-
rspec-core (3.
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-expectations (3.
|
37
|
+
minitest (5.11.3)
|
38
|
+
multi_json (1.13.1)
|
39
|
+
rake (10.5.0)
|
40
|
+
rspec (3.7.0)
|
41
|
+
rspec-core (~> 3.7.0)
|
42
|
+
rspec-expectations (~> 3.7.0)
|
43
|
+
rspec-mocks (~> 3.7.0)
|
44
|
+
rspec-core (3.7.1)
|
45
|
+
rspec-support (~> 3.7.0)
|
46
|
+
rspec-expectations (3.7.0)
|
47
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-mocks (3.
|
48
|
+
rspec-support (~> 3.7.0)
|
49
|
+
rspec-mocks (3.7.0)
|
50
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-support (3.
|
53
|
-
sequel (4.
|
54
|
-
sqlite3 (1.3.
|
51
|
+
rspec-support (~> 3.7.0)
|
52
|
+
rspec-support (3.7.1)
|
53
|
+
sequel (4.49.0)
|
54
|
+
sqlite3 (1.3.13)
|
55
55
|
text_clean (0.2.2)
|
56
|
-
thor (0.
|
57
|
-
thread_safe (0.3.
|
58
|
-
tzinfo (1.2.
|
56
|
+
thor (0.20.0)
|
57
|
+
thread_safe (0.3.6)
|
58
|
+
tzinfo (1.2.5)
|
59
59
|
thread_safe (~> 0.1)
|
60
60
|
|
61
61
|
PLATFORMS
|
data/Rakefile
CHANGED
@@ -205,7 +205,7 @@ module BomDB
|
|
205
205
|
def editions
|
206
206
|
BomDB.db[:editions].
|
207
207
|
left_outer_join(:contents, :edition_id => :edition_id).
|
208
|
-
select_group(
|
208
|
+
select_group(Sequel.qualify("editions", "edition_id"), :edition_name).
|
209
209
|
select_append{ Sequel.as(count(:verse_id), :count) }.
|
210
210
|
order(:edition_name).
|
211
211
|
each do |r|
|
@@ -75,7 +75,7 @@ module BomDB
|
|
75
75
|
def edition_query
|
76
76
|
@db[:editions].
|
77
77
|
left_outer_join(:contents, :edition_id => :edition_id).
|
78
|
-
select_group(
|
78
|
+
select_group(Sequel.qualify("editions", "edition_id"), :edition_year, :edition_name).
|
79
79
|
select_append{ Sequel.as(count(:verse_id), :count) }.
|
80
80
|
having{ count > 0 }.
|
81
81
|
order(:edition_name)
|
@@ -85,10 +85,10 @@ module BomDB
|
|
85
85
|
@db[:verses].
|
86
86
|
join(:books, :book_id => :book_id).
|
87
87
|
join(:editions).
|
88
|
-
join(:contents, :edition_id => :edition_id, :verse_id =>
|
88
|
+
join(:contents, :edition_id => :edition_id, :verse_id => Sequel.qualify("verses", "verse_id")).
|
89
89
|
order(:book_sort, :verse_heading, :verse_chapter, :verse_number).
|
90
|
-
select(
|
91
|
-
where(
|
90
|
+
select(Sequel.qualify("editions", "edition_id"), :book_name, :verse_chapter, :verse_number, :content_body).
|
91
|
+
where(Sequel.qualify("editions", "edition_id") => edition_ids).
|
92
92
|
where(:verse_heading => nil)
|
93
93
|
end
|
94
94
|
|
data/lib/bomdb/query.rb
CHANGED
@@ -21,18 +21,22 @@ module BomDB
|
|
21
21
|
q = db[:verses].
|
22
22
|
join(:books, :book_id => :book_id).
|
23
23
|
join(:editions).
|
24
|
-
join(:contents, :edition_id => :edition_id, :verse_id =>
|
24
|
+
join(:contents, :edition_id => :edition_id, :verse_id => Sequel.qualify("verses", "verse_id")).
|
25
25
|
order(:book_sort, :verse_heading, :verse_chapter, :verse_number).
|
26
26
|
select(:book_name, :verse_chapter, :verse_number, :content_body)
|
27
|
-
|
28
|
-
|
27
|
+
if @edition
|
28
|
+
q = q.where(Sequel.qualify("editions", "edition_id") => edition[:edition_id])
|
29
|
+
end
|
30
|
+
if not @headings
|
31
|
+
q = q.where(:verse_heading => nil)
|
32
|
+
end
|
29
33
|
if @range
|
30
34
|
pericope = Mericope.new(@range)
|
31
35
|
pairs = pericope.ranges.map{ |r| [:verse_range_id, r] }
|
32
|
-
q.where
|
36
|
+
q = q.where(Sequel::SQL::BooleanExpression.from_value_pairs(pairs, :OR))
|
33
37
|
end
|
34
38
|
if @search
|
35
|
-
q.where
|
39
|
+
q = q.where(Sequel.like(Sequel.function(:LOWER, :content_body), "%#{@search.downcase}%"))
|
36
40
|
end
|
37
41
|
if @exclude
|
38
42
|
excluded_ref_names = @exclude.split(/\s*,\s*/).map do |name|
|
@@ -40,11 +44,11 @@ module BomDB
|
|
40
44
|
end
|
41
45
|
excluded_verse_ids = db[:refs].
|
42
46
|
select(:verse_id).
|
43
|
-
where(excluded_ref_names)
|
47
|
+
where(Sequel.&(excluded_ref_names))
|
44
48
|
if @exclude_only_quotations
|
45
|
-
excluded_verse_ids.where
|
49
|
+
excluded_verse_ids = excluded_verse_ids.where(ref_is_quotation: true)
|
46
50
|
end
|
47
|
-
q.exclude
|
51
|
+
q = q.exclude(Sequel.qualify("verses", "verse_id") => excluded_verse_ids)
|
48
52
|
end
|
49
53
|
q
|
50
54
|
end
|
data/lib/bomdb/version.rb
CHANGED
data/spec/bomdb/query_spec.rb
CHANGED
@@ -12,15 +12,36 @@ describe BomDB::Query do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with schema" do
|
15
|
-
|
16
|
-
BomDB::Schema.create_tables(BomDB.db)
|
17
|
-
end
|
15
|
+
let(:db) { BomDB.db }
|
18
16
|
|
19
17
|
context "with data" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
let(:data) { BomDB::Query.new(exclude: 'Bible-OT') }
|
19
|
+
|
20
|
+
it "queries wherefore/therefore" do
|
21
|
+
result = data.books.map do |book,content|
|
22
|
+
[ book,
|
23
|
+
content.scan(/wherefore/i).size,
|
24
|
+
content.scan(/therefore/i).size ]
|
25
|
+
end
|
26
|
+
|
27
|
+
expect(result).to match([
|
28
|
+
["1 Nephi", 99, 13],
|
29
|
+
["2 Nephi", 126, 6],
|
30
|
+
["Jacob", 53, 1],
|
31
|
+
["Enos", 6, 0],
|
32
|
+
["Jarom", 3, 0],
|
33
|
+
["Omni", 6, 0],
|
34
|
+
["Words of Mormon", 5, 0],
|
35
|
+
["Mosiah", 0, 122],
|
36
|
+
["Alma", 3, 288],
|
37
|
+
["Helaman", 0, 63],
|
38
|
+
["3 Nephi", 3, 97],
|
39
|
+
["4 Nephi", 0, 5],
|
40
|
+
["Mormon", 0, 22],
|
41
|
+
["Ether", 63, 26],
|
42
|
+
["Moroni", 38, 0]
|
43
|
+
])
|
44
|
+
end
|
24
45
|
end
|
25
46
|
end
|
26
47
|
end
|
data/spec/spec_helper.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.9.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: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|