console-glitter 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/lib/console-glitter/version.rb +1 -1
- data/lib/console-glitter.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baf523bf1aeebc54f79df59d20d85caf0562e5a3
|
4
|
+
data.tar.gz: 519b75adaec42c3ac17b6d51a48998e50944a8cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b95ffb8053587a36bfb8f7924beafe4b6684ace0886ad7e42e712d45cfc4a056ebb79c6c87f8fa2e9c8bdc42d0504d50ef664b713942251baf038fd73dbc0cb8
|
7
|
+
data.tar.gz: 8b7e398bf8389fecf839b885d67fb13128abb153a6a4f7afb298d542c3b67808ab17f5cd43f80bc217fc59a0b00b172915b9dba48906c20ac3d60d736c94ffb9
|
data/lib/console-glitter.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'console-glitter/version'
|
2
2
|
require 'console-glitter/ansi'
|
3
|
+
require 'io/console'
|
3
4
|
|
4
5
|
module ConsoleGlitter
|
5
6
|
module UI extend self
|
@@ -61,6 +62,33 @@ module ConsoleGlitter
|
|
61
62
|
/^n/i.match(prompt(question, args)).nil?
|
62
63
|
end
|
63
64
|
|
65
|
+
# Public: Wrap Console#prompt, disabling local echo of user input.
|
66
|
+
#
|
67
|
+
# question - Query to be presented to the user.
|
68
|
+
# options - Hash containing arguments defining acceptable responses.
|
69
|
+
# (default: {}):
|
70
|
+
# :default_answer - String containing the default answer. If
|
71
|
+
# this is nil, a non-empty answer MUST be
|
72
|
+
# given.
|
73
|
+
# :allow_empty - Whether or not to allow empty responses.
|
74
|
+
# Unless explicitly allowed, empty answers
|
75
|
+
# will be rejected.
|
76
|
+
# :valid_answers - An Array containing all valid responses. If
|
77
|
+
# this is empty, any answer will be accepted
|
78
|
+
# (unless empty answers are disallowed as
|
79
|
+
# specified above). Valid responses may be
|
80
|
+
# any class with a match method such as
|
81
|
+
# Strings or Regexps.
|
82
|
+
#
|
83
|
+
# Returns a String containing the answer provided by the user.
|
84
|
+
def secure_prompt(question, args = {})
|
85
|
+
IO.console.echo = false
|
86
|
+
prompt(question, args)
|
87
|
+
ensure
|
88
|
+
IO.console.echo = true
|
89
|
+
puts
|
90
|
+
end
|
91
|
+
|
64
92
|
# Public: Render a "spinner" on the command line and yield to a block,
|
65
93
|
# reporting success if nothing is raised, or else reporting failure.
|
66
94
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: console-glitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wuest
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Tools for building nice looking CLI applications
|
14
14
|
email: chris@chriswuest.com
|