Skip to content

Commit

Permalink
add finish client
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 20, 2014
1 parent 137e529 commit b03232e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/general/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
50 changes: 50 additions & 0 deletions library/general/src/lib/installation/finish_client.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b03232e

Please sign in to comment.