repltalk 4.1.0 → 4.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/repltalk/client.rb +3 -14
- data/lib/repltalk/graphql.rb +4 -12
- data/lib/repltalk/structures.rb +18 -16
- data/lib/repltalk.rb +1 -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: 9281c577f7967d08b5046b1f61a4c6cc506c18ce393604e0a8446d448471982c
|
4
|
+
data.tar.gz: da4370aaac2488e2b2e64b7f02e617d27198797c8f615b675dc014fb36a9198f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4bea1b18a212ffcf6a1ef74b66cdcb8dfc72739d17b053d0c5882ec5e103298307c845fd33b1d78a3c739cb954234d6cd6e05279b3ca08b653e40e28934f26c
|
7
|
+
data.tar.gz: 603ec6085baad54772ae1fd456ea80e8789ad6d49e0e9ca39b1cf5bb79ce2077fe4721c33e0dd5149acc8624a3d229da3c212d83d628842397a429fbe4d5ac99
|
data/lib/repltalk/client.rb
CHANGED
@@ -24,7 +24,7 @@ module ReplTalk
|
|
24
24
|
"X-Requested-With": "ReplTalk"
|
25
25
|
)
|
26
26
|
.post(
|
27
|
-
"#{$BASE_URL}/graphql",
|
27
|
+
"#{$BASE_URL}/graphql",
|
28
28
|
form: payload
|
29
29
|
)
|
30
30
|
begin data = JSON.parse(r)
|
@@ -120,25 +120,14 @@ module ReplTalk
|
|
120
120
|
return nil if b == nil || b["board"] == nil
|
121
121
|
Board.new(b["board"])
|
122
122
|
end
|
123
|
-
|
124
|
-
def get_leaderboard(count: nil, since: nil, after: nil)
|
125
|
-
u = graphql(
|
126
|
-
"LeaderboardQuery",
|
127
|
-
GQL::Queries::GET_LEADERBOARD,
|
128
|
-
count: count,
|
129
|
-
since: since,
|
130
|
-
after: after
|
131
|
-
)
|
132
|
-
u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
|
133
|
-
end
|
134
123
|
|
135
|
-
def get_posts(board: "all", order: "
|
124
|
+
def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil)
|
136
125
|
p = graphql(
|
137
126
|
"ReplPostsFeed",
|
138
127
|
GQL::Queries::GET_POSTS,
|
139
128
|
options: {
|
140
129
|
boardSlugs: [board],
|
141
|
-
order: order,
|
130
|
+
order: order.capitalize,
|
142
131
|
count: count,
|
143
132
|
after: after,
|
144
133
|
searchQuery: search
|
data/lib/repltalk/graphql.rb
CHANGED
@@ -126,7 +126,7 @@ module ReplTalk
|
|
126
126
|
isAnnouncement
|
127
127
|
timeCreated
|
128
128
|
isAnswered
|
129
|
-
isAnswerable
|
129
|
+
isAnswerable
|
130
130
|
voteCount
|
131
131
|
canVote
|
132
132
|
hasVoted
|
@@ -136,6 +136,9 @@ module ReplTalk
|
|
136
136
|
repl {
|
137
137
|
#{REPL}
|
138
138
|
}
|
139
|
+
replComment {
|
140
|
+
#{REPL_COMMENT}
|
141
|
+
}
|
139
142
|
board {
|
140
143
|
#{BOARD}
|
141
144
|
}
|
@@ -339,17 +342,6 @@ module ReplTalk
|
|
339
342
|
}
|
340
343
|
"
|
341
344
|
|
342
|
-
GET_LEADERBOARD = "
|
343
|
-
query LeaderboardQuery($count: Int, $after: String, $since: KarmaSince) {
|
344
|
-
leaderboard(count: $count, after: $after, since: $since) {
|
345
|
-
items {
|
346
|
-
#{Fields::USER}
|
347
|
-
karmaSince: karma(since: $since)
|
348
|
-
}
|
349
|
-
}
|
350
|
-
}
|
351
|
-
"
|
352
|
-
|
353
345
|
GET_EXPLORE_FEATURED_REPLS = "
|
354
346
|
query ExploreFeaturedRepls {
|
355
347
|
featuredRepls {
|
data/lib/repltalk/structures.rb
CHANGED
@@ -166,7 +166,7 @@ module ReplTalk
|
|
166
166
|
@url = $BASE_URL + repl["url"]
|
167
167
|
@title = repl["title"]
|
168
168
|
@author = User.new(@client, repl["user"])
|
169
|
-
@description = repl["description"]
|
169
|
+
@description = repl["description"].to_s
|
170
170
|
@timestamp = repl["timeCreated"]
|
171
171
|
@size = repl["size"]
|
172
172
|
@run_count = repl["runCount"]
|
@@ -380,20 +380,33 @@ module ReplTalk
|
|
380
380
|
class Post
|
381
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
|
382
382
|
|
383
|
-
def initialize(client, post)
|
383
|
+
def initialize(client, post)
|
384
384
|
@client = client
|
385
385
|
|
386
386
|
@id = post["id"]
|
387
387
|
@url = $BASE_URL + post["url"]
|
388
388
|
@title = post["title"]
|
389
|
-
@content = post["body"]
|
390
|
-
@preview = post["preview"]
|
391
389
|
@timestamp = post["timeCreated"]
|
392
390
|
|
393
|
-
@board = Board.new(post["board"])
|
391
|
+
@board = post["board"].nil? ? nil : Board.new(post["board"])
|
394
392
|
@repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
|
395
393
|
@author = post["user"] == nil ? nil : User.new(@client, post["user"])
|
396
394
|
@answer = post["answer"] == nil ? nil : Comment.new(@client, post["answer"])
|
395
|
+
|
396
|
+
@content = post["body"]
|
397
|
+
@preview = post["preview"]
|
398
|
+
|
399
|
+
if @content == "" && @repl != nil # new post type
|
400
|
+
if post["replComment"].nil? # no post attached
|
401
|
+
@url = @repl.url
|
402
|
+
@title = @repl.title
|
403
|
+
@content = @repl.description
|
404
|
+
else # post attached
|
405
|
+
@url = "#{@repl.url}?c=#{post["replComment"]["id"]}"
|
406
|
+
@content = post["replComment"]["body"]
|
407
|
+
end
|
408
|
+
@preview = @content.length > 150 ? @content[0..150] : @content
|
409
|
+
end
|
397
410
|
|
398
411
|
@vote_count = post["voteCount"]
|
399
412
|
@comment_count = post["commentCount"]
|
@@ -548,15 +561,4 @@ module ReplTalk
|
|
548
561
|
@username
|
549
562
|
end
|
550
563
|
end
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
class LeaderboardUser < User
|
555
|
-
attr_reader :cycles_since
|
556
|
-
|
557
|
-
def initialize(client, user)
|
558
|
-
super(client, user)
|
559
|
-
@cycles_since = user["karmaSince"]
|
560
|
-
end
|
561
|
-
end
|
562
564
|
end
|
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.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|