picky 4.4.1 → 4.4.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/aux/picky/cli.rb +1 -1
- data/lib/picky/analyzer.rb +1 -1
- data/lib/picky/calculations/location.rb +1 -1
- data/lib/picky/character_substituters/west_european.rb +2 -2
- data/lib/picky/deployment.rb +2 -2
- data/lib/picky/ext/ruby19/extconf.rb +3 -1
- data/lib/picky/extensions/array.rb +1 -1
- data/lib/picky/extensions/class.rb +1 -1
- data/lib/picky/extensions/hash.rb +1 -1
- data/lib/picky/extensions/module.rb +1 -1
- data/lib/picky/extensions/object.rb +1 -1
- data/lib/picky/extensions/string.rb +1 -1
- data/lib/picky/extensions/symbol.rb +1 -1
- data/lib/picky/generators/similarity/phonetic.rb +1 -1
- data/lib/picky/index.rb +2 -2
- data/lib/picky/indexers/base.rb +1 -1
- data/lib/picky/loader.rb +1 -1
- data/lib/picky/performant.rb +1 -1
- data/lib/picky/query/allocation.rb +10 -4
- data/lib/picky/query/allocations.rb +15 -4
- data/lib/picky/query/combination.rb +5 -9
- data/lib/picky/query/combinations.rb +9 -8
- data/lib/picky/query/indexes_check.rb +3 -3
- data/lib/picky/query/qualifier_category_mapper.rb +1 -1
- data/lib/picky/query/token.rb +1 -1
- data/lib/picky/query/tokens.rb +1 -1
- data/lib/picky/rack/harakiri.rb +1 -1
- data/lib/picky/search.rb +1 -1
- data/lib/picky/statistics.rb +1 -1
- data/lib/tasks/try.rb +5 -1
- data/spec/functional/backends/memory_json_utf8_spec.rb +19 -0
- metadata +18 -17
data/aux/picky/cli.rb
CHANGED
data/lib/picky/analyzer.rb
CHANGED
@@ -12,7 +12,7 @@ module Picky
|
|
12
12
|
#
|
13
13
|
class WestEuropean
|
14
14
|
|
15
|
-
def initialize
|
15
|
+
def initialize
|
16
16
|
@chars = ActiveSupport::Multibyte.proxy_class
|
17
17
|
end
|
18
18
|
|
@@ -45,7 +45,7 @@ module Picky
|
|
45
45
|
}.pack 'U*'
|
46
46
|
end
|
47
47
|
|
48
|
-
def to_s
|
48
|
+
def to_s
|
49
49
|
self.class.name
|
50
50
|
end
|
51
51
|
|
data/lib/picky/deployment.rb
CHANGED
data/lib/picky/index.rb
CHANGED
@@ -288,7 +288,7 @@ module Picky
|
|
288
288
|
# THINK Will have to write a wrapper that combines two categories that are
|
289
289
|
# indexed simultaneously, since lat/lng are correlated.
|
290
290
|
#
|
291
|
-
def geo_categories lat_name, lng_name, radius, options = {}
|
291
|
+
def geo_categories lat_name, lng_name, radius, options = {}
|
292
292
|
|
293
293
|
# Extract lat/lng specific options.
|
294
294
|
#
|
@@ -316,7 +316,7 @@ module Picky
|
|
316
316
|
|
317
317
|
end
|
318
318
|
|
319
|
-
def to_stats
|
319
|
+
def to_stats
|
320
320
|
stats = <<-INDEX
|
321
321
|
#{name} (#{self.class}):
|
322
322
|
#{"source: #{source}".indented_to_s}
|
data/lib/picky/indexers/base.rb
CHANGED
data/lib/picky/loader.rb
CHANGED
data/lib/picky/performant.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
module Picky
|
2
2
|
|
3
3
|
module Query
|
4
|
-
|
5
|
-
# An
|
6
|
-
#
|
4
|
+
|
5
|
+
# An Allocation contains an ordered list of
|
6
|
+
# tuples (Combinations).
|
7
|
+
# The Combinations are ordered according to the order
|
8
|
+
# of the words in the query.
|
9
|
+
#
|
10
|
+
# It offers convenience methods to calculate the #ids etc.
|
11
|
+
#
|
12
|
+
# An Allocation is normally contained in an Allocations container.
|
7
13
|
#
|
8
|
-
class Allocation
|
14
|
+
class Allocation
|
9
15
|
|
10
16
|
attr_reader :count,
|
11
17
|
:score,
|
@@ -2,9 +2,17 @@ module Picky
|
|
2
2
|
|
3
3
|
module Query
|
4
4
|
|
5
|
-
# Container class for
|
5
|
+
# Container class for Allocation s.
|
6
6
|
#
|
7
|
-
class
|
7
|
+
# This class is asked by the Results class to
|
8
|
+
# compile and process a query.
|
9
|
+
# It then asks each Allocation to process their
|
10
|
+
# ids and scores.
|
11
|
+
#
|
12
|
+
# It also offers convenience methods to access #ids
|
13
|
+
# of its Allocation s.
|
14
|
+
#
|
15
|
+
class Allocations
|
8
16
|
|
9
17
|
delegate :each,
|
10
18
|
:empty?,
|
@@ -88,8 +96,11 @@ module Picky
|
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
91
|
-
# Same as #process! but
|
92
|
-
#
|
99
|
+
# Same as #process! but removes duplicate ids from results.
|
100
|
+
#
|
101
|
+
# Note that in the result later on an allocation won't be
|
102
|
+
# included if it contains no ids (even in case they have been
|
103
|
+
# eliminated by the unique constraint in this method).
|
93
104
|
#
|
94
105
|
# Note: Slower than #process! especially with large offsets.
|
95
106
|
#
|
@@ -2,16 +2,12 @@ module Picky
|
|
2
2
|
|
3
3
|
module Query
|
4
4
|
|
5
|
-
# Describes the
|
6
|
-
# the index (the bundle): [text, index_bundle]
|
5
|
+
# Describes the Combination of a Token (the text) and
|
6
|
+
# the index (the bundle): [text, index_bundle].
|
7
7
|
#
|
8
|
-
#
|
9
|
-
# [..., [text2, index_bundle2], ...]
|
8
|
+
# An Allocation consists of an ordered number of Combinations.
|
10
9
|
#
|
11
|
-
|
12
|
-
# [[text1, index_bundle1], [text2, index_bundle2], [text3, index_bundle1]]
|
13
|
-
#
|
14
|
-
class Combination # :nodoc:all
|
10
|
+
class Combination
|
15
11
|
|
16
12
|
attr_reader :token,
|
17
13
|
:category
|
@@ -74,7 +70,7 @@ module Picky
|
|
74
70
|
end
|
75
71
|
|
76
72
|
# Example:
|
77
|
-
#
|
73
|
+
# "exact title:Peter*:peter"
|
78
74
|
#
|
79
75
|
def to_s
|
80
76
|
"#{category.bundle_for(token).identifier}(#{to_result.join(':')})"
|
@@ -2,14 +2,15 @@ module Picky
|
|
2
2
|
|
3
3
|
module Query
|
4
4
|
|
5
|
-
# Combinations
|
5
|
+
# Combinations represent an ordered list of Combination s.
|
6
6
|
#
|
7
|
-
#
|
8
|
-
#
|
7
|
+
# Combinations contain methods for calculating score (including
|
8
|
+
# the boost) and ids for each of its Combination s.
|
9
|
+
#
|
10
|
+
# They are the core of an Allocation.
|
11
|
+
# An Allocation consists of a number of Combinations.
|
9
12
|
#
|
10
|
-
|
11
|
-
#
|
12
|
-
class Combinations # :nodoc:all
|
13
|
+
class Combinations
|
13
14
|
|
14
15
|
attr_reader :combinations
|
15
16
|
|
@@ -36,8 +37,8 @@ module Picky
|
|
36
37
|
# that are passed in, are removed.
|
37
38
|
#
|
38
39
|
# Note: This method is not totally independent of the calculate_ids one.
|
39
|
-
#
|
40
|
-
#
|
40
|
+
# Since identifiers are only nullified, we need to not include the
|
41
|
+
# ids that have an associated identifier that is nil.
|
41
42
|
#
|
42
43
|
def remove categories = []
|
43
44
|
@combinations.reject! { |combination| categories.include?(combination.category) }
|
@@ -14,13 +14,13 @@ module Picky
|
|
14
14
|
#
|
15
15
|
# Picky will raise a Query::Indexes::DifferentBackendsError.
|
16
16
|
#
|
17
|
-
def check_backends indexes
|
17
|
+
def check_backends indexes
|
18
18
|
backends = indexes.map &:backend
|
19
19
|
backends.uniq! &:class
|
20
20
|
raise_different backends if backends.size > 1
|
21
21
|
backends
|
22
22
|
end
|
23
|
-
def raise_different backends
|
23
|
+
def raise_different backends
|
24
24
|
raise DifferentBackendsError.new(backends)
|
25
25
|
end
|
26
26
|
|
@@ -31,7 +31,7 @@ module Picky
|
|
31
31
|
# Currently it isn't possible using Memory and Redis etc.
|
32
32
|
# indexes in the same query index group.
|
33
33
|
#
|
34
|
-
class DifferentBackendsError < StandardError
|
34
|
+
class DifferentBackendsError < StandardError
|
35
35
|
def initialize backends
|
36
36
|
@backends = backends
|
37
37
|
end
|
data/lib/picky/query/token.rb
CHANGED
data/lib/picky/query/tokens.rb
CHANGED
data/lib/picky/rack/harakiri.rb
CHANGED
data/lib/picky/search.rb
CHANGED
data/lib/picky/statistics.rb
CHANGED
data/lib/tasks/try.rb
CHANGED
@@ -13,6 +13,25 @@ describe Picky::Backends::Memory::JSON do
|
|
13
13
|
it "works with cyrillic characters" do
|
14
14
|
backend.dump_json key: 'й'
|
15
15
|
end
|
16
|
+
it "works with ascii strings" do
|
17
|
+
# See https://github.com/floere/picky/pull/69.
|
18
|
+
#
|
19
|
+
# Rails sets both encodings to UTF-8.
|
20
|
+
#
|
21
|
+
old_default_external = Encoding.default_external
|
22
|
+
old_default_internal = Encoding.default_internal
|
23
|
+
Encoding.default_external = 'UTF-8'
|
24
|
+
Encoding.default_internal = 'UTF-8'
|
25
|
+
|
26
|
+
ascii = "\xE5".force_encoding 'ASCII-8BIT'
|
27
|
+
# ascii.encode('UTF-8') # Uncomment this to get the error mentioned in the pull request.
|
28
|
+
backend.dump_json ascii => ascii # Pass in the string as both key and value
|
29
|
+
|
30
|
+
# Reset encodings.
|
31
|
+
#
|
32
|
+
Encoding.default_external = old_default_external
|
33
|
+
Encoding.default_internal = old_default_internal
|
34
|
+
end
|
16
35
|
end
|
17
36
|
|
18
37
|
end
|
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.4.
|
4
|
+
version: 4.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70255381661400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70255381661400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: picky-client
|
27
|
-
requirement: &
|
27
|
+
requirement: &70255381659920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.4.
|
32
|
+
version: 4.4.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70255381659920
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: text
|
38
|
-
requirement: &
|
38
|
+
requirement: &70255381674980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70255381674980
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yajl-ruby
|
49
|
-
requirement: &
|
49
|
+
requirement: &70255381674320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70255381674320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activesupport
|
60
|
-
requirement: &
|
60
|
+
requirement: &70255381673560 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70255381673560
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: procrastinate
|
71
|
-
requirement: &
|
71
|
+
requirement: &70255381672800 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.4'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70255381672800
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rack_fast_escape
|
82
|
-
requirement: &
|
82
|
+
requirement: &70255381672420 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70255381672420
|
91
91
|
description: Fast Ruby semantic text search engine with comfortable single field interface.
|
92
92
|
email: florian.hanke+picky@gmail.com
|
93
93
|
executables:
|
@@ -521,3 +521,4 @@ test_files:
|
|
521
521
|
- spec/lib/statistics_spec.rb
|
522
522
|
- spec/lib/tasks/try_spec.rb
|
523
523
|
- spec/lib/tokenizer_spec.rb
|
524
|
+
has_rdoc:
|