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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54dcfc7c9200c82d700cbc217d92b95dfdeb7560
4
- data.tar.gz: e6bb65cb70e0e35b682461354fc7141196d8250a
3
+ metadata.gz: 1e9483032ffd4bb6827da3735db522c02fcd9187
4
+ data.tar.gz: 5673db877cf39e78abde8072e6da6a0fe716c13c
5
5
  SHA512:
6
- metadata.gz: 0785f11056dc78dbfd52414ab3ff14be8ec1bb429ddcbdb90b6a5d77d9c5250308b64e52ba91e5313a7991b84cb50b9f5f94ccfc8fda05c3716479e3f36a9f4e
7
- data.tar.gz: a7a92264369467374a3d7490b7d5f32170d07a923a40e5fe5466888dc0086b339066d153503cd846ab01a535ddf48ef0c300f3e6185573eaef903728fc5e8af1
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.2
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-07-20 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport