diff --git a/library/general/src/Makefile.am b/library/general/src/Makefile.am index 9cdeab00d..31908dc64 100644 --- a/library/general/src/Makefile.am +++ b/library/general/src/Makefile.am @@ -83,8 +83,9 @@ fillup_DATA = \ ylibdir = "${yast2dir}/lib/installation" ylib_DATA = \ + lib/installation/finish_client.rb \ lib/installation/proposal_client.rb -EXTRA_DIST = $(module_DATA) $(client_DATA) $(scrconf_DATA) $(agent_SCRIPTS) $(ydata_DATA) $(fillup_DATA) +EXTRA_DIST = $(module_DATA) $(client_DATA) $(scrconf_DATA) $(agent_SCRIPTS) $(ydata_DATA) $(fillup_DATA) $(ylib_DATA) include $(top_srcdir)/Makefile.am.common diff --git a/library/general/src/lib/installation/finish_client.rb b/library/general/src/lib/installation/finish_client.rb new file mode 100644 index 000000000..cfccb898e --- /dev/null +++ b/library/general/src/lib/installation/finish_client.rb @@ -0,0 +1,50 @@ +require "yast" + +module Installation + # Abstract class that simplify writting finish clients for installation. + # It provides single entry point and abstract methods, that all finish clients + # need to implement. + # @example how to run client + # require "installation/example_finish" + # ::Installation::ExampleFinish.run + # @see for example client in installation clone_finish.rb + # @see inst_finish in yast2-installation doc to get overview of finish client API + class FinishClient < Client + include Yast::Logger + + # Entry point for calling client. Only part needed in client rb file. + # @return response from abstract methods + def self.run + self.new.run + end + + # Dispatches to abstract method based on passed arguments to client + def run + func = Yast::WFM.Args + case func + when "Info" + info + when "Write" + write + else + raise "Invalid action for proposal '#{func.inspect}'" + end + end + + protected + + # Abstract method to write configuration + def write + raise NotImplementedError, "Calling abstract method 'write'" + end + + # Abstract method to provide information about client + # @return [Map] with keys "steps" which specify number of client steps, + # "when" with list of symbols for modes when client make sense, if missing, + # then run always. And last but not least is tittle which is used to display + # to user what happening. + def info + raise NotImplementedError, "Calling abstract method 'info'" + end + end +end