Permalink
Browse files

Merge pull request #51 from designwaves/master

Fixed the deprecation of Object#returning for Object#tap on Connection.url_for
  • Loading branch information...
2 parents f669784 + adfc3c9 commit 34db3c0bc77457d4b047c97a37c86274fb67602f @marcel committed May 29, 2012
Showing with 16 additions and 1 deletion.
  1. +1 −1 lib/aws/s3/connection.rb
  2. +5 −0 lib/aws/s3/extensions.rb
  3. +10 −0 test/extensions_test.rb
View
2 lib/aws/s3/connection.rb
@@ -63,7 +63,7 @@ def url_for(path, options = {})
path = self.class.prepare_path(path)
request = request_method(:get).new(path, {})
query_string = query_string_authentication(request, options)
- returning "#{protocol(options)}#{http.address}#{port_string}#{path}" do |url|
+ "#{protocol(options)}#{http.address}#{port_string}#{path}".tap do |url|
url << "?#{query_string}" if authenticate
end
end
View
5 lib/aws/s3/extensions.rb
@@ -39,6 +39,11 @@ def previous!
end
end
+ def tap
+ yield(self)
+ self
+ end unless ''.respond_to?(:tap)
+
def previous
dup.previous!
end
View
10 test/extensions_test.rb
@@ -74,6 +74,16 @@ def test_remove_extended
assert "318597/620065/GTL_75\24300_A600_A610.zip".remove_extended.valid_utf8?
assert "318597/620065/GTL_75£00_A600_A610.zip".remove_extended.valid_utf8?
end
+
+ def test_tap
+ assert "http://google.com".tap do |url|
+ url << "/analtyics/"
+ end
+ assert "http://google.com".tap do |url|
+ url << "/download.zip"
+ end
+ end
+
end
class CoercibleStringTest < Test::Unit::TestCase

0 comments on commit 34db3c0

Please sign in to comment.