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.24.0 test/hexapdf/content/common.rb
hexapdf-0.23.0 test/hexapdf/content/common.rb
hexapdf-0.22.0 test/hexapdf/content/common.rb
hexapdf-0.21.1 test/hexapdf/content/common.rb
hexapdf-0.21.0 test/hexapdf/content/common.rb
hexapdf-0.20.4 test/hexapdf/content/common.rb
hexapdf-0.20.3 test/hexapdf/content/common.rb
hexapdf-0.20.2 test/hexapdf/content/common.rb
hexapdf-0.20.1 test/hexapdf/content/common.rb
hexapdf-0.20.0 test/hexapdf/content/common.rb
hexapdf-0.19.3 test/hexapdf/content/common.rb
hexapdf-0.19.2 test/hexapdf/content/common.rb
hexapdf-0.19.1 test/hexapdf/content/common.rb
hexapdf-0.19.0 test/hexapdf/content/common.rb
hexapdf-0.18.0 test/hexapdf/content/common.rb
hexapdf-0.17.3 test/hexapdf/content/common.rb
hexapdf-0.17.2 test/hexapdf/content/common.rb
hexapdf-0.16.0 test/hexapdf/content/common.rb
hexapdf-0.15.9 test/hexapdf/content/common.rb
hexapdf-0.15.8 test/hexapdf/content/common.rb