sunspot-null_result 0.3.0 → 0.4.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 +3 -0
- data/lib/sunspot/null_result/grouped_collection.rb +16 -2
- data/lib/sunspot/null_result/version.rb +1 -1
- data/lib/sunspot/null_result.rb +5 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dfee509fb71eb2e20fd91bcce4eb6a0085acc4a
|
4
|
+
data.tar.gz: edc2a804d79ea5fe13902b850b4ad41d2d1101f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6cdd31a553fdb36c9147bb27c01e215bf37be155edac41489048809af779027f88d0b3cee5a429dd08bcd8f39f7a659faf85894195c26c24625b904d58ad71e
|
7
|
+
data.tar.gz: b587b5169c1dace39f4e632a92dca8cc7c4aea421ff8a45e983b971aa2bbeec84b4fe7e89006a7239d9069a82a01e2fc2a755e1c5b39f06eb41cf79f028d0828
|
data/README.md
CHANGED
@@ -4,11 +4,13 @@ module Sunspot
|
|
4
4
|
|
5
5
|
include Enumerable
|
6
6
|
|
7
|
-
attr_reader :collection, :group_by
|
7
|
+
attr_reader :collection, :group_by, :current_page, :total_pages
|
8
8
|
|
9
|
-
def initialize(collection
|
9
|
+
def initialize(collection:, group_by: nil, current_page: 1, total_pages: 1)
|
10
10
|
@collection = group_by.nil? ? [] : Array(collection)
|
11
11
|
@group_by = group_by || :itself
|
12
|
+
@current_page = current_page
|
13
|
+
@total_pages = total_pages
|
12
14
|
end
|
13
15
|
|
14
16
|
def to_a
|
@@ -19,10 +21,22 @@ module Sunspot
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
def empty?
|
25
|
+
to_a.empty?
|
26
|
+
end
|
27
|
+
|
22
28
|
def each(*args, &block)
|
23
29
|
to_a.each(*args, &block)
|
24
30
|
end
|
25
31
|
|
32
|
+
def next_page
|
33
|
+
[current_page + 1, total_pages].min
|
34
|
+
end
|
35
|
+
|
36
|
+
def prev_page
|
37
|
+
[current_page - 1, 0].max
|
38
|
+
end
|
39
|
+
|
26
40
|
end
|
27
41
|
end
|
28
42
|
end
|
data/lib/sunspot/null_result.rb
CHANGED
@@ -32,7 +32,6 @@ module Sunspot
|
|
32
32
|
end
|
33
33
|
alias num_pages total_pages
|
34
34
|
|
35
|
-
|
36
35
|
def previous_page
|
37
36
|
(current_page-1) if current_page > 1
|
38
37
|
end
|
@@ -72,7 +71,11 @@ module Sunspot
|
|
72
71
|
end
|
73
72
|
|
74
73
|
def groups
|
75
|
-
GroupedCollection.new(collection, group_by)
|
74
|
+
GroupedCollection.new(collection: collection, group_by: group_by, current_page: results.current_page, total_pages: results.total_pages)
|
75
|
+
end
|
76
|
+
|
77
|
+
def matches
|
78
|
+
results.size
|
76
79
|
end
|
77
80
|
|
78
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot-null_result
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Zimmermann
|
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: bundler
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.4.
|
99
|
+
rubygems_version: 2.4.6
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Provides a standalone mock result for Solr searches
|