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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5218f7bf1edf9df9a3360e7488cecf285ea7ab02
4
- data.tar.gz: cdede845e0f795e1a11d38fca5c4fec52007f640
3
+ metadata.gz: 9ef43d46210651b66ea43b74d7c839eb46016fb0
4
+ data.tar.gz: d31dc13344a3dc942ff850f368d7879819440ec2
5
5
  SHA512:
6
- metadata.gz: fa072e14a3b56055279761ae47f971282b771603a0df94066973cf5a908e87df17a0e883d26073709267943b22abccd82165cd5b80cd298a145bc908c7515d09
7
- data.tar.gz: c8010f32c6fd199e7eb3d4a3eac3fd6248d033fe99771c03e368bcc8e1c6580b63cc0d9e919ce6a6f992ec235c1355f1a08d7573e9c1c1bfa20c3e0be46c3ed0
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.6)
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.7.7)
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.2.5)
30
- ffi (1.9.10)
31
- i18n (0.7.0)
32
- json (1.8.3)
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.9.0)
38
- multi_json (1.12.1)
39
- rake (10.4.2)
40
- rspec (3.2.0)
41
- rspec-core (~> 3.2.0)
42
- rspec-expectations (~> 3.2.0)
43
- rspec-mocks (~> 3.2.0)
44
- rspec-core (3.2.3)
45
- rspec-support (~> 3.2.0)
46
- rspec-expectations (3.2.1)
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.2.0)
49
- rspec-mocks (3.2.1)
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.2.0)
52
- rspec-support (3.2.2)
53
- sequel (4.35.0)
54
- sqlite3 (1.3.11)
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.19.1)
57
- thread_safe (0.3.5)
58
- tzinfo (1.2.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
@@ -1,2 +1,5 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ # invoke with `bundle exec rake test`
5
+ RSpec::Core::RakeTask.new(:test)
@@ -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(:editions__edition_id, :edition_name).
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(:editions__edition_id, :edition_year, :edition_name).
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 => :verses__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(:editions__edition_id, :book_name, :verse_chapter, :verse_number, :content_body).
91
- where(:editions__edition_id => edition_ids).
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 => :verses__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
- q.where!(:editions__edition_id => edition[:edition_id]) if @edition
28
- q.where!(:verse_heading => nil) unless @headings
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!(Sequel::SQL::BooleanExpression.from_value_pairs(pairs, :OR))
36
+ q = q.where(Sequel::SQL::BooleanExpression.from_value_pairs(pairs, :OR))
33
37
  end
34
38
  if @search
35
- q.where!(Sequel.like(Sequel.function(:LOWER, :content_body), "%#{@search.downcase}%"))
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!(ref_is_quotation: true)
49
+ excluded_verse_ids = excluded_verse_ids.where(ref_is_quotation: true)
46
50
  end
47
- q.exclude!(:verses__verse_id => excluded_verse_ids)
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
@@ -1,3 +1,3 @@
1
1
  module BomDB
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -12,15 +12,36 @@ describe BomDB::Query do
12
12
  end
13
13
 
14
14
  context "with schema" do
15
- before do
16
- BomDB::Schema.create_tables(BomDB.db)
17
- end
15
+ let(:db) { BomDB.db }
18
16
 
19
17
  context "with data" do
20
- # let(:book_id) { BomDB.db[:books].insert(book_name: "1 Nephi") }
21
- # let(:verse1) { BomDB.db[:verses].insert(book_id: book_id, verse_chapter: 1, verse_number: 1) }
22
- # let(:verse2) { BomDB.db[:verses].insert(book_id: book_id, verse_chapter: 1, verse_number: 2) }
23
- # let(:edition1) { BomDB.db[:editions].insert() }
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
@@ -1,5 +1,4 @@
1
1
  require 'rspec'
2
- require 'byebug'
3
2
  require 'tmpdir'
4
3
 
5
4
  require_relative '../lib/bomdb'
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.8.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: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2018-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel