Class: Rspec::Bash::CallConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/bash/call_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, command) ⇒ CallConfiguration

Returns a new instance of CallConfiguration.



8
9
10
11
12
# File 'lib/rspec/bash/call_configuration.rb', line 8

def initialize(config_path, command)
  @config_path = config_path
  @configuration = []
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/rspec/bash/call_configuration.rb', line 6

def command
  @command
end

Instance Method Details

#add_output(content, target, args = []) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/rspec/bash/call_configuration.rb', line 20

def add_output(content, target, args = [])
  current_conf = create_or_get_conf(args)
  current_conf[:outputs] << {
    target: target,
    content: content
  }
  write @configuration
end

#call_configurationObject



29
30
31
32
33
34
35
# File 'lib/rspec/bash/call_configuration.rb', line 29

def call_configuration
  @config_path.open('r') do |conf_file|
    YAML.load(conf_file.read) || []
  end
rescue NoMethodError, Errno::ENOENT
  return []
end

#call_configuration=(new_conf) ⇒ Object



37
38
39
# File 'lib/rspec/bash/call_configuration.rb', line 37

def call_configuration=(new_conf)
  write new_conf
end

#set_exitcode(exitcode, args = []) ⇒ Object



14
15
16
17
18
# File 'lib/rspec/bash/call_configuration.rb', line 14

def set_exitcode(exitcode, args = [])
  current_conf = create_or_get_conf(args)
  current_conf[:exitcode] = exitcode
  write @configuration
end