Class: Installation::ProposalClient

Inherits:
Yast::Client
  • Object
show all
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.

Examples:

how to run a client

require "installation/example_proposal"
::Installation::ExampleProposal.run

See Also:

  • example client in installation clone_proposal.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject

The entry point for calling a client. The only part needed in client rb file.

Returns:

  • response from abstract methods



75
76
77
# File 'library/general/src/lib/installation/proposal_client.rb', line 75

def self.run
  new.run
end

Instance Method Details

#runObject

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