interact 0.4.6 → 0.4.7

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.
@@ -245,9 +245,17 @@ module Interactive
245
245
  [true, options[:default]]
246
246
  end
247
247
  elsif choices = options[:choices]
248
- matches = choices.select { |x|
249
- choice_completion(x, options).start_with? ans
250
- }
248
+ matches = []
249
+
250
+ choices.each do |x|
251
+ completion = choice_completion(x, options)
252
+
253
+ if completion == ans
254
+ return [true, x]
255
+ elsif completion.start_with? ans
256
+ matches << ans
257
+ end
258
+ end
251
259
 
252
260
  if choices and ans =~ /^\s*\d+\s*$/ and \
253
261
  ans.to_i - 1 >= 0 and res = choices.to_a[ans.to_i - 1]
@@ -469,7 +477,14 @@ module Interactive
469
477
  end
470
478
 
471
479
  def chr(x)
472
- x && x.chr
480
+ case x
481
+ when nil
482
+ nil
483
+ when String
484
+ x
485
+ else
486
+ x.chr
487
+ end
473
488
  end
474
489
 
475
490
  private :chr
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2011 Alex Suraci
2
2
 
3
3
  module Interact
4
- VERSION = "0.4.6"
4
+ VERSION = "0.4.7"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interact
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 6
10
- version: 0.4.6
9
+ - 7
10
+ version: 0.4.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-25 00:00:00 Z
18
+ date: 2012-08-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements: []
93
93
 
94
94
  rubyforge_project:
95
- rubygems_version: 1.8.23
95
+ rubygems_version: 1.8.24
96
96
  signing_key:
97
97
  specification_version: 3
98
98
  summary: A simple API for command-line interaction.