Module: BSD::Control

Defined in:
lib/bsd/control.rb,
lib/bsd/control/context.rb,
lib/bsd/control/feature.rb,
lib/bsd/control/version.rb

Defined Under Namespace

Classes: Context, Feature

Constant Summary collapse

Error =
Class.new(RuntimeError)
VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

.contextBSD::Control::Context

Returns an instance of BSD::Control::Context

Returns:



12
13
14
# File 'lib/bsd/control.rb', line 12

def self.context
  @context ||= BSD::Control::Context.new
end

.library_versionString

Returns the version of libhbsdcontrol

Returns:

  • (String)

    Returns the version of libhbsdcontrol



19
20
21
# File 'lib/bsd/control.rb', line 19

def self.library_version
  context.library_version
end

.available_featuresArray<BSD::Control::Feature>

Returns an array of available features

Returns:



26
27
28
# File 'lib/bsd/control.rb', line 26

def self.available_features
  context.available_features
end

.feature(name) ⇒ BSD::Control::Feature

Returns an instance of BSD::Control::Feature

Examples:

BSD::Control
  .feature(:mprotect)
  .enable!("/usr/local/bin/emacs-29.2")

Parameters:

  • name (String)

    The name of a feature

Returns:

Raises:



44
45
46
47
# File 'lib/bsd/control.rb', line 44

def self.feature(name)
  feature = available_features.find { _1.name == name.to_s }
  feature || raise(Error, "'#{name}' wasn't found")
end