Method: RunLoop::Core.dylib_path_from_options

Defined in:
lib/run_loop/core.rb

.dylib_path_from_options(options) ⇒ String?

Extracts the value of :inject_dylib from options Hash.

Parameters:

Returns:

  • (String, nil)

    If the options contains :inject_dylibs and it is a path to a dylib that exists, return the path. Otherwise return nil or raise an error.

Raises:

  • (RuntimeError)

    If :inject_dylib points to a path that does not exist.

  • (ArgumentError)

    If :inject_dylib is not a String.



455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/run_loop/core.rb', line 455

def self.dylib_path_from_options(options)
  inject_dylib = options.fetch(:inject_dylib, nil)
  return nil if inject_dylib.nil?
  unless inject_dylib.is_a? String
    raise ArgumentError, "Expected :inject_dylib to be a path to a dylib, but found '#{inject_dylib}'"
  end
  dylib_path = File.expand_path(inject_dylib)
  unless File.exist?(dylib_path)
    raise "Cannot load dylib.  The file '#{dylib_path}' does not exist."
  end
  dylib_path
end