trample_search 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/trample/condition.rb +11 -6
- data/lib/trample/version.rb +1 -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: b54a2b004d66cc10b02800ca0c760f68f1f9eacf
|
4
|
+
data.tar.gz: 3d6082f9e2ea2a5c84d68992313f10f91f299e23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a0d96d4da55d0363a3d931e441d527c69024f058ae2326452ad8805e34aed2ceb3e072072822fc143e8267f40f77953f69529f0a7be50e3ffe0c8d7311069ee
|
7
|
+
data.tar.gz: 4d7a070c1b741f277b8f13ff60c96d79f997ca40a60cc377ca3251d6285d40972883ecf223b554b88be8931749f385b991e29cb1292499abacbcb6cb5f0070d2
|
data/README.md
CHANGED
@@ -29,6 +29,18 @@ search.query!
|
|
29
29
|
search.results
|
30
30
|
```
|
31
31
|
|
32
|
+
## Install
|
33
|
+
|
34
|
+
```bash
|
35
|
+
$ gem install trample_search
|
36
|
+
```
|
37
|
+
|
38
|
+
or
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
gem 'trample_search'
|
42
|
+
```
|
43
|
+
|
32
44
|
## Usage
|
33
45
|
|
34
46
|
Check out the complete [documentation](http://richmolj.github.io/trample), or see usage in the [specs](https://github.com/richmolj/trample/blob/master/spec/integration/search_spec.rb).
|
data/lib/trample/condition.rb
CHANGED
@@ -19,6 +19,7 @@ module Trample
|
|
19
19
|
attribute :range, Boolean, default: false
|
20
20
|
attribute :fields, Array
|
21
21
|
attribute :user_query, Hash
|
22
|
+
attribute :transform, Proc, default: ->(_,_) { ->(val) { val } }
|
22
23
|
|
23
24
|
def initialize(attrs)
|
24
25
|
attrs.merge!(single: true) if attrs[:name] == :keywords
|
@@ -190,14 +191,18 @@ module Trample
|
|
190
191
|
end
|
191
192
|
|
192
193
|
def to_range_query
|
194
|
+
_from_eq = transform.call(self.from_eq) if from_eq?
|
195
|
+
_to_eq = transform.call(self.to_eq) if to_eq?
|
196
|
+
_from = transform.call(self.from) if from?
|
197
|
+
_to = transform.call(self.to) if to?
|
198
|
+
|
193
199
|
hash = {}
|
194
|
-
hash.merge!(gte:
|
195
|
-
hash.merge!(gt:
|
196
|
-
hash.merge!(lte:
|
197
|
-
hash.merge!(lt:
|
200
|
+
hash.merge!(gte: _from_eq) if _from_eq
|
201
|
+
hash.merge!(gt: _from) if _from
|
202
|
+
hash.merge!(lte: _to_eq) if _to_eq
|
203
|
+
hash.merge!(lt: _to) if _to
|
198
204
|
|
199
|
-
{runtime_query_name => hash}
|
205
|
+
{ runtime_query_name => hash }
|
200
206
|
end
|
201
|
-
|
202
207
|
end
|
203
208
|
end
|
data/lib/trample/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trample_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- richmolj
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|