repltalk 0.5.0 → 1.2.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 +63 -0
- data/lib/repltalk.rb +103 -5
- metadata +19 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a90787033dba7f358725b78a75e013fe4dce8f6ba58129097efbebf908bb74ea
|
4
|
+
data.tar.gz: de1143f3aa2068eef3a62e781bd3cea4bc734623f39167b7a38f77538eb77bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9695086e996e64538e30321da4163b3891e0f72561f97e1a329346dd681de05c62fd8cebacd0b6301986d1ce5b57513395057c6c64f260dbb12640a391ac7831
|
7
|
+
data.tar.gz: 5b940e9378ef07c3f42b1b7cd2ce1906a6acebbe470bcc67bfec605c8cbdcb3e0ffedaa8bc6c35fad91618ed4e77e1992f60788283e46f857a68220c6c6029ea
|
data/lib/queries.rb
CHANGED
@@ -9,6 +9,18 @@ class Queries
|
|
9
9
|
@@organization = "
|
10
10
|
id
|
11
11
|
name
|
12
|
+
country
|
13
|
+
postalCode
|
14
|
+
state
|
15
|
+
city
|
16
|
+
timeCreated
|
17
|
+
"
|
18
|
+
|
19
|
+
@@subscription = "
|
20
|
+
id
|
21
|
+
planId
|
22
|
+
quantity
|
23
|
+
timeCreated
|
12
24
|
"
|
13
25
|
|
14
26
|
@@language = "
|
@@ -17,12 +29,14 @@ class Queries
|
|
17
29
|
displayName
|
18
30
|
tagline
|
19
31
|
icon
|
32
|
+
category
|
20
33
|
"
|
21
34
|
|
22
35
|
@@board = "
|
23
36
|
id
|
24
37
|
name
|
25
38
|
color
|
39
|
+
description
|
26
40
|
"
|
27
41
|
|
28
42
|
@@user = "
|
@@ -40,6 +54,9 @@ class Queries
|
|
40
54
|
organization {
|
41
55
|
#{@@organization}
|
42
56
|
}
|
57
|
+
subscription {
|
58
|
+
#{@@subscription}
|
59
|
+
}
|
43
60
|
languages {
|
44
61
|
#{@@language}
|
45
62
|
}
|
@@ -50,6 +67,7 @@ class Queries
|
|
50
67
|
url
|
51
68
|
title
|
52
69
|
description
|
70
|
+
size
|
53
71
|
imageUrl
|
54
72
|
isPrivate
|
55
73
|
isAlwaysOn
|
@@ -59,6 +77,9 @@ class Queries
|
|
59
77
|
user {
|
60
78
|
#{@@user}
|
61
79
|
}
|
80
|
+
origin {
|
81
|
+
url
|
82
|
+
}
|
62
83
|
"
|
63
84
|
|
64
85
|
@@comment = "
|
@@ -277,6 +298,14 @@ class Queries
|
|
277
298
|
}"
|
278
299
|
end
|
279
300
|
|
301
|
+
def Queries.get_board
|
302
|
+
"query boardBySlug($slug: String!) {
|
303
|
+
board: boardBySlug(slug: $slug) {
|
304
|
+
#{@@board}
|
305
|
+
}
|
306
|
+
}"
|
307
|
+
end
|
308
|
+
|
280
309
|
def Queries.get_posts
|
281
310
|
"query PostsFeed($order: String, $after: String, $searchQuery: String, $languages: [String!], $count: Int, $boardSlugs: [String!], $pinAnnouncements: Boolean, $pinPinned: Boolean) {
|
282
311
|
posts(order: $order, after: $after, searchQuery: $searchQuery, languages: $languages, count: $count, boardSlugs: $boardSlugs, pinAnnouncements: $pinAnnouncements, pinPinned: $pinPinned) {
|
@@ -286,4 +315,38 @@ class Queries
|
|
286
315
|
}
|
287
316
|
}"
|
288
317
|
end
|
318
|
+
|
319
|
+
def Queries.get_leaderboard
|
320
|
+
"query LeaderboardQuery($count: Int, $after: String, $since: KarmaSince) {
|
321
|
+
leaderboard(count: $count, after: $after, since: $since) {
|
322
|
+
items {
|
323
|
+
#{@@user}
|
324
|
+
karmaSince: karma(since: $since)
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
|
332
|
+
class Mutations < Queries
|
333
|
+
def Mutations.create_post
|
334
|
+
"mutation createPost($input: CreatePostInput!) {
|
335
|
+
createPost(input: $input) {
|
336
|
+
post {
|
337
|
+
#{@@post}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}"
|
341
|
+
end
|
342
|
+
|
343
|
+
def Mutations.create_comment
|
344
|
+
"mutation createComment($input: CreateCommentInput!) {
|
345
|
+
createComment(input: $input) {
|
346
|
+
comment {
|
347
|
+
#{@@comment}
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}"
|
351
|
+
end
|
289
352
|
end
|
data/lib/repltalk.rb
CHANGED
@@ -21,11 +21,16 @@ end
|
|
21
21
|
|
22
22
|
|
23
23
|
class Organization
|
24
|
-
attr_reader :id, :name
|
24
|
+
attr_reader :id, :name, :country, :postal_code, :state, :city, :timestamp
|
25
25
|
|
26
26
|
def initialize(organization)
|
27
27
|
@id = organization["id"]
|
28
28
|
@name = organization["name"]
|
29
|
+
@country = organization["country"]
|
30
|
+
@postal_code = organization["postalCode"]
|
31
|
+
@state = organization["state"]
|
32
|
+
@city = organization["city"]
|
33
|
+
@timestamp = organization["timeCreated"]
|
29
34
|
end
|
30
35
|
|
31
36
|
def to_s
|
@@ -35,8 +40,25 @@ end
|
|
35
40
|
|
36
41
|
|
37
42
|
|
43
|
+
class Subscription
|
44
|
+
attr_reader :id, :plan_id, :quantity, :timestamp
|
45
|
+
|
46
|
+
def initialize(subscription)
|
47
|
+
@id = subscription["id"]
|
48
|
+
@plan_id = subscription["planId"]
|
49
|
+
@quantity = subscription["quantity"]
|
50
|
+
@timestamp = subscription["timeCreated"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_s
|
54
|
+
@plan_id
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
38
60
|
class Language
|
39
|
-
attr_reader :id, :key, :name, :tagline, :icon
|
61
|
+
attr_reader :id, :key, :name, :tagline, :icon, :category
|
40
62
|
|
41
63
|
def initialize(lang)
|
42
64
|
@id = lang["id"]
|
@@ -44,6 +66,7 @@ class Language
|
|
44
66
|
@name = lang["displayName"]
|
45
67
|
@tagline = lang["tagline"]
|
46
68
|
@icon = lang["icon"]
|
69
|
+
@category = lang["category"]
|
47
70
|
end
|
48
71
|
|
49
72
|
def to_s
|
@@ -74,7 +97,7 @@ end
|
|
74
97
|
|
75
98
|
|
76
99
|
class Repl
|
77
|
-
attr_reader :id, :url, :title, :author, :description, :language, :img_url, :is_private, :is_always_on
|
100
|
+
attr_reader :id, :url, :title, :author, :description, :size, :language, :img_url, :origin_url, :is_private, :is_always_on
|
78
101
|
|
79
102
|
def initialize(client, repl)
|
80
103
|
@client = client
|
@@ -84,8 +107,10 @@ class Repl
|
|
84
107
|
@title = repl["title"]
|
85
108
|
@author = User.new(@client, repl["user"])
|
86
109
|
@description = repl["description"]
|
110
|
+
@size = repl["size"]
|
87
111
|
@language = Language.new(repl["lang"])
|
88
112
|
@image_url = repl["imageUrl"]
|
113
|
+
@origin_url = repl["origin"] == nil ? nil : $BASE_URL + repl["origin"]["url"]
|
89
114
|
|
90
115
|
@is_private = repl["isPrivate"]
|
91
116
|
@is_always_on = repl["isAlwaysOn"]
|
@@ -121,12 +146,13 @@ end
|
|
121
146
|
|
122
147
|
|
123
148
|
class Board
|
124
|
-
attr_reader :id, :name, :color
|
149
|
+
attr_reader :id, :name, :color, :description
|
125
150
|
|
126
151
|
def initialize(board)
|
127
152
|
@id = board["id"]
|
128
153
|
@name = board["name"]
|
129
154
|
@color = board["color"]
|
155
|
+
@description = board["description"]
|
130
156
|
end
|
131
157
|
|
132
158
|
def to_s
|
@@ -182,6 +208,19 @@ class Comment
|
|
182
208
|
c["comment"]["parentComment"] == nil ? nil : Comment.new(@client, c["comment"]["parentComment"])
|
183
209
|
end
|
184
210
|
|
211
|
+
def create_comment(content)
|
212
|
+
c = @client.graphql(
|
213
|
+
"createComment",
|
214
|
+
Mutations.create_comment,
|
215
|
+
input: {
|
216
|
+
postId: @post_id,
|
217
|
+
commentId: @id,
|
218
|
+
body: content
|
219
|
+
}
|
220
|
+
)
|
221
|
+
Comment.new(@client, c["createComment"]["comment"])
|
222
|
+
end
|
223
|
+
|
185
224
|
def to_s
|
186
225
|
@content
|
187
226
|
end
|
@@ -244,6 +283,18 @@ class Post
|
|
244
283
|
u["post"]["votes"]["items"].map { |vote| User.new(@client, vote["user"]) }
|
245
284
|
end
|
246
285
|
|
286
|
+
def create_comment(content)
|
287
|
+
c = @client.graphql(
|
288
|
+
"createComment",
|
289
|
+
Mutations.create_comment,
|
290
|
+
input: {
|
291
|
+
postId: @id,
|
292
|
+
body: content
|
293
|
+
}
|
294
|
+
)
|
295
|
+
Comment.new(@client, c["createComment"]["comment"])
|
296
|
+
end
|
297
|
+
|
247
298
|
def to_s
|
248
299
|
@title
|
249
300
|
end
|
@@ -252,7 +303,7 @@ end
|
|
252
303
|
|
253
304
|
|
254
305
|
class User
|
255
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :roles, :organization, :languages
|
306
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :organization, :languages
|
256
307
|
|
257
308
|
def initialize(client, user)
|
258
309
|
@client = client
|
@@ -265,6 +316,7 @@ class User
|
|
265
316
|
@cycles = user["karma"]
|
266
317
|
@is_hacker = user["isHacker"]
|
267
318
|
@timestamp = user["timeCreated"]
|
319
|
+
@subscription = user["subscription"] == nil ? nil : Subscription.new(user["subscription"])
|
268
320
|
@roles = user["roles"].map { |role| Role.new(role) }
|
269
321
|
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
270
322
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
@@ -317,6 +369,17 @@ end
|
|
317
369
|
|
318
370
|
|
319
371
|
|
372
|
+
class LeaderboardUser < User
|
373
|
+
attr_reader :cycles_since
|
374
|
+
|
375
|
+
def initialize(client, user)
|
376
|
+
super(client, user)
|
377
|
+
@cycles_since = user["karmaSince"]
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
|
320
383
|
class Client
|
321
384
|
attr_writer :sid
|
322
385
|
|
@@ -399,6 +462,26 @@ class Client
|
|
399
462
|
)
|
400
463
|
Repl.new(self, r["repl"])
|
401
464
|
end
|
465
|
+
|
466
|
+
def get_board(name)
|
467
|
+
b = graphql(
|
468
|
+
"boardBySlug",
|
469
|
+
Queries.get_board,
|
470
|
+
slug: name
|
471
|
+
)
|
472
|
+
Board.new(b["board"])
|
473
|
+
end
|
474
|
+
|
475
|
+
def get_leaderboard(count: nil, since: nil, after: nil)
|
476
|
+
u = graphql(
|
477
|
+
"LeaderboardQuery",
|
478
|
+
Queries.get_leaderboard,
|
479
|
+
count: count,
|
480
|
+
since: since,
|
481
|
+
after: after
|
482
|
+
)
|
483
|
+
u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
|
484
|
+
end
|
402
485
|
|
403
486
|
def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil, languages: nil)
|
404
487
|
p = graphql(
|
@@ -413,4 +496,19 @@ class Client
|
|
413
496
|
)
|
414
497
|
p["posts"]["items"].map { |post| Post.new(self, post) }
|
415
498
|
end
|
499
|
+
|
500
|
+
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
501
|
+
p = graphql(
|
502
|
+
"createPost",
|
503
|
+
Mutations.create_post,
|
504
|
+
input: {
|
505
|
+
boardId: get_board(board_name).id,
|
506
|
+
title: title,
|
507
|
+
body: content,
|
508
|
+
replId: repl_id,
|
509
|
+
showHosted: show_hosted
|
510
|
+
}
|
511
|
+
)
|
512
|
+
Post.new(self, p["createPost"]["post"])
|
513
|
+
end
|
416
514
|
end
|
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.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-03-
|
11
|
+
date: 2021-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.4'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 4.4.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.4'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 4.4.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: json
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.5'
|
31
40
|
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
42
|
+
version: 2.5.1
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.5'
|
38
50
|
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
52
|
+
version: 2.5.1
|
41
53
|
description: With the repltalk gem, you can easily interect with the repltalk graphql
|
42
54
|
api. See https://github.com/Coding-Cactus/repltalk for documentation
|
43
55
|
email: codingcactus.cc@gmail.com
|
@@ -47,7 +59,7 @@ extra_rdoc_files: []
|
|
47
59
|
files:
|
48
60
|
- lib/queries.rb
|
49
61
|
- lib/repltalk.rb
|
50
|
-
homepage:
|
62
|
+
homepage: https://github.com/Coding-Cactus/repltalk
|
51
63
|
licenses:
|
52
64
|
- MIT
|
53
65
|
metadata:
|