ruqqus 1.1.0 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +24 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +33 -0
- data/CODE_OF_CONDUCT.md +51 -0
- data/CONTRIBUTING.md +24 -0
- data/README.md +18 -7
- data/TODO.md +0 -2
- data/assets/ruby-ruqqus.png +0 -0
- data/assets/ruqqus_text_logo.png +0 -0
- data/exe/ruqqus-oauth +2 -2
- data/lib/ruqqus.rb +184 -14
- data/lib/ruqqus/client.rb +126 -16
- data/lib/ruqqus/token.rb +18 -31
- data/lib/ruqqus/types/comment.rb +18 -12
- data/lib/ruqqus/types/guild.rb +60 -33
- data/lib/ruqqus/types/item_base.rb +21 -13
- data/lib/ruqqus/types/post.rb +32 -14
- data/lib/ruqqus/types/submission.rb +68 -46
- data/lib/ruqqus/types/user.rb +55 -30
- data/lib/ruqqus/version.rb +7 -3
- data/ruqqus.gemspec +4 -2
- metadata +17 -10
@@ -6,6 +6,22 @@ module Ruqqus
|
|
6
6
|
# Base class for all all major API types.
|
7
7
|
class ItemBase
|
8
8
|
|
9
|
+
##
|
10
|
+
# @!attribute [r] permalink
|
11
|
+
# @return [String] a relative link to this item.
|
12
|
+
|
13
|
+
##
|
14
|
+
# @!attribute [r] created_utc
|
15
|
+
# @return [Integer] the time the item was created, in seconds since the Unix epoch.
|
16
|
+
|
17
|
+
##
|
18
|
+
# @!attribute [r] created
|
19
|
+
# @return [Time] the time the item was created.
|
20
|
+
|
21
|
+
##
|
22
|
+
# @!attribute [r] id
|
23
|
+
# @return [String] a unique ID for this item.
|
24
|
+
|
9
25
|
##
|
10
26
|
# @return [Boolean] `true` if item has been banned, otherwise `false`.
|
11
27
|
def banned?
|
@@ -13,31 +29,23 @@ module Ruqqus
|
|
13
29
|
end
|
14
30
|
|
15
31
|
##
|
16
|
-
# @return [
|
32
|
+
# @return [Boolean] `true` if this object is equal to another, otherwise `false`.
|
33
|
+
def ==(other)
|
34
|
+
self.class == other.class && id == other.id
|
35
|
+
end
|
36
|
+
|
17
37
|
def created_utc
|
18
38
|
@data[:created_utc]
|
19
39
|
end
|
20
40
|
|
21
|
-
##
|
22
|
-
# @return [Time] the time the item was created.
|
23
41
|
def created
|
24
42
|
Time.at(created_utc)
|
25
43
|
end
|
26
44
|
|
27
|
-
##
|
28
|
-
# @return [String] a unique ID for this item.
|
29
45
|
def id
|
30
46
|
@data[:id]
|
31
47
|
end
|
32
48
|
|
33
|
-
##
|
34
|
-
# @return [Boolean] `true` if this object is equal to another, otherwise `false`.
|
35
|
-
def ==(other)
|
36
|
-
self.class == other.class && id == other.id
|
37
|
-
end
|
38
|
-
|
39
|
-
##
|
40
|
-
# @return [String] a relative link to this item.
|
41
49
|
def permalink
|
42
50
|
@data[:permalink]
|
43
51
|
end
|
data/lib/ruqqus/types/post.rb
CHANGED
@@ -6,44 +6,62 @@ module Ruqqus
|
|
6
6
|
class Post < Submission
|
7
7
|
|
8
8
|
##
|
9
|
-
#
|
9
|
+
# @!attribute [r] thumb_url
|
10
|
+
# @return [String?] the URL of the post's thumbnail image, or `nil` if none exists.
|
11
|
+
|
12
|
+
##
|
13
|
+
# @!attribute [r] url
|
14
|
+
# @return [String?] the URL the post links to, or `nil` if none is specified.
|
15
|
+
|
16
|
+
##
|
17
|
+
# @!attribute [r] author_title
|
18
|
+
# @return [Title?] the title assigned to the author, or `nil` if none is defined.
|
19
|
+
|
20
|
+
##
|
21
|
+
# @!attribute [r] comment_count
|
22
|
+
# @return [Integer] the number of comments made on the post.
|
23
|
+
|
24
|
+
##
|
25
|
+
# @!attribute [r] domain
|
26
|
+
# @return [String] the domain name for link posts, otherwise a short descriptor of the post type.
|
27
|
+
|
28
|
+
##
|
29
|
+
# @!attribute [r] embed_url
|
30
|
+
# @return [String] the embed URL for the post.
|
31
|
+
|
32
|
+
##
|
33
|
+
# @!attribute [r] original_guild_name
|
34
|
+
# @return [String] the name of the guild this post was originally posted in.
|
35
|
+
|
36
|
+
# @@!attribute [r] title
|
37
|
+
# @return [String] the post title.
|
38
|
+
|
39
|
+
|
10
40
|
def author_title
|
11
|
-
#noinspection RubyYardReturnMatch
|
41
|
+
#noinspection RubyYardReturnMatch,RubyResolve
|
12
42
|
@author_title ||= @data[:author_title] ? Title.new(@data[:author_title]) : nil
|
13
43
|
end
|
14
44
|
|
15
|
-
##
|
16
|
-
# @return [Integer] the number of comments made on the post.
|
17
45
|
def comment_count
|
18
46
|
@data[:comment_count]
|
19
47
|
end
|
20
48
|
|
21
|
-
##
|
22
|
-
# @return [String] the domain name for link posts, otherwise a short descriptor of the post type.
|
23
49
|
def domain
|
24
50
|
@data[:domain]
|
25
51
|
end
|
26
52
|
|
27
|
-
##
|
28
|
-
# @return [String] the embed URL for the post.
|
29
53
|
def embed_url
|
30
54
|
@data[:embed_url]
|
31
55
|
end
|
32
56
|
|
33
|
-
##
|
34
|
-
# @return [String] the name of the guild this post was originally posted in.
|
35
57
|
def original_guild_name
|
36
58
|
@data[:original_guild_name]
|
37
59
|
end
|
38
60
|
|
39
|
-
##
|
40
|
-
# @return [String?] the URL of the post's thumbnail image, or `nil` if none exists.
|
41
61
|
def thumb_url
|
42
62
|
@data[:thumb_url]
|
43
63
|
end
|
44
64
|
|
45
|
-
##
|
46
|
-
# @return [String?] the URL the post links to, or `nil` if none is specified.
|
47
65
|
def url
|
48
66
|
#noinspection RubyYardReturnMatch
|
49
67
|
@data[:url]&.empty? ? nil : @data[:url]
|
@@ -7,57 +7,53 @@ module Ruqqus
|
|
7
7
|
class Submission < ItemBase
|
8
8
|
|
9
9
|
##
|
10
|
-
#
|
11
|
-
|
12
|
-
@data[:author]
|
13
|
-
end
|
10
|
+
# @!attribute [r] title
|
11
|
+
# @return [String] the name/title of this item.
|
14
12
|
|
15
13
|
##
|
16
|
-
#
|
17
|
-
|
18
|
-
@data[:body]
|
19
|
-
end
|
14
|
+
# @!attribute [r] author_name
|
15
|
+
# @return [String?] the name of the creator of the item, or `nil` if deleted account.
|
20
16
|
|
21
17
|
##
|
22
|
-
#
|
23
|
-
|
24
|
-
@data[:body_html]
|
25
|
-
end
|
18
|
+
# @!attribute [r] body
|
19
|
+
# @return [String] the text body of the item.
|
26
20
|
|
27
21
|
##
|
28
|
-
#
|
29
|
-
|
30
|
-
@data[:edited_utc]
|
31
|
-
end
|
22
|
+
# @!attribute [r] body_html
|
23
|
+
# @return [String] the text body of the item in HTML format.
|
32
24
|
|
33
25
|
##
|
34
|
-
#
|
35
|
-
|
36
|
-
Time.at(@data[:edited_utc])
|
37
|
-
end
|
26
|
+
# @!attribute [r] last_edit_utc
|
27
|
+
# @return [Integer] the time of the last edit in seconds since the Unix epoch, or `0` if never edited.
|
38
28
|
|
39
29
|
##
|
40
|
-
#
|
41
|
-
|
42
|
-
@data[:edited_utc] != 0
|
43
|
-
end
|
30
|
+
# @!attribute [r] last_edit
|
31
|
+
# @return [Time] the time of the last edit.
|
44
32
|
|
45
33
|
##
|
46
|
-
#
|
47
|
-
|
48
|
-
@data[:upvotes]
|
49
|
-
end
|
34
|
+
# @!attribute [r] upvotes
|
35
|
+
# @return [Integer] the number of upvotes this item has received.
|
50
36
|
|
51
37
|
##
|
52
|
-
#
|
53
|
-
|
54
|
-
@data[:downvotes]
|
55
|
-
end
|
38
|
+
# @!attribute [r] downvotes
|
39
|
+
# @return [Integer] the number of downvotes this item has received.
|
56
40
|
|
57
41
|
##
|
42
|
+
# @!attribute [r] score
|
58
43
|
# @return [Integer] a score calculated by adding upvotes and subtracting downvotes.
|
59
|
-
|
60
|
-
|
44
|
+
|
45
|
+
##
|
46
|
+
# @!attribute [r] fullname
|
47
|
+
# @return [String] the full ID of this item.
|
48
|
+
|
49
|
+
##
|
50
|
+
# @!attribute [r] guild_name
|
51
|
+
# @return [String] the name of the guild this item is contained within.
|
52
|
+
|
53
|
+
##
|
54
|
+
# @return [Boolean] `true` if post has been edited, otherwise `false`.
|
55
|
+
def edited?
|
56
|
+
@data[:edited_utc] != 0
|
61
57
|
end
|
62
58
|
|
63
59
|
##
|
@@ -91,27 +87,53 @@ module Ruqqus
|
|
91
87
|
end
|
92
88
|
|
93
89
|
##
|
94
|
-
# @return [String] the
|
95
|
-
def
|
90
|
+
# @return [String] the string representation of the object.
|
91
|
+
def to_s
|
92
|
+
@data[:id]
|
93
|
+
end
|
94
|
+
|
95
|
+
def author_name
|
96
|
+
@data[:author]
|
97
|
+
end
|
98
|
+
|
99
|
+
def body
|
100
|
+
@data[:body]
|
101
|
+
end
|
102
|
+
|
103
|
+
def body_html
|
104
|
+
@data[:body_html]
|
105
|
+
end
|
106
|
+
|
107
|
+
def last_edit_utc
|
108
|
+
@data[:edited_utc]
|
109
|
+
end
|
110
|
+
|
111
|
+
def last_edit
|
112
|
+
Time.at(@data[:edited_utc])
|
113
|
+
end
|
114
|
+
|
115
|
+
def upvotes
|
116
|
+
@data[:upvotes]
|
117
|
+
end
|
118
|
+
|
119
|
+
def downvotes
|
120
|
+
@data[:downvotes]
|
121
|
+
end
|
122
|
+
|
123
|
+
def score
|
124
|
+
@data[:score]
|
125
|
+
end
|
126
|
+
|
127
|
+
def fullname
|
96
128
|
@data[:fullname]
|
97
129
|
end
|
98
130
|
|
99
|
-
##
|
100
|
-
# @return [String] the name of the guild this item is contained within.
|
101
131
|
def guild_name
|
102
132
|
@data[:guild_name]
|
103
133
|
end
|
104
134
|
|
105
|
-
##
|
106
|
-
# @return [String] the name/title of this item.
|
107
135
|
def title
|
108
136
|
@data[:title]
|
109
137
|
end
|
110
|
-
|
111
|
-
##
|
112
|
-
# @return [String] the string representation of the object.
|
113
|
-
def to_s
|
114
|
-
@data[:id]
|
115
|
-
end
|
116
138
|
end
|
117
139
|
end
|
data/lib/ruqqus/types/user.rb
CHANGED
@@ -6,31 +6,75 @@ module Ruqqus
|
|
6
6
|
class User < ItemBase
|
7
7
|
|
8
8
|
##
|
9
|
-
#
|
9
|
+
# @!attribute [r] comment_count
|
10
|
+
# @return [Integer] the number of comments the user has created.
|
11
|
+
|
12
|
+
##
|
13
|
+
# @!attribute [r] post_count
|
14
|
+
# @return [Integer] the number of posts the user has created.
|
15
|
+
|
16
|
+
##
|
17
|
+
# @!attribute [r] comment_rep
|
18
|
+
# @return [Integer] the amount of rep the user has earned from comments.
|
19
|
+
|
20
|
+
##
|
21
|
+
# @!attribute [r] post_rep
|
22
|
+
# @return [Integer] the amount of rep the user has earned from posts.
|
23
|
+
|
24
|
+
##
|
25
|
+
# @!attribute [r] total_rep
|
26
|
+
# @return [Integer] the total amount of rep the user has earned from comments and posts.
|
27
|
+
|
28
|
+
##
|
29
|
+
# @!attribute [r] badges
|
30
|
+
# @return [Array<Badge>] an array of badges associated with this account.
|
31
|
+
|
32
|
+
##
|
33
|
+
# @!attribute [r] title
|
34
|
+
# @return [Title?] the title the user has associated with their account, or `nil` if none is assigned.
|
35
|
+
|
36
|
+
##
|
37
|
+
# @!attribute [r] banner_url
|
38
|
+
# @return [String] the URL for the banner image associated with the account.
|
39
|
+
|
40
|
+
##
|
41
|
+
# @!attribute [r] profile_url
|
42
|
+
# @return [String] the URL for the profile image associated with the account.
|
43
|
+
|
44
|
+
##
|
45
|
+
# @!attribute [r] bio
|
46
|
+
# @return [String] A brief statement/biography the user has associated with their account.
|
47
|
+
|
48
|
+
##
|
49
|
+
# @!attribute [r] bio_html
|
50
|
+
# @return [String] a brief statement/biography the user has associated with their account in HTML format.
|
51
|
+
|
52
|
+
##
|
53
|
+
# @!attribute [r] ban_reason
|
54
|
+
# @return [String?] the reason the user was banned if they were, otherwise `nil`.
|
55
|
+
|
56
|
+
##
|
57
|
+
# @return [String] the string representation of the object.
|
58
|
+
def to_s
|
59
|
+
@data[:username] || inspect
|
60
|
+
end
|
61
|
+
|
10
62
|
def comment_count
|
11
63
|
@data[:comment_count] || 0
|
12
64
|
end
|
13
65
|
|
14
|
-
##
|
15
|
-
# @return [Integer] the number of posts the user has created.
|
16
66
|
def post_count
|
17
67
|
@data[:post_count] || 0
|
18
68
|
end
|
19
69
|
|
20
|
-
##
|
21
|
-
# @return [Integer] the amount of rep the user has earned from comments.
|
22
70
|
def comment_rep
|
23
71
|
@data[:comment_rep] || 0
|
24
72
|
end
|
25
73
|
|
26
|
-
##
|
27
|
-
# @return [Integer] the amount of rep the user has earned from posts.
|
28
74
|
def post_rep
|
29
75
|
@data[:post_rep] || 0
|
30
76
|
end
|
31
77
|
|
32
|
-
##
|
33
|
-
# @return [Integer] the total amount of rep the user has earned from comments and posts.
|
34
78
|
def total_rep
|
35
79
|
comment_rep + post_rep
|
36
80
|
end
|
@@ -41,53 +85,34 @@ module Ruqqus
|
|
41
85
|
@data[:username]
|
42
86
|
end
|
43
87
|
|
44
|
-
##
|
45
|
-
# @return [Array<Badge>] an array of badges associated with this account.
|
46
88
|
def badges
|
89
|
+
#noinspection RubyResolve
|
47
90
|
@badges ||= @data[:badges].map { |b| Badge.new(b) }
|
48
91
|
end
|
49
92
|
|
50
|
-
##
|
51
|
-
# @return [Title?] the title the user has associated with their account, or `nil` if none is assigned.
|
52
93
|
def title
|
53
|
-
#noinspection RubyYardReturnMatch
|
94
|
+
#noinspection RubyYardReturnMatch,RubyResolve
|
54
95
|
@title ||= @data[:title] ? Title.new(@data[title]) : nil
|
55
96
|
end
|
56
97
|
|
57
|
-
##
|
58
|
-
# @return [String] the URL for the banner image associated with the account.
|
59
98
|
def banner_url
|
60
99
|
@data[:banner_url]
|
61
100
|
end
|
62
101
|
|
63
|
-
##
|
64
|
-
# @return [String] the URL for the profile image associated with the account.
|
65
102
|
def profile_url
|
66
103
|
@data[:profile_url]
|
67
104
|
end
|
68
105
|
|
69
|
-
##
|
70
|
-
# @return [String] A brief statement/biography the user has associated with their account.
|
71
106
|
def bio
|
72
107
|
@data[:bio]
|
73
108
|
end
|
74
109
|
|
75
|
-
##
|
76
|
-
# @return [String] a brief statement/biography the user has associated with their account in HTML format.
|
77
110
|
def bio_html
|
78
111
|
@data[:bio_html]
|
79
112
|
end
|
80
113
|
|
81
|
-
##
|
82
|
-
# @return [String?] the reason the user was banned if they were, otherwise `nil`.
|
83
114
|
def ban_reason
|
84
115
|
@data[:ban_reason]
|
85
116
|
end
|
86
|
-
|
87
|
-
##
|
88
|
-
# @return [String] the string representation of the object.
|
89
|
-
def to_s
|
90
|
-
@data[:username] || inspect
|
91
|
-
end
|
92
117
|
end
|
93
118
|
end
|
data/lib/ruqqus/version.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module Ruqqus
|
2
2
|
|
3
3
|
##
|
4
|
-
# The Ruqqus gem version.
|
5
|
-
|
4
|
+
# The Ruqqus gem version. Version changes implement the following versioning system:
|
5
|
+
#
|
6
|
+
# * `MAJOR` Corresponds to the native Ruqqus API major version
|
7
|
+
# * `MINOR` Indicates possible breaking API changes for existing code
|
8
|
+
# * `REVISION` Added functionality, bug-fixes, and other non-breaking alterations
|
9
|
+
VERSION = '1.1.5'.freeze
|
6
10
|
|
7
11
|
##
|
8
|
-
#
|
12
|
+
# Please listen to this song I wrote. The song is called "Endless Summer".
|
9
13
|
ENDLESS_SUMMER = 'https://youtu.be/o_LskiXQ73c'.freeze
|
10
14
|
|
11
15
|
private_constant(:ENDLESS_SUMMER)
|