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

- (HookFile) initialize(path)

Returns a new instance of HookFile



206
207
208
# File '../../library/general/src/modules/Hooks.rb', line 206

def initialize path
  @path = path
end

Instance Attribute Details

- (Object) content (readonly)

Returns the value of attribute content



204
205
206
# File '../../library/general/src/modules/Hooks.rb', line 204

def content
  @content
end

- (Object) path (readonly)

Returns the value of attribute path



204
205
206
# File '../../library/general/src/modules/Hooks.rb', line 204

def path
  @path
end

- (Object) result (readonly)

Returns the value of attribute result



204
205
206
# File '../../library/general/src/modules/Hooks.rb', line 204

def result
  @result
end

Instance Method Details

- (Object) execute



210
211
212
213
214
215
216
217
# File '../../library/general/src/modules/Hooks.rb', line 210

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

- (Boolean) failed?

Returns:

  • (Boolean)


235
236
237
# File '../../library/general/src/modules/Hooks.rb', line 235

def failed?
  !succeeded?
end

- (Object) output



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

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

- (Boolean) succeeded?

Returns:

  • (Boolean)


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

def succeeded?
  result.exit.zero?
end