Skip to content

Commit

Permalink
Remove support for IO hash syntax
Browse files Browse the repository at this point in the history
As far as I can tell, this code doesn't work, so removing it shouldn't
break anything. I'm willing to add it back if someone writes tests that
actually exercise the code.
  • Loading branch information
sferik committed Aug 26, 2012
1 parent 79dc819 commit bfe842d
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Here are some fun facts about the 3.0 release:

* The entire library is implemented in just 2,000 lines of code
* With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1
* The spec suite contains 673 examples and runs in under 2 seconds on a MacBook
* The spec suite contains 671 examples and runs in under 2 seconds on a MacBook
* This project has 100% C0 code coverage (the tests execute every line of
source code at least once)
* At the time of release, this library is comprehensive: you can request all
Expand Down
3 changes: 0 additions & 3 deletions lib/twitter/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def update_profile(options={})
# @option options [Boolean] :tile Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
# @example Update the authenticating user's profile background image
# Twitter.update_profile_background_image(File.new("we_concept_bg2.png"))
# Twitter.update_profile_background_image(:io => StringIO.new(pic), :type => 'jpg')
def update_profile_background_image(image, options={})
object_from_response(Twitter::User, :post, "/1/account/update_profile_background_image.json", options.merge(:image => image))
end
Expand Down Expand Up @@ -300,7 +299,6 @@ def update_profile_colors(options={})
# @param options [Hash] A customizable set of options.
# @example Update the authenticating user's profile image
# Twitter.update_profile_image(File.new("me.jpeg"))
# Twitter.update_profile_image(:io => StringIO.new(pic), :type => 'jpg')
def update_profile_image(image, options={})
object_from_response(Twitter::User, :post, "/1/account/update_profile_image.json", options.merge(:image => image))
end
Expand Down Expand Up @@ -2165,7 +2163,6 @@ def update(status, options={})
# @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1.
# @example Update the authenticating user's status
# Twitter.update_with_media("I'm tweeting with @gem!", File.new('my_awesome_pic.jpeg'))
# Twitter.update_with_media("I'm tweeting with @gem!", {:io => StringIO.new(pic), :type => 'jpg'})
def update_with_media(status, media, options={})
object_from_response(Twitter::Tweet, :post, "/1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status), :endpoint => @media_endpoint)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def request(method, path, params={}, options={})

def auth_header(method, uri, params={})
# When posting a file, don't sign any params
signature_params = [:post, :put].include?(method.to_sym) && params.values.any?{|value| value.respond_to?(:to_io) || (value.is_a?(Hash) && (value[:io].is_a?(IO) || value[:io].is_a?(StringIO)))} ? {} : params
signature_params = [:post, :put].include?(method.to_sym) && params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params
SimpleOAuth::Header.new(method, uri, signature_params, credentials)
end

Expand Down
3 changes: 0 additions & 3 deletions lib/twitter/request/multipart_with_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ def call(env)
if value.respond_to?(:to_io)
env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path)
env[:request_headers][CONTENT_TYPE] = self.class.mime_type
elsif value.is_a?(Hash) && (value[:io].is_a?(IO) || value[:io].is_a?(StringIO))
env[:body][key] = Faraday::UploadIO.new(value[:io], mime_type('.' + value[:type]), '')
env[:request_headers][CONTENT_TYPE] = self.class.mime_type
end
end
end
Expand Down
14 changes: 0 additions & 14 deletions spec/twitter/api/statuses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -537,20 +537,6 @@
should have_been_made
end
end
context "an IO" do
it "requests the correct resource" do
@client.update_with_media("You always have options", {:io => IO.sysopen(fixture_path + "/we_concept_bg2.png"), :type => 'png'})
a_post("/1/statuses/update_with_media.json", "https://upload.twitter.com").
should have_been_made
end
end
context "a StringIO" do
it "requests the correct resource" do
@client.update_with_media("You always have options", {:io => StringIO.new, :type => 'png'})
a_post("/1/statuses/update_with_media.json", "https://upload.twitter.com").
should have_been_made
end
end
end

describe "#oembed" do
Expand Down

0 comments on commit bfe842d

Please sign in to comment.