repltalk 3.1.0 → 4.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/repltalk/client.rb +36 -9
- data/lib/repltalk/graphql.rb +94 -15
- data/lib/repltalk/structures.rb +114 -24
- data/lib/repltalk.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87b86adfe3aef99370ce5a11bfe9648b52bb987c3f9fd35b929ac811720e48c4
|
4
|
+
data.tar.gz: acf36ed1601688e319397fed44c32287a00a869daac2258b58f17d92d165abbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2ed218280a34de49368f3761a56a37506dafa50c83f0942e6a1b5ea2907b73d367f5a67e1f1d6034c4869b3fd0bcab5e5a5dd78ea1d90e43a1adae4ca902099
|
7
|
+
data.tar.gz: 6d62a0d0989c0456235f61b6cf7ed2f5abe0bb23036de7526e325b82eaf8f99cc337fe45523e1cb9a5dcc78a6ed9804f63e6eaa4fe56d84c9b68930e8ff05d57
|
data/lib/repltalk/client.rb
CHANGED
@@ -132,18 +132,45 @@ module ReplTalk
|
|
132
132
|
u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
|
133
133
|
end
|
134
134
|
|
135
|
-
def get_posts(board: "all", order: "
|
135
|
+
def get_posts(board: "all", order: "New", count: nil, after: nil, search: nil)
|
136
136
|
p = graphql(
|
137
|
-
"
|
137
|
+
"ReplPostsFeed",
|
138
138
|
GQL::Queries::GET_POSTS,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
options: {
|
140
|
+
boardSlugs: [board],
|
141
|
+
order: order,
|
142
|
+
count: count,
|
143
|
+
after: after,
|
144
|
+
searchQuery: search
|
145
|
+
}
|
146
|
+
)
|
147
|
+
p["replPosts"]["items"].map { |post| Post.new(self, post) }
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_explore_featured_repls
|
151
|
+
r = graphql(
|
152
|
+
"ExploreFeaturedRepls",
|
153
|
+
GQL::Queries::GET_EXPLORE_FEATURED_REPLS
|
154
|
+
)
|
155
|
+
r["featuredRepls"].map { |repl| Repl.new(self, repl) }
|
156
|
+
end
|
157
|
+
|
158
|
+
def get_trending_tags(count: nil)
|
159
|
+
t = graphql(
|
160
|
+
"ExploreFeed",
|
161
|
+
GQL::Queries::GET_TRENDING_TAGS,
|
162
|
+
count: count
|
163
|
+
)
|
164
|
+
t["trendingTagsFeed"]["initialTags"].map { |tag| Tag.new(self, tag) }
|
165
|
+
end
|
166
|
+
|
167
|
+
def get_tag(tag)
|
168
|
+
t = graphql(
|
169
|
+
"ExploreTrendingRepls",
|
170
|
+
GQL::Queries::GET_TAG,
|
171
|
+
tag: tag
|
145
172
|
)
|
146
|
-
|
173
|
+
Tag.new(self, t["tag"])
|
147
174
|
end
|
148
175
|
|
149
176
|
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
data/lib/repltalk/graphql.rb
CHANGED
@@ -8,16 +8,6 @@ module ReplTalk
|
|
8
8
|
tagline
|
9
9
|
"
|
10
10
|
|
11
|
-
ORGANIZATION = "
|
12
|
-
id
|
13
|
-
name
|
14
|
-
country
|
15
|
-
postalCode
|
16
|
-
state
|
17
|
-
city
|
18
|
-
timeCreated
|
19
|
-
"
|
20
|
-
|
21
11
|
LANGUAGE = "
|
22
12
|
id
|
23
13
|
key
|
@@ -46,14 +36,25 @@ module ReplTalk
|
|
46
36
|
roles {
|
47
37
|
#{ROLES}
|
48
38
|
}
|
49
|
-
organization {
|
50
|
-
#{ORGANIZATION}
|
51
|
-
}
|
52
39
|
languages {
|
53
40
|
#{LANGUAGE}
|
54
41
|
}
|
55
42
|
"
|
56
43
|
|
44
|
+
TAG = "
|
45
|
+
id
|
46
|
+
replCount
|
47
|
+
replsTaggedTodayCount
|
48
|
+
creatorCount
|
49
|
+
isTrending
|
50
|
+
"
|
51
|
+
|
52
|
+
REACTIONS = "
|
53
|
+
id
|
54
|
+
type
|
55
|
+
count
|
56
|
+
"
|
57
|
+
|
57
58
|
REPL = "
|
58
59
|
id
|
59
60
|
url
|
@@ -61,9 +62,17 @@ module ReplTalk
|
|
61
62
|
description
|
62
63
|
timeCreated
|
63
64
|
size
|
65
|
+
runCount
|
66
|
+
publicForkCount
|
64
67
|
imageUrl
|
65
68
|
isPrivate
|
66
69
|
isAlwaysOn
|
70
|
+
tags {
|
71
|
+
#{TAG}
|
72
|
+
}
|
73
|
+
reactions {
|
74
|
+
#{REACTIONS}
|
75
|
+
}
|
67
76
|
lang {
|
68
77
|
#{LANGUAGE}
|
69
78
|
}
|
@@ -321,8 +330,8 @@ module ReplTalk
|
|
321
330
|
"
|
322
331
|
|
323
332
|
GET_POSTS = "
|
324
|
-
query
|
325
|
-
|
333
|
+
query ReplPostsFeed($options: ReplPostsQueryOptions) {
|
334
|
+
replPosts(options: $options) {
|
326
335
|
items {
|
327
336
|
#{Fields::POST}
|
328
337
|
}
|
@@ -340,6 +349,44 @@ module ReplTalk
|
|
340
349
|
}
|
341
350
|
}
|
342
351
|
"
|
352
|
+
|
353
|
+
GET_EXPLORE_FEATURED_REPLS = "
|
354
|
+
query ExploreFeaturedRepls {
|
355
|
+
featuredRepls {
|
356
|
+
#{Fields::REPL}
|
357
|
+
}
|
358
|
+
}
|
359
|
+
"
|
360
|
+
|
361
|
+
GET_TAG = "
|
362
|
+
query ExploreTrendingRepls($tag: String!) {
|
363
|
+
tag(id: $tag) {
|
364
|
+
#{Fields::TAG}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
"
|
368
|
+
|
369
|
+
GET_TRENDING_TAGS = "
|
370
|
+
query ExploreFeed($count: Int) {
|
371
|
+
trendingTagsFeed(initialTagsCount: $count) {
|
372
|
+
initialTags {
|
373
|
+
#{Fields::TAG}
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
"
|
378
|
+
|
379
|
+
GET_TAGS_REPLS = "
|
380
|
+
query ExploreTrendingRepls($tag: String!, $count: Int, $after: String) {
|
381
|
+
tag(id: $tag) {
|
382
|
+
repls(limit: $count, after: $after) {
|
383
|
+
items {
|
384
|
+
#{Fields::REPL}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
}
|
388
|
+
}
|
389
|
+
"
|
343
390
|
end
|
344
391
|
|
345
392
|
|
@@ -442,6 +489,38 @@ module ReplTalk
|
|
442
489
|
}
|
443
490
|
"
|
444
491
|
|
492
|
+
PUBLISH_REPL = "
|
493
|
+
mutation PublishRepl($input: PublishReplInput!) {
|
494
|
+
publishRepl(input: $input) {
|
495
|
+
... on Repl {
|
496
|
+
#{Fields::REPL}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
}
|
500
|
+
"
|
501
|
+
|
502
|
+
UNPUBLISH_REPL = "
|
503
|
+
mutation ReplViewHeaderActionsUnpublishRepl($input: UnpublishReplInput!) {
|
504
|
+
unpublishRepl(input: $input) {
|
505
|
+
... on Repl {
|
506
|
+
#{Fields::REPL}
|
507
|
+
}
|
508
|
+
}
|
509
|
+
}
|
510
|
+
"
|
511
|
+
|
512
|
+
TOGGLE_REACTION = "
|
513
|
+
mutation ReplViewReactionsToggleReactions($input: SetReplReactionInput!) {
|
514
|
+
setReplReaction(input: $input) {
|
515
|
+
... on Repl {
|
516
|
+
reactions {
|
517
|
+
#{Fields::REACTIONS}
|
518
|
+
}
|
519
|
+
}
|
520
|
+
}
|
521
|
+
}
|
522
|
+
"
|
523
|
+
|
445
524
|
REPORT_POST = "
|
446
525
|
mutation createBoardReport($id: Int!, $reason: String!) {
|
447
526
|
createBoardReport(postId: $id, reason: $reason) {
|
data/lib/repltalk/structures.rb
CHANGED
@@ -18,26 +18,6 @@ module ReplTalk
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
class Organization
|
22
|
-
attr_reader :id, :name, :country, :postal_code, :state, :city, :timestamp
|
23
|
-
|
24
|
-
def initialize(organization)
|
25
|
-
@id = organization["id"]
|
26
|
-
@name = organization["name"]
|
27
|
-
@country = organization["country"]
|
28
|
-
@postal_code = organization["postalCode"]
|
29
|
-
@state = organization["state"]
|
30
|
-
@city = organization["city"]
|
31
|
-
@timestamp = organization["timeCreated"]
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_s
|
35
|
-
@name
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
21
|
class Language
|
42
22
|
attr_reader :id, :key, :name, :tagline, :icon, :category
|
43
23
|
|
@@ -74,6 +54,55 @@ module ReplTalk
|
|
74
54
|
|
75
55
|
|
76
56
|
|
57
|
+
class Tag
|
58
|
+
attr_reader :id, :repl_count, :creator_count, :is_trending, :repls_tagged_today_count
|
59
|
+
|
60
|
+
def initialize(client, tag)
|
61
|
+
@client = client
|
62
|
+
|
63
|
+
@id = tag["id"]
|
64
|
+
@repl_count = tag["replCount"]
|
65
|
+
@is_trending = tag["isTrending"]
|
66
|
+
@creator_count = tag["creatorCount"]
|
67
|
+
@repls_tagged_today_count = tag["replsTaggedTodayCount"]
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_repls(count: nil, after: nil)
|
71
|
+
r = @client.graphql(
|
72
|
+
"ExploreTrendingRepls",
|
73
|
+
GQL::Queries::GET_TAGS_REPLS,
|
74
|
+
tag: @id,
|
75
|
+
count: count,
|
76
|
+
after: after
|
77
|
+
)
|
78
|
+
r["tag"]["repls"]["items"].map { |repl| Repl.new(@client, repl) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s
|
82
|
+
@id
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
class Reaction
|
90
|
+
attr_reader :id, :type, :count
|
91
|
+
|
92
|
+
def initialize(reaction)
|
93
|
+
@id = reaction["id"]
|
94
|
+
@type = reaction["type"]
|
95
|
+
@count = reaction["count"]
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_s
|
99
|
+
@type
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
77
106
|
class ReplComment
|
78
107
|
attr_reader :id, :content, :author, :repl, :replies
|
79
108
|
|
@@ -128,7 +157,7 @@ module ReplTalk
|
|
128
157
|
|
129
158
|
|
130
159
|
class Repl
|
131
|
-
attr_reader :id, :url, :title, :author, :description, :timestamp, :size, :language, :img_url, :origin_url, :is_private, :is_always_on
|
160
|
+
attr_reader :id, :url, :title, :author, :description, :timestamp, :size, :run_count, :fork_count, :language, :img_url, :origin_url, :is_private, :is_always_on, :tags, :reactions
|
132
161
|
|
133
162
|
def initialize(client, repl)
|
134
163
|
@client = client
|
@@ -140,12 +169,17 @@ module ReplTalk
|
|
140
169
|
@description = repl["description"]
|
141
170
|
@timestamp = repl["timeCreated"]
|
142
171
|
@size = repl["size"]
|
172
|
+
@run_count = repl["runCount"]
|
173
|
+
@fork_count = repl["publicForkCount"]
|
143
174
|
@language = Language.new(repl["lang"])
|
144
175
|
@image_url = repl["imageUrl"]
|
145
176
|
@origin_url = repl["origin"] == nil ? nil : $BASE_URL + repl["origin"]["url"]
|
146
177
|
|
147
178
|
@is_private = repl["isPrivate"]
|
148
179
|
@is_always_on = repl["isAlwaysOn"]
|
180
|
+
|
181
|
+
@tags = repl["tags"].map { |tag| Tag.new(@client, tag) }
|
182
|
+
@reactions = repl["reactions"].map { |reaction| Reaction.new(reaction) }
|
149
183
|
end
|
150
184
|
|
151
185
|
def get_forks(count: 100, after: nil)
|
@@ -182,6 +216,63 @@ module ReplTalk
|
|
182
216
|
ReplComment.new(@client, c["createReplComment"])
|
183
217
|
end
|
184
218
|
|
219
|
+
def add_reaction(type)
|
220
|
+
r = @client.graphql(
|
221
|
+
"ReplViewReactionsToggleReactions",
|
222
|
+
GQL::Mutations::TOGGLE_REACTION,
|
223
|
+
input: {
|
224
|
+
replId: @id,
|
225
|
+
react: true,
|
226
|
+
reactionType: type
|
227
|
+
}
|
228
|
+
)
|
229
|
+
if r["setReplReaction"]["reactions"] == nil
|
230
|
+
@reactions
|
231
|
+
else
|
232
|
+
@reactions = r["setReplReaction"]["reactions"].map { |reaction| Reaction.new(reaction) }
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def remove_reaction(type)
|
237
|
+
r = @client.graphql(
|
238
|
+
"ReplViewReactionsToggleReactions",
|
239
|
+
GQL::Mutations::TOGGLE_REACTION,
|
240
|
+
input: {
|
241
|
+
replId: @id,
|
242
|
+
react: false,
|
243
|
+
reactionType: type
|
244
|
+
}
|
245
|
+
)
|
246
|
+
@reactions = r["setReplReaction"]["reactions"].map { |reaction| Reaction.new(reaction) }
|
247
|
+
end
|
248
|
+
|
249
|
+
def publish(description, image_url, tags, enable_comments: true)
|
250
|
+
r = @client.graphql(
|
251
|
+
"PublishRepl",
|
252
|
+
GQL::Mutations::PUBLISH_REPL,
|
253
|
+
input: {
|
254
|
+
replId: @id,
|
255
|
+
replTitle: @title,
|
256
|
+
description: description,
|
257
|
+
imageUrl: image_url,
|
258
|
+
tags: tags,
|
259
|
+
enableComments: enable_comments,
|
260
|
+
}
|
261
|
+
)
|
262
|
+
Repl.new(@client, r["publishRepl"])
|
263
|
+
end
|
264
|
+
|
265
|
+
def unpublish
|
266
|
+
r = @client.graphql(
|
267
|
+
"ReplViewHeaderActionsUnpublishRepl",
|
268
|
+
GQL::Mutations::UNPUBLISH_REPL,
|
269
|
+
input: {
|
270
|
+
replId: @id
|
271
|
+
}
|
272
|
+
)
|
273
|
+
Repl.new(@client, r["unpublishRepl"])
|
274
|
+
end
|
275
|
+
|
185
276
|
def to_s
|
186
277
|
@title
|
187
278
|
end
|
@@ -289,7 +380,7 @@ module ReplTalk
|
|
289
380
|
class Post
|
290
381
|
attr_reader :id, :url, :repl, :board, :title, :author, :answer, :content, :preview, :timestamp, :vote_count, :comment_count, :can_vote, :has_voted, :is_answered, :is_answerable, :is_hidden, :is_pinned, :is_locked, :is_announcement
|
291
382
|
|
292
|
-
def initialize(client, post)
|
383
|
+
def initialize(client, post)
|
293
384
|
@client = client
|
294
385
|
|
295
386
|
@id = post["id"]
|
@@ -395,7 +486,7 @@ module ReplTalk
|
|
395
486
|
|
396
487
|
|
397
488
|
class User
|
398
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :
|
489
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :languages
|
399
490
|
|
400
491
|
def initialize(client, user)
|
401
492
|
return nil if user == nil
|
@@ -410,7 +501,6 @@ module ReplTalk
|
|
410
501
|
@is_hacker = user["isHacker"]
|
411
502
|
@timestamp = user["timeCreated"]
|
412
503
|
@roles = user["roles"].map { |role| Role.new(role) }
|
413
|
-
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
414
504
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
415
505
|
end
|
416
506
|
|
data/lib/repltalk.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|