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 +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +6 -0
- data/README.md +7 -4
- data/lib/inquirer/prompts/checkbox.rb +3 -3
- data/lib/inquirer/version.rb +1 -1
- data/test/classes/checkbox_spec.rb +11 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3d7a97ff5d3ab9355d65e7be7f140478d9752c8
|
4
|
+
data.tar.gz: 714ef7abaabd98595d5bbd9574782e48b1193e15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5273d406e7fa38e80300294b377b2598662025839aba81f8c3b49410f9c25216e49a51e7955ab281220929f5979a649bdf4bdff6c1c869714ccd7498530e21c7
|
7
|
+
data.tar.gz: dc8f42e2146fffd949563c580627907f6e3d84586ef8ee28d545acbeffa20e00135d1f3032fdeadfc8a2e69a96876d1f804b1d87a213018ba78394d0575ccafd
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
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.
|
93
|
-
|
|
94
|
-
|
|
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
|
|
data/lib/inquirer/version.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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.
|