repltalk 3.2.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/repltalk.rb +1 -1
- data/lib/repltalk/client.rb +25 -0
- data/lib/repltalk/graphql.rb +90 -0
- data/lib/repltalk/structures.rb +111 -1
- 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: dd7a674596285cb7f8a4d0c2f6a5a9a03629a128f103def8f25b8404c4a6dba5
|
4
|
+
data.tar.gz: 53337d06dffe548294ffad1019dcb2c89e96f9d307d57d711fee8f29a6f75298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9147b972df6cf7c7c204b748340ad45ddcca8f3d06f8438852625aba108707a6293d2afdcc7728ce3780475237783adb3d846c5802b3333266d9e09f47bb0c6c
|
7
|
+
data.tar.gz: 9b11286a5337596e79c928a68af57519c65a9e700396be6869b777238f5b31a5bfa8db7cbf670d13ba5a131faf36897e65c943e15a17e8cc320bac626bec5740
|
data/lib/repltalk.rb
CHANGED
data/lib/repltalk/client.rb
CHANGED
@@ -146,6 +146,31 @@ module ReplTalk
|
|
146
146
|
p["posts"]["items"].map { |post| Post.new(self, post) }
|
147
147
|
end
|
148
148
|
|
149
|
+
def get_explore_featured_repls
|
150
|
+
r = graphql(
|
151
|
+
"ExploreFeaturedRepls",
|
152
|
+
GQL::Queries::GET_EXPLORE_FEATURED_REPLS
|
153
|
+
)
|
154
|
+
r["featuredRepls"].map { |repl| Repl.new(self, repl) }
|
155
|
+
end
|
156
|
+
|
157
|
+
def get_trending_tags
|
158
|
+
t = graphql(
|
159
|
+
"ExploreFeed",
|
160
|
+
GQL::Queries::GET_TRENDING_TAGS
|
161
|
+
)
|
162
|
+
t["trendingTagsFeed"]["initialTags"].map { |tag| Tag.new(self, tag) }
|
163
|
+
end
|
164
|
+
|
165
|
+
def get_tag(tag)
|
166
|
+
t = graphql(
|
167
|
+
"ExploreTrendingRepls",
|
168
|
+
GQL::Queries::GET_TAG,
|
169
|
+
tag: tag
|
170
|
+
)
|
171
|
+
Tag.new(self, t["tag"])
|
172
|
+
end
|
173
|
+
|
149
174
|
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
150
175
|
p = graphql(
|
151
176
|
"createPost",
|
data/lib/repltalk/graphql.rb
CHANGED
@@ -54,6 +54,20 @@ module ReplTalk
|
|
54
54
|
}
|
55
55
|
"
|
56
56
|
|
57
|
+
TAG = "
|
58
|
+
id
|
59
|
+
replCount
|
60
|
+
replsTaggedTodayCount
|
61
|
+
creatorCount
|
62
|
+
isTrending
|
63
|
+
"
|
64
|
+
|
65
|
+
REACTIONS = "
|
66
|
+
id
|
67
|
+
type
|
68
|
+
count
|
69
|
+
"
|
70
|
+
|
57
71
|
REPL = "
|
58
72
|
id
|
59
73
|
url
|
@@ -61,9 +75,17 @@ module ReplTalk
|
|
61
75
|
description
|
62
76
|
timeCreated
|
63
77
|
size
|
78
|
+
runCount
|
79
|
+
publicForkCount
|
64
80
|
imageUrl
|
65
81
|
isPrivate
|
66
82
|
isAlwaysOn
|
83
|
+
tags {
|
84
|
+
#{TAG}
|
85
|
+
}
|
86
|
+
reactions {
|
87
|
+
#{REACTIONS}
|
88
|
+
}
|
67
89
|
lang {
|
68
90
|
#{LANGUAGE}
|
69
91
|
}
|
@@ -340,6 +362,42 @@ module ReplTalk
|
|
340
362
|
}
|
341
363
|
}
|
342
364
|
"
|
365
|
+
|
366
|
+
GET_EXPLORE_FEATURED_REPLS = "
|
367
|
+
query ExploreFeaturedRepls {
|
368
|
+
featuredRepls {
|
369
|
+
#{Fields::REPL}
|
370
|
+
}
|
371
|
+
}
|
372
|
+
"
|
373
|
+
|
374
|
+
GET_TAG = "
|
375
|
+
query ExploreTrendingRepls($tag: String!) {
|
376
|
+
tag(id: $tag) {
|
377
|
+
#{Fields::TAG}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
"
|
381
|
+
|
382
|
+
GET_TRENDING_TAGS = "
|
383
|
+
query ExploreTrendingRepls($tag: String!) {
|
384
|
+
tag(id: $tag) {
|
385
|
+
#{Fields::TAG}
|
386
|
+
}
|
387
|
+
}
|
388
|
+
"
|
389
|
+
|
390
|
+
GET_TAGS_REPLS = "
|
391
|
+
query ExploreTrendingRepls($tag: String!, $after: String) {
|
392
|
+
tag(id: $tag) {
|
393
|
+
repls(after: $after) {
|
394
|
+
items {
|
395
|
+
#{Fields::REPL}
|
396
|
+
}
|
397
|
+
}
|
398
|
+
}
|
399
|
+
}
|
400
|
+
"
|
343
401
|
end
|
344
402
|
|
345
403
|
|
@@ -442,6 +500,38 @@ module ReplTalk
|
|
442
500
|
}
|
443
501
|
"
|
444
502
|
|
503
|
+
PUBLISH_REPL = "
|
504
|
+
mutation PublishRepl($input: PublishReplInput!) {
|
505
|
+
publishRepl(input: $input) {
|
506
|
+
... on Repl {
|
507
|
+
#{Fields::REPL}
|
508
|
+
}
|
509
|
+
}
|
510
|
+
}
|
511
|
+
"
|
512
|
+
|
513
|
+
UNPUBLISH_REPL = "
|
514
|
+
mutation ReplViewHeaderActionsUnpublishRepl($input: UnpublishReplInput!) {
|
515
|
+
unpublishRepl(input: $input) {
|
516
|
+
... on Repl {
|
517
|
+
#{Fields::REPL}
|
518
|
+
}
|
519
|
+
}
|
520
|
+
}
|
521
|
+
"
|
522
|
+
|
523
|
+
TOGGLE_REACTION = "
|
524
|
+
mutation ReplViewReactionsToggleReactions($input: SetReplReactionInput!) {
|
525
|
+
setReplReaction(input: $input) {
|
526
|
+
... on Repl {
|
527
|
+
reactions {
|
528
|
+
#{Fields::REACTIONS}
|
529
|
+
}
|
530
|
+
}
|
531
|
+
}
|
532
|
+
}
|
533
|
+
"
|
534
|
+
|
445
535
|
REPORT_POST = "
|
446
536
|
mutation createBoardReport($id: Int!, $reason: String!) {
|
447
537
|
createBoardReport(postId: $id, reason: $reason) {
|
data/lib/repltalk/structures.rb
CHANGED
@@ -74,6 +74,54 @@ module ReplTalk
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
+
class Tag
|
78
|
+
attr_reader :id, :repl_count, :creator_count, :is_trending, :repls_tagged_today_count
|
79
|
+
|
80
|
+
def initialize(client, tag)
|
81
|
+
@client = client
|
82
|
+
|
83
|
+
@id = tag["id"]
|
84
|
+
@repl_count = tag["replCount"]
|
85
|
+
@is_trending = tag["isTrending"]
|
86
|
+
@creator_count = tag["creatorCount"]
|
87
|
+
@repls_tagged_today_count = tag["replsTaggedTodayCount"]
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_repls(after: nil)
|
91
|
+
r = @client.graphql(
|
92
|
+
"ExploreTrendingRepls",
|
93
|
+
GQL::Queries::GET_TAGS_REPLS,
|
94
|
+
tag: @id,
|
95
|
+
after: after
|
96
|
+
)
|
97
|
+
r["tag"]["repls"]["items"].map { |repl| Repl.new(@client, repl) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_s
|
101
|
+
@id
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
class Reaction
|
109
|
+
attr_reader :id, :type, :count
|
110
|
+
|
111
|
+
def initialize(reaction)
|
112
|
+
@id = reaction["id"]
|
113
|
+
@type = reaction["type"]
|
114
|
+
@count = reaction["count"]
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_s
|
118
|
+
@type
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
77
125
|
class ReplComment
|
78
126
|
attr_reader :id, :content, :author, :repl, :replies
|
79
127
|
|
@@ -128,7 +176,7 @@ module ReplTalk
|
|
128
176
|
|
129
177
|
|
130
178
|
class Repl
|
131
|
-
attr_reader :id, :url, :title, :author, :description, :timestamp, :size, :language, :img_url, :origin_url, :is_private, :is_always_on
|
179
|
+
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
180
|
|
133
181
|
def initialize(client, repl)
|
134
182
|
@client = client
|
@@ -140,12 +188,17 @@ module ReplTalk
|
|
140
188
|
@description = repl["description"]
|
141
189
|
@timestamp = repl["timeCreated"]
|
142
190
|
@size = repl["size"]
|
191
|
+
@run_count = repl["runCount"]
|
192
|
+
@fork_count = repl["publicForkCount"]
|
143
193
|
@language = Language.new(repl["lang"])
|
144
194
|
@image_url = repl["imageUrl"]
|
145
195
|
@origin_url = repl["origin"] == nil ? nil : $BASE_URL + repl["origin"]["url"]
|
146
196
|
|
147
197
|
@is_private = repl["isPrivate"]
|
148
198
|
@is_always_on = repl["isAlwaysOn"]
|
199
|
+
|
200
|
+
@tags = repl["tags"].map { |tag| Tag.new(@client, tag) }
|
201
|
+
@reactions = repl["reactions"].map { |reaction| Reaction.new(reaction) }
|
149
202
|
end
|
150
203
|
|
151
204
|
def get_forks(count: 100, after: nil)
|
@@ -182,6 +235,63 @@ module ReplTalk
|
|
182
235
|
ReplComment.new(@client, c["createReplComment"])
|
183
236
|
end
|
184
237
|
|
238
|
+
def add_reaction(type)
|
239
|
+
r = @client.graphql(
|
240
|
+
"ReplViewReactionsToggleReactions",
|
241
|
+
GQL::Mutations::TOGGLE_REACTION,
|
242
|
+
input: {
|
243
|
+
replId: @id,
|
244
|
+
react: true,
|
245
|
+
reactionType: type
|
246
|
+
}
|
247
|
+
)
|
248
|
+
if r["setReplReaction"]["reactions"] == nil
|
249
|
+
@reactions
|
250
|
+
else
|
251
|
+
@reactions = r["setReplReaction"]["reactions"].map { |reaction| Reaction.new(reaction) }
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def remove_reaction(type)
|
256
|
+
r = @client.graphql(
|
257
|
+
"ReplViewReactionsToggleReactions",
|
258
|
+
GQL::Mutations::TOGGLE_REACTION,
|
259
|
+
input: {
|
260
|
+
replId: @id,
|
261
|
+
react: false,
|
262
|
+
reactionType: type
|
263
|
+
}
|
264
|
+
)
|
265
|
+
@reactions = r["setReplReaction"]["reactions"].map { |reaction| Reaction.new(reaction) }
|
266
|
+
end
|
267
|
+
|
268
|
+
def publish(description, image_url, tags, enable_comments: true)
|
269
|
+
r = @client.graphql(
|
270
|
+
"PublishRepl",
|
271
|
+
GQL::Mutations::PUBLISH_REPL,
|
272
|
+
input: {
|
273
|
+
replId: @id,
|
274
|
+
replTitle: @title,
|
275
|
+
description: description,
|
276
|
+
imageUrl: image_url,
|
277
|
+
tags: tags,
|
278
|
+
enableComments: enable_comments,
|
279
|
+
}
|
280
|
+
)
|
281
|
+
Repl.new(@client, r["publishRepl"])
|
282
|
+
end
|
283
|
+
|
284
|
+
def unpublish
|
285
|
+
r = @client.graphql(
|
286
|
+
"ReplViewHeaderActionsUnpublishRepl",
|
287
|
+
GQL::Mutations::UNPUBLISH_REPL,
|
288
|
+
input: {
|
289
|
+
replId: @id
|
290
|
+
}
|
291
|
+
)
|
292
|
+
Repl.new(@client, r["unpublishRepl"])
|
293
|
+
end
|
294
|
+
|
185
295
|
def to_s
|
186
296
|
@title
|
187
297
|
end
|
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.0.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-05-
|
11
|
+
date: 2021-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|