Top Level Namespace
Defined Under Namespace
Modules: CFA, CWM, Firewalld, Installation, Packages, UI, Y2Firewall, Y2Issues, Y2Packager, Yast, Yast2
Instance Method Summary collapse
Instance Method Details
#expect_to_show_popup_which_return(output) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'library/general/src/lib/yast2/popup_rspec.rb', line 7 def expect_to_show_popup_which_return(output) expect(Yast2::Popup).to receive(:show).and_call_original allow(Yast::UI).to receive(:OpenDialog).and_return true allow(Yast::UI).to receive(:CloseDialog) allow(Yast::UI).to receive(:SetFocus).and_return true allow(Yast::UI).to receive(:UserInput).and_return output allow(Yast::UI).to receive(:TimeoutUserInput).and_return output end |
#shellwords ⇒ Object
Description
Main goal of hooks is to execute a third party code within the workflow of installation, system update or some other process. Hook files must be executable files written in bash, ruby or anything else available in inst-sys environment.
The module provides method #run which creates a hook and executes it instantly.
This includes following actions:
- adding the hook into the hooks collection - every hook is identified by unique name which should be self-descriptive
- looking up the files matching the hook script pattern: hook_name_[0-9][0-9]_*
- executing the identified hook files
- storing the results returned by the scripts for further inspection later if needed; this might be useful if some of the files has failed and we want to show it the user.
If a hook script returns non-zero result, the whole hook is considered as failed. By default the hooks are searched for in /var/lib/YaST2/hooks directory. This path can be modified globally for all hooks before they get called.
Example
- using a hook within a yast client
module Yast import 'Hooks'
class MyFavoriteClient < Client
def main
# this will change the search path to /var/lib/YaST2/hooks/personal
Hooks.search_path.join!('personal')
# and this will set a completely different path
Hooks.search_path.set "/root/hooks"
hook = Hooks.run 'before_showing_ui'
# Lot of beautiful and useful code follows here.
# If needed make use of:
# * hook.failed?
# * hook.succeeded?
# * hook.name
# * hook.results
# * hook.files
# * hook.search_path
# * Hooks.last.failed?
# * Hooks.last.succeeded?
# * Hooks.last.name
# * Hooks.last.search_path
# * Hooks.last.results
# * Hooks.last.files
Hooks.run 'after_showing_ui'
# reset the search path if needed
Hooks.search_path.reset
end
end
end
60 |
# File 'library/general/src/modules/Hooks.rb', line 60 require "shellwords" |