Permalink
Browse files

Clean up after #349

  • Loading branch information...
sferik committed Feb 6, 2013
1 parent 1d94549 commit c3df1ba1233043f0cbbe12fa5fca80c650c0f13e
Showing with 9 additions and 9 deletions.
  1. +6 −6 lib/twitter/api/tweets.rb
  2. +1 −1 lib/twitter/error/client_error.rb
  3. +2 −2 spec/twitter/api/tweets_spec.rb
View
@@ -212,7 +212,7 @@ def update_with_media(status, media, options={})
# @authentication Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::OEmbed] OEmbed for the requested Tweet.
- # @param id [Integer, String] A Tweet ID.
+ # @param id_or_url [Integer, String] A Tweet ID or URL.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels.
# @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false.
@@ -223,9 +223,9 @@ def update_with_media(status, media, options={})
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
# @example Return oEmbeds for Tweet with the ID 25938088801
# Twitter.status_with_activity(25938088801)
- def oembed(id, options={})
- lookup = ( id.kind_of?(String) and id =~ /^https?:\/\//i ) ? "url" : "id"
- object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?#{lookup}=#{id}", options)
+ def oembed(id_or_url, options={})
+ key = id_or_url.is_a?(String) && id_or_url.match(%r{^https?://}i) ? "url" : "id"
+ object_from_response(Twitter::OEmbed, :get, "/1.1/statuses/oembed.json?#{key}=#{id_or_url}", options)
end
# Returns oEmbeds for Tweets
@@ -251,8 +251,8 @@ def oembed(id, options={})
# @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML.
def oembeds(*args)
arguments = Twitter::API::Arguments.new(args)
- arguments.flatten.threaded_map do |id|
- oembed(id, arguments.options)
+ arguments.flatten.threaded_map do |id_or_url|
+ oembed(id_or_url, arguments.options)
end
end
@@ -22,7 +22,7 @@ def self.parse_error(body)
body[:error]
elsif body[:errors]
first = Array(body[:errors]).first
- if first.kind_of?(Hash)
+ if first.is_a?(Hash)
first[:message].chomp
else
first.chomp
@@ -226,7 +226,7 @@
@client.oembed(25938088801)
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
end
- it "requests the correct resource when a url is given" do
+ it "requests the correct resource when a URL is given" do
@client.oembed("https://twitter.com/sferik/status/25938088801")
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:url => "https://twitter.com/sferik/status/25938088801"}))
end
@@ -245,7 +245,7 @@
@client.oembeds(25938088801)
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:id => "25938088801"})).to have_been_made
end
- it "requests the correct resource when a url is given" do
+ it "requests the correct resource when a URL is given" do
@client.oembeds("https://twitter.com/sferik/status/25938088801")
expect(a_get("/1.1/statuses/oembed.json").with(:query => {:url => "https://twitter.com/sferik/status/25938088801"})).to have_been_made
end

0 comments on commit c3df1ba

Please sign in to comment.