picky 4.31.2 → 4.31.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/picky/backends/redis/list.rb +11 -0
- data/spec/functional/facets_spec.rb +41 -0
- 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: 1e9483032ffd4bb6827da3735db522c02fcd9187
|
4
|
+
data.tar.gz: 5673db877cf39e78abde8072e6da6a0fe716c13c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21ca57dfa6b2ce352c477ffba958aff3a937f5f2e0a5fdecb1053a6c46d9f22038a3ce464d8704482d1783cbc99e3321255e16a650abbc5206b53bd0aee96939
|
7
|
+
data.tar.gz: 9ec1fee93c1a6655f32c98d4214820dff263feebd9900d2459c0463a2e97763ed8ffc76947b83ec1e251cbdfb3259f8d9774da2726095cc721eda5c02c67c022
|
@@ -77,6 +77,17 @@ module Picky
|
|
77
77
|
|
78
78
|
values
|
79
79
|
end
|
80
|
+
|
81
|
+
# Inject.
|
82
|
+
#
|
83
|
+
def inject initial, &block
|
84
|
+
redis_keys = "#{namespace}:*"
|
85
|
+
client.keys(redis_keys).each do |redis_key|
|
86
|
+
key = redis_key[/:([^\:]+)$/, 1]
|
87
|
+
initial = block.call initial, [key, self[key]]
|
88
|
+
end
|
89
|
+
initial
|
90
|
+
end
|
80
91
|
|
81
92
|
end
|
82
93
|
|
@@ -5,6 +5,47 @@ require 'spec_helper'
|
|
5
5
|
# This spec describes
|
6
6
|
#
|
7
7
|
describe 'facets' do
|
8
|
+
|
9
|
+
describe 'with Redis' do
|
10
|
+
let(:redis_index) {
|
11
|
+
index = Picky::Index.new :redis_facets_index do
|
12
|
+
backend Picky::Backends::Redis.new
|
13
|
+
|
14
|
+
category :name
|
15
|
+
category :surname
|
16
|
+
end
|
17
|
+
index.clear
|
18
|
+
|
19
|
+
thing = Struct.new :id, :name, :surname
|
20
|
+
index.add thing.new(1, 'fritz', 'hanke')
|
21
|
+
index.add thing.new(2, 'kaspar', 'schiess')
|
22
|
+
index.add thing.new(3, 'florian', 'hanke')
|
23
|
+
|
24
|
+
index.dump
|
25
|
+
index.load
|
26
|
+
|
27
|
+
index
|
28
|
+
}
|
29
|
+
let(:redis_finder) { Picky::Search.new redis_index }
|
30
|
+
|
31
|
+
describe 'Index#facets' do
|
32
|
+
it 'does not fail' do
|
33
|
+
redis_index.facets(:surname).should == {
|
34
|
+
'hanke' => 2,
|
35
|
+
'schiess' => 1
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'Search#facets' do
|
41
|
+
it 'does not fail' do
|
42
|
+
redis_finder.facets(:surname).should == {
|
43
|
+
'hanke' => 2,
|
44
|
+
'schiess' => 1
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
8
49
|
|
9
50
|
describe 'simple example' do
|
10
51
|
let(:index) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.31.
|
4
|
+
version: 4.31.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|