Class: Yast::HooksClass::HookFile

Inherits:
Object
  • Object
show all
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



197
198
199
# File '../../library/general/src/modules/Hooks.rb', line 197

def initialize path
  @path = path
end

Instance Attribute Details

- (Object) content (readonly)

Returns the value of attribute content



195
196
197
# File '../../library/general/src/modules/Hooks.rb', line 195

def content
  @content
end

- (Object) path (readonly)

Returns the value of attribute path



195
196
197
# File '../../library/general/src/modules/Hooks.rb', line 195

def path
  @path
end

- (Object) result (readonly)

Returns the value of attribute result



195
196
197
# File '../../library/general/src/modules/Hooks.rb', line 195

def result
  @result
end

Instance Method Details

- (Object) execute



201
202
203
204
205
206
207
208
# File '../../library/general/src/modules/Hooks.rb', line 201

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

- (Boolean) failed?

Returns:

  • (Boolean)


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

def failed?
  !succeeded?
end

- (Object) output



214
215
216
217
218
219
220
# File '../../library/general/src/modules/Hooks.rb', line 214

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)


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

def succeeded?
  result.exit.zero?
end