Class: Serverspec::Type::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_ary, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Attribute Details

#resultObject

Returns the value of attribute result.



4
5
6
# File 'lib/serverspec/type/command.rb', line 4

def result
  @result
end

Instance Method Details

#return_exit_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/serverspec/type/command.rb', line 24

def return_exit_status?(status)
  ret = backend.run_command(@name)
  ret.exit_status.to_i == status
end

#return_stderr?(content) ⇒ Boolean

Returns:

  • (Boolean)


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

def return_stderr?(content)
  ret = backend.run_command(@name)
  if content.instance_of?(Regexp)
    ret.stderr =~ content
  else
    ret.stderr.strip == content
  end
end

#return_stdout?(content) ⇒ Boolean

Returns:

  • (Boolean)


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

def return_stdout?(content)
  ret = backend.run_command(@name)
  if content.instance_of?(Regexp)
    ret.stdout =~ content
  else
    ret.stdout.strip == content
  end
end

#stderrObject



36
37
38
39
40
41
# File 'lib/serverspec/type/command.rb', line 36

def stderr
  if @result.nil?
    @result = backend.run_command(@name).stderr
  end
  @result
end

#stdoutObject



29
30
31
32
33
34
# File 'lib/serverspec/type/command.rb', line 29

def stdout
  if @result.nil?
    @result = backend.run_command(@name).stdout
  end
  @result
end