diff --git a/.rubocop.yml b/.rubocop.yml index 6254a3749..b652ba399 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,74 +1,16 @@ -require: - - rubocop-performance - - rubocop-rspec - -AllCops: - TargetRubyVersion: 2.5 - NewCops: enable - -Layout/ArgumentAlignment: - EnforcedStyle: with_fixed_indentation +inherit_gem: + prawn-dev: rubocop.yml Lint/ConstantDefinitionInBlock: Exclude: - manual/text/formatted_callbacks.rb - manual/text/text_box_extensions.rb -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. @@ -82,9 +24,6 @@ Lint/SuppressedException: Exclude: - lib/prawn/text/formatted/box.rb - -Metrics/AbcSize: - Enabled: false Metrics/BlockLength: Exclude: - lib/prawn/graphics.rb @@ -93,17 +32,6 @@ Metrics/BlockLength: - manual/**/*.rb - prawn.gemspec - spec/**/*.rb -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false - Naming/AccessorMethodName: Exclude: @@ -114,43 +42,6 @@ Naming/PredicateName: - lib/prawn/font/ttf.rb - lib/prawn/font/afm.rb -Naming/MethodParameterName: - MinNameLength: 3 - AllowNamesEndingInNumbers: true - AllowedNames: - - id - - 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 @@ -159,64 +50,3 @@ Style/Encoding: - lib/prawn/images/png.rb - lib/prawn/images.rb - spec/png_spec.rb - -Style/GuardClause: - Enabled: false - -# We don't always prefer modifier statements even if they do fit on a line. -Style/IfUnlessModifier: - Enabled: false -Style/WhileUntilModifier: - Enabled: false - -Style/ImplicitRuntimeError: - Enabled: true - -# This one would break our public API -Style/OptionalBooleanParameter: - Enabled: false - -Style/PercentLiteralDelimiters: - PreferredDelimiters: - '%': '()' - '%i': '[]' - '%I': '[]' - '%q': '()' - '%Q': '()' - '%r': '{}' - '%s': '()' - '%w': '[]' - '%W': '[]' - '%x': '()' - -Style/ReturnNil: - Enabled: true - -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 --git a/Rakefile b/Rakefile index bfe8c3b40..5e18d0c04 100644 --- a/Rakefile +++ b/Rakefile @@ -1,23 +1,10 @@ # frozen_string_literal: true -require 'rake' -require 'rspec/core/rake_task' -require 'yard' -require 'rubygems/package_task' -require 'rubocop/rake_task' +GEMSPEC = File.expand_path('prawn.gemspec', __dir__) +require 'prawn/dev/tasks' task default: %i[spec rubocop] -desc 'Run all rspec files' -RSpec::Core::RakeTask.new('spec') do |c| - c.rspec_opts = '-t ~unresolved' -end - -YARD::Rake::YardocTask.new do |t| - t.options = ['--output-dir', 'doc/html'] -end -task docs: :yard - desc "Generate the 'Prawn by Example' manual" task :manual do puts 'Building manual...' @@ -26,12 +13,6 @@ task :manual do puts 'The Prawn manual is available at manual.pdf. Happy Prawning!' end -spec = Gem::Specification.load 'prawn.gemspec' -Gem::PackageTask.new(spec) do |pkg| - pkg.need_zip = true - pkg.need_tar = true -end - desc 'Run a console with Prawn loaded' task :console do require 'irb' @@ -42,13 +23,3 @@ task :console do ARGV.clear IRB.start end - -RuboCop::RakeTask.new - -task :checksum do - require 'digest/sha2' - built_gem_path = "prawn-#{Prawn::VERSION}.gem" - checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path)) - checksum_path = "checksums/#{built_gem_path}.sha512" - File.write(checksum_path, checksum) -end diff --git a/lib/prawn/font.rb b/lib/prawn/font.rb index f7d6962e2..1baa8ff77 100644 --- a/lib/prawn/font.rb +++ b/lib/prawn/font.rb @@ -318,10 +318,10 @@ def self.font_format(src, options) return options.fetch(:format, 'ttf') if src.respond_to? :read case src.to_s - when /\.ttf$/i then 'ttf' - when /\.otf$/i then 'otf' + when /\.ttf$/i then 'ttf' + when /\.otf$/i then 'otf' when /\.dfont$/i then 'dfont' - when /\.ttc$/i then 'ttc' + when /\.ttc$/i then 'ttc' else 'afm' end end diff --git a/lib/prawn/fonts/afm.rb b/lib/prawn/fonts/afm.rb index 7d343d076..dabd772b9 100644 --- a/lib/prawn/fonts/afm.rb +++ b/lib/prawn/fonts/afm.rb @@ -177,7 +177,7 @@ def find_font(file) rescue NoMethodError raise Prawn::Errors::UnknownFont, "Couldn't find the font: #{file} in any of:\n" + - self.class.metrics_path.join("\n") + self.class.metrics_path.join("\n") end def parse_afm(file_name) diff --git a/lib/prawn/graphics.rb b/lib/prawn/graphics.rb index aa9c2f08d..a84c6645c 100644 --- a/lib/prawn/graphics.rb +++ b/lib/prawn/graphics.rb @@ -212,7 +212,7 @@ def ellipse(point, radius1, radius2 = radius1) move_to(x + radius1, y) # Upper right hand corner - curve_to [x, y + radius2], + curve_to [x, y + radius2], bounds: [[x + radius1, y + l2], [x + l1, y + radius2]] # Upper left hand corner @@ -633,10 +633,10 @@ def close_path ops.product(shapes).each do |operation, shape| class_eval <<-METHOD, __FILE__, __LINE__ + 1 - def #{operation}_#{shape}(*args) - #{shape}(*args) - #{operation} - end + def #{operation}_#{shape}(*args) # def fill_polygon(*args) + #{shape}(*args) # polygon(*args) + #{operation} # fill + end # end METHOD end diff --git a/lib/prawn/graphics/join_style.rb b/lib/prawn/graphics/join_style.rb index 892ce0f8f..5940a46ca 100644 --- a/lib/prawn/graphics/join_style.rb +++ b/lib/prawn/graphics/join_style.rb @@ -28,7 +28,7 @@ def join_style(style = nil) unless JOIN_STYLES.key?(current_join_style) raise Prawn::Errors::InvalidJoinStyle, "#{style} is not a recognized join style. Valid styles are " + - JOIN_STYLES.keys.join(', ') + JOIN_STYLES.keys.join(', ') end write_stroke_join_style diff --git a/lib/prawn/graphics/patterns.rb b/lib/prawn/graphics/patterns.rb index 6c2d6baa9..dd2a8b7e1 100644 --- a/lib/prawn/graphics/patterns.rb +++ b/lib/prawn/graphics/patterns.rb @@ -114,6 +114,7 @@ def parse_gradient_arguments( *arguments, from: nil, to: nil, r1: nil, r2: nil, stops: nil, apply_transformations: nil ) + case arguments.length when 0 apply_transformations = true if apply_transformations.nil? diff --git a/lib/prawn/graphics/transformation.rb b/lib/prawn/graphics/transformation.rb index 49f938b28..c865b146f 100644 --- a/lib/prawn/graphics/transformation.rb +++ b/lib/prawn/graphics/transformation.rb @@ -48,7 +48,7 @@ def rotate(angle, options = {}, &block) if options[:origin].nil? transformation_matrix(cos, sin, -sin, cos, 0, 0, &block) else - raise Prawn::Errors::BlockRequired unless block_given? + raise Prawn::Errors::BlockRequired unless block x = options[:origin][0] + bounds.absolute_left y = options[:origin][1] + bounds.absolute_bottom @@ -118,7 +118,7 @@ def scale(factor, options = {}, &block) if options[:origin].nil? transformation_matrix(factor, 0, 0, factor, 0, 0, &block) else - raise Prawn::Errors::BlockRequired unless block_given? + raise Prawn::Errors::BlockRequired unless block x = options[:origin][0] + bounds.absolute_left y = options[:origin][1] + bounds.absolute_bottom diff --git a/lib/prawn/security.rb b/lib/prawn/security.rb index 6cd76c0f6..914967930 100644 --- a/lib/prawn/security.rb +++ b/lib/prawn/security.rb @@ -124,8 +124,8 @@ def self.encrypt_string(str, key, id, gen) def encryption_dictionary { Filter: :Standard, # default PDF security handler - V: 1, # "Algorithm 3.1", PDF reference 1.3 - R: 2, # Revision 2 of the algorithm + V: 1, # "Algorithm 3.1", PDF reference 1.3 + R: 2, # Revision 2 of the algorithm O: PDF::Core::ByteString.new(owner_password_hash), U: PDF::Core::ByteString.new(user_password_hash), P: permissions_value diff --git a/lib/prawn/text/formatted/arranger.rb b/lib/prawn/text/formatted/arranger.rb index 5d17a90ba..3b1fbe786 100644 --- a/lib/prawn/text/formatted/arranger.rb +++ b/lib/prawn/text/formatted/arranger.rb @@ -234,9 +234,8 @@ def repack_unretrieved end def font_style(styles) - if styles.nil? - :normal - elsif styles.include?(:bold) && styles.include?(:italic) + styles = Array(styles) + if styles.include?(:bold) && styles.include?(:italic) :bold_italic elsif styles.include?(:bold) :bold diff --git a/manual/bounding_box/canvas.rb b/manual/bounding_box/canvas.rb index d95b1e664..8311b35d9 100644 --- a/manual/bounding_box/canvas.rb +++ b/manual/bounding_box/canvas.rb @@ -15,9 +15,9 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do canvas do - fill_circle [bounds.left, bounds.top], 30 - fill_circle [bounds.right, bounds.top], 30 + fill_circle [bounds.left, bounds.top], 30 + fill_circle [bounds.right, bounds.top], 30 fill_circle [bounds.right, bounds.bottom], 30 - fill_circle [0, 0], 30 + fill_circle [0, 0], 30 end end diff --git a/manual/document_and_page_options/document_and_page_options.rb b/manual/document_and_page_options/document_and_page_options.rb index 5ee3071a6..ced5fd8ee 100644 --- a/manual/document_and_page_options/document_and_page_options.rb +++ b/manual/document_and_page_options/document_and_page_options.rb @@ -7,10 +7,10 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename, page_size: 'FOLIO') do package 'document_and_page_options' do |p| - p.example 'page_size', eval_source: false, full_source: true + p.example 'page_size', eval_source: false, full_source: true p.example 'page_margins', eval_source: false, full_source: true - p.example 'background', eval_source: false, full_source: true - p.example 'metadata', eval_source: false, full_source: true + p.example 'background', eval_source: false, full_source: true + p.example 'metadata', eval_source: false, full_source: true p.example 'print_scaling', eval_source: false, full_source: true p.intro do diff --git a/manual/graphics/common_lines.rb b/manual/graphics/common_lines.rb index 54e82cb0d..1b661d52d 100644 --- a/manual/graphics/common_lines.rb +++ b/manual/graphics/common_lines.rb @@ -22,7 +22,7 @@ move_down 50 horizontal_rule - vertical_line 100, 300, at: 50 + vertical_line 100, 300, at: 50 horizontal_line 200, 500, at: 150 end diff --git a/manual/graphics/fill_and_stroke.rb b/manual/graphics/fill_and_stroke.rb index 7df46f373..bb4498a0a 100644 --- a/manual/graphics/fill_and_stroke.rb +++ b/manual/graphics/fill_and_stroke.rb @@ -33,7 +33,7 @@ # With block stroke { line [200, 200], [300, 150] } - fill { rectangle [200, 100], 100, 100 } + fill { rectangle [200, 100], 100, 100 } # Method hook stroke_line [400, 200], [500, 150] diff --git a/manual/graphics/lines_and_curves.rb b/manual/graphics/lines_and_curves.rb index c9133500a..4bfa05094 100644 --- a/manual/graphics/lines_and_curves.rb +++ b/manual/graphics/lines_and_curves.rb @@ -29,7 +29,7 @@ line_to 0, 100 curve_to [150, 250], bounds: [[20, 200], [120, 200]] - curve_to [200, 0], bounds: [[150, 200], [450, 10]] + curve_to [200, 0], bounds: [[150, 200], [450, 10]] end # line and curve diff --git a/manual/graphics/stroke_dash.rb b/manual/graphics/stroke_dash.rb index 1eddaa3c2..68386fe3a 100644 --- a/manual/graphics/stroke_dash.rb +++ b/manual/graphics/stroke_dash.rb @@ -28,16 +28,16 @@ 24.times do |i| length = (i / 4) + 1 - space = length # space between dashes same length as dash - phase = 0 # start with dash + space = length # space between dashes same length as dash + phase = 0 # start with dash case i % 4 when 0 then base_y -= 5 - when 1 then phase = length # start with space between dashes + when 1 then phase = length # start with space between dashes when 2 then space = length * 0.5 # space between dashes half as long as dash when 3 - space = length * 0.5 # space between dashes half as long as dash - phase = length # start with space between dashes + space = length * 0.5 # space between dashes half as long as dash + phase = length # start with space between dashes end base_y -= 5 diff --git a/manual/images/horizontal.rb b/manual/images/horizontal.rb index c9bd5e16b..fc8de86d9 100644 --- a/manual/images/horizontal.rb +++ b/manual/images/horizontal.rb @@ -14,11 +14,11 @@ stroke_bounds %i[left center right].each do |position| - text "Image aligned to the #{position}." + text "Image aligned to the #{position}." image "#{Prawn::DATADIR}/images/stef.jpg", position: position end - text 'The next image has a 50 point offset from the left boundary' + text 'The next image has a 50 point offset from the left boundary' image "#{Prawn::DATADIR}/images/stef.jpg", position: 50 end end diff --git a/manual/images/scale.rb b/manual/images/scale.rb index b31517225..262d33a60 100644 --- a/manual/images/scale.rb +++ b/manual/images/scale.rb @@ -8,14 +8,14 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do - text 'Normal size' + text 'Normal size' image "#{Prawn::DATADIR}/images/stef.jpg" move_down 20 - text 'Scaled to 50%' + text 'Scaled to 50%' image "#{Prawn::DATADIR}/images/stef.jpg", scale: 0.5 move_down 20 - text 'Scaled to 200%' + text 'Scaled to 200%' image "#{Prawn::DATADIR}/images/stef.jpg", scale: 2 end diff --git a/manual/images/width_and_height.rb b/manual/images/width_and_height.rb index d63faa12d..b24d95fad 100644 --- a/manual/images/width_and_height.rb +++ b/manual/images/width_and_height.rb @@ -11,14 +11,14 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do - text 'Scale by setting only the width' + text 'Scale by setting only the width' image "#{Prawn::DATADIR}/images/pigs.jpg", width: 150 move_down 20 - text 'Scale by setting only the height' + text 'Scale by setting only the height' image "#{Prawn::DATADIR}/images/pigs.jpg", height: 100 move_down 20 - text 'Stretch to fit the width and height provided' + text 'Stretch to fit the width and height provided' image "#{Prawn::DATADIR}/images/pigs.jpg", width: 500, height: 100 end diff --git a/manual/outline/outline.rb b/manual/outline/outline.rb index bc8cbb25e..b6b3f97ab 100644 --- a/manual/outline/outline.rb +++ b/manual/outline/outline.rb @@ -11,7 +11,7 @@ end p.section 'Adding nodes later' do |s| - s.example 'add_subsection_to', eval_source: false + s.example 'add_subsection_to', eval_source: false s.example 'insert_section_after', eval_source: false end diff --git a/manual/security/security.rb b/manual/security/security.rb index 44e49a433..d272bac79 100644 --- a/manual/security/security.rb +++ b/manual/security/security.rb @@ -6,7 +6,7 @@ Prawn::ManualBuilder::Example.generate('security.pdf', page_size: 'FOLIO') do package 'security' do |p| - p.example 'encryption', eval_source: false, full_source: true + p.example 'encryption', eval_source: false, full_source: true p.example 'permissions', eval_source: false, full_source: true p.intro do diff --git a/manual/text/alignment.rb b/manual/text/alignment.rb index 6e68602f8..a55698f51 100644 --- a/manual/text/alignment.rb +++ b/manual/text/alignment.rb @@ -17,7 +17,7 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do text 'This text should be left aligned' - text 'This text should be centered', align: :center + text 'This text should be centered', align: :center text 'This text should be right aligned', align: :right bounding_box([0, 220], width: 250, height: 220) do @@ -36,7 +36,7 @@ bounding_box([300, 220], width: 250, height: 220) do text 'This text should be vertically top aligned' - text 'This text should be vertically centered', valign: :center + text 'This text should be vertically centered', valign: :center text 'This text should be vertically bottom aligned', valign: :bottom transparent(0.5) { stroke_bounds } end diff --git a/manual/text/column_box.rb b/manual/text/column_box.rb index fc298071b..5dd7bd1f9 100644 --- a/manual/text/column_box.rb +++ b/manual/text/column_box.rb @@ -9,7 +9,7 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do - text 'The Prince', align: :center, size: 18 + text 'The Prince', align: :center, size: 18 text 'Niccolò Machiavelli', align: :center, size: 14 move_down 12 diff --git a/manual/text/formatted_callbacks.rb b/manual/text/formatted_callbacks.rb index d607bc4d3..21ed44df5 100644 --- a/manual/text/formatted_callbacks.rb +++ b/manual/text/formatted_callbacks.rb @@ -47,10 +47,10 @@ def render_in_front(fragment) fragment.bottom_left ) - @document.fill_circle(fragment.top_left, @radius) - @document.fill_circle(fragment.top_right, @radius) + @document.fill_circle(fragment.top_left, @radius) + @document.fill_circle(fragment.top_right, @radius) @document.fill_circle(fragment.bottom_right, @radius) - @document.fill_circle(fragment.bottom_left, @radius) + @document.fill_circle(fragment.bottom_left, @radius) end end diff --git a/manual/text/formatted_text.rb b/manual/text/formatted_text.rb index 1dc67cf37..e248dfc63 100644 --- a/manual/text/formatted_text.rb +++ b/manual/text/formatted_text.rb @@ -24,7 +24,7 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do - formatted_text [ + formatted_text([ { text: 'Some bold. ', styles: [:bold] }, { text: 'Some italic. ', styles: [:italic] }, { text: 'Bold italic. ', styles: %i[bold italic] }, @@ -42,7 +42,7 @@ color: '0000FF', local: './local_file.txt' } - ] + ]) formatted_text_box( [ diff --git a/manual/text/free_flowing_text.rb b/manual/text/free_flowing_text.rb index db8a46046..facf4e1c5 100644 --- a/manual/text/free_flowing_text.rb +++ b/manual/text/free_flowing_text.rb @@ -27,7 +27,7 @@ end bounding_box([300, y_position], width: 200, height: 150) do - transparent(0.5) { stroke_bounds } # This will stroke on one page + transparent(0.5) { stroke_bounds } # This will stroke on one page text 'Now look what happens when the free flowing text reaches the end ' \ 'of a bounding box that is narrower than the margin box.' + @@ -36,7 +36,7 @@ 'was cloned. If we want it to have the same border as the one on ' \ 'the previous page we will need to stroke the boundaries again.' - transparent(0.5) { stroke_bounds } # And this will stroke on the next + transparent(0.5) { stroke_bounds } # And this will stroke on the next end move_cursor_to 200 diff --git a/manual/text/kerning_and_character_spacing.rb b/manual/text/kerning_and_character_spacing.rb index 8a5d93461..e9cf368fb 100644 --- a/manual/text/kerning_and_character_spacing.rb +++ b/manual/text/kerning_and_character_spacing.rb @@ -14,16 +14,16 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do font_size(30) do - text_box 'With kerning:', kerning: true, at: [0, y - 40] + text_box 'With kerning:', kerning: true, at: [0, y - 40] text_box 'Without kerning:', kerning: false, at: [0, y - 80] - text_box 'Tomato', kerning: true, at: [250, y - 40] + text_box 'Tomato', kerning: true, at: [250, y - 40] text_box 'Tomato', kerning: false, at: [250, y - 80] - text_box 'WAR', kerning: true, at: [400, y - 40] + text_box 'WAR', kerning: true, at: [400, y - 40] text_box 'WAR', kerning: false, at: [400, y - 80] - text_box 'F.', kerning: true, at: [500, y - 40] + text_box 'F.', kerning: true, at: [500, y - 40] text_box 'F.', kerning: false, at: [500, y - 80] end diff --git a/manual/text/rendering_and_color.rb b/manual/text/rendering_and_color.rb index 39b1b097a..e175d7f81 100644 --- a/manual/text/rendering_and_color.rb +++ b/manual/text/rendering_and_color.rb @@ -16,7 +16,7 @@ filename = File.basename(__FILE__).gsub('.rb', '.pdf') Prawn::ManualBuilder::Example.generate(filename) do - fill_color '00ff00' + fill_color '00ff00' stroke_color '0000ff' font_size(40) do diff --git a/manual/text/right_to_left_text.rb b/manual/text/right_to_left_text.rb index 25e34e716..3a513557f 100644 --- a/manual/text/right_to_left_text.rb +++ b/manual/text/right_to_left_text.rb @@ -31,7 +31,7 @@ text 'You can override the document direction.', direction: :ltr move_down 20 - formatted_text [ + formatted_text([ { text: '更可怕的是,同质化竞争对手可以按照' }, { text: 'URL', direction: :ltr }, { text: '中后面这个' }, @@ -40,15 +40,15 @@ { text: 'DB', direction: :ltr }, { text: '中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么'\ '难事,这样的话,你就非常被动了。' } - ] + ]) move_down 20 - formatted_text [ + formatted_text([ { text: '更可怕的是,同质化竞争对手可以按照' }, - { text: 'this', direction: :ltr }, + { text: 'this', direction: :ltr }, { text: "won't", direction: :ltr, size: 24 }, - { text: 'work', direction: :ltr }, + { text: 'work', direction: :ltr }, { text: '中的内容,写个小爬虫把你的页面上的关键信息顺次爬下来也不是什么难事' } - ] + ]) end end diff --git a/manual/text/win_ansi_charset.rb b/manual/text/win_ansi_charset.rb index 0f3233891..e5aba7c46 100644 --- a/manual/text/win_ansi_charset.rb +++ b/manual/text/win_ansi_charset.rb @@ -45,8 +45,8 @@ width = width_of(field, size: font_size) case align - when :left then offset = 0 - when :right then offset = total_width - width + when :left then offset = 0 + when :right then offset = total_width - width when :center then offset = (total_width - width) / 2 end diff --git a/prawn.gemspec b/prawn.gemspec index 4fc71ae76..df1ef5fb3 100644 --- a/prawn.gemspec +++ b/prawn.gemspec @@ -41,14 +41,8 @@ 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.1.0') spec.add_development_dependency('prawn-manual_builder', '>= 0.3.0') - spec.add_development_dependency('rake', '~> 12.0') - spec.add_development_dependency('rspec', '~> 3.0') - 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.add_development_dependency('yard') spec.homepage = 'http://prawnpdf.org' spec.description = <