interactive 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c5985a7b36fdd03220b5d270bef623f756f7f0e
4
- data.tar.gz: 1db22d825eb561d7b13ac8f6038ed1f1fea1d977
3
+ metadata.gz: 68405e68b34a2a1d43f70b6957183eb97519e957
4
+ data.tar.gz: 9270c9246a10516500f8803527926ceefcf73523
5
5
  SHA512:
6
- metadata.gz: 33c531c769d32f7a8f9389be7c293d4a710347ff77873acd69c931f262d2c1139b465b00bce77df53f7539ddd63955279f2fbf8b206a3a4c6bec584ccf0aac7d
7
- data.tar.gz: 861e424023ff7546866a2c00469389ffac5a1a7325f305fe2fa479209ceb5db082acd5c18ddc24b24c6ed0e1b47e39800fabd556962c7fe79d0b93067b482c13
6
+ metadata.gz: aae4aef8c2ce8731857bd00e6e9e22eb05b4dc075ad89867cb3f9cd407220086adcc609027321f7da6b1baad7a1c2e7848ce504926293d36d36ed88f2aa1f5c9
7
+ data.tar.gz: e5883dbdeedd0e0aaf75ede9a0646e4488f43d1ab3ac38ce531e2b63c4a599b4de6afaba8b78eed4c356e6c9e7e0284d94262fd7675a335149f79427fd7d7324
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,11 @@
1
+ v0.6.2 -- Sun Jun 28 22:57:18 EDT 2015
2
+ --------------------------------------
3
+ - Display condensed version of indices as a range.
4
+
5
+ v0.6.1 -- Sun Jun 28 22:57:18 EDT 2015
6
+ --------------------------------------
7
+ - pegged gem in runtime dependency because automatic update broke
8
+
1
9
  v0.6.0 -- Sat Mar 28 22:32:12 EDT 2015
2
10
  --------------------------------------
3
11
  - added support for displaying tabular data
data/lib/interactive.rb CHANGED
@@ -7,4 +7,5 @@ require "interactive/question_with_eager_full_explanation"
7
7
  require "interactive/question_with_lazy_full_explanation"
8
8
  require 'interactive/question'
9
9
  require 'interactive/response'
10
+ require 'interactive/options_shortcuts'
10
11
 
@@ -23,7 +23,7 @@ module Interactive
23
23
  end
24
24
 
25
25
  def shortcuts_string
26
- "[#{first_chars_without_last_slash(first_chars)}]"
26
+ "[#{OptionsShortcuts.new(first_chars_without_last_slash(first_chars)).minify}]"
27
27
  end
28
28
 
29
29
  def shortcuts_meanings
@@ -0,0 +1,39 @@
1
+ module Interactive
2
+ class OptionsShortcuts
3
+ def initialize(minifiable_string)
4
+ @minifiable_string = minifiable_string
5
+ end
6
+
7
+ def minify
8
+ if has_only_one_number_or_none?
9
+ @minifiable_string
10
+ else
11
+ non_numerical_options.inject("#{numerical_options.min}..#{numerical_options.max}") do |accum, item|
12
+ "#{accum}/#{item}"
13
+ end
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def has_only_one_number_or_none?
20
+ numerical_options.min == numerical_options.max
21
+ end
22
+
23
+ def numerical_options
24
+ options.select {|option| numeric?(option)}
25
+ end
26
+
27
+ def non_numerical_options
28
+ options.reject {|option| numeric?(option)}
29
+ end
30
+
31
+ def options
32
+ @minifiable_string.split("/")
33
+ end
34
+
35
+ def numeric?(option)
36
+ option.match(/^\d+$/)
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Interactive
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edderic Ugaddan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-27 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -102,6 +102,7 @@ files:
102
102
  - lib/interactive.rb
103
103
  - lib/interactive/option.rb
104
104
  - lib/interactive/options.rb
105
+ - lib/interactive/options_shortcuts.rb
105
106
  - lib/interactive/question.rb
106
107
  - lib/interactive/question_with_eager_full_explanation.rb
107
108
  - lib/interactive/question_with_lazy_full_explanation.rb