Class: SippyCup::XMLScenario
- Inherits:
-
Object
- Object
- SippyCup::XMLScenario
- Defined in:
- lib/sippy_cup/xml_scenario.rb
Overview
A representation of a SIPp XML scenario
Instance Attribute Summary collapse
-
#scenario_options ⇒ Hash
readonly
The options the scenario was created with, either from a manifest or passed as overrides.
Instance Method Summary collapse
-
#initialize(name, xml, media, args = {}) ⇒ XMLScenario
constructor
Create a scenario instance.
-
#to_tmpfiles ⇒ Hash<Symbol => Tempfile>
Write compiled Scenario XML and PCAP media to tempfiles.
-
#to_xml ⇒ String
Dump the scenario to a SIPp XML string.
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_options ⇒ Hash (readonly)
Returns The options the scenario was created with, either from a manifest or passed as overrides.
10 11 12 |
# File 'lib/sippy_cup/xml_scenario.rb', line 10 def @scenario_options end |
Instance Method Details
#to_tmpfiles ⇒ Hash<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_xml ⇒ String
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 |