Class: Yast::HooksClass::HookFile
- Inherits:
-
Object
- Object
- Yast::HooksClass::HookFile
- Includes:
- Logger
- Defined in:
- library/general/src/modules/Hooks.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #content ⇒ Object
- #execute ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(path) ⇒ HookFile
constructor
A new instance of HookFile.
- #output ⇒ Object
- #succeeded? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ HookFile
Returns a new instance of HookFile.
207 208 209 |
# File 'library/general/src/modules/Hooks.rb', line 207 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
205 206 207 |
# File 'library/general/src/modules/Hooks.rb', line 205 def path @path end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
205 206 207 |
# File 'library/general/src/modules/Hooks.rb', line 205 def result @result end |
Instance Method Details
#content ⇒ Object
218 219 220 |
# File 'library/general/src/modules/Hooks.rb', line 218 def content @content ||= ::File.read(path) end |
#execute ⇒ Object
211 212 213 214 215 216 |
# File 'library/general/src/modules/Hooks.rb', line 211 def execute log.info "Executing hook file '#{path}'" @result = OpenStruct.new(SCR.Execute(Path.new(".target.bash_output"), path.to_s.shellescape)) log.error "Hook file '#{path.basename}' failed with stderr: #{result.stderr}" if failed? result end |
#failed? ⇒ Boolean
235 236 237 |
# File 'library/general/src/modules/Hooks.rb', line 235 def failed? !succeeded? end |
#output ⇒ Object
222 223 224 225 226 227 228 229 |
# File 'library/general/src/modules/Hooks.rb', line 222 def output return "" unless result output = [] output << "STDERR: #{result.stderr.strip}" unless result.stderr.empty? output << "STDOUT: #{result.stdout.strip}" unless result.stdout.empty? output.join("; ") end |
#succeeded? ⇒ Boolean
231 232 233 |
# File 'library/general/src/modules/Hooks.rb', line 231 def succeeded? result.exit.zero? end |