Rubbit 0.1.0 → 0.2.1
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.
- checksums.yaml +8 -8
- data/lib/Rubbit/Rubbit_Construction_Layer.rb +0 -2
- data/lib/Rubbit/Rubbit_Objects.rb +170 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODRiMzU0YWQxNzRkNmM1MDUzNDJkMDQ0N2IwYTE0MGY0N2E1YWNlOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTI5YWEwNzYwYzY4ZDliMDkyZjlhMzNiMWM3NTAzODllMWY1NDgxMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWMyOGI1NzQ2MWU0NDUyMzliYWNjYTUwZjk0OWM5NWUzMTI0YTQwNTAzNjE1
|
10
|
+
YmEzYTUxNzU3MDI2NjJjNzYwMzY2Y2E2YWRmMTdkNjJmMzBhYjM3N2Y4YTE3
|
11
|
+
ZWUxMzg2MWM0YWI0Yjg1MTY5ZDZkYmU5NmEwMjdmNGJjYWZjMDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTQ1YTJiNzIwZTA1ZDY0OGZmODI5ZjU2MjZkZmVkMjM1NGMxYmRmYWI2NTU4
|
14
|
+
MDFlNmIwOGZlMjgxMTNhZjAzMGE5NTk5ZGQxZGRlYjNlMDFjYmY1MTBlNzY4
|
15
|
+
N2Q0MzI1Yzg2MmYyZDllNjFiYTYxYTNkYzQ3NmNjNGUwNWQ4N2U=
|
@@ -28,7 +28,6 @@ class Rubbit_Object_Builder
|
|
28
28
|
|
29
29
|
def build_subreddit(display_name)
|
30
30
|
response = Reddit_Net_Wrapper.instance.make_request('get','http://www.reddit.com/r/'+display_name.to_s+"/about.json",{})
|
31
|
-
puts response.code
|
32
31
|
if(response.code=='200')
|
33
32
|
return Subreddit.new(JSON.parse(response.body))
|
34
33
|
elsif(response.code=='403')
|
@@ -278,7 +277,6 @@ class Rubbit_Poster
|
|
278
277
|
def get_modhash
|
279
278
|
response = Reddit_Net_Wrapper.instance.make_request('get','http://www.reddit.com/user/'+@logged_in_user+'/about.json',{})
|
280
279
|
data = JSON.parse(response.body)
|
281
|
-
puts data
|
282
280
|
return data['data']['modhash']
|
283
281
|
end
|
284
282
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'Rubbit/Reddit_Net_Wrapper'
|
2
2
|
require 'Rubbit/Rubbit_Exceptions'
|
3
3
|
|
4
|
+
# == Subreddit
|
5
|
+
# Object Representing a Subreddit.
|
4
6
|
class Subreddit
|
5
7
|
def initialize(json)
|
6
8
|
if(json['kind']=='t5')
|
@@ -12,74 +14,237 @@ class Subreddit
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
17
|
+
# ==== Description
|
18
|
+
#
|
19
|
+
# Returns enumerable ContentGenerator object representing the new queue
|
20
|
+
#
|
21
|
+
# ==== Attributes
|
22
|
+
#
|
23
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
24
|
+
#
|
15
25
|
def get_new(limit=100)
|
16
26
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/new.json',limit)
|
17
27
|
end
|
18
28
|
|
29
|
+
# ==== Description
|
30
|
+
#
|
31
|
+
# Returns enumerable ContentGenerator object representing the hot queue
|
32
|
+
#
|
33
|
+
# ==== Attributes
|
34
|
+
#
|
35
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
36
|
+
#
|
19
37
|
def get_hot(limit=100)
|
20
38
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/hot.json',limit)
|
21
39
|
end
|
22
40
|
|
41
|
+
# ==== Description
|
42
|
+
#
|
43
|
+
# Returns enumerable ContentGenerator object representing the top queue
|
44
|
+
#
|
45
|
+
# ==== Attributes
|
46
|
+
#
|
47
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
48
|
+
#
|
23
49
|
def get_top(limit=100)
|
24
50
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/top.json',limit)
|
25
51
|
end
|
26
52
|
|
53
|
+
# ==== Description
|
54
|
+
#
|
55
|
+
# Returns enumerable ContentGenerator object representing the gilded queue
|
56
|
+
#
|
57
|
+
# ==== Attributes
|
58
|
+
#
|
59
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
60
|
+
#
|
27
61
|
def get_gilded(limit=100)
|
28
62
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/gilded.json',limit)
|
29
63
|
end
|
30
64
|
|
65
|
+
# ==== Description
|
66
|
+
#
|
67
|
+
# Returns enumerable ContentGenerator object representing the rising queue
|
68
|
+
#
|
69
|
+
# ==== Attributes
|
70
|
+
#
|
71
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
72
|
+
#
|
31
73
|
def get_rising(limit=100)
|
32
74
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/rising.json',limit)
|
33
75
|
end
|
34
76
|
|
77
|
+
# ==== Description
|
78
|
+
#
|
79
|
+
# Returns enumerable ContentGenerator object representing the controversial queue
|
80
|
+
#
|
81
|
+
# ==== Attributes
|
82
|
+
#
|
83
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
84
|
+
#
|
35
85
|
def get_controversial(limit=100)
|
36
86
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/controversial.json',limit)
|
37
87
|
end
|
38
88
|
|
89
|
+
|
90
|
+
# ==== Description
|
91
|
+
#
|
92
|
+
# General function for submitting content to a subreddit
|
93
|
+
#
|
94
|
+
# ==== Attributes
|
95
|
+
#
|
96
|
+
# * +title+ - *REQUIRED.* Title for post. Cannot be empty or the function will not work.
|
97
|
+
# * +url+ - The url for the post. Will only be used if kind is "link"
|
98
|
+
# * +text+ - The text for the post. Will only be used if kind is "self"
|
99
|
+
# * +kind+ - Determines type of post. Either link or self.
|
100
|
+
# * +resubmit+ - If true, will make post to subreddit regardless if it is a repost
|
101
|
+
# * +save+ - Will save the post in user's "saved" links if true
|
102
|
+
# * +sendreplies+ - Will send replies to post to user's inbox by default, unless this is set to false
|
103
|
+
#
|
39
104
|
def submit(title,url=nil,text=nil,kind='self',resubmit=false,save=false,sendreplies=true)
|
40
105
|
return Rubbit_Poster.instance.submit(@display_name,title,url,text,kind,resubmit,save,sendreplies)
|
41
106
|
end
|
42
107
|
|
43
|
-
|
108
|
+
# ==== Description
|
109
|
+
#
|
110
|
+
# Function for submitting self posts to a subreddit.
|
111
|
+
#
|
112
|
+
# ==== Attributes
|
113
|
+
#
|
114
|
+
# * +title+ - *REQUIRED.* Title for post. Cannot be empty or the function will not work.
|
115
|
+
# * +text+ - The text for the post.
|
116
|
+
# * +save+ - Will save the post in user's "saved" links if true
|
117
|
+
# * +sendreplies+ - Will send replies to post to user's inbox by default, unless this is set to false
|
118
|
+
#
|
119
|
+
def submit_self(title,text=nil,save=false,sendreplies=true)
|
44
120
|
return submit(title,nil,text,'self',false,save,sendreplies)
|
45
121
|
end
|
46
122
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
123
|
+
# ==== Description
|
124
|
+
#
|
125
|
+
# Function for submitting link posts to a subreddit.
|
126
|
+
#
|
127
|
+
# ==== Attributes
|
128
|
+
#
|
129
|
+
# * +title+ - *REQUIRED.* Title for post. Cannot be empty or the function will not work.
|
130
|
+
# * +url+ - The url for the post.
|
131
|
+
# * +resubmit+ - If true, will make post to subreddit regardless if it is a repost
|
132
|
+
# * +save+ - Will save the post in user's "saved" links if true
|
133
|
+
# * +sendreplies+ - Will send replies to post to user's inbox by default, unless this is set to false
|
134
|
+
#
|
135
|
+
def submit_link(title,url,resubmit=false,save=false,sendreplies=true)
|
136
|
+
return submit(title,url,nil,'link',resubmit,save,sendreplies)
|
137
|
+
end
|
138
|
+
|
139
|
+
# ==== Description
|
140
|
+
#
|
141
|
+
# Returns enumerable ContentGenerator object representing approved contributors to a subreddit
|
142
|
+
#
|
143
|
+
# ==== Attributes
|
144
|
+
#
|
145
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
146
|
+
#
|
51
147
|
def get_contributors(limit=100)
|
52
148
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/about/contributors.json',limit)
|
53
149
|
end
|
54
150
|
|
151
|
+
|
152
|
+
# ==== Description
|
153
|
+
#
|
154
|
+
# Returns enumerable ContentGenerator object representing banned users of a subreddit. Will only work if subreddit moderator.
|
155
|
+
#
|
156
|
+
# ==== Attributes
|
157
|
+
#
|
158
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
159
|
+
#
|
55
160
|
def get_banned(limit=100)
|
56
161
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/about/banned.json',limit)
|
57
162
|
end
|
58
163
|
|
164
|
+
|
165
|
+
# ==== Description
|
166
|
+
#
|
167
|
+
# Returns enumerable ContentGenerator object representing moderators of a subreddit. Will only work if subreddit is viewable.
|
168
|
+
#
|
169
|
+
# ==== Attributes
|
170
|
+
#
|
171
|
+
# * +limit+ - Maximum entries that the returned ContentGenerator will hold. For no limit, use *nil*
|
172
|
+
#
|
59
173
|
def get_moderators(limit=100)
|
60
174
|
return ContentGenerator.new('http://www.reddit.com/r/'+@display_name.to_s+'/about/moderators.json',limit)
|
61
175
|
end
|
62
176
|
|
177
|
+
|
178
|
+
# ==== Description
|
179
|
+
#
|
180
|
+
# Function for adding moderator to a subreddit. Only works if subreddit moderator.
|
181
|
+
#
|
182
|
+
# ==== Attributes
|
183
|
+
#
|
184
|
+
# * +name+ - name of user to add as a moderator
|
185
|
+
# * +permissions+ - string containing permissions to give this user
|
186
|
+
#
|
63
187
|
def add_moderator(name,permissions)
|
64
188
|
return Rubbit_Poster.instance.friend('moderator_invite',name,@display_name,permissions)
|
65
189
|
end
|
66
190
|
|
191
|
+
# ==== Description
|
192
|
+
#
|
193
|
+
# Function for adding contributor to a subreddit. Only works if subreddit moderator.
|
194
|
+
# ==== Attributes
|
195
|
+
#
|
196
|
+
# * +name+ - name of user to add as a contributor
|
197
|
+
#
|
67
198
|
def add_contributor(name)
|
68
199
|
return Rubbit_Poster.instance.friend('contributor',name,@display_name)
|
69
200
|
end
|
70
201
|
|
202
|
+
# ==== Description
|
203
|
+
#
|
204
|
+
# Function for banning a user from a subreddit. Only works if subreddit moderator.
|
205
|
+
#
|
206
|
+
# ==== Attributes
|
207
|
+
#
|
208
|
+
# * +name+ - name of user to ban
|
209
|
+
# * +note+ - note for the ban
|
210
|
+
# * +duration+ - length of period they are banned for, in days. Send *nil* for permanent
|
211
|
+
#
|
71
212
|
def ban(name,note,duration)
|
72
213
|
return Rubbit_Poster.instance.friend('banned',name,@display_name,note,duration)
|
73
214
|
end
|
74
215
|
|
216
|
+
# ==== Description
|
217
|
+
#
|
218
|
+
# Function for removing a moderator from a subreddit. Only works if subreddit moderator and has higher permissions than mod to remove.
|
219
|
+
#
|
220
|
+
# ==== Attributes
|
221
|
+
#
|
222
|
+
# * +name+ - name of moderator to remove
|
223
|
+
#
|
75
224
|
def remove_moderator(name)
|
76
225
|
return Rubbit_Poster.instance.unfriend('moderator',name,@display_name)
|
77
226
|
end
|
78
227
|
|
228
|
+
# ==== Description
|
229
|
+
#
|
230
|
+
# Function for removing a contributor from a subreddit. Only works if subreddit moderator.
|
231
|
+
#
|
232
|
+
# ==== Attributes
|
233
|
+
#
|
234
|
+
# * +name+ - name of contributor to remove
|
235
|
+
#
|
79
236
|
def remove_contributor(name)
|
80
237
|
return Rubbit_Poster.instance.unfriend('contributor',name,@display_name)
|
81
238
|
end
|
82
239
|
|
240
|
+
# ==== Description
|
241
|
+
#
|
242
|
+
# Function for unbanning a user from a subreddit. Only works if subreddit moderator.
|
243
|
+
#
|
244
|
+
# ==== Attributes
|
245
|
+
#
|
246
|
+
# * +name+ - name of user to unban
|
247
|
+
#
|
83
248
|
def unban(name)
|
84
249
|
return Rubbit_Poster.instance.unfriend('ban',name,@display_name)
|
85
250
|
end
|