Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added template support for Prawn PDF #57

Merged
merged 5 commits into from Jun 18, 2020
Merged

Conversation

kbrock
Copy link
Collaborator

@kbrock kbrock commented Jun 4, 2020

Adds #33 by @agios which uses a more recent prawn.

Sure, this version of prawn is still very old, and the gem does not look maintained, but this PR focuses on removing warnings that show up with recent ruby implementations.

This branch of the PR removes the conflict and updates the version of prawn and adds the table gem. But it is largely not my work. So thank you Agios.

The pdf test has been disabled because it seems to fail on every upgrade.
Will look into the issue behind this. The most recent failure is due to significant decimal places for 0 and some font tweaks.

The previous sample pdf had a table with headers but no data. Since this causes problems with later prawn versions, I added a data row.

@kbrock kbrock added the cleanup label Jun 4, 2020
@coveralls
Copy link

coveralls commented Jun 4, 2020

Pull Request Test Coverage Report for Build 82

  • 17 of 56 (30.36%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.3%) to 93.339%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/ruport/formatter/prawn_pdf.rb 17 56 30.36%
Totals Coverage Status
Change from base Build 78: -3.3%
Covered Lines: 1051
Relevant Lines: 1126

💛 - Coveralls

@kbrock kbrock force-pushed the prawn_pdf branch 2 times, most recently from 8ee0253 to e8a4c4c Compare June 5, 2020 00:31
@kbrock
Copy link
Collaborator Author

kbrock commented Jun 5, 2020

@jrafanie this is generating a bunch of warnings in ruby 2.6 (let alone 2.7)
So I wanted to merge this PR (and then run a sweep to clean up the remaining warnings and release / remove our custom gem)

Do you have any comments or concerns for this?
It probably won't concern us too much since this doesn't touch the models.

@jrafanie
Copy link
Collaborator

jrafanie commented Jun 5, 2020

So I wanted to merge this PR (and then run a sweep to clean up the remaining warnings and release / remove our custom gem)

What's in our custom gem? I don't remember what feature we fixed or added.

Do you have any comments or concerns for this?

As long as it works for 2.5 since that's still supported, it should be fine.

@kbrock
Copy link
Collaborator Author

kbrock commented Jun 6, 2020

What's in our custom gem? I don't remember what feature we fixed or added.
-- @jrafanie

As long as it works for 2.5 since that's still supported, it should be fine.

travis runs 2.5 - 2.7 (and this probably runs on 2.3, 2.4)

@kbrock kbrock changed the title Prawn pdf Added template support for Prawn pdf Jun 6, 2020
@kbrock kbrock changed the title Added template support for Prawn pdf Added template support for Prawn PDF Jun 6, 2020
@kbrock
Copy link
Collaborator Author

kbrock commented Jun 6, 2020

kicking. trying to get new coverage numberss

@kbrock kbrock closed this Jun 6, 2020
@kbrock kbrock reopened this Jun 6, 2020
agios and others added 4 commits June 5, 2020 20:22
not sure how stable these tests are
pdfs that look the same can often be different in the binary
@kbrock
Copy link
Collaborator Author

kbrock commented Jun 6, 2020

The decrease in coverage is right.
A lot of code was added to prawn_pdf but tests were not added.
I wonder if there is a way to make the file test more stable.

probably best way to test this stuff is to add some mocking / stubs

@kbrock kbrock requested a review from jrafanie June 10, 2020 21:46
@kbrock
Copy link
Collaborator Author

kbrock commented Jun 10, 2020

@jrafanie I looked over this code and got it working. you ok with these changes?

For ruby 2.7, upgrading prawn gets rid of a lot of warnings. Apps (including miq) end up with a ton of warnings without these changes.

The feature request for templates seem good, though I will probably never use them


expected_output = IO.read(File.join(__dir__, 'expected_outputs/prawn_pdf_formatter/pdf_basic.pdf.test')).bytes
def xtest_render_pdf_basic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a comment as to why it's disabled here. Someone might assume this was a typo and try to fix it not knowing it's intentionally disabled. Maybe use the skip method in minitest?

https://www.paperlesspost.com/blog/teams/skipping-tests-minitest/

Copy link
Collaborator

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is the skipped tests without saying why. If they're flaky or inconsistent, we should make that obvious. The other changes look ok although some of the expected outputs test data changes look 😕 to me. I'm not sure what's going on to make them change.

@kbrock
Copy link
Collaborator Author

kbrock commented Jun 15, 2020

I'm not sure what's going on to make [the tests] change.
--@jrafanie

  1. I changed the pdf we generated to not have an empty table. Certain versions of prawn were not handling that well. To be honest, I don't think an empty data table is that valid of a use case anyway.
  2. Every time we change the version of prawn, it changes the pdf output. E.g.: it changed the number of decimal places when specifying x and y.

The 1 skipped test is essentially doing a diff of the output from prawn.
Any time the version of that library changes (which is probably not going to happen), then minor formatting changes make our tests fail.

I'll put this test back in, but it is fragile.

it is very unstable, so not a good test.
@kbrock
Copy link
Collaborator Author

kbrock commented Jun 17, 2020

reenabled the test

@kbrock kbrock merged commit c7d8452 into ruport:master Jun 18, 2020
@kbrock kbrock deleted the prawn_pdf branch June 18, 2020 21:47
kbrock added a commit to kbrock/ruport that referenced this pull request Sep 19, 2022
- Markdown formatter ruport#54
- Ruby 3.0 support

- Reduced allocations to improve performance ruport#34
- Update Prawn version to 2.4.0 ruport#44 ruport#57 ruport#64
@kbrock kbrock mentioned this pull request Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants