inquirer 0.2.0 → 0.2.1

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: 97119771a6f5d25b26a8c9e46d21833da7916364
4
- data.tar.gz: 85d97425f2efb04f5a1cbd9b7029d0c1f41b1fe2
3
+ metadata.gz: a3d7a97ff5d3ab9355d65e7be7f140478d9752c8
4
+ data.tar.gz: 714ef7abaabd98595d5bbd9574782e48b1193e15
5
5
  SHA512:
6
- metadata.gz: 8322479e68acb817daa91c465302a45e35ea2798386ba367f948ebd93dbd22ef7be33bf6410ff21e0fc82d5cd33d7b0e8ef07f57a54b49aed71859b6886ec3c0
7
- data.tar.gz: 60ae3b63e8ebd9738b755d485294605c751979102026d0cd0e976c25a7989b2c41ee6c26ea0a1598891b0f2e743e3248286486c43a1be6875826fa502d16a276
6
+ metadata.gz: 5273d406e7fa38e80300294b377b2598662025839aba81f8c3b49410f9c25216e49a51e7955ab281220929f5979a649bdf4bdff6c1c869714ccd7498530e21c7
7
+ data.tar.gz: dc8f42e2146fffd949563c580627907f6e3d84586ef8ee28d545acbeffa20e00135d1f3032fdeadfc8a2e69a96876d1f804b1d87a213018ba78394d0575ccafd
@@ -3,5 +3,6 @@ script: "bundle exec rake"
3
3
  rvm:
4
4
  - "1.9.3"
5
5
  - "2.0.0"
6
- - "rbx-2.1.1"
7
- - "rbx-2.2.1"
6
+ - "2.1.0"
7
+ - "2.2.0"
8
+ - "rbx-2.5"
@@ -1,3 +1,9 @@
1
+ ## 0.2.1
2
+
3
+ * feature: add configurable defaults to checkboxes
4
+ * feature: add Ruby MRI 2.1+2.2, Rubinius 2.5 support
5
+ discontinue Rubinius 2.1+2.2
6
+
1
7
  ## 0.2.0
2
8
 
3
9
  * feature: add user input prompt with support for default values
data/README.md CHANGED
@@ -21,12 +21,14 @@ idx = Ask.list "Look behind you...", [
21
21
 
22
22
  ### Checkbox
23
23
 
24
+ Takes optional `default` property that define the checked options
25
+
24
26
  ```ruby
25
27
  idx = Ask.checkbox "Monkey see, monkey...", [
26
28
  "don't",
27
29
  "eats Banana",
28
30
  "do"
29
- ]
31
+ ], default: [true, false, true]
30
32
  # idx is an array containing the selections
31
33
  ```
32
34
 
@@ -89,9 +91,10 @@ Ask.input "What's your name", clear: false, response: false
89
91
  | Ruby | Linux | OS X | Windows |
90
92
  |----------------|:-----:|:----:|:-------:|
91
93
  | MRI 1.9.3 | ✔ | ✔ | ✘ |
92
- | MRI 2.0.0 | ✔ | ✔ | ✘ |
93
- | Rubinius 2.1.1 | ✔ | ✔ | ✘ |
94
- | Rubinius 2.2.1 | ✔ | ✔ | ✘ |
94
+ | MRI 2.0.x | ✔ | ✔ | ✘ |
95
+ | MRI 2.1.x | ✔ | ✔ | ✘ |
96
+ | MRI 2.2.x | ✔ | ✔ | ✘ |
97
+ | Rubinius 2.5.x | ✔ | ✔ | ✘ |
95
98
  | JRuby 1.7.x | ✘ | ✘ | ✘ |
96
99
 
97
100
  ## Contributors
@@ -58,11 +58,11 @@ class CheckboxResponseDefault
58
58
  end
59
59
 
60
60
  class Checkbox
61
- def initialize question = nil, elements = [], renderer = nil, responseRenderer = nil
61
+ def initialize question = nil, elements = [], default = nil, renderer = nil, responseRenderer = nil
62
62
  @elements = elements
63
63
  @question = question
64
64
  @pos = 0
65
- @active = elements.map{|i| false}
65
+ @active = default || elements.map{|i| false}
66
66
  @prompt = ""
67
67
  @renderer = renderer || CheckboxDefault.new( Inquirer::Style::Default )
68
68
  @responseRenderer = responseRenderer = CheckboxResponseDefault.new()
@@ -128,7 +128,7 @@ class Checkbox
128
128
  end
129
129
 
130
130
  def self.ask question = nil, elements = [], opts = {}
131
- l = Checkbox.new question, elements, opts[:renderer], opts[:rendererResponse]
131
+ l = Checkbox.new question, elements, opts[:default], opts[:renderer], opts[:rendererResponse]
132
132
  l.run opts.fetch(:clear, true), opts.fetch(:response, true)
133
133
  end
134
134
 
@@ -1,3 +1,3 @@
1
1
  module Inquirer
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -22,12 +22,23 @@ describe Checkbox do
22
22
  IOHelper.output.must_equal "select:\n\e[36m‣\e[0m⬡ one\n ⬡ two\n ⬡ three\n"
23
23
  end
24
24
 
25
+ it "renders the dialog with 3 items with defaults" do
26
+ Checkbox.ask "select", ["one","two","three"], default: [true, false, true], clear: false, response: false
27
+ IOHelper.output.must_equal "select:\n\e[36m‣\e[0m\e[36m⬢\e[0m one\n ⬡ two\n \e[36m⬢\e[0m three\n"
28
+ end
29
+
25
30
  it "it finishes selection on pressing enter" do
26
31
  IOHelper.keys = "enter"
27
32
  Checkbox.ask( "select", ["one","two","three"], clear: false, response: false
28
33
  ).must_equal [false,false,false]
29
34
  end
30
35
 
36
+ it "it finishes selection on pressing enter with defaults" do
37
+ IOHelper.keys = "enter"
38
+ Checkbox.ask( "select", ["one","two","three"], default: [true, false, true], clear: false, response: false
39
+ ).must_equal [true,false,true]
40
+ end
41
+
31
42
  it "selects and renders other items correctly (press down, press up, space, cycle)" do
32
43
  IOHelper.keys = ["down","space","enter"]
33
44
  Checkbox.ask( "select", ["one","two","three"], clear: false, response: false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inquirer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.2.0
81
+ rubygems_version: 2.4.5
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Interactive user prompts on CLI for ruby.