repltalk 0.0.4 → 0.1.0
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 +4 -4
- data/lib/queries.rb +79 -11
- data/lib/repltalk.rb +37 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5eda6889050be862c69fbce525ca2142b3eb85a976bfba0bb1e2b200da95caf
|
4
|
+
data.tar.gz: e2d69baf3f93e97e9d8058db4902d9e3a0b4dd45d3e81eb3c72bb141f9b20cdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19af26777de115b60947660b54e9ddc3ff1aae1ad95ca6f66f3422f22437d1e6abe12592864c6b16aa82aad80c6141a4132b73a50b6454c123293bd8f75c8d42
|
7
|
+
data.tar.gz: 59a1b5c592b20b369cd86376ce2ad11708c74750f94311c861011998f97707b0e3620f31b38991f652818795da1cc04f1f64831a606d59c5e8cc88f155619e73
|
data/lib/queries.rb
CHANGED
@@ -165,12 +165,6 @@ class Queries
|
|
165
165
|
color
|
166
166
|
__typename
|
167
167
|
}
|
168
|
-
recentComments(count: 3) {
|
169
|
-
id
|
170
|
-
...SimpleCommentComment
|
171
|
-
__typename
|
172
|
-
}
|
173
|
-
__typename
|
174
168
|
}
|
175
169
|
|
176
170
|
fragment PostVoteControlPost on Post {
|
@@ -220,18 +214,92 @@ class Queries
|
|
220
214
|
__typename
|
221
215
|
}
|
222
216
|
__typename
|
217
|
+
}"
|
218
|
+
end
|
219
|
+
|
220
|
+
def Queries.get_user_comments
|
221
|
+
"query ProfileComments($username: String!, $after: String, $order: String, $count: Int) {
|
222
|
+
user: userByUsername(username: $username) {
|
223
|
+
id
|
224
|
+
displayName
|
225
|
+
comments(after: $after, order: $order, count: $count) {
|
226
|
+
items {
|
227
|
+
id
|
228
|
+
...ProfileCommentsComment
|
229
|
+
__typename
|
230
|
+
}
|
231
|
+
pageInfo {
|
232
|
+
nextCursor
|
233
|
+
__typename
|
234
|
+
}
|
235
|
+
__typename
|
236
|
+
}
|
237
|
+
__typename
|
238
|
+
}
|
223
239
|
}
|
224
240
|
|
225
|
-
fragment
|
241
|
+
fragment ProfileCommentsComment on Comment {
|
226
242
|
id
|
243
|
+
body
|
244
|
+
timeCreated
|
245
|
+
url
|
246
|
+
...CommentVoteControlComment
|
227
247
|
user {
|
228
248
|
id
|
229
|
-
|
230
|
-
|
249
|
+
fullName
|
250
|
+
username
|
251
|
+
image
|
252
|
+
bio
|
253
|
+
karma
|
254
|
+
isHacker
|
255
|
+
roles {
|
256
|
+
id
|
257
|
+
name
|
258
|
+
key
|
259
|
+
tagline
|
260
|
+
__typename
|
261
|
+
}
|
262
|
+
organization {
|
263
|
+
id
|
264
|
+
name
|
265
|
+
__typename
|
266
|
+
}
|
267
|
+
languages {
|
268
|
+
id
|
269
|
+
key
|
270
|
+
displayName
|
271
|
+
tagline
|
272
|
+
icon
|
273
|
+
__typename
|
274
|
+
}
|
275
|
+
}
|
276
|
+
post {
|
277
|
+
id
|
278
|
+
title
|
279
|
+
url
|
280
|
+
user {
|
281
|
+
id
|
282
|
+
username
|
283
|
+
url
|
284
|
+
__typename
|
285
|
+
}
|
286
|
+
board {
|
287
|
+
id
|
288
|
+
name
|
289
|
+
url
|
290
|
+
slug
|
291
|
+
__typename
|
292
|
+
}
|
231
293
|
__typename
|
232
294
|
}
|
233
|
-
|
234
|
-
|
295
|
+
__typename
|
296
|
+
}
|
297
|
+
|
298
|
+
fragment CommentVoteControlComment on Comment {
|
299
|
+
id
|
300
|
+
voteCount
|
301
|
+
canVote
|
302
|
+
hasVoted
|
235
303
|
__typename
|
236
304
|
}"
|
237
305
|
end
|
data/lib/repltalk.rb
CHANGED
@@ -78,6 +78,27 @@ class Board
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
class Comment
|
82
|
+
attr_reader :id, :url, :author, :content, :vote_count, :can_vote, :has_voted
|
83
|
+
|
84
|
+
def initialize(client, comment)
|
85
|
+
@client = client
|
86
|
+
|
87
|
+
@id = comment["id"]
|
88
|
+
@url = comment["url"]
|
89
|
+
@author = User.new(@client, comment["user"])
|
90
|
+
@content = comment["body"]
|
91
|
+
@vote_count = comment["voteCount"]
|
92
|
+
|
93
|
+
@can_vote = comment["canVote"]
|
94
|
+
@has_voted = comment["hasVoted"]
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_s
|
98
|
+
@content
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
81
102
|
class Post
|
82
103
|
attr_reader :id, :url, :repl, :board, :title, :author, :content, :preview, :timestamp, :vote_count, :comment_count, :can_vote, :has_voted, :is_anwered, :is_answerable, :is_hidden, :is_pinned, :is_locked, :is_announcement
|
83
104
|
|
@@ -133,7 +154,7 @@ class User
|
|
133
154
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
134
155
|
end
|
135
156
|
|
136
|
-
def get_posts(order
|
157
|
+
def get_posts(order: "new", count: nil, after: nil)
|
137
158
|
p = @client.graphql(
|
138
159
|
"ProfilePosts",
|
139
160
|
Queries.get_user_posts,
|
@@ -143,12 +164,24 @@ class User
|
|
143
164
|
after: after
|
144
165
|
)
|
145
166
|
posts = Array.new
|
146
|
-
p["user"]["posts"]["items"].each
|
147
|
-
posts << Post.new(@client, post)
|
148
|
-
end
|
167
|
+
p["user"]["posts"]["items"].each { |post| posts << Post.new(@client, post) }
|
149
168
|
posts
|
150
169
|
end
|
151
170
|
|
171
|
+
def get_comments(order: "new", count: nil, after: nil)
|
172
|
+
c = @client.graphql(
|
173
|
+
"ProfileComments",
|
174
|
+
Queries.get_user_comments,
|
175
|
+
username: @username,
|
176
|
+
order: order,
|
177
|
+
count: count,
|
178
|
+
after: after
|
179
|
+
)
|
180
|
+
comments = Array.new
|
181
|
+
c["user"]["comments"]["items"].each { |comment| comments << Comment.new(@client, comment) }
|
182
|
+
comments
|
183
|
+
end
|
184
|
+
|
152
185
|
def to_s
|
153
186
|
@username
|
154
187
|
end
|