ruqqus 1.1.4 → 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/CHANGELOG.md +9 -0
- data/CODE_OF_CONDUCT.md +51 -0
- data/CONTRIBUTING.md +24 -0
- data/README.md +5 -2
- data/assets/ruby-ruqqus.png +0 -0
- data/assets/ruqqus_text_logo.png +0 -0
- data/lib/ruqqus/client.rb +14 -1
- data/lib/ruqqus/token.rb +11 -0
- data/lib/ruqqus/types/guild.rb +9 -0
- data/lib/ruqqus/version.rb +1 -1
- data/ruqqus.gemspec +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62b35161bf5278e264c66836f39a80de3492dcd627f7e1e9d701a5439af30649
|
4
|
+
data.tar.gz: 0cbc0628bcceebaac0770ed2c2fa5558d632ab3f02f5c7c9deb500f9552c3e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da177c6d90e02598bb5438d79b3c0fca5219922a1bda1d20a67e458be8bebf078621c45bdbf557f84c278bfa2d668cee6002911512a98ce6dda8945383c97c72
|
7
|
+
data.tar.gz: 46f0839094cfd3e134df3719cc7bf189df295963f34a106c0540063af57d5dac887c7ca5c019e1afb7152c4d4051a025b1dbe12dd7f287ac4c316e9fe265bc18
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: "[BUG] "
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**To Reproduce**
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
1. Go to '...'
|
16
|
+
2. Click on '....'
|
17
|
+
3. Scroll down to '....'
|
18
|
+
4. See error
|
19
|
+
|
20
|
+
**Expected behavior**
|
21
|
+
A clear and concise description of what you expected to happen.
|
22
|
+
|
23
|
+
**Additional context**
|
24
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12
|
+
|
13
|
+
**Describe the solution you'd like**
|
14
|
+
A clear and concise description of what you want to happen.
|
15
|
+
|
16
|
+
**Additional context**
|
17
|
+
Add any other context or screenshots about the feature request here.
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,15 @@ Versioning system:
|
|
10
10
|
* `MINOR` Indicates possible breaking API changes for existing code
|
11
11
|
* `REVISION` Added functionality, bug-fixes, and other non-breaking alterations
|
12
12
|
|
13
|
+
## Version 1.1.5
|
14
|
+
|
15
|
+
* Added `Ruqqus::Clien#post_delete` method
|
16
|
+
* Added `Ruqqus::Guild#guildmasters` attribute
|
17
|
+
|
18
|
+
## Version 1.1.4
|
19
|
+
|
20
|
+
* Improved the way refreshing works to do so within a certain threshold
|
21
|
+
|
13
22
|
## Version 1.1.3
|
14
23
|
|
15
24
|
* Implemented browser-based confirmation process
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful. This will always involve a public and
|
28
|
+
open discussion of the action beinng taken in full transparency.
|
29
|
+
|
30
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
31
|
+
fairly and consistently applying these principles to every aspect of managing
|
32
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
33
|
+
Conduct may be permanently removed from the project team.
|
34
|
+
|
35
|
+
This code of conduct applies both within project spaces and in public spaces
|
36
|
+
when an individual is representing the project or its community.
|
37
|
+
|
38
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
39
|
+
reported by contacting a project maintainer at efreed09@gmail.com. All
|
40
|
+
complaints will be reviewed and investigated and will result in a response that
|
41
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
42
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
43
|
+
incident.
|
44
|
+
|
45
|
+
|
46
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
47
|
+
version 1.3.0, available at
|
48
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
49
|
+
|
50
|
+
[homepage]: http://contributor-covenant.org
|
51
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# How to contribute
|
2
|
+
First of all, thank you for taking the time to contribute to this project. We've tried to make a stable project and try to fix bugs and add new features continuously. You can help us do more.
|
3
|
+
|
4
|
+
## Getting started
|
5
|
+
|
6
|
+
### Check out existing issues/pull requests
|
7
|
+
|
8
|
+
If there is a bug or a feature that is not listed in the **issues** page or there is no one assigned to the issue, feel free to fix/add it! Although it's better to discuss it in the issue or create a new issue for it so there is no confilcting code.
|
9
|
+
|
10
|
+
### Writing some code!
|
11
|
+
|
12
|
+
Contributing to a project on Github is pretty straight forward. If this is you're first time, these are the steps you should take.
|
13
|
+
|
14
|
+
- Fork this repo.
|
15
|
+
|
16
|
+
And that's it! Read the code available and change the part you don't like! You're change should not break the existing code and should pass the tests.
|
17
|
+
|
18
|
+
If you're adding a new functionality, start from the branch **master**. It would be a better practice to create a new branch and work in there.
|
19
|
+
|
20
|
+
When you're done, submit a pull request and for one of the maintainers to check it out. We would let you know if there is any problem or any changes that should be considered.
|
21
|
+
|
22
|
+
### Documentation
|
23
|
+
|
24
|
+
This project enforces 100% documentation coverage, even on non-public methods that aren't part of the API surface. We use [YARD](https://www.rubydoc.info/gems/yard/file/docs/Tags.md) as our tool of choice for documentation. It is rather intuitive, but feel free to ask if you questions if unsure or are unfamiliar with it. Pull requests will not be merged unless documented, so please don't forget to include it!
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="https://raw.githubusercontent.com/
|
2
|
+
<img src="https://raw.githubusercontent.com/ForeverZer0/ruqqus/master/assets/ruqqus_text_logo.png" width="360"/>
|
3
3
|
</p>
|
4
4
|
|
5
5
|
<hr>
|
@@ -97,7 +97,10 @@ and where you store this information so that it is not compromised.
|
|
97
97
|
|
98
98
|
## Usage
|
99
99
|
|
100
|
-
|
100
|
+
For in-depth documentation and instructions on how to get started, please see the following resources:
|
101
|
+
|
102
|
+
* [API Documentation](https://www.rubydoc.info/gems/ruqqus) - Complete documentation of the entire API (100% coverage)
|
103
|
+
* [Wiki](https://github.com/ForeverZer0/ruqqus/wiki) - Public wiki with more in-depth explanation, code samples, best practices, etc.
|
101
104
|
|
102
105
|
### Features
|
103
106
|
|
Binary file
|
Binary file
|
data/lib/ruqqus/client.rb
CHANGED
@@ -52,6 +52,7 @@ module Ruqqus
|
|
52
52
|
@client_secret = client_secret || raise(ArgumentError, 'client secret cannot be nil')
|
53
53
|
|
54
54
|
@token = token.is_a?(Token) ? token : Token.new(client_id, client_secret, token.to_s)
|
55
|
+
@token.refresh(client_id, client_secret)
|
55
56
|
@session = nil
|
56
57
|
end
|
57
58
|
|
@@ -173,6 +174,18 @@ module Ruqqus
|
|
173
174
|
http_post(url).empty? rescue false
|
174
175
|
end
|
175
176
|
|
177
|
+
##
|
178
|
+
# Deletes an existing post.
|
179
|
+
#
|
180
|
+
# @param post [Comment,String] a {Post} instance, or the unique ID of the post to delete.
|
181
|
+
#
|
182
|
+
# @return [Boolean] `true` if deletion completed without error, otherwise `false`.
|
183
|
+
def post_delete(post)
|
184
|
+
id = post.is_a?(Post) ? post.id : post.sub(/^t3_/, '')
|
185
|
+
url = "#{Routes::API_BASE}/delete_post/#{id}"
|
186
|
+
http_post(url).empty? rescue false
|
187
|
+
end
|
188
|
+
|
176
189
|
# @!endgroup Commenting
|
177
190
|
|
178
191
|
# @!group Posting
|
@@ -563,7 +576,7 @@ module Ruqqus
|
|
563
576
|
# @api private
|
564
577
|
# Checks if token is expired, and refreshes if so, calling the {#token_refreshed} block as if defined.
|
565
578
|
def refresh_token
|
566
|
-
return unless @token.
|
579
|
+
return unless @token.need_refresh?
|
567
580
|
@token.refresh(@client_id, @client_secret)
|
568
581
|
@refreshed&.call(@token)
|
569
582
|
end
|
data/lib/ruqqus/token.rb
CHANGED
@@ -4,6 +4,10 @@ module Ruqqus
|
|
4
4
|
# Represents a Ruqqus [OAuth2](https://oauth.net/2/) access token.
|
5
5
|
class Token
|
6
6
|
|
7
|
+
##
|
8
|
+
# The minimum number of seconds that can remain before the token refreshes itself.
|
9
|
+
REFRESH_THRESHOLD = 60
|
10
|
+
|
7
11
|
##
|
8
12
|
# @!attribute [r] access_token
|
9
13
|
# @return [String] the access token value.
|
@@ -74,6 +78,7 @@ module Ruqqus
|
|
74
78
|
data = JSON.parse(resp.body, symbolize_names: true)
|
75
79
|
raise(Ruqqus::Error, 'failed to refresh authentication token') unless resp.code == 200 || data[:oauth_error]
|
76
80
|
@data.merge!(data)
|
81
|
+
sleep(1) # TODO: Test. Get internment 401 error when token needs refreshed
|
77
82
|
end
|
78
83
|
|
79
84
|
##
|
@@ -82,6 +87,12 @@ module Ruqqus
|
|
82
87
|
expires <= Time.now
|
83
88
|
end
|
84
89
|
|
90
|
+
##
|
91
|
+
# @return [Boolean] `true` if remaining lifetime is within the {REFRESH_THRESHOLD}, otherwise `false`.
|
92
|
+
def need_refresh?
|
93
|
+
(expires - Time.now) < REFRESH_THRESHOLD
|
94
|
+
end
|
95
|
+
|
85
96
|
##
|
86
97
|
# @return [String] the object as a JSON-formatted string.
|
87
98
|
def to_json(*_unused_)
|
data/lib/ruqqus/types/guild.rb
CHANGED
@@ -40,6 +40,10 @@ module Ruqqus
|
|
40
40
|
# @!attribute [r] banner_url
|
41
41
|
# @return [String] the URL for the banner image associated with the guild.
|
42
42
|
|
43
|
+
##
|
44
|
+
# @!attribute [r] guildmasters
|
45
|
+
# @return [Array<User>] an array of {User} instances of the moderators for this guild.
|
46
|
+
|
43
47
|
##
|
44
48
|
# @return [Boolean] `true` if the guild contains adult content and flagged as NSFW, otherwise `false`.
|
45
49
|
def nsfw?
|
@@ -99,5 +103,10 @@ module Ruqqus
|
|
99
103
|
def fullname
|
100
104
|
@data[:fullname]
|
101
105
|
end
|
106
|
+
|
107
|
+
def guildmasters
|
108
|
+
return Array.new unless @data[:guildmasters]
|
109
|
+
@data[:guildmasters].map { |gm| User.from_json(gm) }
|
110
|
+
end
|
102
111
|
end
|
103
112
|
end
|
data/lib/ruqqus/version.rb
CHANGED
@@ -6,7 +6,7 @@ module Ruqqus
|
|
6
6
|
# * `MAJOR` Corresponds to the native Ruqqus API major version
|
7
7
|
# * `MINOR` Indicates possible breaking API changes for existing code
|
8
8
|
# * `REVISION` Added functionality, bug-fixes, and other non-breaking alterations
|
9
|
-
VERSION = '1.1.
|
9
|
+
VERSION = '1.1.5'.freeze
|
10
10
|
|
11
11
|
##
|
12
12
|
# Please listen to this song I wrote. The song is called "Endless Summer".
|
data/ruqqus.gemspec
CHANGED
@@ -40,5 +40,5 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency('rake', '~> 13.0')
|
41
41
|
spec.add_development_dependency('yard', '~> 0.9')
|
42
42
|
|
43
|
-
spec.post_install_message =
|
43
|
+
spec.post_install_message = "Please listen to this song I wrote. The song is called \"Endless Summer\".\r\n"
|
44
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.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ForeverZer0
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -89,15 +89,21 @@ executables:
|
|
89
89
|
extensions: []
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
93
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
92
94
|
- ".gitignore"
|
93
95
|
- ".travis.yml"
|
94
96
|
- ".yardopts"
|
95
97
|
- CHANGELOG.md
|
98
|
+
- CODE_OF_CONDUCT.md
|
99
|
+
- CONTRIBUTING.md
|
96
100
|
- Gemfile
|
97
101
|
- LICENSE.txt
|
98
102
|
- README.md
|
99
103
|
- Rakefile
|
100
104
|
- TODO.md
|
105
|
+
- assets/ruby-ruqqus.png
|
106
|
+
- assets/ruqqus_text_logo.png
|
101
107
|
- bin/console
|
102
108
|
- bin/setup
|
103
109
|
- exe/ruqqus-oauth
|
@@ -126,8 +132,8 @@ metadata:
|
|
126
132
|
changelog_uri: https://github.com/ForeverZer0/ruqqus/CHANGELOG.md
|
127
133
|
documentation_uri: https://www.rubydoc.info/gems/ruqqus
|
128
134
|
bug_tracker_uri: https://github.com/ForeverZer0/ruqqus/issues
|
129
|
-
post_install_message: Please listen to this song I wrote. The song is called "Endless
|
130
|
-
Summer"
|
135
|
+
post_install_message: "Please listen to this song I wrote. The song is called \"Endless
|
136
|
+
Summer\".\r\n"
|
131
137
|
rdoc_options: []
|
132
138
|
require_paths:
|
133
139
|
- lib
|