-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
151 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2015 SUSE LLC | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as published by the | ||
# Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# ------------------------------------------------------------------------------ | ||
# | ||
|
||
require "yast" | ||
|
||
module Registration | ||
module UI | ||
# The base class for several clients using the Wizard module | ||
# with exception handling. | ||
class WizardClient | ||
include Yast::I18n | ||
include Yast::Logger | ||
|
||
Yast.import "Wizard" | ||
Yast.import "Report" | ||
|
||
def initialize | ||
textdomain "registration" | ||
end | ||
|
||
# Run the main workflow, opens a Wizard dialog if not present | ||
# and handles raised exceptions | ||
# @return [Symbol] resulting workflow symbol (:next, :abort, ...) | ||
def main | ||
# create the Wizard dialog if needed | ||
wizard_present = Yast::Wizard.IsWizardDialog | ||
Yast::Wizard.CreateDialog unless wizard_present | ||
|
||
begin | ||
run | ||
ensure | ||
Yast::Wizard.CloseDialog unless wizard_present | ||
end | ||
end | ||
|
||
# Run the main workflow, handles exceptions raised during the client call. | ||
# @return [Symbol] resulting workflow symbol (:next, :abort, ...), :abort | ||
# is returned when an exception is raised. | ||
def run | ||
ret = run_sequence | ||
log.info "Sequence result: #{ret}" | ||
ret | ||
rescue => e | ||
log.error "Caught error: #{e.class}: #{e.message.inspect}, #{e.backtrace}" | ||
# TRANSLATORS: error message, %s are details | ||
Yast::Report.Error(_("Internal error: %s") % e.message) | ||
return :abort | ||
end | ||
|
||
# This is main workflow sequence, it needs to be redefined in the derived class. | ||
# @return [Symbol] resulting workflow symbol (:next, :abort, ...) | ||
def run_sequence | ||
raise NotImplementedError, "method run_sequence() must be defined in the derived class" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
2766e32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, nice refactoring :)
2766e32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, CodeClimate complained about the code duplication quite a lot so I was kind of forced to improve it... 😉