ruqqus 1.0.0 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -1
- data/CHANGELOG.md +48 -1
- data/Gemfile +1 -1
- data/README.md +160 -23
- data/Rakefile +1 -2
- data/TODO.md +25 -0
- data/exe/ruqqus-oauth +98 -0
- data/lib/ruqqus.rb +217 -64
- data/lib/ruqqus/client.rb +571 -0
- data/lib/ruqqus/routes.rb +68 -0
- data/lib/ruqqus/token.rb +124 -0
- data/lib/ruqqus/types.rb +11 -0
- data/lib/ruqqus/{badge.rb → types/badge.rb} +0 -0
- data/lib/ruqqus/types/comment.rb +44 -0
- data/lib/ruqqus/{guild.rb → types/guild.rb} +51 -33
- data/lib/ruqqus/{item_base.rb → types/item_base.rb} +25 -15
- data/lib/ruqqus/types/post.rb +70 -0
- data/lib/ruqqus/{submission.rb → types/submission.rb} +66 -59
- data/lib/ruqqus/{title.rb → types/title.rb} +0 -0
- data/lib/ruqqus/types/user.rb +118 -0
- data/lib/ruqqus/version.rb +7 -3
- data/ruqqus.gemspec +6 -2
- metadata +50 -16
- data/lib/ruqqus/comment.rb +0 -61
- data/lib/ruqqus/post.rb +0 -85
- data/lib/ruqqus/user.rb +0 -96
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
module Ruqqus
|
3
|
+
|
4
|
+
##
|
5
|
+
# Represents a post on Ruqqus.
|
6
|
+
class Post < Submission
|
7
|
+
|
8
|
+
##
|
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
|
+
|
40
|
+
def author_title
|
41
|
+
#noinspection RubyYardReturnMatch,RubyResolve
|
42
|
+
@author_title ||= @data[:author_title] ? Title.new(@data[:author_title]) : nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def comment_count
|
46
|
+
@data[:comment_count]
|
47
|
+
end
|
48
|
+
|
49
|
+
def domain
|
50
|
+
@data[:domain]
|
51
|
+
end
|
52
|
+
|
53
|
+
def embed_url
|
54
|
+
@data[:embed_url]
|
55
|
+
end
|
56
|
+
|
57
|
+
def original_guild_name
|
58
|
+
@data[:original_guild_name]
|
59
|
+
end
|
60
|
+
|
61
|
+
def thumb_url
|
62
|
+
@data[:thumb_url]
|
63
|
+
end
|
64
|
+
|
65
|
+
def url
|
66
|
+
#noinspection RubyYardReturnMatch
|
67
|
+
@data[:url]&.empty? ? nil : @data[:url]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require_relative 'item_base'
|
2
1
|
|
3
2
|
module Ruqqus
|
4
3
|
|
@@ -8,64 +7,53 @@ module Ruqqus
|
|
8
7
|
class Submission < ItemBase
|
9
8
|
|
10
9
|
##
|
11
|
-
#
|
12
|
-
|
13
|
-
@data[:author]
|
14
|
-
end
|
10
|
+
# @!attribute [r] title
|
11
|
+
# @return [String] the name/title of this item.
|
15
12
|
|
16
13
|
##
|
17
|
-
#
|
18
|
-
|
19
|
-
#noinspection RubyYardReturnMatch
|
20
|
-
@author ||= author_name ? Ruqqus.user(author_name) : nil
|
21
|
-
end
|
14
|
+
# @!attribute [r] author_name
|
15
|
+
# @return [String?] the name of the creator of the item, or `nil` if deleted account.
|
22
16
|
|
23
17
|
##
|
24
|
-
#
|
25
|
-
|
26
|
-
@data[:body]
|
27
|
-
end
|
18
|
+
# @!attribute [r] body
|
19
|
+
# @return [String] the text body of the item.
|
28
20
|
|
29
21
|
##
|
30
|
-
#
|
31
|
-
|
32
|
-
@data[:body_html]
|
33
|
-
end
|
22
|
+
# @!attribute [r] body_html
|
23
|
+
# @return [String] the text body of the item in HTML format.
|
34
24
|
|
35
25
|
##
|
36
|
-
#
|
37
|
-
|
38
|
-
@data[:edited_utc]
|
39
|
-
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.
|
40
28
|
|
41
29
|
##
|
42
|
-
#
|
43
|
-
|
44
|
-
Time.at(@data[:edited_utc])
|
45
|
-
end
|
30
|
+
# @!attribute [r] last_edit
|
31
|
+
# @return [Time] the time of the last edit.
|
46
32
|
|
47
33
|
##
|
48
|
-
#
|
49
|
-
|
50
|
-
@data[:edited_utc] != 0
|
51
|
-
end
|
34
|
+
# @!attribute [r] upvotes
|
35
|
+
# @return [Integer] the number of upvotes this item has received.
|
52
36
|
|
53
37
|
##
|
54
|
-
#
|
55
|
-
|
56
|
-
@data[:upvotes]
|
57
|
-
end
|
38
|
+
# @!attribute [r] downvotes
|
39
|
+
# @return [Integer] the number of downvotes this item has received.
|
58
40
|
|
59
41
|
##
|
60
|
-
#
|
61
|
-
|
62
|
-
@data[:downvotes]
|
63
|
-
end
|
42
|
+
# @!attribute [r] score
|
43
|
+
# @return [Integer] a score calculated by adding upvotes and subtracting downvotes.
|
64
44
|
|
65
45
|
##
|
66
|
-
#
|
67
|
-
|
68
|
-
|
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
|
69
57
|
end
|
70
58
|
|
71
59
|
##
|
@@ -99,32 +87,51 @@ module Ruqqus
|
|
99
87
|
end
|
100
88
|
|
101
89
|
##
|
102
|
-
# @return [String] the
|
103
|
-
def
|
104
|
-
@data[:
|
90
|
+
# @return [String] the string representation of the object.
|
91
|
+
def to_s
|
92
|
+
@data[:id]
|
105
93
|
end
|
106
94
|
|
107
|
-
|
108
|
-
|
109
|
-
def guild_name
|
110
|
-
@data[:guild_name]
|
95
|
+
def author_name
|
96
|
+
@data[:author]
|
111
97
|
end
|
112
98
|
|
113
|
-
|
114
|
-
|
115
|
-
def guild
|
116
|
-
#noinspection RubyYardReturnMatch
|
117
|
-
@guild ||= guild_name ? Ruqqus.guild(guild_name) : nil
|
99
|
+
def body
|
100
|
+
@data[:body]
|
118
101
|
end
|
119
102
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
128
|
+
@data[:fullname]
|
129
|
+
end
|
130
|
+
|
131
|
+
def guild_name
|
132
|
+
@data[:guild_name]
|
124
133
|
end
|
125
134
|
|
126
|
-
##
|
127
|
-
# @return [String] the name/title of this item.
|
128
135
|
def title
|
129
136
|
@data[:title]
|
130
137
|
end
|
File without changes
|
@@ -0,0 +1,118 @@
|
|
1
|
+
|
2
|
+
module Ruqqus
|
3
|
+
|
4
|
+
##
|
5
|
+
# Represents a Ruqqus user account.
|
6
|
+
class User < ItemBase
|
7
|
+
|
8
|
+
##
|
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
|
+
|
62
|
+
def comment_count
|
63
|
+
@data[:comment_count] || 0
|
64
|
+
end
|
65
|
+
|
66
|
+
def post_count
|
67
|
+
@data[:post_count] || 0
|
68
|
+
end
|
69
|
+
|
70
|
+
def comment_rep
|
71
|
+
@data[:comment_rep] || 0
|
72
|
+
end
|
73
|
+
|
74
|
+
def post_rep
|
75
|
+
@data[:post_rep] || 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def total_rep
|
79
|
+
comment_rep + post_rep
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# @return [String] the username of the account.
|
84
|
+
def username
|
85
|
+
@data[:username]
|
86
|
+
end
|
87
|
+
|
88
|
+
def badges
|
89
|
+
#noinspection RubyResolve
|
90
|
+
@badges ||= @data[:badges].map { |b| Badge.new(b) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def title
|
94
|
+
#noinspection RubyYardReturnMatch,RubyResolve
|
95
|
+
@title ||= @data[:title] ? Title.new(@data[title]) : nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def banner_url
|
99
|
+
@data[:banner_url]
|
100
|
+
end
|
101
|
+
|
102
|
+
def profile_url
|
103
|
+
@data[:profile_url]
|
104
|
+
end
|
105
|
+
|
106
|
+
def bio
|
107
|
+
@data[:bio]
|
108
|
+
end
|
109
|
+
|
110
|
+
def bio_html
|
111
|
+
@data[:bio_html]
|
112
|
+
end
|
113
|
+
|
114
|
+
def ban_reason
|
115
|
+
@data[:ban_reason]
|
116
|
+
end
|
117
|
+
end
|
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.4'.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)
|
data/ruqqus.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = Ruqqus::VERSION
|
8
8
|
spec.authors = ['ForeverZer0']
|
9
9
|
spec.email = ['efreed09@gmail.com']
|
10
|
-
spec.summary = %q{A Ruby API implementation for Ruqqus, an open-source platform for online communities
|
11
|
-
spec.description = %q{A Ruby API implementation for Ruqqus, an open-source platform for online communities, free of censorship and moderator abuse by design.
|
10
|
+
spec.summary = %q{A Ruby API implementation for Ruqqus, an open-source platform for online communities}
|
11
|
+
spec.description = %q{A Ruby API implementation for Ruqqus, an open-source platform for online communities, free of censorship and moderator abuse by design.}
|
12
12
|
spec.homepage = 'https://github.com/ForeverZer0/ruqqus'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
@@ -35,6 +35,10 @@ Gem::Specification.new do |spec|
|
|
35
35
|
# Dependencies
|
36
36
|
spec.add_runtime_dependency('rest-client', '~> 2.1')
|
37
37
|
|
38
|
+
spec.add_development_dependency('mechanize', '~> 2.7')
|
39
|
+
spec.add_development_dependency('tty-prompt', '~> 0.22')
|
38
40
|
spec.add_development_dependency('rake', '~> 13.0')
|
39
41
|
spec.add_development_dependency('yard', '~> 0.9')
|
42
|
+
|
43
|
+
spec.post_install_message = 'Please listen to this song I wrote. The song is called "Endless Summer".'
|
40
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruqqus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ForeverZer0
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mechanize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-prompt
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.22'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.22'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rake
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,12 +81,11 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0.9'
|
55
83
|
description: A Ruby API implementation for Ruqqus, an open-source platform for online
|
56
|
-
communities, free of censorship and moderator abuse by design.
|
57
|
-
still in Beta at this time and the public API for it is still quite limited, this
|
58
|
-
gem will be actively updated as it continues to grow and is developed.
|
84
|
+
communities, free of censorship and moderator abuse by design.
|
59
85
|
email:
|
60
86
|
- efreed09@gmail.com
|
61
|
-
executables:
|
87
|
+
executables:
|
88
|
+
- ruqqus-oauth
|
62
89
|
extensions: []
|
63
90
|
extra_rdoc_files: []
|
64
91
|
files:
|
@@ -70,17 +97,23 @@ files:
|
|
70
97
|
- LICENSE.txt
|
71
98
|
- README.md
|
72
99
|
- Rakefile
|
100
|
+
- TODO.md
|
73
101
|
- bin/console
|
74
102
|
- bin/setup
|
103
|
+
- exe/ruqqus-oauth
|
75
104
|
- lib/ruqqus.rb
|
76
|
-
- lib/ruqqus/
|
77
|
-
- lib/ruqqus/
|
78
|
-
- lib/ruqqus/
|
79
|
-
- lib/ruqqus/
|
80
|
-
- lib/ruqqus/
|
81
|
-
- lib/ruqqus/
|
82
|
-
- lib/ruqqus/
|
83
|
-
- lib/ruqqus/
|
105
|
+
- lib/ruqqus/client.rb
|
106
|
+
- lib/ruqqus/routes.rb
|
107
|
+
- lib/ruqqus/token.rb
|
108
|
+
- lib/ruqqus/types.rb
|
109
|
+
- lib/ruqqus/types/badge.rb
|
110
|
+
- lib/ruqqus/types/comment.rb
|
111
|
+
- lib/ruqqus/types/guild.rb
|
112
|
+
- lib/ruqqus/types/item_base.rb
|
113
|
+
- lib/ruqqus/types/post.rb
|
114
|
+
- lib/ruqqus/types/submission.rb
|
115
|
+
- lib/ruqqus/types/title.rb
|
116
|
+
- lib/ruqqus/types/user.rb
|
84
117
|
- lib/ruqqus/version.rb
|
85
118
|
- ruqqus.gemspec
|
86
119
|
homepage: https://github.com/ForeverZer0/ruqqus
|
@@ -93,7 +126,8 @@ metadata:
|
|
93
126
|
changelog_uri: https://github.com/ForeverZer0/ruqqus/CHANGELOG.md
|
94
127
|
documentation_uri: https://www.rubydoc.info/gems/ruqqus
|
95
128
|
bug_tracker_uri: https://github.com/ForeverZer0/ruqqus/issues
|
96
|
-
post_install_message:
|
129
|
+
post_install_message: Please listen to this song I wrote. The song is called "Endless
|
130
|
+
Summer".
|
97
131
|
rdoc_options: []
|
98
132
|
require_paths:
|
99
133
|
- lib
|
@@ -112,5 +146,5 @@ rubygems_version: 3.1.4
|
|
112
146
|
signing_key:
|
113
147
|
specification_version: 4
|
114
148
|
summary: A Ruby API implementation for Ruqqus, an open-source platform for online
|
115
|
-
communities
|
149
|
+
communities
|
116
150
|
test_files: []
|