Class: SippyCup::XMLScenario

Inherits:
Object
  • Object
show all
Defined in:
lib/sippy_cup/xml_scenario.rb

Overview

A representation of a SIPp XML scenario

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, xml, media, args = {}) ⇒ XMLScenario

Create a scenario instance



20
21
22
23
# File 'lib/sippy_cup/xml_scenario.rb', line 20

def initialize(name, xml, media, args = {})
  @xml, @media = xml, media
  @scenario_options = args.merge name: name
end

Instance Attribute Details

#scenario_optionsHash (readonly)



10
11
12
# File 'lib/sippy_cup/xml_scenario.rb', line 10

def scenario_options
  @scenario_options
end

Instance Method Details

#to_tmpfilesHash<Symbol => Tempfile>

Write compiled Scenario XML and PCAP media to tempfiles.

These will automatically be closed and deleted once they have gone out of scope, and can be used to execute the scenario without leaving stuff behind.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sippy_cup/xml_scenario.rb', line 34

def to_tmpfiles
  scenario_file = Tempfile.new 'scenario'
  scenario_file.write @xml
  scenario_file.rewind

  if @media
    media_file = Tempfile.new 'media'
    media_file.write @media
    media_file.rewind
  else
    media_file = nil
  end

  {scenario: scenario_file, media: media_file}
end

#to_xmlString

Dump the scenario to a SIPp XML string



54
55
56
# File 'lib/sippy_cup/xml_scenario.rb', line 54

def to_xml
  @xml
end