Sha256: c955772b5ae9305134ff03ac2c4aac90225529f594138229dc3fb976aafa1823

Contents?: true

Size: 964 Bytes

Versions: 18

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

require 'rast/rules/rule_evaluator'

# undoc
class RuleProcessor
  # /**
  #  * @param scenario current scenario.
  #  * @param caseFixture current test case fixture.
  #  */
  def evaluate(scenario: [], fixture: nil)
    # if scenario.empty? || fixture.nil?
    #   raise 'Scenario or fixture cannot be nil.'
    # end

    fixture[:spec].rule.outcomes.inject([]) do |retval, outcome|
      process_outcome(
        scenario: scenario,
        fixture: fixture,
        list: retval,
        outcome: outcome
      )
    end
  end

  private

  def process_outcome(scenario: [], fixture: nil, list: [], outcome: '')
    spec = fixture[:spec]

    clause = spec.rule.clause(outcome: outcome)
    rule_evaluator = RuleEvaluator.new(converters: spec.converters)

    rule_evaluator.parse(expression: clause)

    list << rule_evaluator.evaluate(
      scenario: scenario,
      rule_token_convert: spec.token_converter
    )
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rast-0.19.1 lib/rast/rules/rule_processor.rb
rast-0.19.0 lib/rast/rules/rule_processor.rb
rast-0.18.0 lib/rast/rules/rule_processor.rb
rast-0.15.1 lib/rast/rules/rule_processor.rb
rast-0.14.0 lib/rast/rules/rule_processor.rb
rast-0.11.4 lib/rast/rules/rule_processor.rb
rast-0.11.3 lib/rast/rules/rule_processor.rb
rast-0.11.1 lib/rast/rules/rule_processor.rb
rast-0.11.0 lib/rast/rules/rule_processor.rb
rast-0.10.0 lib/rast/rules/rule_processor.rb
rast-0.9.0 lib/rast/rules/rule_processor.rb
rast-0.9.0.pre lib/rast/rules/rule_processor.rb
rast-0.8.1.pre lib/rast/rules/rule_processor.rb
rast-0.8.0.pre lib/rast/rules/rule_processor.rb
rast-0.6.2.pre lib/rast/rules/rule_processor.rb
rast-0.6.1.pre lib/rast/rules/rule_processor.rb
rast-0.6.0.pre lib/rast/rules/rule_processor.rb
rast-0.4.2.pre lib/rast/rules/rule_processor.rb