Control#feature! -> Control#feature

This commit is contained in:
0x1eef 2024-03-08 01:23:16 -03:00
parent d9042ce213
commit e0fab16bce
6 changed files with 14 additions and 14 deletions

View file

@ -33,7 +33,7 @@ The example enables the mprotect feature for the emacs binary:
# As a root account
require 'hbsdctl'
BSD::Control
.feature!(:mprotect)
.feature(:mprotect)
.enable!("/usr/local/bin/emacs-29.2")
```

View file

@ -18,7 +18,7 @@ module BSD::Control
##
# @example
# BSD::Control
# .feature!(:mprotect)
# .feature(:mprotect)
# .enable!("/usr/local/bin/firefox")
#
# @param [String] name
@ -29,7 +29,7 @@ module BSD::Control
#
# @return [BSD::Control::Feature]
# Returns an instance of BSD::Control::Feature.
def self.feature!(name)
def self.feature(name)
feature = Feature.available.find { _1.name == name.to_s }
feature ? feature : raise(Error, "feature '#{name}' wasn't found")
end

View file

@ -6,7 +6,7 @@ module BSD::Control
def test_enable_mprotect
touch(file)
assert BSD::Control.feature!(:mprotect).enable!(file),
assert BSD::Control.feature(:mprotect).enable!(file),
"The enable! method should have returned true"
ensure
rm(file)
@ -15,7 +15,7 @@ module BSD::Control
def test_enable_mprotect_zero_permissions
touch(file)
chmod(0, file)
assert BSD::Control.feature!(:mprotect).enable!(file),
assert BSD::Control.feature(:mprotect).enable!(file),
"The enable! method should have returned true"
ensure
rm(file)
@ -23,7 +23,7 @@ module BSD::Control
def test_enable_mprotect_nonexistent_file
assert_raises(BSD::Control::Error) do
BSD::Control.feature!(:mprotect).enable!(file)
BSD::Control.feature(:mprotect).enable!(file)
end
end

View file

@ -7,16 +7,16 @@ module BSD::Control
def test_mprotect_sysdef_status
touch(file)
assert_equal :sysdef,
BSD::Control.feature!(:mprotect).status(file)
BSD::Control.feature(:mprotect).status(file)
ensure
rm(file)
end
def test_mprotect_enabled_status
touch(file)
BSD::Control.feature!(:mprotect).enable!(file)
BSD::Control.feature(:mprotect).enable!(file)
assert_equal :enabled,
BSD::Control.feature!(:mprotect).status(file)
BSD::Control.feature(:mprotect).status(file)
ensure
rm(file)
end
@ -24,9 +24,9 @@ module BSD::Control
def test_mprotect_disabled_status
touch(file)
BSD::Control.feature!(:mprotect).disable!(file)
BSD::Control.feature(:mprotect).disable!(file)
assert_equal :disabled,
BSD::Control.feature!(:mprotect).status(file)
BSD::Control.feature(:mprotect).status(file)
ensure
rm(file)
end

View file

@ -10,7 +10,7 @@ module BSD::Control
BSD::Control::Error,
"This operation requires root privileges."
) do
BSD::Control.feature!(:mprotect).enable!(file)
BSD::Control.feature(:mprotect).enable!(file)
end
ensure
rm(file)

View file

@ -3,12 +3,12 @@ module BSD::Control
class FeatureBangTest < Test::Unit::TestCase
def test_mprotect_feature
assert_instance_of BSD::Control::Feature,
BSD::Control.feature!(:mprotect)
BSD::Control.feature(:mprotect)
end
def test_nonexistent_feature
assert_raises(BSD::Control::Error) do
BSD::Control.feature!(:non_existent_feature)
BSD::Control.feature(:non_existent_feature)
end
end
end