Skip to content

Commit

Permalink
Fixing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
shayne committed Feb 24, 2011
1 parent c78461d commit 12590d6
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 105 deletions.
6 changes: 3 additions & 3 deletions lib/instagram.rb
Expand Up @@ -5,20 +5,20 @@

module Instagram
extend Configuration

# Alias for Instagram::Client.new
#
# @return [Instagram::Client]
def self.client(options={})
Instagram::Client.new(options)
end

# Delegate to Instagram::Client
def self.method_missing(method, *args, &block)
return super unless client.respond_to?(method)
client.send(method, *args, &block)
end

# Delegate to Instagram::Client
def self.respond_to?(method)
return client.respond_to?(method) || super
Expand Down
2 changes: 1 addition & 1 deletion lib/instagram/api.rb
Expand Up @@ -15,7 +15,7 @@ def initialize(options={})
send("#{key}=", options[key])
end
end

include Connection
include Request
include OAuth
Expand Down
6 changes: 3 additions & 3 deletions lib/instagram/client/comments.rb
Expand Up @@ -19,7 +19,7 @@ def media_comments(id, *args)
response = get("media/#{id}/comments")
response["data"]
end

# Create's a comment for a given media item ID
#
# @overload create_media_comment(id, text)
Expand All @@ -38,7 +38,7 @@ def create_media_comment(id, text, options={})
response = post("media/#{id}/comments", options.merge(:text => text))
response["data"]
end

# Delete's a comment for a given media item ID
#
# @overload delete_media_comment(media_id, comment_id)
Expand All @@ -50,7 +50,7 @@ def create_media_comment(id, text, options={})
# @format :json
# @authenticated true
#
# In order to remove a comment, you must be either the owner comment or the media item (or both).
# In order to remove a comment, you must be either the owner comment or the media item (or both).
# @rate_limited true
# @see TODO:docs url
def delete_media_comment(media_id, comment_id, options={})
Expand Down
4 changes: 2 additions & 2 deletions lib/instagram/client/likes.rb
Expand Up @@ -19,7 +19,7 @@ def media_likes(id, *args)
response = get("media/#{id}/likes")
response["data"]
end

# Issues a like by the currently authenticated user, for a given media item ID
#
# @overload like_media(id, text)
Expand All @@ -37,7 +37,7 @@ def like_media(id, options={})
response = post("media/#{id}/likes", options)
response["data"]
end

# Removes the like on a givem media item ID for the currently authenticated user
#
# @overload unlike_media(id)
Expand Down
4 changes: 2 additions & 2 deletions lib/instagram/client/locations.rb
Expand Up @@ -17,7 +17,7 @@ def location(id, *args)
response = get("locations/#{id}")
response["data"]
end

# Returns a list of recent media items for a given Instagram location
#
# @overload location_recent_media(id, options={})
Expand All @@ -37,7 +37,7 @@ def location_recent_media(id, *args)
response = get("locations/#{id}/media/recent", options)
response["data"]
end

# Returns Instagram locations within proximity of given lat,lng
#
# @param lat [String] A given latitude in decimal format
Expand Down
4 changes: 2 additions & 2 deletions lib/instagram/client/media.rb
Expand Up @@ -20,7 +20,7 @@ def media_item(*args)
response = get("media/#{id}")
response["data"]
end

# Returns a list of the overall most popular media
#
# @overload media_popular(options={})
Expand All @@ -40,7 +40,7 @@ def media_popular(*args)
response = get("media/popular", options)
response["data"]
end

# Returns media items within proximity of given lat,lng
#
# @param lat [String] A given latitude in decimal format
Expand Down
4 changes: 2 additions & 2 deletions lib/instagram/client/tags.rb
Expand Up @@ -17,7 +17,7 @@ def tag(tag, *args)
response = get("tags/#{tag}")
response["data"]
end

# Returns a list of recent media items for a given Instagram tag
#
# @overload tag_recent_media(tag, options={})
Expand All @@ -37,7 +37,7 @@ def tag_recent_media(id, *args)
response = get("tags/#{id}/media/recent", options)
response["data"]
end

# Returns a list of tags starting with the given search query
#
# @format :json
Expand Down
2 changes: 1 addition & 1 deletion lib/instagram/client/utils.rb
Expand Up @@ -3,7 +3,7 @@ class Client
# @private
module Utils
private

# Returns the configured user name or the user name of the authenticated user
#
# @return [String]
Expand Down
26 changes: 13 additions & 13 deletions lib/instagram/configuration.rb
Expand Up @@ -15,49 +15,49 @@ module Configuration
:user_agent,
:proxy
].freeze

# An array of valid request/response formats
#
# @note Not all methods support the XML format.
VALID_FORMATS = [
:json].freeze

# The adapter that will be used to connect if none is set
#
# @note The default faraday adapter is Net::HTTP.
DEFAULT_ADAPTER = Faraday.default_adapter

# By default, don't set an application ID
DEFAULT_CLIENT_ID = nil

# By default, don't set an application secret
DEFAULT_CLIENT_SECRET = nil

# By default, don't set an application redirect uri
DEFAULT_REDIRECT_URI = nil

# By default, don't set a user access token
DEFAULT_ACCESS_TOKEN = nil

