Class: Gridinit::Jmeter::RegexExtractor

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/gridinit-jmeter/post_processors/regex_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#enabled, #update

Constructor Details

#initialize(name, regex, params = {}) ⇒ RegexExtractor

Returns a new instance of RegexExtractor.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gridinit-jmeter/post_processors/regex_extractor.rb', line 8

def initialize(name, regex, params={})
  @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
    <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="#{name}" enabled="true">
      <stringProp name="RegexExtractor.useHeaders">#{use_headers_type(params)}</stringProp>
      <stringProp name="RegexExtractor.refname">#{name}</stringProp>
      <stringProp name="RegexExtractor.regex">#{CGI.escapeHTML regex}</stringProp>
      <stringProp name="RegexExtractor.template">$1$</stringProp>
      <stringProp name="RegexExtractor.default">#{params[:default]}</stringProp>
      <stringProp name="RegexExtractor.match_number">0</stringProp>
      <stringProp name="Sample.scope">all</stringProp>
    </RegexExtractor>
  EOF
  update params
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



5
6
7
# File 'lib/gridinit-jmeter/post_processors/regex_extractor.rb', line 5

def doc
  @doc
end

Instance Method Details

#use_headers_type(params) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/gridinit-jmeter/post_processors/regex_extractor.rb', line 23

def use_headers_type(params)
  #default to true unless explicitly set to false
  if params.has_key?(:match_on)
    params[:match_on]
  else
    'false'
  end
end