ruqqus 0.1.0 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,139 @@
1
+
2
+ module Ruqqus
3
+
4
+ ##
5
+ # @abstract
6
+ # Base class for {Post} and {Comment} types.
7
+ class Submission < ItemBase
8
+
9
+ ##
10
+ # @!attribute [r] title
11
+ # @return [String] the name/title of this item.
12
+
13
+ ##
14
+ # @!attribute [r] author_name
15
+ # @return [String?] the name of the creator of the item, or `nil` if deleted account.
16
+
17
+ ##
18
+ # @!attribute [r] body
19
+ # @return [String] the text body of the item.
20
+
21
+ ##
22
+ # @!attribute [r] body_html
23
+ # @return [String] the text body of the item in HTML format.
24
+
25
+ ##
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.
28
+
29
+ ##
30
+ # @!attribute [r] last_edit
31
+ # @return [Time] the time of the last edit.
32
+
33
+ ##
34
+ # @!attribute [r] upvotes
35
+ # @return [Integer] the number of upvotes this item has received.
36
+
37
+ ##
38
+ # @!attribute [r] downvotes
39
+ # @return [Integer] the number of downvotes this item has received.
40
+
41
+ ##
42
+ # @!attribute [r] score
43
+ # @return [Integer] a score calculated by adding upvotes and subtracting downvotes.
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
57
+ end
58
+
59
+ ##
60
+ # @return [Boolean] `true` if item is adult content and flagged as NSFW, otherwise `false`.
61
+ def nsfw?
62
+ !!@data[:is_nsfw]
63
+ end
64
+
65
+ ##
66
+ # @return [Boolean] `true` if item is adult content and flagged as NSFL, otheriwse `false`.
67
+ def nsfl?
68
+ !!@data[:is_nsfl]
69
+ end
70
+
71
+ ##
72
+ # @return [Boolean] `true` if item has been archived, otherwise `false`.
73
+ def archived?
74
+ !!@data[:is_archived]
75
+ end
76
+
77
+ ##
78
+ # @return [Boolean] `true` if item has been deleted, otherwise `false`.
79
+ def deleted?
80
+ !!@data[:is_deleted]
81
+ end
82
+
83
+ ##
84
+ # @return [Boolean] `true` if item has been classified has offensive, otherwise `false`.
85
+ def offensive?
86
+ !!@data[:is_offensive]
87
+ end
88
+
89
+ ##
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
128
+ @data[:fullname]
129
+ end
130
+
131
+ def guild_name
132
+ @data[:guild_name]
133
+ end
134
+
135
+ def title
136
+ @data[:title]
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,48 @@
1
+
2
+ module Ruqqus
3
+
4
+ ##
5
+ # Describes a title associated with a username.
6
+ class Title
7
+
8
+ ##
9
+ # @!attribute [r] id
10
+ # @return [Integer] a unique ID associated with this title.
11
+
12
+ ##
13
+ # @!attribute [r] text
14
+ # @return [String] the text value of the title.
15
+
16
+ ##
17
+ # @!attribute [r] color
18
+ # @return [String] the color used to display the title in HTML format.
19
+
20
+ ##
21
+ # @!attribute [r] kind
22
+ # @return [Integer] an integer determining the "rank" of the title.
23
+
24
+ ##
25
+ # Creates a new instance of the {Title} class.
26
+ #
27
+ # @param data [Hash] the parsed JSON payload defining this instance.
28
+ def initialize(data)
29
+ @data = data || raise(ArgumentError, 'data cannot be nil')
30
+ end
31
+
32
+ def id
33
+ @data[:id]
34
+ end
35
+
36
+ def text
37
+ @data[:text]
38
+ end
39
+
40
+ def color
41
+ @data[:color]
42
+ end
43
+
44
+ def kind
45
+ @data[:kind]
46
+ end
47
+ end
48
+ end
@@ -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
@@ -1,3 +1,16 @@
1
1
  module Ruqqus
2
- VERSION = "0.1.0"
2
+
3
+ ##
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.3'.freeze
10
+
11
+ ##
12
+ # Please listen to this song I wrote. The song is called "Endless Summer".
13
+ ENDLESS_SUMMER = 'https://youtu.be/o_LskiXQ73c'.freeze
14
+
15
+ private_constant(:ENDLESS_SUMMER)
3
16
  end
@@ -2,20 +2,24 @@ require_relative 'lib/ruqqus/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
 
5
+ # Required specifications
5
6
  spec.name = 'ruqqus'
6
7
  spec.version = Ruqqus::VERSION
7
8
  spec.authors = ['ForeverZer0']
