elastic_queue 0.0.13 → 0.0.14
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/Gemfile.lock +3 -3
- data/lib/elastic_queue/filters.rb +2 -2
- data/lib/elastic_queue/version.rb +3 -2
- data/spec/lib/integration/elastic_queue_filters_spec.rb +38 -8
- 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: d769bd3556106cd8ba5b46f4431c240c9224f09b
|
4
|
+
data.tar.gz: abafb1ff884a54e50f1d2fccaf89828f4d344790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6354f5f3e4b483aa664ac99d61c8a1de523835f550869315d0d47aa8741a80209142eb694adfc64960de6c24c468467704294b4bb8a45c430f0597595ae7c68e
|
7
|
+
data.tar.gz: 336a51bb66c21ddef868b4dc0a1483827a13e245bb51846af5852243c328f284c12a442f8169759b1b069804fd62a5f31805dc506ad757c94f89d60caa1d2bfe
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
elastic_queue (0.0.
|
4
|
+
elastic_queue (0.0.14)
|
5
5
|
activerecord (~> 3.0)
|
6
6
|
activesupport (~> 3.0)
|
7
7
|
elasticsearch (~> 0.4)
|
@@ -56,8 +56,8 @@ GEM
|
|
56
56
|
diff-lcs (>= 1.1.3, < 2.0)
|
57
57
|
rspec-mocks (2.14.6)
|
58
58
|
sqlite3 (1.3.9)
|
59
|
-
tzinfo (0.3.
|
60
|
-
will_paginate (3.0.
|
59
|
+
tzinfo (0.3.40)
|
60
|
+
will_paginate (3.0.7)
|
61
61
|
|
62
62
|
PLATFORMS
|
63
63
|
ruby
|
@@ -13,7 +13,7 @@ module ElasticQueue
|
|
13
13
|
|
14
14
|
def option_to_filter(key, value)
|
15
15
|
# return and_options(value) if key == :and
|
16
|
-
if [:or, :and].include?(key)
|
16
|
+
if [:or, :and, :not].include?(key)
|
17
17
|
join_options(key, value)
|
18
18
|
elsif value.is_a? Array
|
19
19
|
or_filter(key, value)
|
@@ -30,7 +30,7 @@ module ElasticQueue
|
|
30
30
|
|
31
31
|
def join_options(operator, options)
|
32
32
|
conditions = options.map { |o| options_to_filters(o) }.flatten
|
33
|
-
{ operator => conditions }
|
33
|
+
operator == :not ? { not: { filter: { and: conditions } } } : { operator => conditions }
|
34
34
|
end
|
35
35
|
|
36
36
|
def or_filter(term, values)
|
@@ -41,6 +41,11 @@ describe 'ElasticQueue::Filters integration' do
|
|
41
41
|
expect(TestAnimalsQueue.query.filter(name: 'a').all.map(&:name)).to eq ['a']
|
42
42
|
end
|
43
43
|
|
44
|
+
it 'can filter out one value' do
|
45
|
+
@create_animals.call
|
46
|
+
expect(TestAnimalsQueue.query.filter(not: [ { name: 'a'} ]).all.map(&:name).sort).to eq ['b', 'c']
|
47
|
+
end
|
48
|
+
|
44
49
|
it 'can filter by a less than or greater than a time' do
|
45
50
|
@create_animals.call
|
46
51
|
expect(TestAnimalsQueue.query.filter(birthdate: { after: Date.today - 1.year - 1.day }).all.map(&:name)).to eq ['a']
|
@@ -110,16 +115,41 @@ describe 'ElasticQueue::Filters integration' do
|
|
110
115
|
# (rusty, killer, speedy) && ( rusty || lucky, killer, old bess, cock-a-doodle-doo)
|
111
116
|
name: ['rusty', 'killer', 'speedy'], #(rusty, killer, speedy) && (
|
112
117
|
or: [
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
118
|
+
and: [ # rusty ||
|
119
|
+
{ species: ['dog', 'mountain lion'] },
|
120
|
+
{ dangerous: false }
|
121
|
+
],
|
122
|
+
or: [ #speedy, killer, old bess, cock-a-doodle-doo )
|
123
|
+
{ species: ['horse', 'chicken'] },
|
124
|
+
{ dangerous: true }
|
125
|
+
]
|
120
126
|
]
|
121
|
-
]
|
122
127
|
}).all.map(&:name).sort).to eq ['killer', 'rusty', 'speedy']
|
123
128
|
end
|
129
|
+
|
130
|
+
it 'can nest multiple ands and ors and nots' do
|
131
|
+
Animal.create({ name: 'rusty', species: 'dog', dangerous: false })
|
132
|
+
Animal.create({ name: 'killer', species: 'mountain lion', dangerous: true })
|
133
|
+
Animal.create({ name: 'cock-a-doodle-doo', species: 'chicken', dangerous: false })
|
134
|
+
Animal.create({ name: 'old bess', species: 'cow', dangerous: true })
|
135
|
+
Animal.create({ name: 'speedy', species: 'horse', dangerous: false })
|
136
|
+
expect(TestAnimalsQueue.query.filter({
|
137
|
+
#(rusty, killer, speedy, cock-a-doodle-doo) && (! rusty && (rusty || speedy, killer, old bess, cock-a-doodle-doo))
|
138
|
+
name: ['rusty', 'killer', 'speedy', 'cock-a-doodle-doo'], #(rusty, killer, speedy, cock-a-doodle-doo) && (
|
139
|
+
not: [ # ! rusty &&
|
140
|
+
{ name: 'rusty' }
|
141
|
+
],
|
142
|
+
or: [
|
143
|
+
and: [ # (rusty ||
|
144
|
+
{ species: ['dog', 'mountain lion'] },
|
145
|
+
{ dangerous: false }
|
146
|
+
],
|
147
|
+
or: [ #speedy, killer, old bess, cock-a-doodle-doo ))
|
148
|
+
{ species: ['horse', 'chicken'] },
|
149
|
+
{ not: [ { dangerous: false } ] },
|
150
|
+
]
|
151
|
+
]
|
152
|
+
}).all.map(&:name).sort).to eq ['cock-a-doodle-doo', 'killer', 'speedy']
|
153
|
+
end
|
124
154
|
end
|
125
155
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruth Thompson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|