Fix TypeError in Grid#apply_gutter when gutter is not specified#1390
Open
55728 wants to merge 1 commit intoprawnpdf:masterfrom
Open
Fix TypeError in Grid#apply_gutter when gutter is not specified#139055728 wants to merge 1 commit intoprawnpdf:masterfrom
55728 wants to merge 1 commit intoprawnpdf:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1343
Closes #1344
Problem
Since commit be66ddd ("Update code style"),
define_gridraises aTypeErrorwhen called without gutter options:The same error occurs when only one of
row_gutterorcolumn_gutteris specified:The cause is that
apply_gutterwas changed fromoptions[:row_gutter].to_f(which returns0.0fornil) toFloat(options[:row_gutter])(which raisesTypeErrorfornil).Solution
Use
Hash#fetchwith a default value of0:This preserves the stricter
Float()conversion for invalid values while defaulting to zero when options are omitted.Tests
Added three test cases covering:
row_gutterspecified (column_gutterdefaults to 0)column_gutterspecified (row_gutterdefaults to 0)Note
@afdev82 previously addressed this in their fork (adnotam/prawn@327de7e) but a PR was not opened against upstream. This PR follows a similar approach.