autocompletion 0.0.2 → 0.0.3
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/autocompletion.gemspec +1 -1
- data/lib/autocompletion.rb +16 -4
- data/lib/autocompletion/version.rb +1 -1
- metadata +2 -3
data/autocompletion.gemspec
CHANGED
data/lib/autocompletion.rb
CHANGED
@@ -65,11 +65,11 @@ class AutoCompletion
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# @return [AutoCompletion]
|
68
|
-
# Map a list of entities to one its attributes.
|
68
|
+
# Map a list of entities to one of its attributes.
|
69
69
|
# The block should return string which can be prefix-searched.
|
70
70
|
def self.map_key(entities)
|
71
|
-
mapped = entities.
|
72
|
-
[
|
71
|
+
mapped = entities.map { |entity|
|
72
|
+
[yield(entity), entity]
|
73
73
|
}
|
74
74
|
|
75
75
|
unordered_tuples(mapped)
|
@@ -144,7 +144,7 @@ class AutoCompletion
|
|
144
144
|
# Returns an array of distinct entities matching the given prefixes.
|
145
145
|
def complete(*prefixes)
|
146
146
|
# short-cut
|
147
|
-
return [] if empty? || prefixes.any? { |word|
|
147
|
+
return [] if empty? || prefixes.empty? || prefixes.any? { |word|
|
148
148
|
word < @entities.first[0,word.size] || word > @entities[-2][0,word.size]
|
149
149
|
}
|
150
150
|
|
@@ -215,4 +215,16 @@ class AutoCompletion
|
|
215
215
|
|
216
216
|
return (final_left<<1)..((final_right<<1)+1)
|
217
217
|
end
|
218
|
+
|
219
|
+
# @private
|
220
|
+
# @see Object#inspect
|
221
|
+
def inspect
|
222
|
+
sprintf "\#<%s:%x size: %d, unique: %d, %p..%p>",
|
223
|
+
self.class,
|
224
|
+
object_id>>1,
|
225
|
+
size,
|
226
|
+
count_distinct_prefixes,
|
227
|
+
@entities[0],
|
228
|
+
@entities[-2]
|
229
|
+
end
|
218
230
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autocompletion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Stefan Rusterholz
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This gem provides fast prefix-autocompletion in pure ruby.
|
15
15
|
email: stefan.rusterholz@gmail.com
|
@@ -47,4 +47,3 @@ signing_key:
|
|
47
47
|
specification_version: 3
|
48
48
|
summary: Fast prefix-autocompletion in pure ruby.
|
49
49
|
test_files: []
|
50
|
-
has_rdoc:
|