Class: Auth
- Inherits:
-
Object
- Object
- Auth
- Defined in:
- lib/auth.rb
Overview
When action require privilege, Auth search on the system for sudo or doas.
Instance Method Summary collapse
-
#initialize ⇒ Auth
constructor
A new instance of Auth.
- #mkdir(path) ⇒ Object
- #sysctl(flag, value) ⇒ Object
- #write(content, file) ⇒ Object
Constructor Details
#initialize ⇒ Auth
Returns a new instance of Auth.
8 9 10 |
# File 'lib/auth.rb', line 8 def initialize @auth = search_app end |
Instance Method Details
#mkdir(path) ⇒ Object
12 13 14 15 16 |
# File 'lib/auth.rb', line 12 def mkdir(path) return if Dir.exist?(path) x("mkdir -p #{path}") end |
#sysctl(flag, value) ⇒ Object
18 19 20 21 22 |
# File 'lib/auth.rb', line 18 def sysctl(flag, value) return if flag.nil? x("sysctl -w #{flag}=#{value}") end |
#write(content, file) ⇒ Object
24 25 26 27 28 |
# File 'lib/auth.rb', line 24 def write(content, file) temp = Tempfile.new File.write(temp.path, "#{content}\n") x("cp #{temp.path} #{file}") end |