Sha256: 357aa8397671e9d01730617c859d3417277195f091e795b60e9fb36282dcd936

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

module JmeterPerf
  class DSL
    # DSL method synonymous with the JMeter Element Counter
    # @see https://github.com/jlurena/jmeter_perf/wiki/1.-DSL-Documentation#counter
    # @param [Hash] params Parameters for the Counter element (default: `{}`).
    # @yield block to attach to the Counter element
    # @return [JmeterPerf::Counter], a subclass of JmeterPerf::DSL that can be chained with other DSL methods.
    def counter(params = {}, &)
      node = JmeterPerf::Counter.new(params)
      attach_node(node, &)
    end
  end

  class Counter
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "Counter" : (params[:name] || "Counter")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <CounterConfig guiclass="CounterConfigGui" testclass="CounterConfig" testname="#{testname}" enabled="true">
          <stringProp name="CounterConfig.start"/>
          <stringProp name="CounterConfig.end"/>
          <stringProp name="CounterConfig.incr"/>
          <stringProp name="CounterConfig.name"/>
          <stringProp name="CounterConfig.format"/>
          <boolProp name="CounterConfig.per_user">true</boolProp>
          <boolProp name="CounterConfig.reset_on_tg_iteration">true</boolProp>
        </CounterConfig>
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/dsl/counter.rb