picky 4.6.1 → 4.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/picky/pool.rb +22 -3
- data/lib/picky/results.rb +2 -4
- data/lib/picky/search.rb +1 -1
- data/spec/functional/facets_spec.rb +8 -1
- data/spec/lib/pool_spec.rb +16 -16
- metadata +6 -6
data/lib/picky/pool.rb
CHANGED
@@ -7,12 +7,30 @@ module Picky
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
|
10
|
+
# Installs itself on a few internal classes.
|
11
|
+
#
|
12
|
+
# Note: If you need to run two consecutive queries,
|
13
|
+
# this can't be used.
|
14
|
+
#
|
15
|
+
# TODO Also install calling release_all after each query.
|
16
|
+
#
|
17
|
+
def install
|
18
|
+
Query::Token.extend self
|
19
|
+
Query::Tokens.extend self
|
20
|
+
Query::Combination.extend self
|
21
|
+
Query::Combinations.extend self
|
22
|
+
Query::Allocation.extend self
|
23
|
+
Query::Allocations.extend self
|
24
|
+
end
|
25
|
+
|
26
|
+
# Initialise/Reset the pool.
|
27
|
+
#
|
10
28
|
def clear
|
11
29
|
require 'set'
|
12
30
|
@pools = Set.new
|
13
31
|
end
|
14
32
|
|
15
|
-
# Add a
|
33
|
+
# Add a pooled class to the managed pools.
|
16
34
|
#
|
17
35
|
def add klass
|
18
36
|
@pools << klass
|
@@ -34,7 +52,8 @@ module Picky
|
|
34
52
|
add klass
|
35
53
|
|
36
54
|
class << klass
|
37
|
-
|
55
|
+
|
56
|
+
# Initialise/Reset the class pool.
|
38
57
|
#
|
39
58
|
def clear
|
40
59
|
@__free__ = []
|
@@ -44,7 +63,7 @@ module Picky
|
|
44
63
|
# Obtain creates a new reference if there is no free one
|
45
64
|
# and uses an existing one if there is.
|
46
65
|
#
|
47
|
-
def
|
66
|
+
def new *args, &block
|
48
67
|
unless reference = @__free__.shift
|
49
68
|
reference = allocate
|
50
69
|
end
|
data/lib/picky/results.rb
CHANGED
@@ -43,14 +43,12 @@ module Picky
|
|
43
43
|
|
44
44
|
# Delegates to allocations.
|
45
45
|
#
|
46
|
-
# TODO Remove parameter in 5.0 and just call the method with amount.
|
47
|
-
#
|
48
46
|
# Note that this is an expensive call and
|
49
47
|
# should not be done repeatedly. Just keep
|
50
48
|
# a reference to the result.
|
51
49
|
#
|
52
|
-
def ids only =
|
53
|
-
allocations.ids only
|
50
|
+
def ids only = amount
|
51
|
+
allocations.ids only
|
54
52
|
end
|
55
53
|
|
56
54
|
# The total results. Delegates to the allocations.
|
data/lib/picky/search.rb
CHANGED
@@ -216,7 +216,7 @@ module Picky
|
|
216
216
|
#
|
217
217
|
# Parameters:
|
218
218
|
# * text: The string to tokenize.
|
219
|
-
# * partialize_last: Whether to partialize the last token
|
219
|
+
# * partialize_last: Whether to partialize the last token.
|
220
220
|
#
|
221
221
|
# Note: By default, the last token is always partial.
|
222
222
|
#
|
@@ -9,7 +9,7 @@ describe 'facets' do
|
|
9
9
|
describe 'simple example' do
|
10
10
|
let(:index) {
|
11
11
|
index = Picky::Index.new :facets do
|
12
|
-
category :name
|
12
|
+
category :name, partial: Picky::Partial::Substring.new(from: 1)
|
13
13
|
category :surname
|
14
14
|
end
|
15
15
|
|
@@ -73,6 +73,13 @@ describe 'facets' do
|
|
73
73
|
'fritz' => 1,
|
74
74
|
'florian' => 1
|
75
75
|
}
|
76
|
+
|
77
|
+
# It allows explicit partial matches.
|
78
|
+
#
|
79
|
+
finder.facets(:name, filter: 'surname:hank*').should == {
|
80
|
+
'fritz' => 1,
|
81
|
+
'florian' => 1
|
82
|
+
}
|
76
83
|
end
|
77
84
|
end
|
78
85
|
end
|
data/spec/lib/pool_spec.rb
CHANGED
@@ -30,40 +30,40 @@ describe Picky::Pool do
|
|
30
30
|
OtherPoolTest.clear
|
31
31
|
end
|
32
32
|
it 'lets me get an instance' do
|
33
|
-
PoolTest.
|
33
|
+
PoolTest.new(1).should be_kind_of(PoolTest)
|
34
34
|
end
|
35
35
|
it 'does not create a new reference if it has free ones' do
|
36
|
-
pt1 = PoolTest.
|
37
|
-
pt2 = PoolTest.
|
36
|
+
pt1 = PoolTest.new 1
|
37
|
+
pt2 = PoolTest.new 2
|
38
38
|
pt1.release
|
39
39
|
|
40
40
|
PoolTest.free_size.should == 1
|
41
41
|
end
|
42
|
-
it 'gives me the released reference if I try to
|
43
|
-
pt1 = PoolTest.
|
44
|
-
pt2 = PoolTest.
|
42
|
+
it 'gives me the released reference if I try to new' do
|
43
|
+
pt1 = PoolTest.new 1
|
44
|
+
pt2 = PoolTest.new 2
|
45
45
|
pt1.release
|
46
46
|
|
47
|
-
PoolTest.
|
47
|
+
PoolTest.new(3).number.should == 3
|
48
48
|
end
|
49
49
|
it 'releases all PoolTests if called on PoolTest' do
|
50
|
-
pt1 = PoolTest.
|
51
|
-
PoolTest.
|
52
|
-
OtherPoolTest.
|
53
|
-
OtherPoolTest.
|
50
|
+
pt1 = PoolTest.new 1
|
51
|
+
PoolTest.new 2
|
52
|
+
OtherPoolTest.new 1
|
53
|
+
OtherPoolTest.new 2
|
54
54
|
|
55
55
|
OtherPoolTest.free_size.should == 0
|
56
56
|
|
57
57
|
PoolTest.release_all
|
58
58
|
|
59
|
-
PoolTest.
|
59
|
+
PoolTest.new(3).should == pt1
|
60
60
|
OtherPoolTest.free_size.should == 0
|
61
61
|
end
|
62
62
|
it 'releases all if called on Pool' do
|
63
|
-
PoolTest.
|
64
|
-
PoolTest.
|
65
|
-
OtherPoolTest.
|
66
|
-
OtherPoolTest.
|
63
|
+
PoolTest.new 1
|
64
|
+
PoolTest.new 2
|
65
|
+
OtherPoolTest.new 1
|
66
|
+
OtherPoolTest.new 2
|
67
67
|
|
68
68
|
PoolTest.free_size.should == 0
|
69
69
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.6.
|
4
|
+
version: 4.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 4.6.
|
37
|
+
version: 4.6.2
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 4.6.
|
45
|
+
version: 4.6.2
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: text
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: '3
|
85
|
+
version: '3'
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '3
|
93
|
+
version: '3'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: procrastinate
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|