redd 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redd/clients/base/privatemessages.rb +5 -0
- data/lib/redd/clients/base/read.rb +14 -0
- data/lib/redd/clients/base/utilities.rb +10 -8
- data/lib/redd/clients/base.rb +7 -5
- data/lib/redd/objects/base.rb +1 -0
- data/lib/redd/objects/labeled_multi.rb +13 -0
- data/lib/redd/objects/private_message.rb +10 -0
- data/lib/redd/objects/submission.rb +35 -0
- data/lib/redd/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c90f67d9e2534cad626e22954ec8d4b901219fde
|
4
|
+
data.tar.gz: 3a100caa0269c8fdbd4b14dfc1a6c8a1664b707a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03f52c6f88fefb1f14e6ae690d98bf53240dc9f7bf76039ff2b236e6e98c41f774f327c8a9fab85780ace0cf3c623188d13b971a5878369f0ed9f870463cf5d9
|
7
|
+
data.tar.gz: 33fb6ee0ce7d72dca59af56a93b43284f0417f624945329466970c91a2dee84dbd51d9845dbaf63d40dd8c9d2ad26a86793ff514e5aa67fce403f3c69591a069
|
@@ -29,6 +29,20 @@ module Redd
|
|
29
29
|
request_object(:get, "/r/#{name}/about.json")
|
30
30
|
end
|
31
31
|
|
32
|
+
# Fetch a list of multis belonging to the user.
|
33
|
+
def my_multis
|
34
|
+
multis = get("/api/multi/mine").body
|
35
|
+
multis.map { |thing| object_from_body(thing) }
|
36
|
+
end
|
37
|
+
|
38
|
+
# Fetch an individual multi from its path.
|
39
|
+
# @param [String] path The multi's path.
|
40
|
+
# @return [Objects::LabeledMulti]
|
41
|
+
def multi_from_path(path)
|
42
|
+
without_slash = path.gsub(/^\//, "")
|
43
|
+
request_object(:get, "/api/multi/" + without_slash)
|
44
|
+
end
|
45
|
+
|
32
46
|
# @!method get_hot(subreddit = nil, **params)
|
33
47
|
# @!method get_new(subreddit = nil, **params)
|
34
48
|
# @!method get_top(subreddit = nil, **params)
|
@@ -2,6 +2,7 @@ require_relative "../../objects/base"
|
|
2
2
|
require_relative "../../objects/thing"
|
3
3
|
require_relative "../../objects/listing"
|
4
4
|
require_relative "../../objects/wiki_page"
|
5
|
+
require_relative "../../objects/labeled_multi"
|
5
6
|
require_relative "../../objects/more_comments"
|
6
7
|
require_relative "../../objects/comment"
|
7
8
|
require_relative "../../objects/user"
|
@@ -17,14 +18,15 @@ module Redd
|
|
17
18
|
module Utilities
|
18
19
|
# The kind strings and the objects that should be used for them.
|
19
20
|
OBJECT_KINDS = {
|
20
|
-
"Listing"
|
21
|
-
"wikipage"
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
21
|
+
"Listing" => Objects::Listing,
|
22
|
+
"wikipage" => Objects::WikiPage,
|
23
|
+
"LabeledMulti" => Objects::LabeledMulti,
|
24
|
+
"more" => Objects::MoreComments,
|
25
|
+
"t1" => Objects::Comment,
|
26
|
+
"t2" => Objects::User,
|
27
|
+
"t3" => Objects::Submission,
|
28
|
+
"t4" => Objects::PrivateMessage,
|
29
|
+
"t5" => Objects::Subreddit
|
28
30
|
}
|
29
31
|
|
30
32
|
# Request and create an object from the response.
|
data/lib/redd/clients/base.rb
CHANGED
@@ -89,12 +89,14 @@ module Redd
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
# @param [Access]
|
92
|
+
# @param [Access] new_access The access to use.
|
93
93
|
# @yield The client with the given access.
|
94
|
-
def with(
|
95
|
-
|
96
|
-
|
97
|
-
yield
|
94
|
+
def with(new_access)
|
95
|
+
old_access = @access
|
96
|
+
@access = new_access
|
97
|
+
response = yield(self)
|
98
|
+
@access = old_access
|
99
|
+
response
|
98
100
|
end
|
99
101
|
|
100
102
|
# Obtain a new access token using a refresh token.
|
data/lib/redd/objects/base.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Redd
|
2
|
+
module Objects
|
3
|
+
# A comment that can be made on a link.
|
4
|
+
class LabeledMulti < Base
|
5
|
+
# @see Objects::Base
|
6
|
+
def initialize(client, attributes = {})
|
7
|
+
attr_dup = attributes.dup
|
8
|
+
attr_dup[:subreddits].map! { |sub| sub[:name] }
|
9
|
+
super(client, attr_dup)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -13,6 +13,16 @@ module Redd
|
|
13
13
|
def block_sender!
|
14
14
|
post("/api/block", id: fullname)
|
15
15
|
end
|
16
|
+
|
17
|
+
# Mark the message as read.
|
18
|
+
def mark_as_read
|
19
|
+
post("/api/read_message", id: fullname)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Mark the message as unread and add orangered to account.
|
23
|
+
def mark_as_unread
|
24
|
+
post("/api/unread_message", id: fullname)
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
18
28
|
end
|
@@ -25,6 +25,19 @@ module Redd
|
|
25
25
|
self[:gilded] > 0
|
26
26
|
end
|
27
27
|
|
28
|
+
# Mark the thing as Not Suitable For Work.
|
29
|
+
def mark_as_nsfw
|
30
|
+
get("/api/marknsfw", id: fullname)
|
31
|
+
self[:over_18] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# No longer mark the thing as Not Suitable For Work.
|
35
|
+
def unmark_as_nsfw
|
36
|
+
get("/api/unmarknsfw", id: fullname)
|
37
|
+
self[:over_18] = false
|
38
|
+
end
|
39
|
+
alias_method :mark_as_safe, :unmark_as_nsfw
|
40
|
+
|
28
41
|
# Reply to the thing.
|
29
42
|
# @param text [String] The text to comment.
|
30
43
|
# @return [Objects::Comment] The reply.
|
@@ -32,6 +45,28 @@ module Redd
|
|
32
45
|
client.add_comment(self, text)
|
33
46
|
end
|
34
47
|
|
48
|
+
# Set the submission to "contest mode" (comments are randomly sorted)
|
49
|
+
def set_contest_mode
|
50
|
+
post("/api/set_contest_mode", id: fullname, state: true)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Unset the "contest mode".
|
54
|
+
def unset_contest_mode
|
55
|
+
post("/api/set_contest_mode", id: fullname, state: false)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Set the submission as the sticky post of the subreddit
|
59
|
+
def set_sticky
|
60
|
+
post("/api/set_subreddit_sticky", id: fullname, state: true)
|
61
|
+
self[:stickied] = true
|
62
|
+
end
|
63
|
+
|
64
|
+
# Unsticky the post from the subreddit
|
65
|
+
def unset_sticky
|
66
|
+
post("/api/set_subreddit_sticky", id: fullname, state: false)
|
67
|
+
self[:stickied] = false
|
68
|
+
end
|
69
|
+
|
35
70
|
# @return [Listing] The submission's comments.
|
36
71
|
# @todo Allow for various depths and contexts and what not. Maybe a
|
37
72
|
# get_comment method?
|
data/lib/redd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Avinash Dwarapu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- lib/redd/error.rb
|
172
172
|
- lib/redd/objects/base.rb
|
173
173
|
- lib/redd/objects/comment.rb
|
174
|
+
- lib/redd/objects/labeled_multi.rb
|
174
175
|
- lib/redd/objects/listing.rb
|
175
176
|
- lib/redd/objects/more_comments.rb
|
176
177
|
- lib/redd/objects/private_message.rb
|