Subject: Re: [sup-talk] [PATCH] Remove use of Object tap method

From: Rich Lane <[email-masked]>
Date: Wed, 03 Mar 2010 13:12:01 -0500

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
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: rick.tessner <[email-masked]>
Date: Tue, 02 Mar 2010 14:10:15 -0800

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.

    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
[email-masked]
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Ben Walton <[email-masked]>
Date: Tue, 02 Mar 2010 17:46:17 -0500

Thanks
-Ben

---

From: Ben Walton <[email-masked]>
Date: Wed, 03 Mar 2010 13:25:04 -0500

> 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

---

From: Ben Walton <[email-masked]>
Date: Tue, 2 Mar 2010 14:20:50 -0500

The tip of next uses Object.tap in the buffer manager code.  This blew
up on me.  The attached patch corrects this.

(I'm going to have to build me a ruby 1.9 rpm soon, me thinks.)

Ben Walton (1):
  Remove use of Object tap method

 lib/sup/buffer.rb |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

---

From: Ben Walton <[email-masked]>
Date: Tue, 2 Mar 2010 14:20:51 -0500

Signed-off-by: Ben Walton <[email-masked]>
---
 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