Skip to content
This repository

Fixed the deprecation of Object#returning for Object#tap on Connection.url_for #51

Merged
merged 2 commits into from about 2 years ago

2 participants

Brian Bokor Marcel Molina
Brian Bokor

Signed-off-by: designwaves brian.bokor@designwaves.com

Brian Bokor bokor Fixed deprecated returning to use tap instead on the Connection.url_for
Signed-off-by: designwaves <brian.bokor@designwaves.com>
2b2c980
Marcel Molina
Owner

Thanks for modernizing. As is though this breaks backwards compatibility with older versions of Ruby. The safe, though more tedious, way is to add String#tap in the extensions file iff String does not have an instance method 'tap'.

Brian Bokor

OH yes very true....forgot to check for that. Want me to update it?

Brian Bokor

Actually looked at the extensions file and not sure what I would add quite yet unless you have an idea of what I could add quickly. I'll have to look at it more later tonight or tomorrow.

Marcel Molina
Owner

Something like this:

class String
  def tap
    # implementation ...
  end
end unless ''.respond_to?(:tap)
Brian Bokor bokor Updated Extensions to have string#tap and added test case
Signed-off-by: designwaves <brian.bokor@designwaves.com>
adfc3c9
Brian Bokor

Updated the code and seems to be working fine (obviously you would have to give the go ahead but I think it is all good. Might want to make sure the tests run for you too cause I had some issues running the test cases so I built a test in my application and copied it

Brian Bokor

Marcel, does this look sufficient or would you like me to fix anything else in this pull request?

Marcel Molina marcel merged commit 34db3c0 into from
Marcel Molina marcel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jan 16, 2012
Brian Bokor bokor Fixed deprecated returning to use tap instead on the Connection.url_for
Signed-off-by: designwaves <brian.bokor@designwaves.com>
2b2c980
Jan 17, 2012
Brian Bokor bokor Updated Extensions to have string#tap and added test case
Signed-off-by: designwaves <brian.bokor@designwaves.com>
adfc3c9
This page is out of date. Refresh to see the latest.
2  lib/aws/s3/connection.rb
@@ -63,7 +63,7 @@ def url_for(path, options = {})
63 63 path = self.class.prepare_path(path)
64 64 request = request_method(:get).new(path, {})
65 65 query_string = query_string_authentication(request, options)
66   - returning "#{protocol(options)}#{http.address}#{port_string}#{path}" do |url|
  66 + "#{protocol(options)}#{http.address}#{port_string}#{path}".tap do |url|
67 67 url << "?#{query_string}" if authenticate
68 68 end
69 69 end
5 lib/aws/s3/extensions.rb
@@ -38,6 +38,11 @@ def previous!
38 38 end
39 39 end
40 40
  41 + def tap
  42 + yield(self)
  43 + self
  44 + end unless ''.respond_to?(:tap)
  45 +
41 46 def previous
42 47 dup.previous!
43 48 end
10 test/extensions_test.rb
@@ -74,6 +74,16 @@ def test_remove_extended
74 74 assert "318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.valid_utf8?
75 75 assert "318597/620065/GTL_75£00_A600_A610.zip".remove_extended.valid_utf8?
76 76 end
  77 +
  78 + def test_tap
  79 + assert "http://google.com".tap do |url|
  80 + url << "/analtyics/"
  81 + end
  82 + assert "http://google.com".tap do |url|
  83 + url << "/download.zip"
  84 + end
  85 + end
  86 +
77 87 end
78 88
79 89 class CoercibleStringTest < Test::Unit::TestCase

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.