Skip to content

Loading…

allowing Data.new to accept StringIO instances #18

Closed
wants to merge 2 commits into from

3 participants

@terencehonles

No description provided.

@ueno
Owner

Hmm, I don't think it's is a good idea to load stringio module unconditionally. Why doesn't it respond to to_io?

@terencehonles

I hope you're just speaking aloud... I have no idea why the implementers of StringIO didn't make it respond to to_io or subclass an IO base class, but it doesn't. Ruby is not my preferred language, but If you don't want to take this contribution my employers will continue using my fork of this repository.

Regarding requiring stringio: I did that because I ruby 1.8.7 does not include it by default and it needs to be required. Although we don't use ruby 1.8.7 I figured you might want not to get bug reports from people using ruby 1.8.7

@ueno
Owner

How about defined?(StringIO) and object.is_a?(StringIO) instead of requiring it?

@terencehonles
@nobu

Does IOCallback works fine with StringIO, which does not provide event triggers?

@terencehonles

I've been able to encrypt StringIO files and verify their result. (Single/Multiple recipients + armor)

So as far as I can tell it's working

@ueno
Owner

Fixed in that way: bfede6a

@ueno ueno closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 14, 2013
  1. @terencehonles
Commits on Feb 20, 2013
  1. @terencehonles
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/gpgme/data.rb
View
2 lib/gpgme/data.rb
@@ -45,6 +45,8 @@ def new(object = nil)
object
elsif object.is_a?(Integer)
from_fd(object)
+ elsif defined?(StringIO) and object.is_a?(StringIO)
+ from_io(object)
elsif object.respond_to? :to_str
from_str(object.to_str)
elsif object.respond_to? :to_io
Something went wrong with that request. Please try again.