Skip to content

Commit

Permalink
Bump up prawn-dev to 0.3.0
Browse files Browse the repository at this point in the history
This update moves the minimum supported Ruby version to 2.6 and updates Rubocop libraries.

Additional changes in this PR include:

Minor changes to address lints
Removal of 2.5, 2.5.0, and jruby-9.2 from the CI matrix because of the new minimum version
  • Loading branch information
petergoldstein authored and pointlessone committed Feb 8, 2022
1 parent 4c27b67 commit 538cde7
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 54 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ jobs:
fail-fast: false
matrix:
ruby:
- "2.5.0"
- "2.5"
- "2.6.0"
- "2.6"
- "2.7.0"
Expand All @@ -47,7 +45,6 @@ jobs:
- "3.1.0"
- "3.1"
- ruby-head
- jruby-9.2
- jruby-9.3
steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/document/column_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions lib/prawn/font.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/prawn/fonts/afm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions lib/prawn/fonts/ttf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/graphics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 9 additions & 11 deletions lib/prawn/grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/repeater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def repeat(page_filter, options = {}, &block)
end
end

class Repeater #:nodoc:
class Repeater # :nodoc:
class << self
attr_writer :count

Expand Down
10 changes: 6 additions & 4 deletions lib/prawn/text/formatted/arranger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 #%<method>s'
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/text/formatted/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 5 additions & 3 deletions lib/prawn/text/formatted/fragment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/prawn/text/formatted/line_wrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/prawn/text/formatted/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions lib/prawn/text/formatted/wrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions manual/outline/add_subsection_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions prawn.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions spec/prawn/graphics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/prawn_manual_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
MANUAL_HASH =
case RUBY_ENGINE
when 'ruby'
'de26db4fe63e024231c0a332203b41305103d877b584a2e98dbd0561bced39f2c066b5c0c96a4686e586a9deb347f099dac4c646446dadb1521a7d4a674ae6fb'
'1dbd5d466eb58d4d495aee6869eb839e3995fbe8607318c491786b959f490e5aab968574a2fea8c3e42ef3d54374bc903357f5cc7b5065f5fe71999830d7c995'
when 'jruby'
'c002ffaf6fe4b2877bd2244735e99c04a4b28b06bc365f343411af052d491660e0d858a956a757ad15a4ed16d6808fc8d726fd683d524f5a3f7c0c8b9566b683'
'e23a8336dd55ca007d93eaaacb9ef6ca4d3e91d4b6ccf5e504925212907ebf3a0c7334e1a614ee5e54de800bd4500a3b2430e038bd9f75879c4a69c68589408d'
end

RSpec.describe Prawn do
Expand Down

0 comments on commit 538cde7

Please sign in to comment.