8
9
  spec.email = ['efreed09@gmail.com']
9
-
10
- spec.summary = %q{Base library for interacting with the ruqqus.com API.}
11
- spec.description = %q{Base library for interacting with the ruqqus.com API.}
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')
15
15
 
16
- spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata['source_code_uri'] = 'https://github.com/ForeverZer0/ruqqus'
18
- spec.metadata['changelog_uri'] = 'https://github.com/ForeverZer0/ruqqus/CHANGELOG.md'
16
+ # Metadata
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/ForeverZer0/ruqqus'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/ForeverZer0/ruqqus/CHANGELOG.md'
21
+ spec.metadata['documentation_uri'] = 'https://www.rubydoc.info/gems/ruqqus'
22
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/ForeverZer0/ruqqus/issues'
19
23
 
20
24
  # Specify which files should be added to the gem when it is released.
21
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -23,9 +27,17 @@ Gem::Specification.new do |spec|
23
27
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
28
  end
25
29
 
30
+ # Register executables (none yet...)
26
31
  spec.bindir = 'exe'
27
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
33
  spec.require_paths = ['lib']
29
34
 
30
- spec.add_runtime_dependency('nokogiri', '~> 1.10')
35
+ # Dependencies
36
+ spec.add_runtime_dependency('rest-client', '~> 2.1')
37
+
38
+ spec.add_development_dependency('mechanize', '~> 2.7')
39
+ spec.add_development_dependency('tty-prompt', '~> 0.22')
40
+ spec.add_development_dependency('yard', '~> 0.9')
41
+
42
+ spec.post_install_message = 'Please listen to this song I wrote. The song is called "Endless Summer".'
31
43
  end
metadata CHANGED
@@ -1,56 +1,119 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruqqus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.3
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-25 00:00:00.000000000 Z
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: nokogiri
14
+ name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '2.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
27
- description: Base library for interacting with the ruqqus.com API.
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ description: A Ruby API implementation for Ruqqus, an open-source platform for online
70
+ communities, free of censorship and moderator abuse by design.
28
71
  email:
29
72
  - efreed09@gmail.com
30
- executables: []
73
+ executables:
74
+ - ruqqus-oauth
31
75
  extensions: []
32
76
  extra_rdoc_files: []
33
77
  files:
34
78
  - ".gitignore"
35
79
  - ".travis.yml"
80
+ - ".yardopts"
36
81
  - CHANGELOG.md
37
82
  - Gemfile
38
83
  - LICENSE.txt
39
84
  - README.md
40
85
  - Rakefile
86
+ - TODO.md
41
87
  - bin/console
42
88
  - bin/setup
89
+ - exe/ruqqus-oauth
43
90
  - lib/ruqqus.rb
91
+ - lib/ruqqus/client.rb
92
+ - lib/ruqqus/routes.rb
93
+ - lib/ruqqus/token.rb
94
+ - lib/ruqqus/types.rb
95
+ - lib/ruqqus/types/badge.rb
96
+ - lib/ruqqus/types/comment.rb
97
+ - lib/ruqqus/types/guild.rb
98
+ - lib/ruqqus/types/item_base.rb
99
+ - lib/ruqqus/types/post.rb
100
+ - lib/ruqqus/types/submission.rb
101
+ - lib/ruqqus/types/title.rb
102
+ - lib/ruqqus/types/user.rb
44
103
  - lib/ruqqus/version.rb
45
104
  - ruqqus.gemspec
46
105
  homepage: https://github.com/ForeverZer0/ruqqus
47
106
  licenses:
48
107
  - MIT
49
108
  metadata:
109
+ allowed_push_host: https://rubygems.org
50
110
  homepage_uri: https://github.com/ForeverZer0/ruqqus
51
111
  source_code_uri: https://github.com/ForeverZer0/ruqqus
52
112
  changelog_uri: https://github.com/ForeverZer0/ruqqus/CHANGELOG.md
53
- post_install_message:
113
+ documentation_uri: https://www.rubydoc.info/gems/ruqqus
114
+ bug_tracker_uri: https://github.com/ForeverZer0/ruqqus/issues
115
+ post_install_message: Please listen to this song I wrote. The song is called "Endless
116
+ Summer".
54
117
  rdoc_options: []
55
118
  require_paths:
56
119
  - lib
@@ -68,5 +131,6 @@ requirements: []
68
131
  rubygems_version: 3.1.4
69
132
  signing_key:
70
133
  specification_version: 4
71
- summary: Base library for interacting with the ruqqus.com API.
134
+ summary: A Ruby API implementation for Ruqqus, an open-source platform for online
135
+ communities
72
136
  test_files: []