Class: LicenseAcceptance::PromptAcceptance
- Inherits:
-
Object
- Object
- LicenseAcceptance::PromptAcceptance
- Includes:
- Logger
- Defined in:
- lib/license_acceptance/prompt_acceptance.rb
Constant Summary collapse
- WIDTH =
50.freeze
- PASTEL =
Pastel.new
- BORDER =
"+---------------------------------------------+".freeze
- YES =
PASTEL.green.bold("yes")
- CHECK =
PASTEL.green("✔")
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(config) ⇒ PromptAcceptance
constructor
A new instance of PromptAcceptance.
- #request(missing_licenses, &persist_callback) ⇒ Object
Methods included from Logger
Constructor Details
#initialize(config) ⇒ PromptAcceptance
Returns a new instance of PromptAcceptance.
12 13 14 |
# File 'lib/license_acceptance/prompt_acceptance.rb', line 12 def initialize(config) @output = config.output end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
10 11 12 |
# File 'lib/license_acceptance/prompt_acceptance.rb', line 10 def output @output end |
Instance Method Details
#request(missing_licenses, &persist_callback) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/license_acceptance/prompt_acceptance.rb', line 22 def request(missing_licenses, &persist_callback) logger.debug("Requesting a license for #{missing_licenses.map(&:name)}") c = missing_licenses.size s = c > 1 ? "s": "" acceptance_question = "Do you accept the #{c} product license#{s} (#{YES}/no)?" output.puts <<~EOM #{BORDER} Chef License Acceptance Before you can continue, #{c} product license#{s} must be accepted. View the license at https://www.chef.io/end-user-license-agreement/ License#{s} that need accepting: * #{missing_licenses.map(&:pretty_name).join("\n * ")} #{acceptance_question} EOM if ask(output, c, s, persist_callback) output.puts BORDER return true end output.puts <<~EOM If you do not accept this license you will not be able to use Chef products. #{acceptance_question} EOM answer = ask(output, c, s, persist_callback) if answer != "yes" output.puts BORDER end return answer end |