Module: Puppet::Module::Tool::Utils::Interrogation
- Included in:
- Applications::Application, Repository
- Defined in:
- lib/puppet/module/tool/utils/interrogation.rb
Overview
Interrogation
This module contains methods to emit text to the console, such as headers.
Instance Method Summary collapse
- #confirms?(question) ⇒ Boolean
- #header(text) ⇒ Object
- #prompt(question, quiet = false) ⇒ Object
- #say(*args) ⇒ Object
- #subheader(line) ⇒ Object
Instance Method Details
#confirms?(question) ⇒ Boolean
21 22 23 24 |
# File 'lib/puppet/module/tool/utils/interrogation.rb', line 21 def confirms?(question) $stderr.print "#{question} [y/N]: " $stdin.gets =~ /y/i end |
#header(text) ⇒ Object
9 10 11 |
# File 'lib/puppet/module/tool/utils/interrogation.rb', line 9 def header(text) $stderr.puts('=' * text.size, text, "-" * text.size) end |
#prompt(question, quiet = false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/module/tool/utils/interrogation.rb', line 26 def prompt(question, quiet = false) $stderr.print "#{question}: " system 'stty -echo' if quiet $stdin.gets.strip ensure if quiet system 'stty echo' say "\n---------" end end |
#say(*args) ⇒ Object
13 14 15 |
# File 'lib/puppet/module/tool/utils/interrogation.rb', line 13 def say(*args) $stderr.puts(*args) end |
#subheader(line) ⇒ Object
17 18 19 |
# File 'lib/puppet/module/tool/utils/interrogation.rb', line 17 def subheader(line) say line, ('-' * line.size) end |