stretchy 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stretchy/api.rb +26 -3
- data/lib/stretchy/factory.rb +1 -0
- data/lib/stretchy/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: 0c3818aa28e0d5d43fa9b1abc168571856081382
|
4
|
+
data.tar.gz: 31e8a84723d588e7b5e0ffff48c205bf9a96a514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a43550179be297d7e581075223a43781cf24f23e9eca3f379256492186107154cdd76d398184efff9f3b1ac9c4ee11c37c4b576dd90c2c8e0aac0366172f06ec
|
7
|
+
data.tar.gz: 9cd2d2c2344b52bcf20cb4e852cc20514f48cc1bc80aca17a35b51a59370b5c74dd13edbb08e60a996c0a1672e304627a846020d4968169c5e58153acf7e8810
|
data/lib/stretchy/api.rb
CHANGED
@@ -11,6 +11,21 @@ module Stretchy
|
|
11
11
|
|
12
12
|
attr_reader :collector, :root, :context
|
13
13
|
|
14
|
+
delegate [
|
15
|
+
:total,
|
16
|
+
:total_count,
|
17
|
+
:length,
|
18
|
+
:size,
|
19
|
+
:total_pages,
|
20
|
+
:results,
|
21
|
+
:hits,
|
22
|
+
:to_a,
|
23
|
+
:ids,
|
24
|
+
:scores,
|
25
|
+
:explanations,
|
26
|
+
:aggregations
|
27
|
+
] => :results_obj
|
28
|
+
|
14
29
|
def initialize(options = {})
|
15
30
|
@collector = AndCollector.new(options[:nodes] || [], query: true)
|
16
31
|
@root = options[:root] || {}
|
@@ -42,6 +57,12 @@ module Stretchy
|
|
42
57
|
add_root from: start * per, size: per
|
43
58
|
end
|
44
59
|
|
60
|
+
def per(num = nil)
|
61
|
+
return limit if num.nil?
|
62
|
+
add_root size: [num.to_i, 1].max
|
63
|
+
end
|
64
|
+
alias :per_page :per
|
65
|
+
|
45
66
|
def current_page
|
46
67
|
Utils.current_page(offset, limit)
|
47
68
|
end
|
@@ -154,10 +175,12 @@ module Stretchy
|
|
154
175
|
@results ||= Results.new request, response
|
155
176
|
end
|
156
177
|
|
178
|
+
def count
|
179
|
+
results_obj.ids.count
|
180
|
+
end
|
181
|
+
|
157
182
|
def method_missing(method, *args, &block)
|
158
|
-
if
|
159
|
-
results_obj.send(method, *args, &block)
|
160
|
-
elsif collector.respond_to?(method)
|
183
|
+
if collector.respond_to?(method)
|
161
184
|
collector.send(method, *args, &block)
|
162
185
|
else
|
163
186
|
super
|
data/lib/stretchy/factory.rb
CHANGED
data/lib/stretchy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agius
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|