diff -Nru ruby-pdf-core-0.8.1/CHANGELOG.md ruby-pdf-core-0.9.0/CHANGELOG.md --- ruby-pdf-core-0.8.1/CHANGELOG.md 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/CHANGELOG.md 2020-10-24 15:32:00.000000000 +0000 @@ -4,13 +4,24 @@ ## Unreleased +## [0.9.0][] + +## Changed + +- Increased precision of real numbers to 5 + Alexander Mankuta +- Dropped 2.3 & 2.4 Ruby support + Alexander Mankuta +- Updated code style + Alexander Mankuta + ## [0.8.1][] - 2018-04-28 ### Fixed -- Make sure stamp streams are fritable +- Make sure stamp streams are writable Alexander Mankuta -- Handle text rendering from forzen strings +- Handle text rendering from frozen strings Alexander Mankuta ## [0.8.0][] - 2018-04-27 @@ -55,6 +66,7 @@ - A trailer can be assigned to DocumentState Robert Bousquet, [#16](https://github.com/prawnpdf/pdf-core/pull/16) +[0.9.0]: https://github.com/prawnpdf/pdf-core/compare/0.8.1..0.9.0 [0.8.1]: https://github.com/prawnpdf/pdf-core/compare/0.8.0...0.8.1 [0.8.0]: https://github.com/prawnpdf/pdf-core/compare/0.7.0...0.8.0 [0.7.0]: https://github.com/prawnpdf/pdf-core/compare/0.6.1...0.7.0 diff -Nru ruby-pdf-core-0.8.1/checksums/pdf-core-0.9.0.gem.sha512 ruby-pdf-core-0.9.0/checksums/pdf-core-0.9.0.gem.sha512 --- ruby-pdf-core-0.8.1/checksums/pdf-core-0.9.0.gem.sha512 1970-01-01 00:00:00.000000000 +0000 +++ ruby-pdf-core-0.9.0/checksums/pdf-core-0.9.0.gem.sha512 2020-10-24 15:32:00.000000000 +0000 @@ -0,0 +1 @@ +75b4da5e18ed0f884f0c582e36cd3338f579fd7229ccf3decc8989f73be1bab4838c14518d1c87a1785af0d9e59ae5b59613f92af76e452da87d1627782d5478 \ No newline at end of file diff -Nru ruby-pdf-core-0.8.1/debian/changelog ruby-pdf-core-0.9.0/debian/changelog --- ruby-pdf-core-0.8.1/debian/changelog 2020-09-01 21:09:02.000000000 +0000 +++ ruby-pdf-core-0.9.0/debian/changelog 2021-11-22 09:08:33.000000000 +0000 @@ -1,3 +1,17 @@ +ruby-pdf-core (0.9.0-1) unstable; urgency=medium + + [ Debian Janitor ] + * Set upstream metadata fields: Bug-Submit. + * Update standards version to 4.5.1, no changes needed. + + [ Cédric Boutillier ] + * New upstream version 0.9.0 + * Breaks ruby-prawn < 2.4 + * Update standards version to 4.6.0, no changes needed. + * Refresh patch + + -- Cédric Boutillier Mon, 22 Nov 2021 10:08:33 +0100 + ruby-pdf-core (0.8.1-2) unstable; urgency=medium [ Utkarsh Gupta ] diff -Nru ruby-pdf-core-0.8.1/debian/control ruby-pdf-core-0.9.0/debian/control --- ruby-pdf-core-0.8.1/debian/control 2020-09-01 21:09:02.000000000 +0000 +++ ruby-pdf-core-0.9.0/debian/control 2021-11-22 09:08:33.000000000 +0000 @@ -4,11 +4,12 @@ Maintainer: Debian Ruby Team Uploaders: Cédric Boutillier Build-Depends: debhelper-compat (= 13), - gem2deb, + gem2deb (>= 1), + rake, ruby-pdf-inspector, ruby-pdf-reader, ruby-rspec -Standards-Version: 4.5.0 +Standards-Version: 4.6.0 Vcs-Git: https://salsa.debian.org/ruby-team/ruby-pdf-core.git Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-pdf-core Homepage: https://github.com/prawnpdf/pdf-core @@ -22,8 +23,7 @@ Depends: ${misc:Depends}, ${ruby:Depends}, ${shlibs:Depends}, - ruby-pdf-reader -Breaks: ruby-prawn (<< 2.2~) +Breaks: ruby-prawn (<< 2.4~) Description: Ruby library to render PDF documents PDF::Core is a pure Ruby library to render PDF documents. It supports several PDF features, such as among others: diff -Nru ruby-pdf-core-0.8.1/debian/patches/clean_spec_helper.patch ruby-pdf-core-0.9.0/debian/patches/clean_spec_helper.patch --- ruby-pdf-core-0.8.1/debian/patches/clean_spec_helper.patch 2020-09-01 21:09:02.000000000 +0000 +++ ruby-pdf-core-0.9.0/debian/patches/clean_spec_helper.patch 2021-11-22 09:08:33.000000000 +0000 @@ -4,17 +4,14 @@ Origin: vendor Author: Cédric Boutillier Forwarded: no -Last-Update: 2018-09-30 +Last-Update: 2021-11-22 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb -@@ -2,15 +2,7 @@ +@@ -2,12 +2,7 @@ puts "PDF::Core specs: Running on Ruby Version: #{RUBY_VERSION}" --require 'bundler' --Bundler.setup -- -if ENV['COVERAGE'] - require 'simplecov' - SimpleCov.start diff -Nru ruby-pdf-core-0.8.1/debian/ruby-tests.rake ruby-pdf-core-0.9.0/debian/ruby-tests.rake --- ruby-pdf-core-0.8.1/debian/ruby-tests.rake 2020-09-01 21:09:02.000000000 +0000 +++ ruby-pdf-core-0.9.0/debian/ruby-tests.rake 2021-11-22 09:08:33.000000000 +0000 @@ -1,7 +1,6 @@ -require 'rspec/core/rake_task' +require 'gem2deb/rake/spectask' -RSpec::Core::RakeTask.new("spec") do |c| - c.rspec_opts = "-t ~unresolved" +Gem2Deb::Rake::RSpecTask.new do |spec| + spec.pattern = './spec/**/*_spec.rb' + spec.rspec_opts = "-t ~unresolved" end - -task :default => [:spec] diff -Nru ruby-pdf-core-0.8.1/debian/upstream/metadata ruby-pdf-core-0.9.0/debian/upstream/metadata --- ruby-pdf-core-0.8.1/debian/upstream/metadata 2020-09-01 21:09:02.000000000 +0000 +++ ruby-pdf-core-0.9.0/debian/upstream/metadata 2021-11-22 09:08:33.000000000 +0000 @@ -1,3 +1,4 @@ Bug-Database: https://github.com/prawnpdf/pdf-core/issues +Bug-Submit: https://github.com/prawnpdf/pdf-core/issues/new Repository: https://github.com/prawnpdf/pdf-core.git Repository-Browse: https://github.com/prawnpdf/pdf-core diff -Nru ruby-pdf-core-0.8.1/.github/workflows/ci.yml ruby-pdf-core-0.9.0/.github/workflows/ci.yml --- ruby-pdf-core-0.8.1/.github/workflows/ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-pdf-core-0.9.0/.github/workflows/ci.yml 2020-10-24 15:32:00.000000000 +0000 @@ -0,0 +1,35 @@ +name: CI + +on: + push: + pull_request_target: + schedule: + - cron: "6 20 * * 6" + +jobs: + test: + runs-on: ubuntu-latest + container: ${{matrix.image}} + strategy: + fail-fast: false + matrix: + image: + - ruby:2.5.0 + - ruby:2.5 + - ruby:2.6.0 + - ruby:2.6 + - ruby:2.7.0 + - ruby:2.7 + - jruby:9.2 + include: + - image: ruby:rc + continue-on-error: true + steps: + - uses: actions/checkout@v1 + - name: Set up Ruby + run: | + gem update --system > /dev/null + gem --version + gem install -g + - name: Run tests + run: rake diff -Nru ruby-pdf-core-0.8.1/.gitignore ruby-pdf-core-0.9.0/.gitignore --- ruby-pdf-core-0.8.1/.gitignore 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/.gitignore 2020-10-24 15:32:00.000000000 +0000 @@ -1,2 +1,3 @@ Gemfile.lock coverage/* +pkg/ diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/byte_string.rb ruby-pdf-core-0.9.0/lib/pdf/core/byte_string.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/byte_string.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/byte_string.rb 2020-10-24 15:32:00.000000000 +0000 @@ -1,4 +1,3 @@ - # frozen_string_literal: true module PDF diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/document_state.rb ruby-pdf-core-0.9.0/lib/pdf/core/document_state.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/document_state.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/document_state.rb 2020-10-24 15:32:00.000000000 +0000 @@ -28,18 +28,18 @@ @on_page_create_callback = nil end - attr_accessor :store, :version, :pages, :page, :trailer, :compress, - :encrypt, :encryption_key, :skip_encoding, - :before_render_callbacks, :on_page_create_callback + attr_accessor :store, :version, :pages, :page, :trailer, :compress, :encrypt, :encryption_key, :skip_encoding + attr_accessor :before_render_callbacks, :on_page_create_callback def populate_pages_from_store(document) return 0 if @store.page_count <= 0 || !@pages.empty? count = (1..@store.page_count) - @pages = count.map do |index| - orig_dict_id = @store.object_id_for_page(index) - PDF::Core::Page.new(document, object_id: orig_dict_id) - end + @pages = + count.map do |index| + orig_dict_id = @store.object_id_for_page(index) + PDF::Core::Page.new(document, object_id: orig_dict_id) + end end def normalize_metadata(options) diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/filter_list.rb ruby-pdf-core-0.9.0/lib/pdf/core/filter_list.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/filter_list.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/filter_list.rb 2020-10-24 15:32:00.000000000 +0000 @@ -3,6 +3,18 @@ module PDF module Core class FilterList + class NotFilter < StandardError + DEFAULT_MESSAGE = 'Can not interpret input as a filter' + MESSAGE_WITH_FILTER = 'Can not interpret input as a filter: %s' + + def initialize(message = DEFAULT_MESSAGE, filter: nil) + if filter + super format(MESSAGE_WITH_FILTER, filter: filter) + else + super(message) + end + end + end def initialize @list = [] end @@ -16,7 +28,7 @@ @list << [name, params] end else - raise "Can not interpret input as filter: #{filter.inspect}" + raise NotFilter.new(filter: filter) end self @@ -43,10 +55,8 @@ @list.inspect end - def each - @list.each do |filter| - yield(filter) - end + def each(&block) + @list.each(&block) end end end diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/graphics_state.rb ruby-pdf-core-0.9.0/lib/pdf/core/graphics_state.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/graphics_state.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/graphics_state.rb 2020-10-24 15:32:00.000000000 +0000 @@ -1,4 +1,3 @@ - # frozen_string_literal: true # @@ -45,8 +44,7 @@ # NOTE: This class may be a good candidate for a copy-on-write hash. class GraphicState - attr_accessor :color_space, :dash, :cap_style, :join_style, :line_width, - :fill_color, :stroke_color + attr_accessor :color_space, :dash, :cap_style, :join_style, :line_width, :fill_color, :stroke_color def initialize(previous_state = nil) if previous_state @@ -65,11 +63,12 @@ def dash_setting return '[] 0 d' unless @dash[:dash] - array = if @dash[:dash].is_a?(Array) - @dash[:dash] - else - [@dash[:dash], @dash[:space]] - end + array = + if @dash[:dash].is_a?(Array) + @dash[:dash] + else + [@dash[:dash], @dash[:space]] + end "[#{PDF::Core.real_params(array)}] "\ "#{PDF::Core.real(@dash[:phase])} d" diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/literal_string.rb ruby-pdf-core-0.9.0/lib/pdf/core/literal_string.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/literal_string.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/literal_string.rb 2020-10-24 15:32:00.000000000 +0000 @@ -1,4 +1,3 @@ - # frozen_string_literal: true module PDF diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/name_tree.rb ruby-pdf-core-0.9.0/lib/pdf/core/name_tree.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/name_tree.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/name_tree.rb 2020-10-24 15:32:00.000000000 +0000 @@ -31,7 +31,7 @@ end def size - leaf? ? children.size : children.map(&:size).reduce(:+) + leaf? ? children.size : children.sum(&:size) end def leaf? @@ -78,7 +78,7 @@ children.insert(insertion_point(value), value) split! if children.length > limit else - fit = children.detect { |child| child >= value } + fit = children.find { |child| child >= value } fit ||= children.last fit << value end @@ -107,8 +107,7 @@ def deep_copy node = dup node.instance_variable_set('@children', Utils.deep_clone(children)) - node.instance_variable_set('@ref', - node.ref ? node.ref.deep_copy : nil) + node.instance_variable_set('@ref', node.ref ? node.ref.deep_copy : nil) node end diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/outline_item.rb ruby-pdf-core-0.9.0/lib/pdf/core/outline_item.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/outline_item.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/outline_item.rb 2020-10-24 15:32:00.000000000 +0000 @@ -3,8 +3,7 @@ module PDF module Core class OutlineItem #:nodoc: - attr_accessor :count, :first, :last, :next, :prev, :parent, :title, :dest, - :closed + attr_accessor :count, :first, :last, :next, :prev, :parent, :title, :dest, :closed def initialize(title, parent, options) @closed = options[:closed] diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/page.rb ruby-pdf-core-0.9.0/lib/pdf/core/page.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/page.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/page.rb 2020-10-24 15:32:00.000000000 +0000 @@ -12,8 +12,7 @@ module PDF module Core class Page #:nodoc: - attr_accessor :art_indents, :bleeds, :crops, :document, :margins, :stack, - :trims + attr_accessor :art_indents, :bleeds, :crops, :document, :margins, :stack, :trims attr_writer :content, :dictionary ZERO_INDENTS = { @@ -25,20 +24,22 @@ def initialize(document, options = {}) @document = document - @margins = options[:margins] || { left: 36, - right: 36, - top: 36, - bottom: 36 } + @margins = options[:margins] || { + left: 36, + right: 36, + top: 36, + bottom: 36 + } @crops = options[:crops] || ZERO_INDENTS @bleeds = options[:bleeds] || ZERO_INDENTS @trims = options[:trims] || ZERO_INDENTS @art_indents = options[:art_indents] || ZERO_INDENTS @stack = GraphicStateStack.new(options[:graphic_state]) - @size = options[:size] || 'LETTER' - @layout = options[:layout] || :portrait + @size = options[:size] || 'LETTER' + @layout = options[:layout] || :portrait - @stamp_stream = nil - @stamp_dictionary = nil + @stamp_stream = nil + @stamp_dictionary = nil @content = document.ref({}) content << 'q' << "\n" @@ -85,7 +86,7 @@ graphic_stack_size = stack.stack.size document.save_graphics_state - document.send(:freeze_stamp_graphics) + document.__send__(:freeze_stamp_graphics) yield if block_given? until graphic_stack_size == stack.stack.size diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/pdf_object.rb ruby-pdf-core-0.9.0/lib/pdf/core/pdf_object.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/pdf_object.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/pdf_object.rb 2020-10-24 15:32:00.000000000 +0000 @@ -13,7 +13,7 @@ module_function def real(num) - num.to_f.round(4) + format('%.5f', number: num).sub(/((?" + "<#{obj.unpack1('H*')}>" when String obj = utf8_to_utf16(obj) unless in_content_stream "<#{string_to_hex(obj)}>" when Symbol - '/' + obj.to_s.unpack('C*').map do |n| - if n < 33 || n > 126 || [35, 40, 41, 47, 60, 62].include?(n) - '#' + n.to_s(16).upcase - else - [n].pack('C*') - end - end.join + name_string = + obj.to_s.unpack('C*').map do |n| + if ESCAPED_NAME_CHARACTERS.include?(n) + "##{n.to_s(16).upcase}" + else + [n].pack('C*') + end + end.join + "/#{name_string}" when ::Hash output = +'<< ' obj.each do |k, v| @@ -98,7 +102,7 @@ when PDF::Core::NameTree::Node pdf_object(obj.to_hash) when PDF::Core::NameTree::Value - pdf_object(obj.name) + ' ' + pdf_object(obj.value) + "#{pdf_object(obj.name)} #{pdf_object(obj.value)}" when PDF::Core::OutlineRoot, PDF::Core::OutlineItem pdf_object(obj.to_hash) else diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/reference.rb ruby-pdf-core-0.9.0/lib/pdf/core/reference.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/reference.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/reference.rb 2020-10-24 15:32:00.000000000 +0000 @@ -13,6 +13,12 @@ class Reference #:nodoc: attr_accessor :gen, :data, :offset, :stream, :identifier + class CannotAttachStream < StandardError + def initialize(message = 'Cannot attach stream to a non-dictionary object') + super + end + end + def initialize(id, data) @identifier = id @gen = 0 @@ -34,8 +40,9 @@ def <<(io) unless @data.is_a?(::Hash) - raise 'Cannot attach stream to non-dictionary object' + raise CannotAttachStream end + (@stream ||= Stream.new) << io end diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/renderer.rb ruby-pdf-core-0.9.0/lib/pdf/core/renderer.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/renderer.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/renderer.rb 2020-10-24 15:32:00.000000000 +0000 @@ -170,9 +170,7 @@ if output.instance_of?(StringIO) str = output.string str.force_encoding(::Encoding::ASCII_8BIT) - return str - else - return nil + str end end @@ -210,7 +208,7 @@ output << "0 #{state.store.size + 1}\n" output << "0000000000 65535 f \n" state.store.each do |ref| - output.printf('%010d', ref.offset) + output.printf('%010d', offset: ref.offset) output << " 00000 n \n" end end diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/stream.rb ruby-pdf-core-0.9.0/lib/pdf/core/stream.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/stream.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/stream.rb 2020-10-24 15:32:00.000000000 +0000 @@ -90,8 +90,14 @@ end def inspect - "#<#{self.class.name}:0x#{format '%014x', object_id} "\ - "@stream=#{@stream.inspect}, @filters=#{@filters.inspect}>" + format( + '#<%s:0x%014x '\ + '@stream=%s, @filters=%s>', + class: self.class.name, + object_id: object_id, + stream: @stream.inspect, + filters: @filters.inspect + ) end end end diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/text.rb ruby-pdf-core-0.9.0/lib/pdf/core/text.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/text.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/text.rb 2020-10-24 15:32:00.000000000 +0000 @@ -17,11 +17,18 @@ stroke: 1, fill_stroke: 2, invisible: 3, - fill_clip: 4, stroke_clip: 5, + fill_clip: 4, + stroke_clip: 5, fill_stroke_clip: 6, clip: 7 }.freeze + class BadFontFamily < StandardError + def initialize(message = 'Bad font family') + super + end + end + attr_reader :skip_encoding # Low level call to set the current font style and extract text options @@ -29,7 +36,8 @@ # def process_text_options(options) if options[:style] - raise 'Bad font family' unless font.family + raise BadFontFamily unless font.family + font(font.family, style: options[:style]) end @@ -47,6 +55,7 @@ # def default_kerning? return true unless defined?(@default_kerning) + @default_kerning end @@ -182,6 +191,7 @@ if mode.nil? return defined?(@text_rendering_mode) && @text_rendering_mode || :fill end + unless MODES.key?(mode) raise ArgumentError, "mode must be between one of #{MODES.keys.join(', ')} (#{mode})" @@ -211,6 +221,7 @@ if amount.nil? return defined?(@character_spacing) && @character_spacing || 0 end + original_character_spacing = character_spacing if original_character_spacing == amount yield @@ -229,6 +240,7 @@ # def word_spacing(amount = nil) return defined?(@word_spacing) && @word_spacing || 0 if amount.nil? + original_word_spacing = word_spacing if original_word_spacing == amount yield @@ -246,8 +258,7 @@ # percentage of the normal width. def horizontal_text_scaling(amount = nil) if amount.nil? - return defined?(@horizontal_text_scaling) && - @horizontal_text_scaling || 100 + return defined?(@horizontal_text_scaling) && @horizontal_text_scaling || 100 end original_horizontal_text_scaling = horizontal_text_scaling @@ -262,7 +273,6 @@ end end - # rubocop: disable Naming/UncommunicativeMethodParamName def add_text_content(text, x, y, options) chunks = font.encode_text(text, options) @@ -291,12 +301,11 @@ ].join(' ') operation = options[:kerning] && string.is_a?(Array) ? 'TJ' : 'Tj' - add_content PDF::Core.pdf_object(string, true) + ' ' + operation + add_content "#{PDF::Core.pdf_object(string, true)} #{operation}" end add_content "ET\n" end - # rubocop: enable Naming/UncommunicativeMethodParamName end end end diff -Nru ruby-pdf-core-0.8.1/lib/pdf/core/utils.rb ruby-pdf-core-0.9.0/lib/pdf/core/utils.rb --- ruby-pdf-core-0.8.1/lib/pdf/core/utils.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/lib/pdf/core/utils.rb 2020-10-24 15:32:00.000000000 +0000 @@ -3,10 +3,11 @@ module PDF module Core module Utils + module_function + def deep_clone(object) Marshal.load(Marshal.dump(object)) end - module_function :deep_clone end end end diff -Nru ruby-pdf-core-0.8.1/pdf-core.gemspec ruby-pdf-core-0.9.0/pdf-core.gemspec --- ruby-pdf-core-0.8.1/pdf-core.gemspec 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/pdf-core.gemspec 2020-10-24 15:32:00.000000000 +0000 @@ -2,15 +2,16 @@ Gem::Specification.new do |spec| spec.name = 'pdf-core' - spec.version = '0.8.1' + spec.version = '0.9.0' spec.platform = Gem::Platform::RUBY spec.summary = 'PDF::Core is used by Prawn to render PDF documents' - spec.files = Dir.glob('lib/**/**/*') + - %w[COPYING GPLv2 GPLv3 LICENSE] + - %w[Gemfile Rakefile] + - ['pdf-core.gemspec'] + spec.files = + Dir.glob('lib/**/**/*') + + %w[COPYING GPLv2 GPLv3 LICENSE] + + %w[Gemfile Rakefile] + + ['pdf-core.gemspec'] spec.require_path = 'lib' - spec.required_ruby_version = '>= 2.3' + spec.required_ruby_version = '>= 2.5' spec.required_rubygems_version = '>= 1.3.6' spec.cert_chain = ['certs/pointlessone.pem'] @@ -29,16 +30,15 @@ 'gregory.t.brown@gmail.com', 'brad@bradediger.com', 'dnelson@bluejade.com', 'greenberg@entryway.net', 'jimmy@deefa.com' ] - spec.rubyforge_project = 'prawn' spec.licenses = %w[PRAWN GPL-2.0 GPL-3.0] - spec.add_development_dependency('bundler') spec.add_development_dependency('pdf-inspector', '~> 1.1.0') spec.add_development_dependency('pdf-reader', '~>1.2') spec.add_development_dependency('rake') spec.add_development_dependency('rspec') - spec.add_development_dependency('rubocop', '~> 0.55') - spec.add_development_dependency('rubocop-rspec', '~> 1.25') + spec.add_development_dependency('rubocop', '~> 0.93') + spec.add_development_dependency('rubocop-performance', '~> 1.8') + spec.add_development_dependency('rubocop-rspec', '~> 1.44') spec.add_development_dependency('simplecov') - spec.homepage = 'http://prawn.majesticseacreature.com' + spec.homepage = 'http://prawnpdf.org' spec.description = 'PDF::Core is used by Prawn to render PDF documents' end diff -Nru ruby-pdf-core-0.8.1/Rakefile ruby-pdf-core-0.9.0/Rakefile --- ruby-pdf-core-0.8.1/Rakefile 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/Rakefile 2020-10-24 15:32:00.000000000 +0000 @@ -1,8 +1,5 @@ # frozen_string_literal: true -require 'bundler' -Bundler.setup - require 'rake' require 'rspec/core/rake_task' @@ -15,3 +12,19 @@ require 'rubocop/rake_task' RuboCop::RakeTask.new + +require 'rubygems/package_task' +spec = Gem::Specification.load 'pdf-core.gemspec' +Gem::PackageTask.new(spec) do |pkg| + pkg.need_zip = true + pkg.need_tar = true +end + +task :checksum do + require 'digest/sha2' + built_gem_path = "pkg/pdf-core-#{spec.version}.gem" + gem_file_name = File.basename(built_gem_path) + checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path)) + checksum_path = "checksums/#{gem_file_name}.sha512" + File.write(checksum_path, checksum) +end diff -Nru ruby-pdf-core-0.8.1/README.md ruby-pdf-core-0.9.0/README.md --- ruby-pdf-core-0.8.1/README.md 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/README.md 2020-10-24 15:32:00.000000000 +0000 @@ -1,7 +1,7 @@ # PDF::Core -[![Build Status](https://travis-ci.org/prawnpdf/prawn.png?branch=master)](https://travis-ci.org/prawnpdf/prawn) -![Maintained: yes](https://img.shields.io/badge/maintained-yes-brightgreen.png) +![Maintained: yes](https://img.shields.io/badge/maintained-yes-brightgreen.svg) +![CI status](https://github.com/prawnpdf/pdf-core/workflows/CI/badge.svg) This is an experimental gem that extracts low-level PDF functionality from Prawn. More details to come soon! diff -Nru ruby-pdf-core-0.8.1/.rubocop.yml ruby-pdf-core-0.9.0/.rubocop.yml --- ruby-pdf-core-0.8.1/.rubocop.yml 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/.rubocop.yml 2020-10-24 15:32:00.000000000 +0000 @@ -1,72 +1,179 @@ -require: rubocop-rspec +require: + - rubocop-performance + - rubocop-rspec AllCops: - TargetRubyVersion: 2.3 - Include: - - '**/Rakefile' - - '*.gemspec' + TargetRubyVersion: 2.5 + NewCops: enable Exclude: - - 'pkg/**/*' + - pkg/**/* -# These cops need to remain disabled for valid reasons on this code base +Layout/ArgumentAlignment: + EnforcedStyle: with_fixed_indentation -Metrics/AbcSize: - Enabled: false +Lint/ConstantDefinitionInBlock: + Exclude: + - manual/text/formatted_callbacks.rb + - manual/text/text_box_extensions.rb -Metrics/BlockLength: +Layout/FirstArrayElementLineBreak: + Enabled: true + +Layout/FirstHashElementLineBreak: + Enabled: true + +Layout/FirstMethodArgumentLineBreak: + Enabled: true + +Layout/FirstMethodParameterLineBreak: + Enabled: true + +Layout/FirstArgumentIndentation: + EnforcedStyle: consistent + +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +Layout/HeredocArgumentClosingParenthesis: + Enabled: true + +Layout/MultilineAssignmentLayout: + Enabled: true + +Layout/MultilineHashKeyLineBreaks: + Enabled: true + +Layout/MultilineMethodArgumentLineBreaks: + Enabled: true + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Layout/MultilineOperationIndentation: + EnforcedStyle: indented + Exclude: + - prawn.gemspec + +Layout/ParameterAlignment: + EnforcedStyle: with_fixed_indentation + +Layout/SpaceAroundOperators: + AllowForAlignment: false + + +Lint/HeredocMethodCallPosition: + Enabled: true + +# FIXME +Lint/NumberConversion: Enabled: false +# This file shows examples on how to instantiate a document in multiple ways, +# it does not actually do the instantiation and isn't actually shadowing any +# variables. +Lint/ShadowingOuterLocalVariable: + Exclude: + - manual/basic_concepts/creation.rb + +# In this case we supress Prawn::Errors::CannotFit while trying to scale +# text down to fit. +Lint/SuppressedException: + Exclude: + - lib/prawn/text/formatted/box.rb + + +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Exclude: + - '*.gemspec' + - spec/**/*.rb Metrics/ClassLength: Enabled: false - Metrics/CyclomaticComplexity: Enabled: false - Metrics/MethodLength: Enabled: false - Metrics/ModuleLength: Enabled: false - Metrics/PerceivedComplexity: Enabled: false -RSpec/ExampleLength: - Max: 19 - -RSpec/MultipleExpectations: - Enabled: false -# set_ methods are the part of PDF::Reader API Naming/AccessorMethodName: - Enabled: false + Exclude: + - lib/prawn/graphics/color.rb -Naming/FileName: +Naming/PredicateName: Exclude: - - Gemfile + - lib/prawn/font/ttf.rb + - lib/prawn/font/afm.rb -Layout/AlignParameters: - EnforcedStyle: with_fixed_indentation +Naming/MethodParameterName: + MinNameLength: 3 + AllowNamesEndingInNumbers: true + AllowedNames: + - id + - io + - to + - at + - x + - x1 + - x2 + - y + - y1 + - y2 + - r1 + - r2 + + ForbiddenNames: [] + + +# This one doesn't work well with YARD +Style/AccessorGrouping: + Enabled: false # We need to reference non-ascii characters when testing and explaining # behavior related to win-1252, UTF-8 and UTF-16 encodings for example. Style/AsciiComments: Enabled: false +Style/AutoResourceCleanup: + Enabled: true + +Style/CollectionMethods: + Enabled: true + Style/Documentation: Enabled: false +Style/Encoding: + # To be safe we are leaving these files encoded ASCII-8BIT as + # discussed at https://github.com/prawnpdf/prawn/pull/705 + Exclude: + - lib/prawn/images/jpg.rb + - lib/prawn/images/png.rb + - lib/prawn/images.rb + - spec/png_spec.rb + Style/GuardClause: Enabled: false -# We don't always prefer modified if statements even if they do fit on -# a line. +# We don't always prefer modifier statements even if they do fit on a line. Style/IfUnlessModifier: Enabled: false +Style/WhileUntilModifier: + Enabled: false -Layout/MultilineOperationIndentation: - Exclude: - - prawn.gemspec +Style/ImplicitRuntimeError: + Enabled: true + +# This one would break our public API +Style/OptionalBooleanParameter: + Enabled: false Style/PercentLiteralDelimiters: PreferredDelimiters: @@ -81,9 +188,34 @@ '%W': '[]' '%x': '()' -Style/SymbolProc: - Exclude: - - 'spec/spec_helper.rb' +Style/ReturnNil: + Enabled: true -Style/WhileUntilModifier: +Style/Send: + Enabled: true + + +Performance/CaseWhenSplat: + Enabled: true + +Performance/IoReadlines: + Enabled: true + + +RSpec/DescribedClassModuleWrapping: + Enabled: true + +RSpec/ExampleLength: Enabled: false + +RSpec/MessageExpectation: + Enabled: true + +RSpec/MultipleExpectations: + Enabled: false + +RSpec/NestedGroups: + Max: 5 + +RSpec/NotToNot: + EnforcedStyle: to_not diff -Nru ruby-pdf-core-0.8.1/spec/filters_spec.rb ruby-pdf-core-0.9.0/spec/filters_spec.rb --- ruby-pdf-core-0.8.1/spec/filters_spec.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/spec/filters_spec.rb 2020-10-24 15:32:00.000000000 +0000 @@ -4,8 +4,7 @@ FILTERS = { FlateDecode: { - 'test' => (+"x\x9C+I-.\x01\x00\x04]\x01\xC1") - .force_encoding(Encoding::ASCII_8BIT) + 'test' => (+"x\x9C+I-.\x01\x00\x04]\x01\xC1").force_encoding(Encoding::ASCII_8BIT) }, DCTDecode: { 'test' => 'test' } }.freeze diff -Nru ruby-pdf-core-0.8.1/spec/pdf/core/name_tree_spec.rb ruby-pdf-core-0.9.0/spec/pdf/core/name_tree_spec.rb --- ruby-pdf-core-0.8.1/spec/pdf/core/name_tree_spec.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/spec/pdf/core/name_tree_spec.rb 2020-10-24 15:32:00.000000000 +0000 @@ -5,7 +5,7 @@ RSpec.describe PDF::Core::NameTree do def tree_dump(tree) if tree.is_a?(PDF::Core::NameTree::Node) - '[' + tree.children.map { |child| tree_dump(child) }.join(',') + ']' + "[#{tree.children.map { |child| tree_dump(child) }.join(',')}]" else "#{tree.name}=#{tree.value}" end @@ -21,24 +21,21 @@ PDF::Core::NameTree::Value.new(name, value) end - # FIXME: This is a dummy that's meant to stand in for a Prawn::Document. - # It causes the tests to pass but I have no idea if it's really a - # sufficient test double or not. - # rubocop: disable RSpec/InstanceVariable - class RefExposingDocument - def initialize - @object_store = [] - end - - attr_reader :object_store - - def ref!(obj) - @object_store << obj - end + let(:pdf) do + document_class = + Class.new do + def initialize + @object_store = [] + end + + attr_reader :object_store + + def ref!(obj) + @object_store << obj + end + end + document_class.new end - # rubocop: enable RSpec/InstanceVariable - - let(:pdf) { RefExposingDocument.new } it 'has no children when first initialized' do node = PDF::Core::NameTree::Node.new(pdf, 3) diff -Nru ruby-pdf-core-0.8.1/spec/pdf/core/page_spec.rb ruby-pdf-core-0.9.0/spec/pdf/core/page_spec.rb --- ruby-pdf-core-0.8.1/spec/pdf/core/page_spec.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/spec/pdf/core/page_spec.rb 2020-10-24 15:32:00.000000000 +0000 @@ -3,26 +3,26 @@ require 'spec_helper' RSpec.describe PDF::Core::Page do - # rubocop: disable RSpec/InstanceVariable - class Document - def initialize - @store = PDF::Core::ObjectStore.new - @state = PDF::Core::DocumentState.new({}) - @renderer = PDF::Core::Renderer.new(@state) - end - attr_reader :state + let(:doc) do + document_class = + Class.new do + def initialize + @store = PDF::Core::ObjectStore.new + @state = PDF::Core::DocumentState.new({}) + @renderer = PDF::Core::Renderer.new(@state) + end + attr_reader :state - def ref(*args) - @renderer.ref(*args) - end + def ref(*args) + @renderer.ref(*args) + end - def save_graphics_state; end + def save_graphics_state; end - def freeze_stamp_graphics; end + def freeze_stamp_graphics; end + end + document_class.new end - # rubocop: enable RSpec/InstanceVariable - - let(:doc) { Document.new } it 'embeds MediaBox' do page = described_class.new doc, size: 'A4' @@ -80,7 +80,7 @@ page.stamp_stream(ref) do page.content << 'test' end - end.not_to raise_error + end.to_not raise_error expect(ref.stream.filtered_stream).to eq 'test' end end diff -Nru ruby-pdf-core-0.8.1/spec/pdf/core/text_spec.rb ruby-pdf-core-0.9.0/spec/pdf/core/text_spec.rb --- ruby-pdf-core-0.8.1/spec/pdf/core/text_spec.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/spec/pdf/core/text_spec.rb 2020-10-24 15:32:00.000000000 +0000 @@ -3,40 +3,38 @@ require 'spec_helper' RSpec.describe PDF::Core::Text do - class DummyFont - def encode_text(text, _options) - [nil, text] - end - - def identifier_for(_subset) - :Font - end - - def add_to_current_page(_subset); end - end - - # rubocop: disable RSpec/InstanceVariable - class TextMock - include PDF::Core::Text - - attr_reader :text - - def add_content(str) - @text ||= +'' - @text << str - end + let(:mock) do + text_mock_class = + Class.new do + include PDF::Core::Text + + attr_reader :text + + def add_content(str) + @text ||= +'' + @text << str + end - def font - @font ||= DummyFont.new - end + def font + @font ||= Class.new do + def encode_text(text, _options) + [nil, text] + end + + def add_to_current_page(_subset); end + + def identifier_for(_subset) + :Font + end + end.new + end - def font_size - 12 - end + def font_size + 12 + end + end + text_mock_class.new end - # rubocop: enable RSpec/InstanceVariable - - let(:mock) { TextMock.new } describe 'horizontal_text_scaling' do describe 'called without argument' do @@ -72,6 +70,7 @@ expect(result).to eq(0) end end + describe 'called with argument' do before do mock.character_spacing(10) do @@ -92,7 +91,7 @@ describe '#add_text_content' do it 'handles frozen strings' do expect { mock.add_text_content 'text', 0, 0, {} } - .not_to raise_error + .to_not raise_error end end end diff -Nru ruby-pdf-core-0.8.1/spec/pdf/core_pdf_object_spec.rb ruby-pdf-core-0.9.0/spec/pdf/core_pdf_object_spec.rb --- ruby-pdf-core-0.8.1/spec/pdf/core_pdf_object_spec.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/spec/pdf/core_pdf_object_spec.rb 2020-10-24 15:32:00.000000000 +0000 @@ -7,146 +7,160 @@ # See PDF Reference, Sixth Edition (1.7) pp51-60 for details RSpec.describe PDF::Core, '.pdf_object' do it "converts Ruby's nil to PDF null" do - expect(PDF::Core.pdf_object(nil)).to eq 'null' + expect(described_class.pdf_object(nil)).to eq 'null' end it 'converts Ruby booleans to PDF booleans' do - expect(PDF::Core.pdf_object(true)).to eq 'true' - expect(PDF::Core.pdf_object(false)).to eq 'false' + expect(described_class.pdf_object(true)).to eq 'true' + expect(described_class.pdf_object(false)).to eq 'false' end - it 'converts a Ruby number to PDF number' do - expect(PDF::Core.pdf_object(42)).to eq '42' - - # numbers are rounded to four decimal places - expect(PDF::Core.pdf_object(1.214112421)).to eq '1.2141' + describe 'numbers' do + it 'converts a n integer to PDF number' do + expect(described_class.pdf_object(42)).to eq '42' + end + + it 'rounds a float to five significant digits' do + expect(described_class.pdf_object(1.214117421)).to eq '1.21412' + end + + it 'produces no trailing zeroes' do + expect(described_class.pdf_object(1.200000001)).to eq '1.2' + end end it 'drops trailing fraction zeros from numbers' do - expect(PDF::Core.pdf_object(42.0)).to eq '42' + expect(described_class.pdf_object(42.0)).to eq '42' # numbers are rounded to four decimal places - expect(PDF::Core.pdf_object(1.200000)).to eq '1.2' + expect(described_class.pdf_object(1.200000)).to eq '1.2' end it 'converts a Ruby time object to a PDF timestamp' do t = Time.now - expect(PDF::Core.pdf_object(t)) - .to eq t.strftime('(D:%Y%m%d%H%M%S%z').chop.chop + "'00')" + expect(described_class.pdf_object(t)) + .to eq "#{t.strftime('(D:%Y%m%d%H%M%S%z').chop.chop}'00')" end it 'converts a Ruby string to PDF string when inside a content stream' do s = 'I can has a string' - expect(PDF::Inspector.parse(PDF::Core.pdf_object(s, true))).to eq s + expect(PDF::Inspector.parse(described_class.pdf_object(s, true))).to eq s end it 'converts a Ruby string to a UTF-16 PDF string when outside of '\ 'a content stream' do s = 'I can has a string' - s_utf16 = "\xFE\xFF" + s.unpack('U*').pack('n*') - expect(PDF::Inspector.parse(PDF::Core.pdf_object(s, false))).to eq s_utf16 + s_utf16 = "\xFE\xFF#{s.unpack('U*').pack('n*')}" + parsed_s = PDF::Inspector.parse(described_class.pdf_object(s, false)) + expect(parsed_s).to eq s_utf16 end it 'converts a Ruby string with characters outside the BMP to its '\ 'UTF-16 representation with a BOM' do # U+10192 ROMAN SEMUNCIA SIGN semuncia = [65_938].pack('U') - expect(PDF::Core.pdf_object(semuncia, false).upcase).to eq '' + expect(described_class.pdf_object(semuncia, false).upcase) + .to eq '' end it 'passes through bytes regardless of content stream status for '\ 'ByteString' do expect( - PDF::Core.pdf_object(PDF::Core::ByteString.new("\xDE\xAD\xBE\xEF")).upcase + described_class.pdf_object(PDF::Core::ByteString.new("\xDE\xAD\xBE\xEF")) + .upcase ).to eq '' end it 'escapes parens when converting from Ruby string to PDF' do s = 'I )(can has a string' - expect(PDF::Inspector.parse(PDF::Core.pdf_object(s, true))).to eq s + expect(PDF::Inspector.parse(described_class.pdf_object(s, true))).to eq s end it 'handles ruby escaped parens when converting to PDF string' do s = 'I can \\)( has string' - expect(PDF::Inspector.parse(PDF::Core.pdf_object(s, true))).to eq s + expect(PDF::Inspector.parse(described_class.pdf_object(s, true))).to eq s end it 'escapes various strings correctly when converting a LiteralString' do ls = PDF::Core::LiteralString.new('abc') - expect(PDF::Core.pdf_object(ls)).to eq '(abc)' + expect(described_class.pdf_object(ls)).to eq '(abc)' ls = PDF::Core::LiteralString.new("abc\x0Ade") # should escape \n - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C\x0Ade)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C\x0Ade)" ls = PDF::Core::LiteralString.new("abc\x0Dde") # should escape \r - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C\x0Dde)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C\x0Dde)" ls = PDF::Core::LiteralString.new("abc\x09de") # should escape \t - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C\x09de)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C\x09de)" ls = PDF::Core::LiteralString.new("abc\x08de") # should escape \b - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C\x08de)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C\x08de)" ls = PDF::Core::LiteralString.new("abc\x0Cde") # should escape \f - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C\x0Cde)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C\x0Cde)" ls = PDF::Core::LiteralString.new('abc(de') # should escape \( - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C(de)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C(de)" ls = PDF::Core::LiteralString.new('abc)de') # should escape \) - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C)de)" + expect(described_class.pdf_object(ls)).to eq "(abc\x5C)de)" ls = PDF::Core::LiteralString.new("abc\x5Cde") # should escape \\ - expect(PDF::Core.pdf_object(ls)).to eq "(abc\x5C\x5Cde)" - expect(PDF::Core.pdf_object(ls).size).to eq 9 + expect(described_class.pdf_object(ls)).to eq "(abc\x5C\x5Cde)" + expect(described_class.pdf_object(ls).size).to eq 9 end it 'escapes strings correctly when converting a LiteralString that is '\ 'not utf-8' do data = "\x43\xaf\xc9\x7f\xef\xf\xe6\xa8\xcb\x5c\xaf\xd0" ls = PDF::Core::LiteralString.new(data) - expect(PDF::Core.pdf_object(ls)) + expect(described_class.pdf_object(ls)) .to eq "(\x43\xaf\xc9\x7f\xef\xf\xe6\xa8\xcb\x5c\x5c\xaf\xd0)" end it 'converts a Ruby symbol to PDF name' do - expect(PDF::Core.pdf_object(:my_symbol)).to eq '/my_symbol' + expect(described_class.pdf_object(:my_symbol)).to eq '/my_symbol' expect( - PDF::Core.pdf_object(:"A;Name_With-Various***Characters?") + described_class.pdf_object(:"A;Name_With-Various***Characters?") ).to eq '/A;Name_With-Various***Characters?' end it 'converts a whitespace or delimiter containing Ruby symbol to '\ 'a PDF name' do - expect(PDF::Core.pdf_object(:'my symbol')).to eq '/my#20symbol' - expect(PDF::Core.pdf_object(:'my#symbol')).to eq '/my#23symbol' - expect(PDF::Core.pdf_object(:'my/symbol')).to eq '/my#2Fsymbol' - expect(PDF::Core.pdf_object(:'my(symbol')).to eq '/my#28symbol' - expect(PDF::Core.pdf_object(:'my)symbol')).to eq '/my#29symbol' - expect(PDF::Core.pdf_object(:'mysymbol')).to eq '/my#3Esymbol' + expect(described_class.pdf_object(:'my symbol')).to eq '/my#20symbol' + expect(described_class.pdf_object(:'my#symbol')).to eq '/my#23symbol' + expect(described_class.pdf_object(:'my/symbol')).to eq '/my#2Fsymbol' + expect(described_class.pdf_object(:'my(symbol')).to eq '/my#28symbol' + expect(described_class.pdf_object(:'my)symbol')).to eq '/my#29symbol' + expect(described_class.pdf_object(:'mysymbol')).to eq '/my#3Esymbol' end it 'converts a Ruby array to PDF Array when inside a content stream' do - expect(PDF::Core.pdf_object([1, 2, 3])).to eq '[1 2 3]' + expect(described_class.pdf_object([1, 2, 3])).to eq '[1 2 3]' expect( - PDF::Inspector.parse(PDF::Core.pdf_object([[1, 2], :foo, 'Bar'], true)) + PDF::Inspector.parse( + described_class.pdf_object([[1, 2], :foo, 'Bar'], true) + ) ).to eq [[1, 2], :foo, 'Bar'] end it 'converts a Ruby array to PDF Array when outside a content stream' do - bar = "\xFE\xFF" + 'Bar'.unpack('U*').pack('n*') - expect(PDF::Core.pdf_object([1, 2, 3])).to eq '[1 2 3]' + expect(described_class.pdf_object([1, 2, 3])).to eq '[1 2 3]' + bar = "\xFE\xFF\x00B\x00a\x00r" expect( - PDF::Inspector.parse(PDF::Core.pdf_object([[1, 2], :foo, 'Bar'], false)) + PDF::Inspector.parse( + described_class.pdf_object([[1, 2], :foo, 'Bar'], false) + ) ).to eq [[1, 2], :foo, bar] end it 'converts a Ruby hash to a PDF Dictionary when inside a content stream' do - dict = PDF::Core.pdf_object( + dict = described_class.pdf_object( { - :foo => :bar, + :foo => :bar, 'baz' => [1, 2, 3], :bang => { a: 'what', b: %i[you say] } }, @@ -161,8 +175,8 @@ end it 'converts a Ruby hash to a PDF Dictionary when outside a content stream' do - what = "\xFE\xFF" + 'what'.unpack('U*').pack('n*') - dict = PDF::Core.pdf_object( + what = "\xFE\xFF\x00w\x00h\x00a\x00t" + dict = described_class.pdf_object( { foo: :bar, 'baz' => [1, 2, 3], @@ -179,13 +193,13 @@ end it 'does not allow keys other than strings or symbols for PDF dicts' do - expect { PDF::Core.pdf_object(:foo => :bar, :baz => :bang, 1 => 4) } + expect { described_class.pdf_object(:foo => :bar, :baz => :bang, 1 => 4) } .to raise_error(PDF::Core::Errors::FailedObjectConversion) end it 'converts a Prawn::Reference to a PDF indirect object reference' do ref = PDF::Core::Reference.new(1, true) - expect(PDF::Core.pdf_object(ref)).to eq ref.to_s + expect(described_class.pdf_object(ref)).to eq ref.to_s end it 'converts a NameTree::Node to a PDF hash' do @@ -193,7 +207,7 @@ node = PDF::Core::NameTree::Node.new(nil, 10) node.add 'hello', 1.0 node.add 'world', 2.0 - data = PDF::Core.pdf_object(node) + data = described_class.pdf_object(node) res = PDF::Inspector.parse(data) expect(res).to eq(Names: ['hello', 1.0, 'world', 2.0]) end diff -Nru ruby-pdf-core-0.8.1/spec/spec_helper.rb ruby-pdf-core-0.9.0/spec/spec_helper.rb --- ruby-pdf-core-0.8.1/spec/spec_helper.rb 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/spec/spec_helper.rb 2020-10-24 15:32:00.000000000 +0000 @@ -2,9 +2,6 @@ puts "PDF::Core specs: Running on Ruby Version: #{RUBY_VERSION}" -require 'bundler' -Bundler.setup - if ENV['COVERAGE'] require 'simplecov' SimpleCov.start @@ -16,13 +13,15 @@ require 'pdf/reader' require 'pdf/inspector' +# rubocop: disable Style/SymbolProc RSpec.configure do |config| config.disable_monkey_patching! end +# rubocop: enable Style/SymbolProc RSpec::Matchers.define :have_parseable_xobjects do match do |actual| - expect { PDF::Inspector::XObject.analyze(actual.render) }.not_to raise_error + expect { PDF::Inspector::XObject.analyze(actual.render) }.to_not raise_error true end failure_message_for_should do |actual| diff -Nru ruby-pdf-core-0.8.1/.travis.yml ruby-pdf-core-0.9.0/.travis.yml --- ruby-pdf-core-0.8.1/.travis.yml 2018-04-28 07:50:04.000000000 +0000 +++ ruby-pdf-core-0.9.0/.travis.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -language: ruby -before_install: - - gem install bundler - - bundle --version -rvm: - - 2.3.0 - - 2.3.7 - - 2.4.0 - - 2.4.4 - - 2.5.0 - - 2.5.1 - - jruby-9.1.13.0 - - jruby-9.1.17.0