Rubbit 0.0.7 → 0.0.8
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/Reddit_Net_Wrapper.rb +1 -1
- data/lib/Rubbit/Rubbit_Construction_Layer.rb +23 -36
- data/lib/Rubbit/Rubbit_Exceptions.rb +14 -0
- data/lib/Rubbit/Rubbit_Objects.rb +4 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2I2NDlhOTg0OWU1MDljYTQ4NjliZTk0YWI3NzBjOWU5ZmE3ODYxYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjU4YmFmZTA4MmU2ODcxMWJmZGMzNWNlOGIyMjBhYTdkOTNkODRlZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Nzk2Mjk2Mzc5Y2EyNmUxNjkzM2Q4N2JmMDgyNDI1NjM0OGM2NDAwYTZjOWUy
|
10
|
+
MDIwMzliYmZkYjliZDkyM2NiNTM5OGQzODczMDAxYzM4ZGQyZWQxNmZlZWRi
|
11
|
+
YmQzY2ExZTU1NWQ4NWFmZGMzOTNlY2YyMTkxMjc3M2JjM2UwMGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWRmYTdmZTJlZDU4NWRiMDMzMDllN2FmYzg1YTM5YmEzMDk4YTFlZTVhZTcx
|
14
|
+
MzRmYzE4ZTNjNmI0ODdiMDc2NDc1OTg1NGM4YjJhZTU3MWQ3ZjQyNTA1YWMz
|
15
|
+
MWY3ZGNhOWY3MTYwYThlNDJkNzMyYzMwZWZlMzI3NjhiNmYwZGM=
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'Rubbit/Rubbit_Objects'
|
2
2
|
require 'Rubbit/Reddit_Net_Wrapper'
|
3
|
+
require 'Rubbit/Rubbit_Exceptions'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
class Rubbit_Object_Builder
|
@@ -26,6 +27,10 @@ class Rubbit_Object_Builder
|
|
26
27
|
puts response.code
|
27
28
|
if(response.code=='200')
|
28
29
|
return Subreddit.new(JSON.parse(response.body))
|
30
|
+
elsif(response.code=='403')
|
31
|
+
raise PrivateDataException, "/r/" + display_name + " is a private subreddit."
|
32
|
+
elsif(response.code=='404')
|
33
|
+
raise InvalidSubredditException, "/r/" + display_name + " does not exist."
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -33,6 +38,8 @@ class Rubbit_Object_Builder
|
|
33
38
|
response = Reddit_Net_Wrapper.instance.make_request('get','http://www.reddit.com/user/'+user.to_s+'/about.json',{})
|
34
39
|
if(response.code=='200')
|
35
40
|
return Redditor.new(JSON.parse(response.body))
|
41
|
+
else
|
42
|
+
raise InvalidUserException, "User unable to be retrieved"
|
36
43
|
end
|
37
44
|
end
|
38
45
|
|
@@ -55,7 +62,7 @@ class Rubbit_Object_Builder
|
|
55
62
|
elsif(json['kind']=='t4')
|
56
63
|
return Message.new(json)
|
57
64
|
else
|
58
|
-
|
65
|
+
raise InvalidSubmissionException, "Could not get submission"
|
59
66
|
end
|
60
67
|
end
|
61
68
|
end
|
@@ -65,8 +72,11 @@ class Rubbit_Object_Builder
|
|
65
72
|
if(response.code=='200')
|
66
73
|
json = JSON.parse(response.body,:max_nesting=>100)
|
67
74
|
return Listing.new(json[1])
|
75
|
+
elsif(response.code=='403')
|
76
|
+
raise PrivateDataException
|
77
|
+
else
|
78
|
+
raise InvalidSubmissionException, "Could not get comment"
|
68
79
|
end
|
69
|
-
return
|
70
80
|
end
|
71
81
|
|
72
82
|
private_class_method :new
|
@@ -102,11 +112,12 @@ class Rubbit_Poster
|
|
102
112
|
login_status = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/login/',params).code
|
103
113
|
|
104
114
|
if(login_status=='200')
|
105
|
-
user = Rubbit_Object_Builder.instance.build_user(
|
115
|
+
user = Rubbit_Object_Builder.instance.build_user(user)
|
106
116
|
@logged_in_user = user.name
|
107
117
|
return user
|
118
|
+
else
|
119
|
+
raise InvalidUserException, "Could not validate login credentials"
|
108
120
|
end
|
109
|
-
return nil
|
110
121
|
end
|
111
122
|
|
112
123
|
def clear_sessions(curpass)
|
@@ -117,10 +128,7 @@ class Rubbit_Poster
|
|
117
128
|
|
118
129
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/clear_sessions/',params)
|
119
130
|
|
120
|
-
|
121
|
-
return true
|
122
|
-
end
|
123
|
-
return false
|
131
|
+
return response.body
|
124
132
|
end
|
125
133
|
|
126
134
|
def delete_user(user,passwd,message,confirm)
|
@@ -132,10 +140,7 @@ class Rubbit_Poster
|
|
132
140
|
params['uh']=get_modhash
|
133
141
|
|
134
142
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/delete_user/',params)
|
135
|
-
|
136
|
-
return true
|
137
|
-
end
|
138
|
-
return false
|
143
|
+
return response.body
|
139
144
|
end
|
140
145
|
|
141
146
|
def update(email,newpass,curpass,verify,verpass)
|
@@ -149,10 +154,7 @@ class Rubbit_Poster
|
|
149
154
|
params['uh']=get_modhash
|
150
155
|
|
151
156
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/update/',params)
|
152
|
-
|
153
|
-
return true
|
154
|
-
end
|
155
|
-
return false
|
157
|
+
return response.body
|
156
158
|
end
|
157
159
|
|
158
160
|
def submit(sr,title,url=nil,text=nil,kind='self',resubmit=nil,save=false,sendreplies=true)
|
@@ -184,10 +186,7 @@ class Rubbit_Poster
|
|
184
186
|
|
185
187
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/comment',params)
|
186
188
|
|
187
|
-
|
188
|
-
return true
|
189
|
-
end
|
190
|
-
return false
|
189
|
+
return response.body
|
191
190
|
end
|
192
191
|
|
193
192
|
def hide(id)
|
@@ -197,10 +196,7 @@ class Rubbit_Poster
|
|
197
196
|
|
198
197
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/hide',params)
|
199
198
|
|
200
|
-
|
201
|
-
return true
|
202
|
-
end
|
203
|
-
return false
|
199
|
+
return response.body
|
204
200
|
end
|
205
201
|
|
206
202
|
def delete(id)
|
@@ -210,10 +206,7 @@ class Rubbit_Poster
|
|
210
206
|
|
211
207
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/del',params)
|
212
208
|
|
213
|
-
|
214
|
-
return true
|
215
|
-
end
|
216
|
-
return false
|
209
|
+
return response.body
|
217
210
|
end
|
218
211
|
|
219
212
|
def edit(id,text)
|
@@ -225,10 +218,7 @@ class Rubbit_Poster
|
|
225
218
|
|
226
219
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/editusertext',params)
|
227
220
|
|
228
|
-
|
229
|
-
return true
|
230
|
-
end
|
231
|
-
return false
|
221
|
+
return response.body
|
232
222
|
end
|
233
223
|
|
234
224
|
def mark_nsfw(id)
|
@@ -238,10 +228,7 @@ class Rubbit_Poster
|
|
238
228
|
|
239
229
|
response = Reddit_Net_Wrapper.instance.make_request('post','http://www.reddit.com/api/marknsfw',params)
|
240
230
|
|
241
|
-
|
242
|
-
return true
|
243
|
-
end
|
244
|
-
return false
|
231
|
+
return response.body
|
245
232
|
end
|
246
233
|
|
247
234
|
def get_modhash
|
@@ -108,7 +108,6 @@ class ContentGenerator
|
|
108
108
|
@count = 0
|
109
109
|
@data = []
|
110
110
|
@after = after
|
111
|
-
@modhash = nil
|
112
111
|
end
|
113
112
|
|
114
113
|
def each
|
@@ -174,6 +173,10 @@ class ContentGenerator
|
|
174
173
|
return listing.children[0]
|
175
174
|
end
|
176
175
|
end
|
176
|
+
|
177
|
+
def length
|
178
|
+
return @data.length
|
179
|
+
end
|
177
180
|
end
|
178
181
|
|
179
182
|
class Comment
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Rubbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- /u/The1RGood
|
@@ -19,6 +19,7 @@ files:
|
|
19
19
|
- lib/Rubbit.rb
|
20
20
|
- lib/Rubbit/Reddit_Net_Wrapper.rb
|
21
21
|
- lib/Rubbit/Rubbit_Construction_Layer.rb
|
22
|
+
- lib/Rubbit/Rubbit_Exceptions.rb
|
22
23
|
- lib/Rubbit/Rubbit_Objects.rb
|
23
24
|
homepage: http://rubygems.org/gems/rubbit
|
24
25
|
licenses:
|