Skip to content

Remove superfluous pdf-core requires - #1032

Merged
fidothe merged 1 commit into
prawnpdf:masterfrom
fidothe:sidestep-double-load-ruby-bug
Jul 6, 2017
Merged

Remove superfluous pdf-core requires#1032
fidothe merged 1 commit into
prawnpdf:masterfrom
fidothe:sidestep-double-load-ruby-bug

Conversation

@fidothe

@fidothe fidothe commented Jul 5, 2017

Copy link
Copy Markdown
Contributor

We require pdf/core in lib/prawn.rb, and were requiring
pdf/core/text and pdf/core/byte_string in lib/prawn/text.rb and
lib/prawn/security.rb respectively.

Those second requires were causing double-loads and warnings under
certain circumstances because of a bug in Ruby
(https://bugs.ruby-lang.org/issues/10222).

We use objects under the PDF::Core namespace freely throught Prawn and
those two requires seem to be both out of character (in the rest of the
codebase it's assumed that PDF::Core has already been required), and
overkill (pdf-core's codebase itself generally assumes that all the
objects under its namespace are already required).

I think it's safe to just remove these requires deeper into pdf-core -
it makes these double-load problems go away and is more in keeping with
the way the code is structured.

There is the larger question of the architecture of pdf-core – whether
it's a grab-bag of objects and modules to be picked-and-chosen from, or
a single entity that should be used complete. I don't think there's a
significant impact to that process from this approach to removing the
warnings.

Fixes #1024
Obsoletes #1026

@fidothe
fidothe requested a review from pointlessone July 5, 2017 10:14
@pointlessone

Copy link
Copy Markdown
Member

Thank you for your contribution!

@pointlessone

Copy link
Copy Markdown
Member

Please rebase his branch and let it go through CI.

We require `pdf/core` in `lib/prawn.rb`, and were requiring
`pdf/core/text` and `pdf/core/byte_string` in `lib/prawn/text.rb` and
`lib/prawn/security.rb` respectively.

Those second requires were causing double-loads and warnings under
certain circumstances because of a bug in Ruby
(https://bugs.ruby-lang.org/issues/10222).

We use objects under the `PDF::Core` namespace freely throught Prawn and
those two requires seem to be both out of character (in the rest of the
codebase it's assumed that `PDF::Core` has already been required), and
overkill (`pdf-core`'s codebase itself generally assumes that all the
objects under its namespace are already required).

I think it's safe to just remove these requires deeper into `pdf-core` -
it makes these double-load problems go away and is more in keeping with
the way the code is structured.

There is the larger question of the architecture of `pdf-core` – whether
it's a grab-bag of objects and modules to be picked-and-chosen from, or
a single entity that should be used complete. I don't think there's a
significant impact to that process from this approach to removing the
warnings.
@fidothe
fidothe force-pushed the sidestep-double-load-ruby-bug branch from c31c2c4 to 8e753d6 Compare July 5, 2017 12:45
@fidothe fidothe self-assigned this Jul 6, 2017
@fidothe
fidothe merged commit 9250c86 into prawnpdf:master Jul 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants