History

Require open-uri in DocsCLI#download_docs

Thibaut committed 12 years ago

Commit 89f2f2f1 parent 5cb35cb1 file · +5 −5Browse files

Unified · Split

lib/tasks/docs.thor+5−5
@@ -1,8 +1,3 @@
1−# Prevents this error: https://gist.github.com/nitay/0cbf5ccb2bc611f627e5
2−# See also: http://stackoverflow.com/questions/694115/why-does-ruby-open-uris-open-return-a-stringio-in-my-unit-test-but-a-fileio-in
3−OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
4−OpenURI::Buffer.const_set 'StringMax', 0
5−
61 class DocsCLI < Thor
72 include Thor::Actions
83
@@ -139,6 +134,11 @@ class DocsCLI < Thor · 130 unmodified lines
139134 end
140135
141136 def download_docs(docs)
137+ # Don't allow downloaded files to be created as StringIO
138+ require 'open-uri'
139+ OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
140+ OpenURI::Buffer.const_set 'StringMax', 0
141+
142142 require 'thread'
143143 length = docs.length
144144 i = 0