Sha256: 64476785f62d580094ae7598cd35e998de4ea0baa347a2fe35a4881960626bd7

Contents?: true

Size: 912 Bytes

Versions: 38

Compression:

Stored size: 912 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, range: 0..-1)
    processor = TestHelper::OperatorRecorder.new
    HexaPDF::Content::Parser.new.parse(content, processor)
    result = processor.recorded_ops[range]
    result.map!(&:first) if only_names
    assert_equal(operators, result)
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
hexapdf-0.15.7 test/hexapdf/content/common.rb
hexapdf-0.15.6 test/hexapdf/content/common.rb
hexapdf-0.15.5 test/hexapdf/content/common.rb
hexapdf-0.15.4 test/hexapdf/content/common.rb
hexapdf-0.15.3 test/hexapdf/content/common.rb
hexapdf-0.15.2 test/hexapdf/content/common.rb
hexapdf-0.15.1 test/hexapdf/content/common.rb
hexapdf-0.15.0 test/hexapdf/content/common.rb
hexapdf-0.14.4 test/hexapdf/content/common.rb
hexapdf-0.14.3 test/hexapdf/content/common.rb
hexapdf-0.14.2 test/hexapdf/content/common.rb
hexapdf-0.14.1 test/hexapdf/content/common.rb
hexapdf-0.14.0 test/hexapdf/content/common.rb
hexapdf-0.13.0 test/hexapdf/content/common.rb
hexapdf-0.12.3 test/hexapdf/content/common.rb
hexapdf-0.12.2 test/hexapdf/content/common.rb
hexapdf-0.12.1 test/hexapdf/content/common.rb
hexapdf-0.12.0 test/hexapdf/content/common.rb