# The endpoint that will be used to connect if none is set
#
# @note There is no reason to use any other endpoint at this time
DEFAULT_ENDPOINT = 'https://api.instagram.com/v1/'.freeze

# The response format appended to the path and sent in the 'Accept' header if none is set
#
# @note JSON is the only available format at this time
DEFAULT_FORMAT = :json
DEFAULT_FORMAT = :json

# By default, don't use a proxy server
DEFAULT_PROXY = nil

# The user agent that will be sent to the API endpoint if none is set
DEFAULT_USER_AGENT = "Instagram Ruby Gem #{Instagram::VERSION}".freeze

# @private
attr_accessor *VALID_OPTIONS_KEYS

# When this module is extended, set all configuration options to their default values
def self.extended(base)
base.reset
Expand All @@ -74,7 +74,7 @@ def options
option.merge!(key => send(key))
end
end

# Reset all configuration options to defaults
def reset
self.adapter = DEFAULT_ADAPTER
Expand Down
2 changes: 1 addition & 1 deletion lib/instagram/error.rb
Expand Up @@ -10,7 +10,7 @@ class NotFound < Error; end

# Raised when Instagram returns the HTTP status code 500
class InternalServerError < Error; end

# Raised when Instagram returns the HTTP status code 503
class ServiceUnavailable < Error; end
end
6 changes: 3 additions & 3 deletions lib/instagram/request.rb
Expand Up @@ -5,17 +5,17 @@ module Request
def get(path, options={}, raw=false, unformatted=false)
request(:get, path, options, raw, unformatted)
end

# Perform an HTTP POST request
def post(path, options={}, raw=false, unformatted=false)
request(:post, path, options, raw, unformatted)
end

# Perform an HTTP PUT request
def put(path, options={}, raw=false, unformatted=false)
request(:put, path, options, raw, unformatted)
end

# Perform an HTTP DELETE request
def delete(path, options={}, raw=false, unformatted=false)
request(:delete, path, options, raw, unformatted)
Expand Down
20 changes: 10 additions & 10 deletions spec/instagram/api_spec.rb
Expand Up @@ -64,43 +64,43 @@
end
end
end

describe ".authorize_url" do

it "should generate an authorize URL with necessary params" do
params = { :client_id => "CID", :client_secret => "CS" }

client = Instagram::Client.new(params)

redirect_uri = 'http://localhost:4567/oauth/callback'
url = client.authorize_url(:redirect_uri => redirect_uri)

params2 = client.send(:access_token_params).merge(params)
params2[:redirect_uri] = redirect_uri
params2[:response_type] = "code"
url2 = client.send(:connection).build_url("/oauth/authorize/", params2).to_s

url2.should == url
end
end

describe ".get_access_token" do

before do
@client = Instagram::Client.new(:client_id => "CID", :client_secret => "CS")
@url = @client.send(:connection).build_url("/oauth/access_token/").to_s
stub_request(:post, @url).
with(:body => {:client_id => "CID", :client_secret => "CS", :redirect_uri => "http://localhost:4567/oauth/callback", :grant_type => "authorization_code", :code => "C"}).
to_return(:status => 200, :body => fixture("access_token.json"), :headers => {})
end

it "should get the correct resource" do
@client.get_access_token(code="C", :redirect_uri => "http://localhost:4567/oauth/callback")
a_request(:post, @url).
with(:body => {:client_id => "CID", :client_secret => "CS", :redirect_uri => "http://localhost:4567/oauth/callback", :grant_type => "authorization_code", :code => "C"}).
should have_been_made
end

it "should return a hash with an access_token and user data" do
response = @client.get_access_token(code="C", :redirect_uri => "http://localhost:4567/oauth/callback")
response.access_token.should == "at"
Expand Down
22 changes: 11 additions & 11 deletions spec/instagram/client/likes_spec.rb
Expand Up @@ -3,57 +3,57 @@
describe Instagram::Client do
Instagram::Configuration::VALID_FORMATS.each do |format|
context ".new(:format => '#{format}')" do

before do
@client = Instagram::Client.new(:format => format, :client_id => 'CID', :client_secret => 'CS', :access_token => 'AT')
end

describe ".media_likes" do

before do
stub_get("media/777/likes.#{format}").
with(:query => {:access_token => @client.access_token}).
to_return(:body => fixture("media_likes.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
end

it "should get the correct resource" do
@client.media_likes(777)
a_get("media/777/likes.#{format}").
with(:query => {:access_token => @client.access_token}).
should have_been_made
end

it "should return an array of user search results" do
comments = @client.media_likes(777)
comments.should be_a Array
comments.first.username.should == "chris"
end
end

describe ".like_media" do

before do
stub_post("media/777/likes.#{format}").
with(:body => {:access_token => @client.access_token}).
to_return(:body => fixture("media_liked.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
end

it "should get the correct resource" do
@client.like_media(777)
a_post("media/777/likes.#{format}").
with(:body => {:access_token => @client.access_token}).
should have_been_made
end
end

describe ".unlike_media" do

before do
stub_delete("media/777/likes.#{format}").
with(:query => {:access_token => @client.access_token}).
to_return(:body => fixture("media_unliked.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
end

it "should get the correct resource" do
@client.unlike_media(777)
a_delete("media/777/likes.#{format}").
Expand Down

0 comments on commit 12590d6

Please sign in to comment.