Class: Panacea::Rails::Customizer
- Inherits:
-
Object
- Object
- Panacea::Rails::Customizer
- Defined in:
- lib/panacea/rails/customizer.rb
Overview
Panacea::Rails::Customizer
This class is in charge of asking the configuration questions. It saves the answers on the .panacea file.
Constant Summary collapse
- WELCOME_MESSAGE =
ASCII art displayed at the start of the Panacea command
" _____________________________\n| ..... // |\n| _d^^^^^^^^^b_ // |\n| .d'' `` |\n| .p' /|\n| .d' .//| Welcome to Panacea!\n| .d' ----------- - `b. | You are about to boost your fresh\n| :: --------------------- :: | %{app_name} Rails App\n| :: --- P A N A C E A --- :: |\n| :: --------------------- :: | Full documentation here: https://panacea.website\n| `p. ------------------- .q' | Most of the defaults are false or disabled,\n| `p. ----------------- .q' | if you want to enable a feature please answer yes\n| `b. --------------- .d' |\n| `q.. -------- ..p' |\n| ^q........p^ |\n|____________''''_____________|\n\n"
Instance Attribute Summary collapse
-
#answers ⇒ Object
readonly
A Hash where each question’s answer is stored.
-
#app_name ⇒ Object
readonly
App’s name.
-
#passed_args ⇒ Object
readonly
A String with the arguments passed to the Panacea command.
-
#prompt ⇒ Object
readonly
A TTY::Prompt instance.
-
#questions ⇒ Object
readonly
A Hash with the questions loaded from config/questions.yaml file.
Class Method Summary collapse
-
.start(app_name, passed_args) ⇒ Object
This method receives the App’s name and the passed arguments.
Instance Method Summary collapse
-
#initialize(app_name, passed_args, prompt: TTY::Prompt.new) ⇒ Customizer
constructor
Panacea::Rails::Customizer initialize method.
-
#start ⇒ Object
This method shows the Welcome message.
Constructor Details
#initialize(app_name, passed_args, prompt: TTY::Prompt.new) ⇒ Customizer
Panacea::Rails::Customizer initialize method
A TTY::Prompt instance is used as default prompt.
73 74 75 76 77 78 |
# File 'lib/panacea/rails/customizer.rb', line 73 def initialize(app_name, passed_args, prompt: TTY::Prompt.new) @app_name = app_name @passed_args = passed_args @answers = {} @prompt = prompt end |
Instance Attribute Details
#answers ⇒ Object (readonly)
A Hash where each question’s answer is stored
59 60 61 |
# File 'lib/panacea/rails/customizer.rb', line 59 def answers @answers end |
#app_name ⇒ Object (readonly)
App’s name
63 64 65 |
# File 'lib/panacea/rails/customizer.rb', line 63 def app_name @app_name end |
#passed_args ⇒ Object (readonly)
A String with the arguments passed to the Panacea command
67 68 69 |
# File 'lib/panacea/rails/customizer.rb', line 67 def passed_args @passed_args end |
#prompt ⇒ Object (readonly)
A TTY::Prompt instance
55 56 57 |
# File 'lib/panacea/rails/customizer.rb', line 55 def prompt @prompt end |
#questions ⇒ Object (readonly)
A Hash with the questions loaded from config/questions.yaml file
51 52 53 |
# File 'lib/panacea/rails/customizer.rb', line 51 def questions @questions end |
Class Method Details
.start(app_name, passed_args) ⇒ Object
This method receives the App’s name and the passed arguments.
It creates a new instance of Panacea::Rails::Customizer class and executes the start instance method.
45 46 47 |
# File 'lib/panacea/rails/customizer.rb', line 45 def self.start(app_name, passed_args) new(app_name, passed_args).start end |
Instance Method Details
#start ⇒ Object
This method shows the Welcome message. Then, it ask the questions using the default prompt. It also tracks the answers only if the end user agrees to. At the end, it saves the answers to the .panacea file.
85 86 87 88 89 |
# File 'lib/panacea/rails/customizer.rb', line 85 def start ask_questions save_answers end |