CloudSesame 0.9.1 → 0.9.2

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: 45e91a7582d996276e3fc0b28078ab0bf8ca64cd
4
- data.tar.gz: 5d7ac46418e7ff5ca948b70c4abea3ae265b3794
3
+ metadata.gz: 5acd8fee5275581b3fc7fac1f332e5779b3aa064
4
+ data.tar.gz: 5f1313d23fb0297f89dcf0783d29fab8fe853af1
5
5
  SHA512:
6
- metadata.gz: 4fab65fb6973916daf9462762667db1a8b8016113e569403ac709eeab784f6ddb36994cb63d0ba9064c554486d832e942ab734a3503f7f3adf8e9abaa1f6cb12
7
- data.tar.gz: 144650056b9cef90fabf98ea06e91c654b314c51022f18dd8db4bfee51b5885675010f30f6e18202c6a88f6fceb8712250e1cdecc070b71467195e85474b73cc
6
+ metadata.gz: 294d90239e515d7f13da742a0c62169ff9630324c1209bc631b3f6733bfdec4059437ea5abd798dc64bcdee821fa8acb681c5ceabe7437b3378995b1de6591e1
7
+ data.tar.gz: 4292d9628ef96012dd6662fffd4d449c2d54b06338481c7bf2f3fbbfafbf708b7f5ef080d6bbae86d3edbf06b019f959fe11397473d488410fa0fce252f08692
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
2
  DisabledByDefault: true
3
+ TargetRubyVersion: 2.3
3
4
 
4
5
  #################### Lint ################################
5
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CloudSesame (0.9.1)
4
+ CloudSesame (0.9.2)
5
5
  aws-sdk (~> 2)
6
6
 
7
7
  GEM
data/cloud_sesame.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'CloudSesame'
3
- s.version = '0.9.1'
3
+ s.version = '0.9.2'
4
4
  s.date = '2016-09-12'
5
5
  s.summary = "AWS CloudSearch Query DSL"
6
6
  s.description = "AWS CloudSearch Query DSL"
@@ -2,7 +2,11 @@ module CloudSesame
2
2
  module Query
3
3
  module DSL
4
4
  module AnyTermMethods
5
- def any_term(field, words, options = {})
5
+ DELIMITER = ' '.freeze
6
+
7
+ def any_term(field, phrase, options = {})
8
+ words = phrase&.split(DELIMITER)
9
+
6
10
  if words && words.length > 0
7
11
  or!(options) do
8
12
  words.map do |word|
@@ -2,7 +2,7 @@ module CloudSesame
2
2
  module Query
3
3
  module DSL
4
4
  module KGramPhraseMethods
5
- DELIMITER = / |-/.freeze
5
+ DELIMITER = ' '.freeze
6
6
  MULTIPLIER = 10 # Even number that controls the separation between k-grams
7
7
 
8
8
  def k_gram_phrase(field, value, options = {})
@@ -26,7 +26,7 @@ module CloudSesame
26
26
  end
27
27
 
28
28
  literal field, term(value, boost: MULTIPLIER)
29
- any_term(field, words)
29
+ any_term(field, words.join(' '))
30
30
  end
31
31
  end
32
32
 
@@ -14,27 +14,38 @@ module CloudSesame
14
14
  let(:root) { cloudsearch.request.filter_query.root }
15
15
 
16
16
  describe '#any_term' do
17
- let(:words) { %w(listerine mouth wash) }
17
+ let(:phrase) { 'listerine mouth wash' }
18
18
 
19
19
  it 'inserts an OR node at its scope level' do
20
- expect { cloudsearch.any_term(:name, words) }.to change { root.children }.by([AST::Or])
20
+ expect { cloudsearch.any_term(:name, phrase) }.to change { root.children }.by([AST::Or])
21
21
  end
22
22
 
23
23
  describe 'in the OR node' do
24
24
  let(:or_node) { root.children.first }
25
25
 
26
26
  it 'builds a term node with each word' do
27
- cloudsearch.any_term(:name, words)
27
+ cloudsearch.any_term(:name, phrase)
28
28
 
29
29
  expect(or_node.children[0]).to be_kind_of AST::Term
30
30
  expect(or_node.children[0].child.value).to eq('listerine')
31
31
  end
32
+
33
+ context 'when - is in phrase' do
34
+ let(:phrase) { 'a-b c' }
35
+
36
+ it 'only splits on space' do
37
+ cloudsearch.any_term(:name, phrase)
38
+
39
+ expect(or_node.children.length).to eq(2)
40
+ end
41
+ end
32
42
  end
33
43
 
34
- context 'when words is empty or nil' do
44
+ context 'when phrase is empty' do
45
+ let(:phrase) { nil }
46
+
35
47
  it 'does not build anything' do
36
- expect { cloudsearch.any_term(:name, nil) }.to_not change { root.children }
37
- expect { cloudsearch.any_term(:name, []) }.to_not change { root.children }
48
+ expect { cloudsearch.any_term(:name, phrase) }.to_not change { root.children }
38
49
  end
39
50
  end
40
51
  end
@@ -98,6 +98,11 @@ module CloudSesame
98
98
  expect(node.children[2]).to be_kind_of(AST::Term)
99
99
  expect(node.children[2].child.value).to eq('wash')
100
100
  end
101
+
102
+ it 'splits the phrase on space and nothing else' do
103
+ cloudsearch.k_gram_phrase(:name, 'word-word2 word3')
104
+ expect(or_node.children.length).to eq(3)
105
+ end
101
106
  end
102
107
 
103
108
  context 'when phrase is empty' do
@@ -108,7 +113,6 @@ module CloudSesame
108
113
  end
109
114
  end
110
115
  end
111
-
112
116
  end
113
117
  end
114
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudSesame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chu