Class: Zae::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/zae/permission.rb

Overview

define how command should be run, either to become super user or not.

Constant Summary collapse

BECOMERS =
[Pathname.new('/usr/bin/sudo'), Pathname.new('/usr/bin/doas')].freeze

Instance Method Summary collapse

Constructor Details

#initialize(action, configuration) ⇒ Permission

Returns a new instance of Permission.



23
24
25
26
# File 'lib/zae/permission.rb', line 23

def initialize(action, configuration)
  @action = action
  @configuration = configuration
end

Instance Method Details

#becomerObject

find becomer program to use in system



34
35
36
# File 'lib/zae/permission.rb', line 34

def becomer
  BECOMERS.first { |exe| return exe if exe.exist? }
end

#super?Boolean

needs to be super user to run?

Returns:

  • (Boolean)


29
30
31
# File 'lib/zae/permission.rb', line 29

def super?
  @configuration[:super].key?(@action)
end