Class: Installation::ProposalClient
- Inherits:
-
Yast::Client
- Object
- Yast::Client
- Installation::ProposalClient
- Includes:
- Yast::Logger
- Defined in:
- library/general/src/lib/installation/proposal_client.rb
Overview
Abstract class that simplifies writing proposal clients for installation. It provides a single entry point which dispatches calls to the abstract methods that all proposal clients need to implement.
It is recommended to use ProposalClient as base class for new clients.
API for YaST2 installation proposal
Motivation
After five releases, YaST2 is now smart enough to make reasonable proposals for (nearly) every installation setting, thus it is no longer necessary to ask the user that many questions during installation: Most users simply hit the [next] button anyway.
Hence, YaST2 now collects all the individual proposals from its submodules and presents them for confirmation right away. The user can change each individual setting, but he is no longer required to go through all the steps just to change some simple things. The only that (currently) really has to be queried is the installation language - this cannot reasonably be guessed (yet?).
Overview
YaST2 installation modules should cooperate with the main program in a consistent API. General usage:
inst_proposal (main program) creates an empty dialog with RichText widget
inst_proposal calls each sub-module in turn to make a proposal
the user may choose to change individual settings (by clicking on a hyperlink)
inst_proposal starts that module's sub-workflow which runs independently. After this, inst_proposal tells all subsequent (all?) modules to check their states and return whether a change of their proposal is necessary after the user interaction.
main program calls each sub-module to write the settings to the system
The Write
method
In addition to the methods defined (and documented) in
ProposalClient, there's a method called Write
which will
write the proposed (and probably modified) settings to the system.
It is up to the proposal dispatcher how it remembers the settings. The errors must be reported using the Report:: module to have the possibility to control the behaviour from the main program.
This Write
method is optional. The dispatcher module is required to allow
this method to be called without returning an error value if it is not
there.
Return Values
Returns true, if the settings were written successfully.
Class Method Summary collapse
-
.run ⇒ Object
The entry point for calling a client.
Instance Method Summary collapse
-
#ask_user(_attrs) ⇒ Hash
protected
An abstract method to run an interactive workflow -- let the user decide upon values he might want to change.
-
#description ⇒ Hash
protected
An abstract method to return human readable titles both for the RichText (HTML) widget and for menu entries.
-
#make_proposal(_attrs) ⇒ Hash
protected
Abstract method to create proposal suggestion for installation.
-
#run ⇒ Object
Dispatches to abstract method based on passed Arguments to client.
- #write ⇒ Object protected
Class Method Details
.run ⇒ Object
The entry point for calling a client. The only part needed in client rb file.
75 76 77 |
# File 'library/general/src/lib/installation/proposal_client.rb', line 75 def self.run new.run end |
Instance Method Details
#ask_user(_attrs) ⇒ Hash (protected)
An abstract method to run an interactive workflow -- let the user decide upon values he might want to change.
It may contain one single dialog, a sequence of dialogs, or one master dialog with one or more "expert" dialogs. It can also be a non-interactive response to clicking on a hyperlink. The module is responsible for controlling the workflow sequence (i.e., "Next", "Back" buttons etc.).
Submodules do not provide an "Abort" button to abort the entire installation. If the user wishes to do that, he can always go back to the main dialog (the installation proposal) and choose "Abort" there.
245 246 247 |
# File 'library/general/src/lib/installation/proposal_client.rb', line 245 def ask_user(_attrs) raise NotImplementedError, "Calling abstract method 'ask_user'" end |
#description ⇒ Hash (protected)
An abstract method to return human readable titles both for the RichText (HTML) widget and for menu entries. It also specifies an ID which is used when the user selects the module.
283 284 285 |
# File 'library/general/src/lib/installation/proposal_client.rb', line 283 def description raise NotImplementedError, "Calling abstract method 'description'" end |
#make_proposal(_attrs) ⇒ Hash (protected)
Abstract method to create proposal suggestion for installation
193 194 195 |
# File 'library/general/src/lib/installation/proposal_client.rb', line 193 def make_proposal(_attrs) raise NotImplementedError, "Calling abstract method 'make_proposal'" end |
#run ⇒ Object
Dispatches to abstract method based on passed Arguments to client
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'library/general/src/lib/installation/proposal_client.rb', line 80 def run func, param = Yast::WFM.Args log.info "Called #{self.class}.run with #{func} and params #{param}" case func when "MakeProposal" make_proposal(param) when "AskUser" ask_user(param) when "Description" description when "Write" write else raise ArgumentError, "Invalid action for proposal '#{func.inspect}'" end end |
#write ⇒ Object (protected)
287 288 289 |
# File 'library/general/src/lib/installation/proposal_client.rb', line 287 def write # doing nothing is OK. or is it? clarify the API, the docs, actual usage! end |