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

Can't open document using a Pathname. Breaking change between 0.4.0 and 0.6.0 #101

Open
hpoo opened this issue Apr 23, 2021 · 2 comments
Open
Labels

Comments

@hpoo
Copy link

hpoo commented Apr 23, 2021

Describe the bug

Upgrading gem from 0.4 to 0.6. Code no longer works since I call Document.open with a Pathname

To Reproduce

see example

example

require 'docx'
pn = Pathname.new("/home/me/mydoc.docx")
doc = Docx::Document.new(pn)

=> undefined method `close' for nil:NilClass

Sample docx file

N/A

Expected behavior

document object could be opened with a Pathname as in version 0.4

Environment

  • Ruby version: (jruby 9.2.14.0 - ruby 2.5.7)
  • docx gem version: [0.6.0
  • OS: Ubuntu
@hpoo hpoo added the bug label Apr 23, 2021
@satoryu
Copy link
Member

satoryu commented Apr 27, 2021

HI, Docx::Document.new does not support Pathname, expects the path to a docx file given as String.

So the following code would work:

doc = Docx::Document.new("/home/me/mydoc.docx")

if you have any reason why you need to use Pathname instead of String, could you explain it?

@hpoo
Copy link
Author

hpoo commented Apr 27, 2021

Hi,

Since the major version number of the gem had not changed I thought the API-break was unintentional. Hence the report.

I noticed the issue with some old code using Pathname instead of String. But I can live without Pathname, no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants