Class: Prepper::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/prepper/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, opts = {}) ⇒ Command

Returns a new instance of Command.



5
6
7
8
9
10
11
12
13
# File 'lib/prepper/command.rb', line 5

def initialize(command, opts = {})
  @command = command
  @opts = opts
  @user = opts[:user] || "root"
  @within = opts[:within] || "/"
  @env = opts[:env] || {}
  @sudo = opts[:sudo] || false
  @verifier = opts[:verifier]
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/prepper/command.rb', line 3

def command
  @command
end

#envObject (readonly)

Returns the value of attribute env.



3
4
5
# File 'lib/prepper/command.rb', line 3

def env
  @env
end

#optsObject (readonly)

Returns the value of attribute opts.



3
4
5
# File 'lib/prepper/command.rb', line 3

def opts
  @opts
end

#sudoObject (readonly)

Returns the value of attribute sudo.



3
4
5
# File 'lib/prepper/command.rb', line 3

def sudo
  @sudo
end

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/prepper/command.rb', line 3

def user
  @user
end

#verifierObject (readonly)

Returns the value of attribute verifier.



3
4
5
# File 'lib/prepper/command.rb', line 3

def verifier
  @verifier
end

#withinObject (readonly)

Returns the value of attribute within.



3
4
5
# File 'lib/prepper/command.rb', line 3

def within
  @within
end

Instance Method Details

#to_sObject



15
16
17
18
19
20
21
# File 'lib/prepper/command.rb', line 15

def to_s
  if @sudo
    @command.dup.prepend("sudo ")
  else
    @command
  end
end