* [sup-talk] [PATCH] Remove use of Object tap method @ 2010-03-02 19:20 Ben Walton 2010-03-02 22:10 ` rick.tessner 0 siblings, 1 reply; 5+ messages in thread From: Ben Walton @ 2010-03-02 19:20 UTC (permalink / raw) To: sup-talk; +Cc: Ben Walton Remove ruby 1.9-ism in buffer.rb. This keeps things running on older ruby versions. Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca> --- lib/sup/buffer.rb | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index 5772bb0..ccbd38f 100644 --- a/lib/sup/buffer.rb +++ b/lib/sup/buffer.rb @@ -612,7 +612,12 @@ EOS tf.deactivate draw_screen :sync => false, :status => status, :title => title end - tf.value.tap { |x| x.force_encoding Encoding::UTF_8 if x && x.respond_to?(:encoding) } + + v = if tf.value && tf.value.respond_to?(:encoding) + tf.value.force_encoding Encoding::UTF_8 + else + tf.value + end end def ask_getch question, accept=nil -- 1.7.0 _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH] Remove use of Object tap method 2010-03-02 19:20 [sup-talk] [PATCH] Remove use of Object tap method Ben Walton @ 2010-03-02 22:10 ` rick.tessner 2010-03-02 22:46 ` Ben Walton 0 siblings, 1 reply; 5+ messages in thread From: rick.tessner @ 2010-03-02 22:10 UTC (permalink / raw) To: sup-talk Excerpts from Ben Walton's message of Tue Mar 02 11:20:51 -0800 2010: > Remove ruby 1.9-ism in buffer.rb. This keeps things running on older > ruby versions. What about adding a lib/sup/tap.rb that looks like this: unless Object.respond_to?(:tap) class Object def tap yield self self end end end and then adding a: require 'tap' to lib/sup.rb? 'tap' is a really handy little method that cleans up code nicely. :) -- Rick Tessner rick.tessner@gmail.com _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH] Remove use of Object tap method 2010-03-02 22:10 ` rick.tessner @ 2010-03-02 22:46 ` Ben Walton 2010-03-03 18:12 ` Rich Lane 0 siblings, 1 reply; 5+ messages in thread From: Ben Walton @ 2010-03-02 22:46 UTC (permalink / raw) To: sup-talk [-- Attachment #1.1: Type: text/plain, Size: 324 bytes --] Excerpts from rick.tessner's message of Tue Mar 02 17:10:15 -0500 2010: > What about adding a lib/sup/tap.rb that looks like this: Or putting that directly in the lib/sup/util.rb that already has monkey patching type code? I'm ok with this solution and agree that the tap method is a beautiful little thing. Thanks -Ben [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 189 bytes --] [-- Attachment #2: Type: text/plain, Size: 140 bytes --] _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH] Remove use of Object tap method 2010-03-02 22:46 ` Ben Walton @ 2010-03-03 18:12 ` Rich Lane 2010-03-03 18:25 ` Ben Walton 0 siblings, 1 reply; 5+ messages in thread From: Rich Lane @ 2010-03-03 18:12 UTC (permalink / raw) To: Ben Walton; +Cc: sup-talk Excerpts from Ben Walton's message of 2010-03-02 17:46:17 -0500: > Excerpts from rick.tessner's message of Tue Mar 02 17:10:15 -0500 2010: > > > What about adding a lib/sup/tap.rb that looks like this: > > Or putting that directly in the lib/sup/util.rb that already has > monkey patching type code? I'm ok with this solution and agree that > the tap method is a beautiful little thing. What do you think about requiring the backports gem and getting rid of the compatibility code in util? _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sup-talk] [PATCH] Remove use of Object tap method 2010-03-03 18:12 ` Rich Lane @ 2010-03-03 18:25 ` Ben Walton 0 siblings, 0 replies; 5+ messages in thread From: Ben Walton @ 2010-03-03 18:25 UTC (permalink / raw) To: Rich Lane; +Cc: sup-talk [-- Attachment #1.1: Type: text/plain, Size: 412 bytes --] Excerpts from Rich Lane's message of Wed Mar 03 13:12:01 -0500 2010: > What do you think about requiring the backports gem and getting rid of > the compatibility code in util? I wasn't aware of this gem. It sounds like a better route from the supportability point of view. I'll check it out and see if there is anything that isn't agreeable about it. Do others already have experience with it? Thanks -Ben [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 189 bytes --] [-- Attachment #2: Type: text/plain, Size: 140 bytes --] _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-03 18:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-03-02 19:20 [sup-talk] [PATCH] Remove use of Object tap method Ben Walton 2010-03-02 22:10 ` rick.tessner 2010-03-02 22:46 ` Ben Walton 2010-03-03 18:12 ` Rich Lane 2010-03-03 18:25 ` Ben Walton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox