diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2744f6bfd..c3bb75015 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,8 +36,6 @@ jobs: fail-fast: false matrix: ruby: - - "2.5.0" - - "2.5" - "2.6.0" - "2.6" - "2.7.0" @@ -47,7 +45,6 @@ jobs: - "3.1.0" - "3.1" - ruby-head - - jruby-9.2 - jruby-9.3 steps: - uses: actions/checkout@v1 diff --git a/lib/prawn/document.rb b/lib/prawn/document.rb index 439667d5a..686eb829b 100644 --- a/lib/prawn/document.rb +++ b/lib/prawn/document.rb @@ -753,7 +753,7 @@ def apply_margin_options(options) end end - def font_metric_cache #:nodoc: + def font_metric_cache # :nodoc: @font_metric_cache ||= FontMetricCache.new(self) end end diff --git a/lib/prawn/document/column_box.rb b/lib/prawn/document/column_box.rb index dc766893e..5bf74b34d 100644 --- a/lib/prawn/document/column_box.rb +++ b/lib/prawn/document/column_box.rb @@ -52,7 +52,7 @@ def init_column_box(user_block, options = {}) # work. # class ColumnBox < BoundingBox - def initialize(document, parent, point, options = {}) #:nodoc: + def initialize(document, parent, point, options = {}) # :nodoc: super @columns = options[:columns] || 3 @spacer = options[:spacer] || @document.font_size diff --git a/lib/prawn/encoding.rb b/lib/prawn/encoding.rb index 5284352a0..0919bdf20 100644 --- a/lib/prawn/encoding.rb +++ b/lib/prawn/encoding.rb @@ -9,7 +9,7 @@ module Prawn module Encoding # Map between unicode and WinAnsiEnoding # - class WinAnsi #:nodoc: + class WinAnsi # :nodoc: CHARACTERS = %w[ .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef diff --git a/lib/prawn/font.rb b/lib/prawn/font.rb index 6eb4dac94..41281adff 100644 --- a/lib/prawn/font.rb +++ b/lib/prawn/font.rb @@ -236,7 +236,7 @@ def save_font # ++ # # @private - def find_font(name, options = {}) #:nodoc: + def find_font(name, options = {}) # :nodoc: if font_families.key?(name) family = name name = font_families[name][options[:style] || :normal] @@ -257,7 +257,7 @@ def find_font(name, options = {}) #:nodoc: # Hash of Font objects keyed by names # - def font_registry #:nodoc: + def font_registry # :nodoc: @font_registry ||= {} end @@ -328,7 +328,7 @@ def self.font_format(src, options) end end - def initialize(document, name, options = {}) #:nodoc: + def initialize(document, name, options = {}) # :nodoc: @document = document @name = name @options = options @@ -400,11 +400,11 @@ def add_to_current_page(subset) @document.state.page.fonts[identifier_for(subset)] = @references[subset] end - def identifier_for(subset) #:nodoc: + def identifier_for(subset) # :nodoc: @subset_name_cache[subset] ||= "#{@identifier}.#{subset}".to_sym end - def inspect #:nodoc: + def inspect # :nodoc: "#{self.class.name}< #{name}: #{size} >" end @@ -413,13 +413,13 @@ def inspect #:nodoc: # that cache certain values (See # Prawn::Table::Text#styled_with_of_single_character) # - def hash #:nodoc: + def hash # :nodoc: [self.class, name, family].hash end # Compliments the #hash implementation above # - def eql?(other) #:nodoc: + def eql?(other) # :nodoc: self.class == other.class && name == other.name && family == other.family && size == other.size end diff --git a/lib/prawn/fonts/afm.rb b/lib/prawn/fonts/afm.rb index dabd772b9..a1dcbfc7c 100644 --- a/lib/prawn/fonts/afm.rb +++ b/lib/prawn/fonts/afm.rb @@ -44,14 +44,14 @@ def self.metrics_path end end - attr_reader :attributes #:nodoc: + attr_reader :attributes # :nodoc: # parse each ATM font file once only def self.font_data @font_data ||= SynchronizedCache.new end - def initialize(document, name, options = {}) #:nodoc: + def initialize(document, name, options = {}) # :nodoc: name ||= options[:family] unless BUILT_INS.include?(name) raise Prawn::Errors::UnknownFont, @@ -84,7 +84,7 @@ def bbox end # NOTE: String *must* be encoded as WinAnsi - def compute_width_of(string, options = {}) #:nodoc: + def compute_width_of(string, options = {}) # :nodoc: scale = (options[:size] || size) / 1000.0 if options[:kerning] diff --git a/lib/prawn/fonts/ttf.rb b/lib/prawn/fonts/ttf.rb index 587093350..7a28a9ca5 100644 --- a/lib/prawn/fonts/ttf.rb +++ b/lib/prawn/fonts/ttf.rb @@ -61,7 +61,7 @@ def initialize(document, name, options = {}) end # NOTE: +string+ must be UTF8-encoded. - def compute_width_of(string, options = {}) #:nodoc: + def compute_width_of(string, options = {}) # :nodoc: scale = (options[:size] || size) / 1000.0 if options[:kerning] kern(string).reduce(0) do |s, r| @@ -323,7 +323,7 @@ def embed(reference, subset) hmtx = font.horizontal_metrics widths = font.cmap.tables.first.code_map.map do |gid| Integer(hmtx.widths[gid] * scale_factor) - end[32..-1] + end[32..] # It would be nice to have Encoding set for the macroman subsets, # and only do a ToUnicode cmap for non-encoded unicode subsets. diff --git a/lib/prawn/graphics.rb b/lib/prawn/graphics.rb index a84c6645c..9beea14c2 100644 --- a/lib/prawn/graphics.rb +++ b/lib/prawn/graphics.rb @@ -237,7 +237,7 @@ def ellipse(point, radius1, radius2 = radius1) # def polygon(*points) move_to points[0] - (points[1..-1] << points[0]).each do |point| + (points[1..] << points[0]).each do |point| line_to(*point) end # close the path diff --git a/lib/prawn/grid.rb b/lib/prawn/grid.rb index 6dca7c7e1..0b5e48fd1 100644 --- a/lib/prawn/grid.rb +++ b/lib/prawn/grid.rb @@ -34,18 +34,16 @@ def define_grid(options = {}) def grid(*args) @boxes ||= {} @boxes[args] ||= - begin - if args.empty? - @grid + if args.empty? + @grid + else + g1, g2 = args + + if g1.is_a?(Array) && g2.is_a?(Array) && + g1.length == 2 && g2.length == 2 + multi_box(single_box(*g1), single_box(*g2)) else - g1, g2 = args - - if g1.is_a?(Array) && g2.is_a?(Array) && - g1.length == 2 && g2.length == 2 - multi_box(single_box(*g1), single_box(*g2)) - else - single_box(g1, g2) - end + single_box(g1, g2) end end end diff --git a/lib/prawn/repeater.rb b/lib/prawn/repeater.rb index bc5b3f010..1d4e4644a 100644 --- a/lib/prawn/repeater.rb +++ b/lib/prawn/repeater.rb @@ -83,7 +83,7 @@ def repeat(page_filter, options = {}, &block) end end - class Repeater #:nodoc: + class Repeater # :nodoc: class << self attr_writer :count diff --git a/lib/prawn/text/formatted/arranger.rb b/lib/prawn/text/formatted/arranger.rb index 3b1fbe786..ee1659d2c 100644 --- a/lib/prawn/text/formatted/arranger.rb +++ b/lib/prawn/text/formatted/arranger.rb @@ -9,10 +9,10 @@ module Prawn module Text - module Formatted #:nodoc: + module Formatted # :nodoc: # @private - class Arranger #:nodoc: + class Arranger # :nodoc: class NotFinalized < StandardError DEFAULT_MESSAGE = 'Lines must be finalized' MESSAGE_WITH_METHOD = 'Lines must be finalized before calling #%s' @@ -277,13 +277,15 @@ def apply_font_size(size, styles, &block) def subscript?(styles) if styles.nil? then false - else styles.include?(:subscript) + else + styles.include?(:subscript) end end def superscript?(styles) if styles.nil? then false - else styles.include?(:superscript) + else + styles.include?(:superscript) end end diff --git a/lib/prawn/text/formatted/box.rb b/lib/prawn/text/formatted/box.rb index 5948e97f7..16b6b3a4f 100644 --- a/lib/prawn/text/formatted/box.rb +++ b/lib/prawn/text/formatted/box.rb @@ -257,7 +257,7 @@ def height # def draw_fragment( fragment, accumulated_width = 0, line_width = 0, word_spacing = 0 - ) #:nodoc: + ) # :nodoc: case @align when :left x = @at[0] diff --git a/lib/prawn/text/formatted/fragment.rb b/lib/prawn/text/formatted/fragment.rb index c10ecc17f..3eac70ab7 100644 --- a/lib/prawn/text/formatted/fragment.rb +++ b/lib/prawn/text/formatted/fragment.rb @@ -32,7 +32,8 @@ def initialize(text, format_state, document) def width if @word_spacing.zero? then @width - else @width + @word_spacing * space_count + else + @width + @word_spacing * space_count end end @@ -51,7 +52,8 @@ def superscript? def y_offset if subscript? then -descender elsif superscript? then 0.85 * ascender - else 0 + else + 0 end end @@ -211,7 +213,7 @@ def process_text(text) string = string.rstrip if soft_hyphens_need_processing?(string) - string = process_soft_hyphens(string[0..-2]) + string[-1..-1] + string = process_soft_hyphens(string[0..-2]) + string[-1..] end elsif soft_hyphens_need_processing?(string) string = process_soft_hyphens(string) diff --git a/lib/prawn/text/formatted/line_wrap.rb b/lib/prawn/text/formatted/line_wrap.rb index bc3b5e4f1..eac14dff3 100644 --- a/lib/prawn/text/formatted/line_wrap.rb +++ b/lib/prawn/text/formatted/line_wrap.rb @@ -10,9 +10,9 @@ module Prawn module Text - module Formatted #:nodoc: + module Formatted # :nodoc: # @private - class LineWrap #:nodoc: + class LineWrap # :nodoc: # The width of the last wrapped line # def width diff --git a/lib/prawn/text/formatted/parser.rb b/lib/prawn/text/formatted/parser.rb index ee7b85c37..2200e4ff5 100644 --- a/lib/prawn/text/formatted/parser.rb +++ b/lib/prawn/text/formatted/parser.rb @@ -100,7 +100,7 @@ def self.to_string(array) end.join end - def self.array_paragraphs(array) #:nodoc: + def self.array_paragraphs(array) # :nodoc: paragraphs = [] paragraph = [] previous_string = "\n" diff --git a/lib/prawn/text/formatted/wrap.rb b/lib/prawn/text/formatted/wrap.rb index a78f00428..81b4fdac5 100644 --- a/lib/prawn/text/formatted/wrap.rb +++ b/lib/prawn/text/formatted/wrap.rb @@ -11,10 +11,10 @@ module Prawn module Text - module Formatted #:nodoc: + module Formatted # :nodoc: # @private - module Wrap #:nodoc: + module Wrap # :nodoc: def initialize(_array, options) @line_wrap = Prawn::Text::Formatted::LineWrap.new @arranger = Prawn::Text::Formatted::Arranger.new( @@ -44,7 +44,7 @@ def initialize(_array, options) # # Returns any formatted text that was not printed # - def wrap(array) #:nodoc: + def wrap(array) # :nodoc: initialize_wrap(array) stop = false diff --git a/manual/outline/add_subsection_to.rb b/manual/outline/add_subsection_to.rb index de6b17c54..d5f9ab93e 100644 --- a/manual/outline/add_subsection_to.rb +++ b/manual/outline/add_subsection_to.rb @@ -44,17 +44,17 @@ outline.add_subsection_to('Section 1') do outline.page title: 'Added later - last position', - destination: 6 + destination: 6 end outline.add_subsection_to('Added later - first position') do outline.page title: 'Another page added later', - destination: 7 + destination: 7 end # The title provided is for a page which will be converted into a section outline.add_subsection_to('Page 3') do outline.page title: 'Last page added', - destination: 8 + destination: 8 end end diff --git a/prawn.gemspec b/prawn.gemspec index 7c071ba16..5626666bd 100644 --- a/prawn.gemspec +++ b/prawn.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |spec| '.yardopts' ] spec.require_path = 'lib' - spec.required_ruby_version = '>= 2.5' + spec.required_ruby_version = '>= 2.6' spec.required_rubygems_version = '>= 1.3.6' spec.authors = [ @@ -42,7 +42,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency('pdf-inspector', '>= 1.2.1', '< 2.0.a') spec.add_development_dependency('pdf-reader', ['~> 1.4', '>= 1.4.1']) - spec.add_development_dependency('prawn-dev', '~> 0.2.0') + spec.add_development_dependency('prawn-dev', '~> 0.3.0') spec.add_development_dependency('prawn-manual_builder', '>= 0.3.0') spec.homepage = 'http://prawnpdf.org' diff --git a/spec/prawn/graphics_spec.rb b/spec/prawn/graphics_spec.rb index b9f34b754..64515a62c 100644 --- a/spec/prawn/graphics_spec.rb +++ b/spec/prawn/graphics_spec.rb @@ -186,7 +186,7 @@ end it 'moves the pointer to the center of the ellipse after drawing' do - expect(curve.coords[-2..-1]).to eq([100, 100]) + expect(curve.coords[-2..]).to eq([100, 100]) end end @@ -199,7 +199,7 @@ it 'strokes the same path as the equivalent ellipse' do middle = curve.coords.length / 2 - expect(curve.coords[0...middle]).to eq(curve.coords[middle..-1]) + expect(curve.coords[0...middle]).to eq(curve.coords[middle..]) end end diff --git a/spec/prawn_manual_spec.rb b/spec/prawn_manual_spec.rb index e4a3f15cd..57720ccd0 100644 --- a/spec/prawn_manual_spec.rb +++ b/spec/prawn_manual_spec.rb @@ -6,9 +6,9 @@ MANUAL_HASH = case RUBY_ENGINE when 'ruby' - 'de26db4fe63e024231c0a332203b41305103d877b584a2e98dbd0561bced39f2c066b5c0c96a4686e586a9deb347f099dac4c646446dadb1521a7d4a674ae6fb' + '1dbd5d466eb58d4d495aee6869eb839e3995fbe8607318c491786b959f490e5aab968574a2fea8c3e42ef3d54374bc903357f5cc7b5065f5fe71999830d7c995' when 'jruby' - 'c002ffaf6fe4b2877bd2244735e99c04a4b28b06bc365f343411af052d491660e0d858a956a757ad15a4ed16d6808fc8d726fd683d524f5a3f7c0c8b9566b683' + 'e23a8336dd55ca007d93eaaacb9ef6ca4d3e91d4b6ccf5e504925212907ebf3a0c7334e1a614ee5e54de800bd4500a3b2430e038bd9f75879c4a69c68589408d' end RSpec.describe Prawn do