ruby-docx/docx

Can't call .stream on Document

nocoli opened this issue ยท 6 comments

I need to get the current state as an IO - ready to be uploaded. I can see the stream method when I look at the Document class but get the following error when I try and call it:

NoMethodError:
       undefined method `stream' for #<Docx::Document:0x000055fa7bb472a8>

Example of what I am trying to do:

doc = Docx::Document.open(downloaded_file)
# make changes to doc.zip
stream = doc.stream

@nocoli thank you for opening this issue.
Which version of docx are you using?

@satoryu Using docx-0.4.0.

After running gem install docx I get the following confirmation this version has been installed:

$ sudo gem install docx
Fetching: docx-0.4.0.gem (100%)
Successfully installed docx-0.4.0
Parsing documentation for docx-0.4.0
Installing ri documentation for docx-0.4.0
Done installing documentation for docx after 0 seconds
1 gem installed

I can then navigate to the gem on my local machine and can see inside docx-0.4.0/lib/docx.document.rb that the stream method is not present for some reason

Ah... the PR #66 for Docx::Document#stream was merged after releasing v0.4.0.
The feature is going to be shipped as next version.

if you want to use it, you install the edge version by adding/updating Gemfile for your app:

gem 'docx', github: 'ruby-docx/docx'

I started preparing for next release v0.5 #86 . This release includes Docx::Document#stream.

@nocoli released v0.5.0 ๐ŸŽ‰

I confirmed stream works with v0.5:

irb(main):001:0> require 'docx'
=> true
irb(main):002:0> Docx::VERSION
=> "0.5.0"
irb(main):003:0> doc = Docx::Document.open('/Users/satoryu/Downloads/Document.docx')
WARNING: Nokogiri was built against LibXML version 2.9.10, but has dynamically loaded 2.9.4
irb(main):004:0> doc.stream
=> #<StringIO:0x00007fca1d8ffce8>