Skip to content

Commit

Permalink
Merge pull request marcel#51 from designwaves/master
Browse files Browse the repository at this point in the history
Fixed the deprecation of Object#returning for Object#tap on Connection.url_for
  • Loading branch information
marcel committed May 29, 2012
2 parents f669784 + adfc3c9 commit 34db3c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/aws/s3/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/aws/s3/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def previous!
end
end

def tap
yield(self)
self
end unless ''.respond_to?(:tap)

def previous
dup.previous!
end
Expand Down
10 changes: 10 additions & 0 deletions test/extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34db3c0

Please sign in to comment.