disqussion 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +3 -3
- data/HISTORY.mkd +9 -0
- data/README.mkd +4 -2
- data/lib/disqussion/client/forums.rb +38 -1
- data/lib/disqussion/client/users.rb +69 -17
- data/lib/disqussion/version.rb +1 -1
- data/spec/disqussion/client/forums_spec.rb +30 -8
- data/spec/disqussion/client/posts_spec.rb +8 -0
- data/spec/disqussion/client/threads_spec.rb +20 -0
- data/spec/disqussion/client/users_spec.rb +68 -3
- data/spec/fixtures/forums/create.json +1 -1
- data/spec/fixtures/forums/details.json +1 -1
- data/spec/fixtures/forums/listMostLikedUsers.json +510 -0
- data/spec/fixtures/forums/listThreads.json +25 -25
- data/spec/fixtures/forums/listUsers.json +490 -0
- data/spec/fixtures/threads/create.json +1 -1
- data/spec/fixtures/threads/details.json +1 -1
- data/spec/fixtures/threads/list.json +25 -25
- data/spec/fixtures/threads/listMostLiked.json +25 -25
- data/spec/fixtures/users/details.json +1 -1
- data/spec/fixtures/users/listActiveForums.json +32 -0
- data/spec/fixtures/users/listForums.json +41 -0
- data/spec/fixtures/users/listPosts.json +55 -0
- data/spec/fixtures/users/unfollow.json +4 -0
- metadata +13 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
disqussion (0.0.
|
4
|
+
disqussion (0.0.2)
|
5
5
|
faraday (~> 0.6.1)
|
6
6
|
faraday_middleware (~> 0.6.3)
|
7
7
|
hashie (~> 1.0.0)
|
@@ -29,8 +29,8 @@ GEM
|
|
29
29
|
ruby_core_source (>= 0.1.4)
|
30
30
|
maruku (0.6.0)
|
31
31
|
syntax (>= 1.0.0)
|
32
|
-
multi_json (1.0.
|
33
|
-
multipart-post (1.1.
|
32
|
+
multi_json (1.0.2)
|
33
|
+
multipart-post (1.1.1)
|
34
34
|
nokogiri (1.4.4)
|
35
35
|
rack (1.2.2)
|
36
36
|
rake (0.8.7)
|
data/HISTORY.mkd
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
HISTORY
|
2
2
|
=======
|
3
|
+
|
4
|
+
0.0.3 - May 18, 2011
|
5
|
+
----------------------
|
6
|
+
* Added following missing features: Users#listActiveForums, Users#listForums, Users#listPosts, Users#unfollow, Forums#listMostLikedUsers, Forums#listUsers
|
7
|
+
|
8
|
+
0.0.2 - May 18, 2011
|
9
|
+
----------------------
|
10
|
+
* Fixed bug with EventMachine detection in configuration
|
11
|
+
|
3
12
|
0.0.1 - May 10, 2011
|
4
13
|
----------------------
|
5
14
|
* First release
|
data/README.mkd
CHANGED
@@ -22,8 +22,10 @@ Continuous Integration
|
|
22
22
|
----------------------
|
23
23
|
[](http://travis-ci.org/jeremyvdw/disqussion)
|
24
24
|
|
25
|
-
What's in 0.
|
26
|
-
|
25
|
+
What's in 0.0.3?
|
26
|
+
----------------
|
27
|
+
|
28
|
+
Disqussion currently covers *only* stable Disqus API for: applications, forums, posts, reactions, threads and users features.
|
27
29
|
|
28
30
|
The error classes are consistent with [Disqus's documented response codes](http://disqus.com/api/docs/errors/).
|
29
31
|
Error details from Disqus API are encapsulated in HTTP response.
|
@@ -62,10 +62,26 @@ module Disqussion
|
|
62
62
|
response = get('forums/listCategories', options)
|
63
63
|
end
|
64
64
|
|
65
|
-
# NOTE: to be implemented
|
66
65
|
# Returns a list of users active within a forum ordered by most likes received.
|
66
|
+
# @accessibility: public key, secret key
|
67
|
+
# @methods: GET
|
68
|
+
# @format: json, jsonp
|
69
|
+
# @authenticated: false
|
70
|
+
# @limited: false
|
71
|
+
# @param forum [String] Forum ID (aka short name).
|
72
|
+
# @return [Hashie::Rash] Details on the list of posts.
|
73
|
+
# @param options [Hash] A customizable set of options.
|
74
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
|
75
|
+
# @option options [Integer] :cursor. Defaults to null
|
76
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
77
|
+
# @option options [String] :order. Defaults to "desc". Choices: asc, desc
|
78
|
+
# @example Return list of most liked users for forum 'myforum'
|
79
|
+
# Disqussion::Client.forums.listMostLikedUsers("myforum")
|
67
80
|
# @see: http://disqus.com/api/3.0/forums/listMostLikedUsers.json
|
68
81
|
def listMostLikedUsers(*args)
|
82
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
83
|
+
options[:forum] = args.first
|
84
|
+
response = get('forums/listMostLikedUsers', options)
|
69
85
|
end
|
70
86
|
|
71
87
|
# Returns a list of posts within a forum.
|
@@ -118,5 +134,26 @@ module Disqussion
|
|
118
134
|
response = get('forums/listThreads', options)
|
119
135
|
end
|
120
136
|
|
137
|
+
# Returns a list of users active within a forum.
|
138
|
+
# @accessibility: public key, secret key
|
139
|
+
# @methods: GET
|
140
|
+
# @format: json, jsonp
|
141
|
+
# @authenticated: false
|
142
|
+
# @limited: false
|
143
|
+
# @param forum [String] Forum ID (aka short name).
|
144
|
+
# @return [Hashie::Rash] Details on the list of posts.
|
145
|
+
# @param options [Hash] A customizable set of options.
|
146
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
|
147
|
+
# @option options [Integer] :cursor. Defaults to null
|
148
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
149
|
+
# @option options [String] :order. Defaults to "desc". Choices: asc, desc
|
150
|
+
# @example Return list of active users for forum 'myforum'
|
151
|
+
# Disqussion::Client.forums.listUsers("myforum")
|
152
|
+
# @see: http://disqus.com/api/3.0/forums/listUsers.json
|
153
|
+
def listUsers(*args)
|
154
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
155
|
+
options[:forum] = args.first
|
156
|
+
response = get('forums/listUsers', options)
|
157
|
+
end
|
121
158
|
end
|
122
159
|
end
|
@@ -10,7 +10,7 @@ module Disqussion
|
|
10
10
|
# @return [Hashie::Rash] Details on the requested user.
|
11
11
|
# @example Return extended information for 'the88'
|
12
12
|
# Disqussion::Client.user("the88")
|
13
|
-
# Disqussion::Client.user(
|
13
|
+
# Disqussion::Client.user(1234) # Same as above
|
14
14
|
# @see: http://disqus.com/api/3.0/users/details.json
|
15
15
|
def details(*args)
|
16
16
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -29,7 +29,7 @@ module Disqussion
|
|
29
29
|
# @return [Hashie::Rash] Details on the requested user.
|
30
30
|
# @example Return extended information for 'the88'
|
31
31
|
# Disqussion::Client.follow("the88")
|
32
|
-
# Disqussion::Client.follow(
|
32
|
+
# Disqussion::Client.follow(1234) # Same as above
|
33
33
|
# @see: http://disqus.com/api/3.0/users/details.json
|
34
34
|
def follow(*args)
|
35
35
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -39,48 +39,98 @@ module Disqussion
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Returns a list of forums a user has been active on.
|
42
|
-
|
43
|
-
|
42
|
+
# @accessibility: public key, secret key
|
43
|
+
# @methods: GET
|
44
|
+
# @format: json, jsonp
|
45
|
+
# @authenticated: false
|
46
|
+
# @limited: false
|
47
|
+
# @return [Hashie::Rash] Details on the list of posts.
|
48
|
+
# @param options [Hash] A customizable set of options.
|
49
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
|
50
|
+
# @option options [Integer] :cursor. Defaults to null
|
51
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
52
|
+
# @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
|
53
|
+
# @option options [String] :order. Defaults to "desc". Choices: asc, desc
|
54
|
+
# @example Return a list of forums user 1234 has been active on
|
55
|
+
# Disqussion::Client.users.listActiveForums(:user => 1234)
|
56
|
+
# @see: http://disqus.com/api/3.0/users/listActiveForums.json
|
57
|
+
def listActiveForums(*args)
|
58
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
59
|
+
response = get('users/listActiveForums', options)
|
44
60
|
end
|
45
61
|
|
46
62
|
# BETA
|
47
63
|
# Returns a list of threads a user has participated in sorted by last activity.
|
48
|
-
def listActiveThreads
|
64
|
+
def listActiveThreads(*args)
|
49
65
|
|
50
66
|
end
|
51
67
|
|
52
68
|
# BETA
|
53
69
|
# Returns a list of various activity types made by the user.
|
54
|
-
def listActivity
|
70
|
+
def listActivity(*args)
|
55
71
|
|
56
72
|
end
|
57
73
|
|
58
74
|
# BETA
|
59
75
|
# Returns a list of users a user is being followed by.
|
60
|
-
def listFollowers
|
76
|
+
def listFollowers(*args)
|
61
77
|
|
62
78
|
end
|
63
79
|
|
64
80
|
# BETA
|
65
81
|
# Returns a list of users a user is following.
|
66
|
-
def listFollowing
|
82
|
+
def listFollowing(*args)
|
67
83
|
|
68
84
|
end
|
69
|
-
|
85
|
+
|
70
86
|
# Returns a list of forums a user owns.
|
71
|
-
|
72
|
-
|
87
|
+
# @accessibility: public key, secret key
|
88
|
+
# @methods: GET
|
89
|
+
# @format: json, jsonp
|
90
|
+
# @authenticated: false
|
91
|
+
# @limited: false
|
92
|
+
# @return [Hashie::Rash] Details on the list of forums.
|
93
|
+
# @param options [Hash] A customizable set of options.
|
94
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
|
95
|
+
# @option options [Integer] :cursor. Defaults to null
|
96
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
97
|
+
# @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
|
98
|
+
# @option options [String] :order. Defaults to "desc". Choices: asc, desc
|
99
|
+
# @example Return a list of forums owned by user 1234
|
100
|
+
# Disqussion::Client.users.listForums(:user => 1234)
|
101
|
+
# @see: http://disqus.com/api/3.0/users/listForums.json
|
102
|
+
def listForums(*args)
|
103
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
104
|
+
response = get('users/listForums', options)
|
73
105
|
end
|
74
106
|
|
75
107
|
# BETA
|
76
108
|
# Returns a list of forums a user has been active on recenty, sorted by the user's activity.
|
77
|
-
def listMostActiveForums
|
109
|
+
def listMostActiveForums(*args)
|
78
110
|
|
79
111
|
end
|
80
112
|
|
81
113
|
# Returns a list of posts made by the user.
|
82
|
-
|
83
|
-
|
114
|
+
# @accessibility: public key, secret key
|
115
|
+
# @methods: GET
|
116
|
+
# @format: json, jsonp
|
117
|
+
# @authenticated: false
|
118
|
+
# @limited: false
|
119
|
+
# @return [Hashie::Rash] Details on the list of forums.
|
120
|
+
# @param options [Hash] A customizable set of options.
|
121
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
|
122
|
+
# @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread.
|
123
|
+
# @option options [Integer] :cursor. Defaults to null
|
124
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
125
|
+
# @option options [Integer] :user. Defaults to null. Looks up a user by ID. You may look up a user by username using the 'username' query type.
|
126
|
+
# @option options [String, Array] :include. Allows multiple. Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged, highlighted
|
127
|
+
# @option options [String] :order. Defaults to "desc". Choices: asc, desc
|
128
|
+
# @example Return a list of user 1234s posts
|
129
|
+
# Disqussion::Client.users.listPosts(:user => 1234)
|
130
|
+
# @see: http://disqus.com/api/3.0/users/listPosts.json
|
131
|
+
def listPosts(*args)
|
132
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
133
|
+
response = get('users/listPosts', options)
|
84
134
|
end
|
85
135
|
|
86
136
|
# Unfollow a user
|
@@ -93,10 +143,12 @@ module Disqussion
|
|
93
143
|
# @return [Hashie::Rash] Details on the requested user.
|
94
144
|
# @example Return extended information for 'the88'
|
95
145
|
# Disqussion::Client.unfollow("the88")
|
96
|
-
# Disqussion::Client.unfollow(
|
146
|
+
# Disqussion::Client.unfollow(1234) # Same as above
|
97
147
|
# @see: http://disqus.com/api/3.0/users/details.json
|
98
|
-
def unfollow
|
99
|
-
|
148
|
+
def unfollow(*args)
|
149
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
150
|
+
target = args.first
|
151
|
+
merge_target_into_options!(target, options)
|
100
152
|
response = post('users/unfollow', options)
|
101
153
|
end
|
102
154
|
end
|
data/lib/disqussion/version.rb
CHANGED
@@ -33,15 +33,15 @@ describe Disqussion::Forums do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe ".
|
36
|
+
describe ".listMostLikedUsers" do
|
37
37
|
before do
|
38
|
-
stub_get("forums/
|
39
|
-
to_return(:body => fixture("forums/
|
38
|
+
stub_get("forums/listMostLikedUsers.json", :query => { :forum => "the88" }).
|
39
|
+
to_return(:body => fixture("forums/listMostLikedUsers.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
40
40
|
end
|
41
41
|
|
42
|
-
it "returns details on the requested list of
|
43
|
-
@client.
|
44
|
-
a_get("forums/
|
42
|
+
it "returns details on the requested list of users." do
|
43
|
+
@client.listMostLikedUsers("the88")
|
44
|
+
a_get("forums/listMostLikedUsers.json", :query => { :forum => "the88" }).
|
45
45
|
should have_been_made
|
46
46
|
end
|
47
47
|
end
|
@@ -59,8 +59,17 @@ describe Disqussion::Forums do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
describe ".
|
63
|
-
|
62
|
+
describe ".listPosts" do
|
63
|
+
before do
|
64
|
+
stub_get("forums/listPosts.json", :query => { :forum => "the88" }).
|
65
|
+
to_return(:body => fixture("forums/listPosts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns details on the requested list of posts." do
|
69
|
+
@client.listPosts("the88")
|
70
|
+
a_get("forums/listPosts.json", :query => { :forum => "the88" }).
|
71
|
+
should have_been_made
|
72
|
+
end
|
64
73
|
end
|
65
74
|
|
66
75
|
describe ".listThreads" do
|
@@ -75,6 +84,19 @@ describe Disqussion::Forums do
|
|
75
84
|
should have_been_made
|
76
85
|
end
|
77
86
|
end
|
87
|
+
|
88
|
+
describe ".listUsers" do
|
89
|
+
before do
|
90
|
+
stub_get("forums/listUsers.json", :query => { :forum => "the88" }).
|
91
|
+
to_return(:body => fixture("forums/listUsers.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
92
|
+
end
|
93
|
+
|
94
|
+
it "returns details on the requested list of users." do
|
95
|
+
@client.listUsers("the88")
|
96
|
+
a_get("forums/listUsers.json", :query => { :forum => "the88" }).
|
97
|
+
should have_been_made
|
98
|
+
end
|
99
|
+
end
|
78
100
|
end
|
79
101
|
end
|
80
102
|
end
|
@@ -46,6 +46,10 @@ describe Disqussion::Posts do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
describe ".getContext" do
|
50
|
+
pending
|
51
|
+
end
|
52
|
+
|
49
53
|
describe ".highlight" do
|
50
54
|
before do
|
51
55
|
stub_post("posts/highlight.json", :body => { :post => "199088808" }).
|
@@ -72,6 +76,10 @@ describe Disqussion::Posts do
|
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
79
|
+
describe ".listPopular" do
|
80
|
+
pending
|
81
|
+
end
|
82
|
+
|
75
83
|
describe ".remove" do
|
76
84
|
before do
|
77
85
|
stub_post("posts/remove.json", :body => { :post => "199088808" }).
|
@@ -46,6 +46,14 @@ describe Disqussion::Threads do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
describe ".listBydate" do
|
50
|
+
pending
|
51
|
+
end
|
52
|
+
|
53
|
+
describe ".listHot" do
|
54
|
+
pending
|
55
|
+
end
|
56
|
+
|
49
57
|
describe ".listMostLiked" do
|
50
58
|
before do
|
51
59
|
stub_get("threads/listMostLiked.json", :query => { :forum => "the88" }).
|
@@ -59,6 +67,10 @@ describe Disqussion::Threads do
|
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
70
|
+
describe ".listPopular" do
|
71
|
+
pending
|
72
|
+
end
|
73
|
+
|
62
74
|
describe ".listPosts" do
|
63
75
|
before do
|
64
76
|
stub_get("threads/listPosts.json", :query => { :thread => "mythread" }).
|
@@ -72,6 +84,10 @@ describe Disqussion::Threads do
|
|
72
84
|
end
|
73
85
|
end
|
74
86
|
|
87
|
+
describe ".listSimilar" do
|
88
|
+
pending
|
89
|
+
end
|
90
|
+
|
75
91
|
describe ".open" do
|
76
92
|
before do
|
77
93
|
stub_post("threads/open.json", :body => { :thread => "12345678" }).
|
@@ -111,6 +127,10 @@ describe Disqussion::Threads do
|
|
111
127
|
end
|
112
128
|
end
|
113
129
|
|
130
|
+
describe ".update" do
|
131
|
+
pending
|
132
|
+
end
|
133
|
+
|
114
134
|
describe ".vote" do
|
115
135
|
before do
|
116
136
|
stub_post("threads/vote.json", :body => { :vote => "1", :thread => "12345678" }).
|
@@ -20,14 +20,79 @@ describe Disqussion::Users do
|
|
20
20
|
|
21
21
|
describe ".follow" do
|
22
22
|
it "get the correct resource" do
|
23
|
-
stub_post("users/follow.json", :body => { :target => "
|
23
|
+
stub_post("users/follow.json", :body => { :target => "1234" }).
|
24
24
|
to_return(:body => fixture("users/follow.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
25
25
|
|
26
|
-
@client.follow(
|
26
|
+
@client.follow(1234)
|
27
27
|
|
28
|
-
a_post("users/follow.json", :body => { :target => "
|
28
|
+
a_post("users/follow.json", :body => { :target => "1234"}).should have_been_made
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe ".listActiveForums" do
|
33
|
+
it "get list of forums users has been active on." do
|
34
|
+
stub_get("users/listActiveForums.json", :query => { :user => "1234" }).
|
35
|
+
to_return(:body => fixture("users/listActiveForums.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
36
|
+
|
37
|
+
@client.listActiveForums(:user => 1234)
|
38
|
+
|
39
|
+
a_get("users/listActiveForums.json", :query => { :user => "1234"}).should have_been_made
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".listActiveThreads" do
|
44
|
+
pending
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".listActivity" do
|
48
|
+
pending
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".listFollowers" do
|
52
|
+
pending
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".listFollowing" do
|
56
|
+
pending
|
57
|
+
end
|
58
|
+
|
59
|
+
describe ".listForums" do
|
60
|
+
it "get list of users forums." do
|
61
|
+
stub_get("users/listForums.json", :query => { :user => "1234" }).
|
62
|
+
to_return(:body => fixture("users/listForums.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
63
|
+
|
64
|
+
@client.listForums(:user => 1234)
|
65
|
+
|
66
|
+
a_get("users/listForums.json", :query => { :user => "1234"}).should have_been_made
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "listMostActiveForums" do
|
71
|
+
pending
|
72
|
+
end
|
73
|
+
|
74
|
+
describe ".listPosts" do
|
75
|
+
it "get list of users posts." do
|
76
|
+
stub_get("users/listPosts.json", :query => { :user => "191921097" }).
|
77
|
+
to_return(:body => fixture("users/listPosts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
78
|
+
|
79
|
+
@client.listPosts(:user => 191921097)
|
80
|
+
|
81
|
+
a_get("users/listPosts.json", :query => { :user => "191921097"}).should have_been_made
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "unfollow" do
|
86
|
+
it "get the correct resource" do
|
87
|
+
stub_post("users/unfollow.json", :body => { :target => "12345678" }).
|
88
|
+
to_return(:body => fixture("users/unfollow.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
89
|
+
|
90
|
+
@client.unfollow(12345678)
|
91
|
+
|
92
|
+
a_post("users/unfollow.json", :body => { :target => "12345678"}).should have_been_made
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
31
96
|
end
|
32
97
|
end
|
33
98
|
end
|