Permalink
Browse files

Updated README; Removed unused dependency to simple_oauth; Implemente…

…d Client::Forums methods; Enhanced test helpers
  • Loading branch information...
1 parent 83f8fd7 commit e3bacd8040b08dbd78f0859ee20bbd1a193e99fb @jeremyvdw committed May 7, 2011
View
@@ -7,7 +7,6 @@ PATH
hashie (~> 1.0.0)
multi_json (~> 1.0.0)
rash (~> 0.3.0)
- simple_oauth (~> 0.1.4)
GEM
remote: http://rubygems.org/
@@ -55,7 +54,6 @@ GEM
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
- simple_oauth (0.1.4)
simplecov (0.4.2)
simplecov-html (~> 0.4.4)
simplecov-html (0.4.4)
View
@@ -25,7 +25,6 @@ Continuous Integration
What's in 0.1?
------------------
-```
The error classes are consistent with [Disqus's documented response codes](http://disqus.com/api/docs/errors/). These changes should make it easier to rescue from specific errors and take action accordingly. We've also added support for two new classes of error.
<table>
@@ -58,7 +57,6 @@ The error classes are consistent with [Disqus's documented response codes](http:
</tr>
</tbody>
</table>
-```
Here are a few reasons use (and improve) this gem:
View
@@ -34,5 +34,4 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('faraday_middleware', '~> 0.6.3')
s.add_runtime_dependency('multi_json', '~> 1.0.0')
s.add_runtime_dependency('rash', '~> 0.3.0')
- s.add_runtime_dependency('simple_oauth', '~> 0.1.4')
end
@@ -10,10 +10,12 @@ class Applications < Client
# @return [Hashie::Rash] API usage per day for this application.
# @param application [Integer] Defaults to null
# @param days [Integer] Defaults to 30, Maximum length of 30
+ # @example Returns the API usage per day for this application.
+ # Disqussion::Client.applications.listUsage
# @see http://disqus.com/api/3.0/applications/listUsage.json
def listUsage(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
get('applications/listUsage', options)
end
end
-end
+end
@@ -1,6 +1,5 @@
module Disqussion
class Forums < Client
- # NOTE: to be implemented when debugged
# Creates a new forum.
# @accessibility: public key, secret key
# @methods: GET
@@ -10,12 +9,18 @@ class Forums < Client
# @param website [String] Disqus website name.
# @param name [String] Forum name.
# @param short_name [String] Forum short name (aka forum id).
- # @return {CURRENTLY BUGGED}
+ # @return [Hashie::Rash] New forum infos
# @example Creates a new forum 'myforum'
- # Disqus.create("myforum")
+ # Disqussion::Client.forums.create("the88", "My Forum", "myforum")
# @see: http://disqus.com/api/3.0/forums/create.json
- def create(website, name, short_name)
- response = get('forums/create', website, name, short_name)
+ def create(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ if args.size == 3
+ options.merge!(:website => args[0], :name => args[1], :short_name => args[2])
+ response = get('forums/create', options)
+ else
+ puts "#{Kernel.caller.first}: forums.create expects 3 arguments: website, name, short_name"
+ end
end
# Returns forum details.
@@ -27,10 +32,12 @@ def create(website, name, short_name)
# @param forum [String] Forum ID (aka short name).
# @return [Hashie::Rash] Details on the requested forum.
# @example Return extended information for forum 'myforum'
- # Disqus.details("myforum")
+ # Disqussion::Client.forums.details("myforum")
# @see: http://disqus.com/api/3.0/forums/details.json
- def details(forum)
- response = get('forums/details', forum)
+ def details(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ options[:forum] = args.first
+ response = get('forums/details', options)
end
# Returns a list of categories within a forum.
@@ -42,21 +49,23 @@ def details(forum)
# @param forum [String] Forum ID (aka short name).
# @return [Hashie::Rash] Details on the requested list of categories.
# @param options [Hash] A customizable set of options.
- # @option options [Datetime, Timestamp] :since_id. Unix timestamp (or ISO datetime standard). Defaults to null
+ # @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
# @option options [Integer] :cursor. Defaults to null
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
# @option options [String] :order. Defaults to "asc". Choices: asc, desc
# @example Return extended information for forum 'myforum'
- # Disqus.listCategories("myforum", {:cursor => 10, :limit => 10, :order => 'asc'})
+ # Disqussion::Client.forums.listCategories("myforum", {:cursor => 10, :limit => 10, :order => 'asc'})
# @see: http://disqus.com/api/3.0/forums/details.json
- def listCategories(forum, options = {})
- response = get('forums/listCategories', forum, options)
+ def listCategories(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ options[:forum] = args.first
+ response = get('forums/listCategories', options)
end
# NOTE: to be implemented
# Returns a list of users active within a forum ordered by most likes received.
# @see: http://disqus.com/api/3.0/forums/listMostLikedUsers.json
- def listMostLikedUsers(forum, options = {})
+ def listMostLikedUsers(*args)
end
# Returns a list of posts within a forum.
@@ -68,18 +77,20 @@ def listMostLikedUsers(forum, options = {})
# @param forum [String] Forum ID (aka short name).
# @return [Hashie::Rash] Details on the list of posts.
# @param options [Hash] A customizable set of options.
- # @option options [Datetime, Timestamp] :since_id. Unix timestamp (or ISO datetime standard). Defaults to null
+ # @option options [Datetime, Timestamp] :since. Defaults to null. Unix timestamp (or ISO datetime standard).
# @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: thread.
# @option options [Integer] :cursor. Defaults to null
- # @option options [Integer] :limit. Defaults to 25. Maximum length of 100
+ # @option options [Integer] :limit. Defaults to 25. Maximum number of posts to return. Maximum length of 100
# @option options [Integer] :query. Defaults to null.
# @option options [String, Array] :include allows multiple. Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged
- # @option options [String] :order. Defaults to "asc". Choices: asc, desc
+ # @option options [String] :order. Defaults to "desc". Choices: asc, desc
# @example Return list of (all) posts for forum 'myforum', including related threads
- # Disqus.listPosts("myforum", {:related => ["thread"], :include => ["spam", "deleted", "flagged"]})
+ # Disqussion::Client.forums.listPosts("myforum", {:related => ["thread"], :include => ["spam", "deleted", "flagged"]})
# @see: http://disqus.com/api/3.0/forums/listPosts.json
- def listPosts(forum, options = {})
- response = get('forums/listPosts', forum, options)
+ def listPosts(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ options[:forum] = args.first
+ response = get('forums/listPosts', options)
end
# Returns a list of threads within a forum.
@@ -92,18 +103,19 @@ def listPosts(forum, options = {})
# @return [Hashie::Rash] Details on the list of posts.
# @param options [Hash] A customizable set of options.
# @option options [Integer, String, Array] :thread. Allows multiple. Defaults to null. Looks up a thread by ID. You may pass use the 'ident' or 'link' query types instead of an ID by including 'forum'
- # @option options [Datetime, Timestamp] :since_id. Unix timestamp (or ISO datetime standard). Defaults to null
+ # @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
# @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, author.
# @option options [Integer] :cursor. Defaults to null
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
# @option options [String, Array] :include allows multiple. Defaults to ["open", "close"]. Choices: open, closed, killed.
# @option options [String] :order. Defaults to "desc". Choices: asc, desc
# @example Return list of (all) threads for forum 'myforum', including closed ones and related forums.
- # Disqus.listThreads("myforum", {:related => ["forum"], :include => ["close"]})
+ # Disqussion::Client.forums.listThreads("myforum", {:related => ["forum"], :include => ["close"]})
# @see: http://disqus.com/api/3.0/forums/listThreads.json
- def listThreads(forum, options = {})
- # NOTE: extract :thread to tie it up
- response = get('forums/listThreads', forum, options)
+ def listThreads(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ options[:forum] = args.first
+ response = get('forums/listThreads', options)
end
end
@@ -9,8 +9,8 @@ class Users < Client
# @param user [Integer, String] A Disqus user ID or screen name.
# @return [Hashie::Rash] Details on the requested user.
# @example Return extended information for 'the88'
- # Disqus.user("the88")
- # Disqus.user(6138058) # Same as above
+ # Disqussion::Client.user("the88")
+ # Disqussion::Client.user(6138058) # Same as above
# @see: http://disqus.com/api/3.0/users/details.json
def details(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
@@ -28,8 +28,8 @@ def details(*args)
# @param target [Integer, String] A Disqus user ID or screen name.
# @return [Hashie::Rash] Details on the requested user.
# @example Return extended information for 'the88'
- # Disqus.follow("the88")
- # Disqus.follow(6138058) # Same as above
+ # Disqussion::Client.follow("the88")
+ # Disqussion::Client.follow(6138058) # Same as above
# @see: http://disqus.com/api/3.0/users/details.json
def follow(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
@@ -92,8 +92,8 @@ def listPosts
# @param user [Integer, String] A Disqus user ID or screen name.
# @return [Hashie::Rash] Details on the requested user.
# @example Return extended information for 'the88'
- # Disqus.unfollow("the88")
- # Disqus.unfollow(6138058) # Same as above
+ # Disqussion::Client.unfollow("the88")
+ # Disqussion::Client.unfollow(6138058) # Same as above
# @see: http://disqus.com/api/3.0/users/details.json
def unfollow
merge_user_into_options!(user, options)
@@ -6,16 +6,75 @@
before do
@client = Disqussion::Client.forums
end
-
+
describe ".create" do
+ before do
+ stub_get("forums/create.json", :query => { :website => "the88", :name => "My Forum", :short_name => "myforum" }).
+ to_return(:body => fixture("forums/create.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+
+ it "returns new forum infos." do
+ @client.create("the88", "My Forum", "myforum")
+ a_get("forums/create.json", :query => { :website => "the88", :name => "My Forum", :short_name => "myforum" }).
+ should have_been_made
+ end
end
-
+
describe ".details" do
+ before do
+ stub_get("forums/details.json", :query => { :forum => "the88" }).
+ to_return(:body => fixture("forums/details.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+
+ it "returns details on the requested forum." do
+ @client.details("the88")
+ a_get("forums/details.json", :query => { :forum => "the88" }).
+ should have_been_made
+ end
end
-
- describe ".list_categories" do
+
+ describe ".listPosts" do
+ before do
+ stub_get("forums/listPosts.json", :query => { :forum => "the88" }).
+ to_return(:body => fixture("forums/listPosts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+
+ it "returns details on the requested list of posts." do
+ @client.listPosts("the88")
+ a_get("forums/listPosts.json", :query => { :forum => "the88" }).
+ should have_been_made
+ end
+ end
+
+ describe ".listCategories" do
+ before do
+ stub_get("forums/listCategories.json", :query => { :forum => "the88" }).
+ to_return(:body => fixture("forums/listCategories.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+
+ it "returns details on the requested list of categories." do
+ @client.listCategories("the88")
+ a_get("forums/listCategories.json", :query => { :forum => "the88" }).
+ should have_been_made
+ end
+ end
+
+ describe ".listMostLikedUsers" do
+ pending
+ end
+
+ describe ".listThreads" do
+ before do
+ stub_get("forums/listThreads.json", :query => { :forum => "the88" }).
+ to_return(:body => fixture("forums/listThreads.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+
+ it "returns details on the requested list of threads." do
+ @client.listThreads("the88")
+ a_get("forums/listThreads.json", :query => { :forum => "the88" }).
+ should have_been_made
+ end
end
-
end
end
end
@@ -0,0 +1,12 @@
+{
+ "code": 0,
+ "response": {
+ "id": "myforum",
+ "name": "the88",
+ "founder": "6138058",
+ "favicon": {
+ "permalink": "http://disqus.com/api/forums/favicons/atestforum.jpg",
+ "cache": "http://mediacdn.disqus.com/1304703476/images/favicon-default.png"
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit e3bacd8

Please sign in to comment.