Class: SpecInfra::Backend::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/specinfra/backend/base.rb

Direct Known Subclasses

Cmd, Dockerfile, Exec, ShellScript, WinRM

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

Default action is to call check_zero with args



26
27
28
29
30
31
32
# File 'lib/specinfra/backend/base.rb', line 26

def method_missing(meth, *args, &block)
  if meth.to_s =~ /^check/
    check_zero(meth, *args)
  else
    run_command(commands.send(meth, *args))
  end
end

Instance Method Details

#check_zero(cmd, *args) ⇒ Object



21
22
23
# File 'lib/specinfra/backend/base.rb', line 21

def check_zero(cmd, *args)
  run_command(commands.send(cmd, *args)).success?
end

#commandsObject



17
18
19
# File 'lib/specinfra/backend/base.rb', line 17

def commands
  @commands
end

#set_commands(c) ⇒ Object



9
10
11
# File 'lib/specinfra/backend/base.rb', line 9

def set_commands(c)
  @commands = c
end

#set_example(e) ⇒ Object



13
14
15
# File 'lib/specinfra/backend/base.rb', line 13

def set_example(e)
  @example = e
end