autocompletion 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "autocompletion"
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
  s.authors = "Stefan Rusterholz"
7
7
  s.email = "stefan.rusterholz@gmail.com"
8
8
  s.homepage = "http://github.com/apeiros/autocompletion"
@@ -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.flat_map { |entity|
72
- [key, yield(entity)]
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
@@ -9,5 +9,5 @@ end
9
9
  class AutoCompletion
10
10
 
11
11
  # The version of the gem
12
- Version = Gem::Version.new("0.0.2")
12
+ Version = Gem::Version.new("0.0.3")
13
13
  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: 2012-08-08 00:00:00.000000000 Z
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: