Class: GitWit::Actions::Ssh::Sudoers

Inherits:
Thor::Actions::EmptyDirectory
  • Object
show all
Defined in:
lib/git_wit/actions/ssh/sudoers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, name, config = {}) ⇒ Sudoers

Returns a new instance of Sudoers.



6
7
8
9
# File 'lib/git_wit/actions/ssh/sudoers.rb', line 6

def initialize(base, name, config = {})
  @base, @name = base, name
  @config = {verbose: true}.merge config
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



4
5
6
# File 'lib/git_wit/actions/ssh/sudoers.rb', line 4

def base
  @base
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/git_wit/actions/ssh/sudoers.rb', line 4

def name
  @name
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/git_wit/actions/ssh/sudoers.rb', line 22

def exists?
  `sudo grep '#{sentinel}' /etc/sudoers 2>/dev/null`
  $?.success?
end

#invoke!Object



11
12
13
14
15
# File 'lib/git_wit/actions/ssh/sudoers.rb', line 11

def invoke!
  invoke_with_conflict_check do
    create
  end
end

#revoke!Object



17
18
19
20
# File 'lib/git_wit/actions/ssh/sudoers.rb', line 17

def revoke!
  say_status :remove, :red
  destroy if !pretend? && exists?
end