repltalk 0.5.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/queries.rb +89 -0
- data/lib/repltalk.rb +126 -5
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ade4342442037dfec06df6d42dc4fb825aa0ae28020a9a65a8cc6072ff1d5a83
|
4
|
+
data.tar.gz: eabb22b821d0170bbec6a1cdcf1a9b8ab877d7cf5c746796ed56d098fa07b23f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e1d95df4fa09ec118ee4d82115652831fded6cb0b9b55b09045d68f7ff0cc48c975a28de0b6e207de5d786c8ebc3f1482cdf4225b80f06baf407074e10b264c
|
7
|
+
data.tar.gz: fc16a9bccab5cca65fa7041b9dce1720198d686582a47beb64310c0b6eb3d5e5359685bfbdd5120366d3df797608468e11040b9d5fce1cdaa32d98dd126ad7c7
|
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) {
|
@@ -297,4 +326,64 @@ class Queries
|
|
297
326
|
}
|
298
327
|
}"
|
299
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.edit_post
|
344
|
+
"mutation updatePost($input: UpdatePostInput!) {
|
345
|
+
updatePost(input: $input) {
|
346
|
+
post {
|
347
|
+
#{@@post}
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
"
|
352
|
+
end
|
353
|
+
|
354
|
+
def Mutations.delete_post
|
355
|
+
"mutation deletePost($id: Int!) {
|
356
|
+
deletePost(id: $id) {
|
357
|
+
id
|
358
|
+
}
|
359
|
+
}"
|
360
|
+
end
|
361
|
+
|
362
|
+
def Mutations.create_comment
|
363
|
+
"mutation createComment($input: CreateCommentInput!) {
|
364
|
+
createComment(input: $input) {
|
365
|
+
comment {
|
366
|
+
#{@@comment}
|
367
|
+
}
|
368
|
+
}
|
369
|
+
}"
|
370
|
+
end
|
371
|
+
|
372
|
+
def Mutations.edit_comment
|
373
|
+
"mutation updateComment($input: UpdateCommentInput!) {
|
374
|
+
updateComment(input: $input) {
|
375
|
+
comment {
|
376
|
+
#{@@comment}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}"
|
380
|
+
end
|
381
|
+
|
382
|
+
def Mutations.delete_comment
|
383
|
+
"mutation deleteComment($id: Int!) {
|
384
|
+
deleteComment(id: $id) {
|
385
|
+
id
|
386
|
+
}
|
387
|
+
}"
|
388
|
+
end
|
300
389
|
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,40 @@ 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
|
+
|
224
|
+
def edit(content)
|
225
|
+
c = @client.graphql(
|
226
|
+
"updateComment",
|
227
|
+
Mutations.edit_comment,
|
228
|
+
input: {
|
229
|
+
id: @id,
|
230
|
+
body: content
|
231
|
+
}
|
232
|
+
)
|
233
|
+
Comment.new(@client, c["updateComment"]["comment"])
|
234
|
+
end
|
235
|
+
|
236
|
+
def delete
|
237
|
+
@client.graphql(
|
238
|
+
"deleteComment",
|
239
|
+
Mutations.delete_comment,
|
240
|
+
id: @id
|
241
|
+
)
|
242
|
+
nil
|
243
|
+
end
|
244
|
+
|
185
245
|
def to_s
|
186
246
|
@content
|
187
247
|
end
|
@@ -244,6 +304,42 @@ class Post
|
|
244
304
|
u["post"]["votes"]["items"].map { |vote| User.new(@client, vote["user"]) }
|
245
305
|
end
|
246
306
|
|
307
|
+
def create_comment(content)
|
308
|
+
c = @client.graphql(
|
309
|
+
"createComment",
|
310
|
+
Mutations.create_comment,
|
311
|
+
input: {
|
312
|
+
postId: @id,
|
313
|
+
body: content
|
314
|
+
}
|
315
|
+
)
|
316
|
+
Comment.new(@client, c["createComment"]["comment"])
|
317
|
+
end
|
318
|
+
|
319
|
+
def edit(title: @title, content: @content, repl_id: @repl.id, show_hosted: false)
|
320
|
+
p = @client.graphql(
|
321
|
+
"updatePost",
|
322
|
+
Mutations.edit_post,
|
323
|
+
input: {
|
324
|
+
id: @id,
|
325
|
+
title: title,
|
326
|
+
body: content,
|
327
|
+
replId: repl_id,
|
328
|
+
showHosted: show_hosted
|
329
|
+
}
|
330
|
+
)
|
331
|
+
Post.new(@client, p["updatePost"]["post"])
|
332
|
+
end
|
333
|
+
|
334
|
+
def delete
|
335
|
+
@client.graphql(
|
336
|
+
"deletePost",
|
337
|
+
Mutations.delete_post,
|
338
|
+
id: @id
|
339
|
+
)
|
340
|
+
nil
|
341
|
+
end
|
342
|
+
|
247
343
|
def to_s
|
248
344
|
@title
|
249
345
|
end
|
@@ -252,7 +348,7 @@ end
|
|
252
348
|
|
253
349
|
|
254
350
|
class User
|
255
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :roles, :organization, :languages
|
351
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :organization, :languages
|
256
352
|
|
257
353
|
def initialize(client, user)
|
258
354
|
@client = client
|
@@ -265,6 +361,7 @@ class User
|
|
265
361
|
@cycles = user["karma"]
|
266
362
|
@is_hacker = user["isHacker"]
|
267
363
|
@timestamp = user["timeCreated"]
|
364
|
+
@subscription = user["subscription"] == nil ? nil : Subscription.new(user["subscription"])
|
268
365
|
@roles = user["roles"].map { |role| Role.new(role) }
|
269
366
|
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
270
367
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
@@ -411,6 +508,15 @@ class Client
|
|
411
508
|
Repl.new(self, r["repl"])
|
412
509
|
end
|
413
510
|
|
511
|
+
def get_board(name)
|
512
|
+
b = graphql(
|
513
|
+
"boardBySlug",
|
514
|
+
Queries.get_board,
|
515
|
+
slug: name
|
516
|
+
)
|
517
|
+
Board.new(b["board"])
|
518
|
+
end
|
519
|
+
|
414
520
|
def get_leaderboard(count: nil, since: nil, after: nil)
|
415
521
|
u = graphql(
|
416
522
|
"LeaderboardQuery",
|
@@ -435,4 +541,19 @@ class Client
|
|
435
541
|
)
|
436
542
|
p["posts"]["items"].map { |post| Post.new(self, post) }
|
437
543
|
end
|
544
|
+
|
545
|
+
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
546
|
+
p = graphql(
|
547
|
+
"createPost",
|
548
|
+
Mutations.create_post,
|
549
|
+
input: {
|
550
|
+
boardId: get_board(board_name).id,
|
551
|
+
title: title,
|
552
|
+
body: content,
|
553
|
+
replId: repl_id,
|
554
|
+
showHosted: show_hosted
|
555
|
+
}
|
556
|
+
)
|
557
|
+
Post.new(self, p["createPost"]["post"])
|
558
|
+
end
|
438
559
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
@@ -14,30 +14,42 @@ dependencies:
|
|
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:
|