Class: Yast::HooksClass::HookFile

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
library/general/src/modules/Hooks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ HookFile



202
203
204
# File 'library/general/src/modules/Hooks.rb', line 202

def initialize(path)
  @path = path
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content



200
201
202
# File 'library/general/src/modules/Hooks.rb', line 200

def content
  @content
end

#pathObject (readonly)

Returns the value of attribute path



200
201
202
# File 'library/general/src/modules/Hooks.rb', line 200

def path
  @path
end

#resultObject (readonly)

Returns the value of attribute result



200
201
202
# File 'library/general/src/modules/Hooks.rb', line 200

def result
  @result
end

Instance Method Details

#executeObject



206
207
208
209
210
211
212
213
# File 'library/general/src/modules/Hooks.rb', line 206

def execute
  log.info "Executing hook file '#{path}'"
  @result = OpenStruct.new(SCR.Execute(Path.new(".target.bash_output"), path.to_s))
  if failed?
    log.error "Hook file '#{path.basename}' failed with stderr: #{result.stderr}"
  end
  result
end

#failed?Boolean



231
232
233
# File 'library/general/src/modules/Hooks.rb', line 231

def failed?
  !succeeded?
end

#outputObject



219
220
221
222
223
224
225
# File 'library/general/src/modules/Hooks.rb', line 219

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



227
228
229
# File 'library/general/src/modules/Hooks.rb', line 227

def succeeded?
  result.exit.zero?
end