Sha256: 3a51f5f5126266060a30841aefbad84f91a56a6919f280e1f0166506eb45c1f4

Contents?: true

Size: 891 Bytes

Versions: 19

Compression:

Stored size: 891 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/content/processor'

module TestHelper

  # Can be used to to record operators parsed from content streams.
  class OperatorRecorder < HexaPDF::Content::Processor

    undef :paint_xobject

    attr_reader :recorded_ops

    def initialize
      super
      operators.clear
      @recorded_ops = []
    end

    def respond_to_missing?(*)
      true
    end

    def method_missing(msg, *params)
      @recorded_ops << (params.empty? ? [msg] : [msg, params])
    end

  end

  # Asserts that the content string contains the operators.
  def assert_operators(content, operators, only_names: false)
    processor = TestHelper::OperatorRecorder.new
    HexaPDF::Content::Parser.new.parse(content, processor)
    result = processor.recorded_ops
    result.map!(&:first) if only_names
    assert_equal(operators, result)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hexapdf-0.11.9 test/hexapdf/content/common.rb
hexapdf-0.11.8 test/hexapdf/content/common.rb
hexapdf-0.11.7 test/hexapdf/content/common.rb
hexapdf-0.11.6 test/hexapdf/content/common.rb
hexapdf-0.11.5 test/hexapdf/content/common.rb
hexapdf-0.11.4 test/hexapdf/content/common.rb
hexapdf-0.11.3 test/hexapdf/content/common.rb
hexapdf-0.11.2 test/hexapdf/content/common.rb
hexapdf-0.11.1 test/hexapdf/content/common.rb
hexapdf-0.11.0 test/hexapdf/content/common.rb
hexapdf-0.10.0 test/hexapdf/content/common.rb
hexapdf-0.9.3 test/hexapdf/content/common.rb
hexapdf-0.9.2 test/hexapdf/content/common.rb
hexapdf-0.9.1 test/hexapdf/content/common.rb
hexapdf-0.9.0 test/hexapdf/content/common.rb
hexapdf-0.8.0 test/hexapdf/content/common.rb
hexapdf-0.7.0 test/hexapdf/content/common.rb
hexapdf-0.6.0 test/hexapdf/content/common.rb
hexapdf-0.5.0 test/hexapdf/content/common.rb