disqussion 0.0.3 → 0.0.4
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 +13 -13
- data/HISTORY.mkd +4 -0
- data/README.mkd +5 -5
- data/lib/disqussion/client/categories.rb +112 -1
- data/lib/disqussion/client/exports.rb +22 -0
- data/lib/disqussion/client/forums.rb +3 -3
- data/lib/disqussion/client/imports.rb +36 -1
- data/lib/disqussion/client/reports.rb +75 -0
- data/lib/disqussion/version.rb +1 -1
- data/lib/disqussion/widget.rb +168 -168
- data/lib/faraday/response/raise_http_4xx.rb +4 -11
- data/spec/disqussion/client/categories_spec.rb +76 -0
- data/spec/disqussion/client/export_spec.rb +24 -0
- data/spec/disqussion/client/imports_spec.rb +37 -0
- data/spec/disqussion/client/reports_spec.rb +63 -0
- data/spec/faraday/response_spec.rb +2 -3
- data/spec/fixtures/categories/create.json +10 -0
- data/spec/fixtures/categories/details.json +10 -0
- data/spec/fixtures/categories/list.json +21 -0
- data/spec/fixtures/categories/listPosts.json +46 -0
- data/spec/fixtures/categories/listThreads.json +54 -0
- data/spec/fixtures/exports/exportForum.json +4 -0
- data/spec/fixtures/faraday/error2.json +4 -0
- data/spec/fixtures/imports/details.json +4 -0
- data/spec/fixtures/imports/list.json +113 -0
- data/spec/fixtures/reports/domains.json +4 -0
- data/spec/fixtures/reports/ips.json +82 -0
- data/spec/fixtures/reports/threads.json +4 -0
- data/spec/fixtures/reports/users.json +82 -0
- metadata +36 -2
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.4)
|
5
5
|
faraday (~> 0.6.1)
|
6
6
|
faraday_middleware (~> 0.6.3)
|
7
7
|
hashie (~> 1.0.0)
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
remote: http://rubygems.org/
|
13
13
|
specs:
|
14
14
|
ZenTest (4.5.0)
|
15
|
-
addressable (2.2.
|
15
|
+
addressable (2.2.6)
|
16
16
|
archive-tar-minitar (0.5.2)
|
17
17
|
columnize (0.3.2)
|
18
18
|
crack (0.1.8)
|
@@ -36,14 +36,14 @@ GEM
|
|
36
36
|
rake (0.8.7)
|
37
37
|
rash (0.3.0)
|
38
38
|
hashie (~> 1.0.0)
|
39
|
-
rspec (2.
|
40
|
-
rspec-core (~> 2.
|
41
|
-
rspec-expectations (~> 2.
|
42
|
-
rspec-mocks (~> 2.
|
43
|
-
rspec-core (2.
|
44
|
-
rspec-expectations (2.
|
39
|
+
rspec (2.6.0)
|
40
|
+
rspec-core (~> 2.6.0)
|
41
|
+
rspec-expectations (~> 2.6.0)
|
42
|
+
rspec-mocks (~> 2.6.0)
|
43
|
+
rspec-core (2.6.0)
|
44
|
+
rspec-expectations (2.6.0)
|
45
45
|
diff-lcs (~> 1.1.2)
|
46
|
-
rspec-mocks (2.
|
46
|
+
rspec-mocks (2.6.0)
|
47
47
|
ruby-debug-base19 (0.11.25)
|
48
48
|
columnize (>= 0.3.1)
|
49
49
|
linecache19 (>= 0.5.11)
|
@@ -56,12 +56,12 @@ GEM
|
|
56
56
|
archive-tar-minitar (>= 0.5.2)
|
57
57
|
simplecov (0.4.2)
|
58
58
|
simplecov-html (~> 0.4.4)
|
59
|
-
simplecov-html (0.4.
|
59
|
+
simplecov-html (0.4.5)
|
60
60
|
syntax (1.0.0)
|
61
|
-
webmock (1.6.
|
62
|
-
addressable (
|
61
|
+
webmock (1.6.4)
|
62
|
+
addressable (~> 2.2, > 2.2.5)
|
63
63
|
crack (>= 0.1.7)
|
64
|
-
yard (0.
|
64
|
+
yard (0.7.1)
|
65
65
|
|
66
66
|
PLATFORMS
|
67
67
|
ruby
|
data/HISTORY.mkd
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
HISTORY
|
2
2
|
=======
|
3
3
|
|
4
|
+
0.0.4 - May 19, 2011
|
5
|
+
----------------------
|
6
|
+
* Added following features: Categories, Exports, Imports, Reports
|
7
|
+
|
4
8
|
0.0.3 - May 18, 2011
|
5
9
|
----------------------
|
6
10
|
* Added following missing features: Users#listActiveForums, Users#listForums, Users#listPosts, Users#unfollow, Forums#listMostLikedUsers, Forums#listUsers
|
data/README.mkd
CHANGED
@@ -2,8 +2,6 @@ The Disqussion Ruby Gem
|
|
2
2
|
====================
|
3
3
|
A Ruby wrapper for the Disqus API
|
4
4
|
|
5
|
-
IMPORTANT: This gem is non-usable for production, beta version expected on May 9th 2011
|
6
|
-
|
7
5
|
Installation
|
8
6
|
------------
|
9
7
|
``` sh
|
@@ -22,12 +20,14 @@ Continuous Integration
|
|
22
20
|
----------------------
|
23
21
|
[](http://travis-ci.org/jeremyvdw/disqussion)
|
24
22
|
|
25
|
-
What's in 0.0.
|
23
|
+
What's in 0.0.4?
|
26
24
|
----------------
|
27
25
|
|
28
|
-
Disqussion currently covers *only* stable Disqus API for: applications, forums, posts, reactions, threads and users
|
26
|
+
Disqussion currently covers *only* stable Disqus API features for: applications, categories, exports, forums, imports, posts, reactions, reports, threads and users.
|
27
|
+
|
28
|
+
Missing following features: blacklists and whitelists.
|
29
29
|
|
30
|
-
The error classes are consistent with [Disqus
|
30
|
+
The error classes are consistent with [Disqus documented response codes](http://disqus.com/api/docs/errors/).
|
31
31
|
Error details from Disqus API are encapsulated in HTTP response.
|
32
32
|
|
33
33
|
<table>
|
@@ -1,4 +1,115 @@
|
|
1
1
|
module Disqussion
|
2
2
|
class Categories < Client
|
3
|
+
# Creates a new category.
|
4
|
+
# @accessibility: public key, secret key
|
5
|
+
# @methods: POST
|
6
|
+
# @format: json, jsonp
|
7
|
+
# @authenticated: false
|
8
|
+
# @limited: false
|
9
|
+
# @param forum [String] Looks up a forum by ID (aka short name)
|
10
|
+
# @param title [String] Maximum length of 50
|
11
|
+
# @param options [Hash] A customizable set of options.
|
12
|
+
# @option options [String] :default. Defaults to false.
|
13
|
+
# @return [Hashie::Rash] New category infos
|
14
|
+
# @example Creates a new category "My category" in forum "the88"
|
15
|
+
# Disqussion::Client.categories.create("the88", "My category")
|
16
|
+
# @see: http://disqus.com/api/3.0/categories/create.json
|
17
|
+
def create(*args)
|
18
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
19
|
+
if args.size == 2
|
20
|
+
options.merge!(:forum => args[0], :title => args[1])
|
21
|
+
response = post('categories/create', options)
|
22
|
+
else
|
23
|
+
puts "#{Kernel.caller.first}: categories.create expects 2 arguments: forum, title"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns category details.
|
28
|
+
# @accessibility: public key, secret key
|
29
|
+
# @methods: GET
|
30
|
+
# @format: json, jsonp
|
31
|
+
# @authenticated: false
|
32
|
+
# @limited: false
|
33
|
+
# @param category [Integer] Looks up a category by ID.
|
34
|
+
# @return [Hashie::Rash] Details on the requested category.
|
35
|
+
# @example
|
36
|
+
# Disqussion::Client.categories.details(19122)
|
37
|
+
# @see: http://disqus.com/api/3.0/categories/details.json
|
38
|
+
def details(*args)
|
39
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
40
|
+
options[:category] = args.first
|
41
|
+
response = get('categories/details', options)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns a list of categories within a forum.
|
45
|
+
# @accessibility: public key, secret key
|
46
|
+
# @methods: GET
|
47
|
+
# @format: json, jsonp
|
48
|
+
# @authenticated: false
|
49
|
+
# @limited: false
|
50
|
+
# @return [Hashie::Rash] Details on the requested list of categories.
|
51
|
+
# @param options [Hash] A customizable set of options.
|
52
|
+
# @option options [Array, String] :forum allow multiple. Defaults to null. Looks up a forum by ID (aka short name)
|
53
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null
|
54
|
+
# @option options [Integer] :cursor. Defaults to null
|
55
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
56
|
+
# @option options [String] :order. Defaults to "asc". Choices: asc, desc
|
57
|
+
# @example Return list of categories within forum 'myforum'
|
58
|
+
# Disqussion::Client.categories.list("myforum", {:cursor => 10, :limit => 10, :order => 'asc'})
|
59
|
+
# @see: http://disqus.com/api/3.0/categories/list.json
|
60
|
+
def list(*args)
|
61
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
62
|
+
response = get('categories/list', options)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns a list of posts within a category.
|
66
|
+
# @accessibility: public key, secret key
|
67
|
+
# @methods: GET
|
68
|
+
# @format: json, jsonp, rss
|
69
|
+
# @authenticated: false
|
70
|
+
# @limited: false
|
71
|
+
# @param forum [Integer] Category ID.
|
72
|
+
# @return [Hashie::Rash] Details on the requested 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, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread.
|
76
|
+
# @option options [Integer] :cursor. Defaults to null.
|
77
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
78
|
+
# @option options [Integer] :query. Defaults to null.
|
79
|
+
# @option options [String, Array] :include. allows multiple. Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged.
|
80
|
+
# @option options [String] :order. Defaults to "asc". Choices: asc, desc.
|
81
|
+
# @example Return list of posts within category 827231
|
82
|
+
# Disqussion::Client.categories.listPosts(827231, {:cursor => 10, :limit => 10, :order => 'asc'})
|
83
|
+
# @see: http://disqus.com/api/3.0/categories/listPosts.json
|
84
|
+
def listPosts(*args)
|
85
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
86
|
+
options[:category] = args.first
|
87
|
+
response = get('categories/listPosts', options)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns a list of threads within a category sorted by the date created.
|
91
|
+
# @accessibility: public key, secret key
|
92
|
+
# @methods: GET
|
93
|
+
# @format: json, jsonp, rss
|
94
|
+
# @authenticated: false
|
95
|
+
# @limited: false
|
96
|
+
# @param forum [Integer] Category ID.
|
97
|
+
# @return [Hashie::Rash] Details on the requested list of threads.
|
98
|
+
# @param options [Hash] A customizable set of options.
|
99
|
+
# @option options [Datetime, Timestamp] :since. Unix timestamp (or ISO datetime standard). Defaults to null.
|
100
|
+
# @option options [Integer, String] :related. Allows multiple. Defaults to []. You may specify relations to include with your response. Choices: forum, thread.
|
101
|
+
# @option options [Integer] :cursor. Defaults to null.
|
102
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
103
|
+
# @option options [Integer] :query. Defaults to null.
|
104
|
+
# @option options [String, Array] :include. allows multiple. Defaults to ["approved"]. Choices: unapproved, approved, spam, deleted, flagged.
|
105
|
+
# @option options [String] :order. Defaults to "asc". Choices: asc, desc.
|
106
|
+
# @example Return list of threads within category 827231
|
107
|
+
# Disqussion::Client.categories.listThreads(827231, {:cursor => 10, :limit => 10, :order => 'asc'})
|
108
|
+
# @see: http://disqus.com/api/3.0/categories/listThreads.json
|
109
|
+
def listThreads(*args)
|
110
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
111
|
+
options[:category] = args.first
|
112
|
+
response = get('categories/listThreads', options)
|
113
|
+
end
|
3
114
|
end
|
4
|
-
end
|
115
|
+
end
|
@@ -1,4 +1,26 @@
|
|
1
1
|
module Disqussion
|
2
2
|
class Exports < Client
|
3
|
+
# Export a forum
|
4
|
+
# @accessibility: public key, secret key
|
5
|
+
# @methods: POST
|
6
|
+
# @format: json, jsonp
|
7
|
+
# @authenticated: true
|
8
|
+
# @limited: false
|
9
|
+
# @param forum [String] Forum short name (aka forum id).
|
10
|
+
# @return [Hashie::Rash] Export infos
|
11
|
+
# @param options [Hash] A customizable set of options.
|
12
|
+
# @option options [String] :format. Defaults to "xml". Choices: xml, xml-old
|
13
|
+
# @example Export forum "the88"
|
14
|
+
# Disqussion::Client.exports.exportForum("the88")
|
15
|
+
# @see: http://disqus.com/api/3.0/exports/exportForum.json
|
16
|
+
def exportForum(*args)
|
17
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
18
|
+
if args.size == 1
|
19
|
+
options.merge!(:forum => args[0])
|
20
|
+
response = post('exports/exportForum', options)
|
21
|
+
else
|
22
|
+
puts "#{Kernel.caller.first}: exports.exportForum expects an arguments: forum"
|
23
|
+
end
|
24
|
+
end
|
3
25
|
end
|
4
26
|
end
|
@@ -53,9 +53,9 @@ module Disqussion
|
|
53
53
|
# @option options [Integer] :cursor. Defaults to null
|
54
54
|
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100
|
55
55
|
# @option options [String] :order. Defaults to "asc". Choices: asc, desc
|
56
|
-
# @example Return
|
57
|
-
# Disqussion::Client.
|
58
|
-
# @see: http://disqus.com/api/3.0/forums/
|
56
|
+
# @example Return list of categories within forum 'myforum'
|
57
|
+
# Disqussion::Client.categories.list("myforum", {:cursor => 10, :limit => 10, :order => 'asc'})
|
58
|
+
# @see: http://disqus.com/api/3.0/forums/listCategories.json
|
59
59
|
def listCategories(*args)
|
60
60
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
61
61
|
options[:forum] = args.first
|
@@ -1,4 +1,39 @@
|
|
1
1
|
module Disqussion
|
2
2
|
class Imports < Client
|
3
|
+
#
|
4
|
+
# @accessibility: public key, secret key
|
5
|
+
# @methods: GET
|
6
|
+
# @format: json, jsonp
|
7
|
+
# @authenticated: true
|
8
|
+
# @limited: false
|
9
|
+
# @param group [Integer] group ID
|
10
|
+
# @return [Hashie::Rash] Details on the requested import.
|
11
|
+
# @example
|
12
|
+
# Disqussion::Client.imports.details(987)
|
13
|
+
# @see: http://disqus.com/api/3.0/imports/details.json
|
14
|
+
def details(*args)
|
15
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
16
|
+
options[:group] = args.first
|
17
|
+
response = get('imports/details', options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns list of previous imports.
|
21
|
+
# @accessibility: public key, secret key
|
22
|
+
# @methods: GET
|
23
|
+
# @format: json, jsonp
|
24
|
+
# @authenticated: true
|
25
|
+
# @limited: false
|
26
|
+
# @param forum [String] Allows multiple. Looks up a forum by ID (aka short name).
|
27
|
+
# @return [Hashie::Rash] Details on the requested category.
|
28
|
+
# @param options [Hash] A customizable set of options.
|
29
|
+
# @option options [Integer] :cursor. Defaults to null.
|
30
|
+
# @example
|
31
|
+
# Disqussion::Client.imports.list("the88")
|
32
|
+
# @see: http://disqus.com/api/3.0/imports/list.json
|
33
|
+
def list(*args)
|
34
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
35
|
+
options[:forum] = args.first
|
36
|
+
response = get('imports/list', options)
|
37
|
+
end
|
3
38
|
end
|
4
|
-
end
|
39
|
+
end
|
@@ -1,4 +1,79 @@
|
|
1
1
|
module Disqussion
|
2
2
|
class Reports < Client
|
3
|
+
# Returns report on domains
|
4
|
+
# @accessibility: public key, secret key
|
5
|
+
# @methods: GET
|
6
|
+
# @format: json, jsonp
|
7
|
+
# @authenticated: false
|
8
|
+
# @limited: false
|
9
|
+
# @param options [Hash] A customizable set of options.
|
10
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
|
11
|
+
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
|
12
|
+
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
|
13
|
+
# @return [Hashie::Rash] Returns report
|
14
|
+
# @example Return report on comments by domains usage
|
15
|
+
# Disqussion::Client.reports.domains
|
16
|
+
# @see: http://disqus.com/api/3.0/reports/domains.json
|
17
|
+
def domains(*args)
|
18
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
19
|
+
response = get('reports/domains', options)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns report on ips
|
23
|
+
# @accessibility: public key, secret key
|
24
|
+
# @methods: GET
|
25
|
+
# @format: json, jsonp
|
26
|
+
# @authenticated: false
|
27
|
+
# @limited: false
|
28
|
+
# @param options [Hash] A customizable set of options.
|
29
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
|
30
|
+
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
|
31
|
+
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
|
32
|
+
# @return [Hashie::Rash] Returns report
|
33
|
+
# @example Return report on comments by IPs usage
|
34
|
+
# Disqussion::Client.reports.ips
|
35
|
+
# @see: http://disqus.com/api/3.0/reports/ips.json
|
36
|
+
def ips(*args)
|
37
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
38
|
+
response = get('reports/ips', options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns report on threads
|
42
|
+
# @accessibility: public key, secret key
|
43
|
+
# @methods: GET
|
44
|
+
# @format: json, jsonp
|
45
|
+
# @authenticated: false
|
46
|
+
# @limited: false
|
47
|
+
# @param options [Hash] A customizable set of options.
|
48
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
|
49
|
+
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
|
50
|
+
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
|
51
|
+
# @return [Hashie::Rash] Returns report
|
52
|
+
# @example Return report on comments by threads
|
53
|
+
# Disqussion::Client.reports.threads
|
54
|
+
# @see: http://disqus.com/api/3.0/reports/threads.json
|
55
|
+
def threads(*args)
|
56
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
57
|
+
response = get('reports/threads', options)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns report on users
|
61
|
+
# @accessibility: public key, secret key
|
62
|
+
# @methods: GET
|
63
|
+
# @format: json, jsonp
|
64
|
+
# @authenticated: false
|
65
|
+
# @limited: false
|
66
|
+
# @param options [Hash] A customizable set of options.
|
67
|
+
# @option options [Integer] :limit. Defaults to 25. Maximum length of 100.
|
68
|
+
# @option options [Integer] :page. Defaults to 0. Maximum length of 10.
|
69
|
+
# @option options [Array, String] :forum. Allow multiple. Defaults to null. Looks up a forum by ID (aka short name).
|
70
|
+
# @return [Hashie::Rash] Returns report
|
71
|
+
# @example Return report on comments by users
|
72
|
+
# Disqussion::Client.reports.users
|
73
|
+
# @see: http://disqus.com/api/3.0/reports/users.json
|
74
|
+
def users(*args)
|
75
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
76
|
+
response = get('reports/users', options)
|
77
|
+
end
|
3
78
|
end
|
4
79
|
end
|
data/lib/disqussion/version.rb
CHANGED