rublox 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e1d91f1dc37df6df866bdf110705af8a5f78e68748edd2d577ff44de821e0f7
4
- data.tar.gz: c91696dacf025936ce517ffdcca4cae5672856bcd46822b04f28c002bc5eb0e5
3
+ metadata.gz: 1fe191ff9c3e921f2a1c0f00ccdf523b5aabc191eb78549f3838da2232950408
4
+ data.tar.gz: 1fda6fca724bbff7f182f39a7f7731f3a3e71014a5d6c421d74e604a14a8814d
5
5
  SHA512:
6
- metadata.gz: db8304263e8be041a5fb44b6c090240014c5473c84088d72b7c881b0c40abad7134d6f5dec7842b1d7a767655db833a193d4c8c79d5f0486c9a06d59748ea175
7
- data.tar.gz: a32d33986c09589f38f95f9e91b8f4746b4236fea4263aabbb41af8fc63f6d717e865d21d02755b1a578c2673a45cf4f5a22fda4f3f8fb13b6fd659856fd4a6f
6
+ metadata.gz: 99cd4156f683cdfa1743c4fb28f6264636df0708d5c7a0b9050ae30285222385eba0aa5a144438b5ccdad29a751b41af9c178ae542862649bc8cc44d86ccfe73
7
+ data.tar.gz: 5ea680e0d48a0c46f3fc247f113881146d2f60e12c9d8bb5adb7d4f53052d051fc8b871476fcda5e4f73398f872b68a9bb557337b45a279a986e4ba74b32666f
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- # frozen_string_literal: true
2
-
3
- source "http://rubygems.org"
4
- ruby ">= 3.0"
5
-
6
- gemspec
1
+ # frozen_string_literal: true
2
+
3
+ source "http://rubygems.org"
4
+ ruby ">= 3.0"
5
+
6
+ gemspec
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Roblox API wrappers
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Roblox API wrappers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,68 +1,68 @@
1
- <div align="center">
2
- <img src="https://raw.githubusercontent.com/roblox-api-wrappers/.github/main/res/rublox_logo.png" alt="rublox" width="15%" height="15%"/>
3
- </div>
4
-
5
- <br>
6
-
7
- <div align="center">
8
- <a href="https://rubygems.org/gems/rublox">
9
- <img alt="gem" src="https://img.shields.io/gem/dt/rublox?color=rgb%28170%2C%200%2C%200%29&logo=rubygems&style=flat-square">
10
- </a>
11
-
12
- <a href="https://rubygems.org/gems/rublox">
13
- <img alt="gem version" src="https://img.shields.io/gem/v/rublox?color=rgb%28170%2C%200%2C%200%29&label=gem%20version&logo=rubygems&style=flat-square">
14
- </a>
15
-
16
- <a href="https://github.com/roblox-api-wrappers/rublox/blob/main/LICENSE">
17
- <img alt="license: MIT" src="https://img.shields.io/github/license/roblox-api-wrappers/rublox?color=rgb%28150%2C%200%2C%200%29&logo=github&style=flat-square">
18
- </a>
19
-
20
- <img alt="commit activity" src="https://img.shields.io/github/commit-activity/m/roblox-api-wrappers/rublox?color=rgb%28170%2C%200%2C%200%29&logo=github&style=flat-square">
21
-
22
- <img alt="repo stars" src="https://img.shields.io/github/stars/roblox-api-wrappers/rublox?color=rgb%28170%2C%200%2C%200%29&logo=github&style=flat-square">
23
-
24
- <a href="https://rubydoc.info/gems/rublox">
25
- <img alt="docs" src="https://img.shields.io/badge/docs-rubydoc.info-aa0000?style=flat-square">
26
- </a>
27
-
28
- <a href="https://guilded.gg/roblox-api-wrappers">
29
- <img alt="support server" src="https://img.shields.io/badge/guilded-support%20server-aa0000.svg?style=flat-square&logo=guilded">
30
- </a>
31
- </div>
32
-
33
- <div align="center"> <i>rublox is a Roblox web API wrapper written in Ruby. It aims to provide an object oriented interface to get and modify data from Roblox's web API. </i> </div>
34
-
35
- <br>
36
-
37
- # Installation
38
-
39
- Include rublox in your application's `Gemfile`
40
-
41
- ```ruby
42
- gem "rublox", "~> 0.1.0"
43
- ```
44
-
45
- or run
46
-
47
- > $ gem install rublox
48
-
49
- on your terminal.
50
-
51
- # Getting started
52
-
53
- The gateway to the API is the [Rublox::Client](https://rubydoc.info/gems/rublox/Rublox/Client) object. You can initialize it with your _.ROBLOSECURITY_ cookie if you need functionality that needs it.
54
-
55
- ```ruby
56
- # Without a cookie
57
- client = Rublox::Client.new
58
- # With a cookie
59
- client = Rublox::Client.new("_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this ...")
60
- ```
61
-
62
- **(if you open-source/work with other people on your application, it is recommended to keep your cookie in a `.env` file and load it with a library like [dotenv](https://rubygems.org/gems/dotenv))**
63
-
64
- From there, you can build off your application's logic with methods provided via [Rublox::Client](https://rubydoc.info/gems/rublox/Rublox/Client)
65
-
66
- # Documentation
67
-
68
- You can access the documentation at https://rubydoc.info/gems/rublox.
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/roblox-api-wrappers/.github/main/res/rublox_logo.png" alt="rublox" width="15%" height="15%"/>
3
+ </div>
4
+
5
+ <br>
6
+
7
+ <div align="center">
8
+ <a href="https://rubygems.org/gems/rublox">
9
+ <img alt="gem" src="https://img.shields.io/gem/dt/rublox?color=rgb%28170%2C%200%2C%200%29&logo=rubygems&style=flat-square">
10
+ </a>
11
+
12
+ <a href="https://rubygems.org/gems/rublox">
13
+ <img alt="gem version" src="https://img.shields.io/gem/v/rublox?color=rgb%28170%2C%200%2C%200%29&label=gem%20version&logo=rubygems&style=flat-square">
14
+ </a>
15
+
16
+ <a href="https://github.com/roblox-api-wrappers/rublox/blob/main/LICENSE">
17
+ <img alt="license: MIT" src="https://img.shields.io/github/license/roblox-api-wrappers/rublox?color=rgb%28150%2C%200%2C%200%29&logo=github&style=flat-square">
18
+ </a>
19
+
20
+ <img alt="commit activity" src="https://img.shields.io/github/commit-activity/m/roblox-api-wrappers/rublox?color=rgb%28170%2C%200%2C%200%29&logo=github&style=flat-square">
21
+
22
+ <img alt="repo stars" src="https://img.shields.io/github/stars/roblox-api-wrappers/rublox?color=rgb%28170%2C%200%2C%200%29&logo=github&style=flat-square">
23
+
24
+ <a href="https://rubydoc.info/gems/rublox">
25
+ <img alt="docs" src="https://img.shields.io/badge/docs-rubydoc.info-aa0000?style=flat-square">
26
+ </a>
27
+
28
+ <a href="https://guilded.gg/roblox-api-wrappers">
29
+ <img alt="support server" src="https://img.shields.io/badge/guilded-support%20server-aa0000.svg?style=flat-square&logo=guilded">
30
+ </a>
31
+ </div>
32
+
33
+ <div align="center"> <i>rublox is a Roblox web API wrapper written in Ruby. It aims to provide an object oriented interface to get and modify data from Roblox's web API. </i> </div>
34
+
35
+ <br>
36
+
37
+ # Installation
38
+
39
+ Include rublox in your application's `Gemfile`
40
+
41
+ ```ruby
42
+ gem "rublox", "~> 0.2.0"
43
+ ```
44
+
45
+ or run
46
+
47
+ > $ gem install rublox
48
+
49
+ on your terminal.
50
+
51
+ # Getting started
52
+
53
+ The gateway to the API is the [Rublox::Client](https://rubydoc.info/gems/rublox/Rublox/Client) object. You can initialize it with your _.ROBLOSECURITY_ cookie if you need functionality that needs it.
54
+
55
+ ```ruby
56
+ # Without a cookie
57
+ client = Rublox::Client.new
58
+ # With a cookie
59
+ client = Rublox::Client.new("_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this ...")
60
+ ```
61
+
62
+ **(if you open-source/work with other people on your application, it is recommended to keep your cookie in a `.env` file and load it with a library like [dotenv](https://rubygems.org/gems/dotenv))**
63
+
64
+ From there, you can build off your application's logic with methods provided via [Rublox::Client](https://rubydoc.info/gems/rublox/Rublox/Client)
65
+
66
+ # Documentation
67
+
68
+ You can access the documentation at https://rubydoc.info/gems/rublox.
data/Rakefile CHANGED
@@ -1,33 +1,33 @@
1
- # frozen_string_literal: true
2
-
3
- require "rake"
4
-
5
- desc "run rubocop"
6
- task :rubocop do
7
- system "rubocop"
8
- end
9
-
10
- desc "run tests"
11
- task :test do
12
- system "ruby -I ./lib ./tests/run_tests.rb"
13
- end
14
-
15
- desc "build docs"
16
- task :docs do
17
- system "yardoc"
18
- end
19
-
20
- desc "build docs, showing private objects"
21
- task :docs_priv do
22
- system "yardoc --private"
23
- end
24
-
25
- desc "open local server to live preview docs"
26
- task :doc_server do
27
- system "yard server --reload"
28
- end
29
-
30
- desc "list all undocumented objects"
31
- task :list_undoc do
32
- system "yard stats --list-undoc"
33
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+
5
+ desc "run rubocop"
6
+ task :rubocop do
7
+ system "rubocop"
8
+ end
9
+
10
+ desc "run tests"
11
+ task :test do
12
+ system "ruby -I ./lib ./tests/run_tests.rb"
13
+ end
14
+
15
+ desc "build docs"
16
+ task :docs do
17
+ system "yardoc"
18
+ end
19
+
20
+ desc "build docs, showing private objects"
21
+ task :docs_priv do
22
+ system "yardoc --private"
23
+ end
24
+
25
+ desc "open local server to live preview docs"
26
+ task :doc_server do
27
+ system "yard server --reload"
28
+ end
29
+
30
+ desc "list all undocumented objects"
31
+ task :list_undoc do
32
+ system "yard stats --list-undoc"
33
+ end
@@ -1,50 +1,50 @@
1
- # frozen_string_literal: true
2
-
3
- require "rublox/models/group_member"
4
- require "rublox/models/group_role"
5
-
6
- module Rublox
7
- # This mixin module contains functions that can be called on group objects.
8
- # @abstract
9
- module Group
10
- # @example
11
- # client = Rublox::Client.new
12
- # group = client.group_from_id(1)
13
- # group.roles.each { |role| puts role.rank } # 0, 1, 180, 100, 254, 255
14
- # @return [Array<GroupRole>] the group's roles
15
- def roles
16
- @client.http_client.get(
17
- URL.endpoint("groups", "v1/groups/#{@id}/roles")
18
- )["roles"].map { |role| GroupRole.new(role, self, @client) }
19
- end
20
-
21
- # @example
22
- # client = Rublox::Client.new
23
- # group = client.group_from_id(7384468)
24
- # member = group.member_by_id(1)
25
- # puts member.role.rank # -> 1
26
- # @param id [Integer] the user's ID
27
- # @return [GroupMember] the user as a group member object
28
- def member_by_id(id)
29
- member_by_user(@client.user_from_id(id))
30
- rescue Errors::UserNotFoundError
31
- raise Errors::MemberNotFoundError.new(id, @id)
32
- end
33
-
34
- # @example
35
- # client = Rublox::Client.new
36
- # group = client.group_from_id(7384468)
37
- # owner_member = group.member_by_user(group.owner)
38
- # puts owner_member.role.rank # -> 255
39
- # @param user [FullUser, LimitedUser] the user to tie to the group member
40
- # @return [GroupMember] the user as a group member object
41
- def member_by_user(user)
42
- data = @client.http_client.get(
43
- URL.endpoint("groups", "v2/users/#{user.id}/groups/roles")
44
- )["data"].find { |member_data| member_data["group"]["id"] == @id }
45
- raise Errors::MemberNotFoundError.new(user.id, @id) unless data
46
-
47
- GroupMember.new(user, GroupRole.new(data["role"], self, @client), self, @client)
48
- end
49
- end
50
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "rublox/models/group_member"
4
+ require "rublox/models/group_role"
5
+
6
+ module Rublox
7
+ # This mixin module contains functions that can be called on group objects.
8
+ # @abstract
9
+ module Group
10
+ # @example
11
+ # client = Rublox::Client.new
12
+ # group = client.group_from_id(1)
13
+ # group.roles.each { |role| puts role.rank } # 0, 1, 180, 100, 254, 255
14
+ # @return [Array<GroupRole>] the group's roles
15
+ def roles
16
+ @client.http_client.get(
17
+ URL.endpoint("groups", "v1/groups/#{@id}/roles")
18
+ )["roles"].map { |role| GroupRole.new(role, self, @client) }
19
+ end
20
+
21
+ # @example
22
+ # client = Rublox::Client.new
23
+ # group = client.group_from_id(7384468)
24
+ # member = group.member_by_id(1)
25
+ # puts member.role.rank # -> 1
26
+ # @param id [Integer] the user's ID
27
+ # @return [GroupMember] the user as a group member object
28
+ def member_by_id(id)
29
+ member_by_user(@client.user_from_id(id))
30
+ rescue Errors::UserNotFoundError
31
+ raise Errors::MemberNotFoundError.new(id, @id)
32
+ end
33
+
34
+ # @example
35
+ # client = Rublox::Client.new
36
+ # group = client.group_from_id(7384468)
37
+ # owner_member = group.member_by_user(group.owner)
38
+ # puts owner_member.role.rank # -> 255
39
+ # @param user [FullUser, LimitedUser] the user to tie to the group member
40
+ # @return [GroupMember] the user as a group member object
41
+ def member_by_user(user)
42
+ data = @client.http_client.get(
43
+ URL.endpoint("groups", "v2/users/#{user.id}/groups/roles")
44
+ )["data"].find { |member_data| member_data["group"]["id"] == @id }
45
+ raise Errors::MemberNotFoundError.new(user.id, @id) unless data
46
+
47
+ GroupMember.new(user, GroupRole.new(data["role"], self, @client), self, @client)
48
+ end
49
+ end
50
+ end
@@ -1,89 +1,89 @@
1
- # frozen_string_literal: true
2
-
3
- require "rublox/util/url"
4
-
5
- module Rublox
6
- # This mixin module contains functions that can be called on user objects.
7
- # @abstract
8
- module User
9
- # @example Updating a {FullUser}
10
- # client = Rublox::Client.new
11
- # user = client.user_from_id(1)
12
- # puts user.display_name # -> Roblox
13
- # # suppose the Roblox account changes it's display name to "ABC"
14
- # refreshed_user = user.refresh
15
- # puts refreshed_user.display_name # -> ABC
16
- # @example Updating a {LimitedUser}
17
- # client = Rublox::Client.new
18
- # group = client.group_from_id(1)
19
- # # say we want the user's join date. LimitedUsers do not contain that information, so we can update it to get a
20
- # # FullUser, which has that
21
- # the_full_user_owner = group.owner.refresh
22
- # # we can now get the owner's join date
23
- # puts the_full_user_owner.join_date.inspect # "2008-09-30 15:54:26 UTC"
24
- # @return [FullUser] a mirrored {FullUser} object, containing new information
25
- # about theuser if it has been changed, or if the user is a {LimitedUser}.
26
- def refresh
27
- @client.user_from_id(@id)
28
- end
29
-
30
- # @example
31
- # client = Rublox::Client.new
32
- # user = client.user_from_id(1)
33
- # puts user.friend_count # -> 0
34
- # @return [Integer] the count of how many friends the user has
35
- def friend_count
36
- @client.http_client.get(
37
- URL.endpoint("friends", "/v1/users/#{@id}/friends/count")
38
- )["count"]
39
- end
40
-
41
- # @example
42
- # client = Rublox::Client.new
43
- # user = client.user_from_id(1)
44
- # puts user.follower_count # -> around 6 million
45
- # @return [Integer] the count of how many followers the user has
46
- def follower_count
47
- @client.http_client.get(
48
- URL.endpoint("friends", "/v1/users/#{@id}/followers/count")
49
- )["count"]
50
- end
51
-
52
- # @example
53
- # client = Rublox::Client.new
54
- # user = client.user_from_id(1)
55
- # puts user.followings_count # -> 0
56
- # @return [Integer] the count of how many users the user has followed
57
- def followings_count
58
- @client.http_client.get(
59
- URL.endpoint("friends", "/v1/users/#{@id}/followings/count")
60
- )["count"]
61
- end
62
-
63
- # @example
64
- # client = Rublox::Client.new
65
- # user = client.user_from_id(1)
66
- # puts user.status # -> "Welcome to Roblox, the Imagination Platform. Make friends, explore, and play games!"
67
- # @return [String] the user's status
68
- def status
69
- @client.http_client.get(
70
- URL.endpoint("users", "/v1/users/#{@id}/status")
71
- )["status"]
72
- end
73
-
74
- # @example
75
- # client = Rublox::Client.new
76
- # user = client.user_from_id(1)
77
- # presence = user.presence
78
- # puts presence.last_location # -> "Website"
79
- # @return [Presence] the presence state of the user
80
- def presence
81
- @client.user_presence_from_id(@id)
82
- end
83
-
84
- # @return [String] a readable string representation of the user
85
- def to_s
86
- "User of ID #{@id}, username: #{@username}"
87
- end
88
- end
89
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "rublox/util/url"
4
+
5
+ module Rublox
6
+ # This mixin module contains functions that can be called on user objects.
7
+ # @abstract
8
+ module User
9
+ # @example Updating a {FullUser}
10
+ # client = Rublox::Client.new
11
+ # user = client.user_from_id(1)
12
+ # puts user.display_name # -> Roblox
13
+ # # suppose the Roblox account changes it's display name to "ABC"
14
+ # refreshed_user = user.refresh
15
+ # puts refreshed_user.display_name # -> ABC
16
+ # @example Updating a {LimitedUser}
17
+ # client = Rublox::Client.new
18
+ # group = client.group_from_id(1)
19
+ # # say we want the user's join date. LimitedUsers do not contain that information, so we can update it to get a
20
+ # # FullUser, which has that
21
+ # the_full_user_owner = group.owner.refresh
22
+ # # we can now get the owner's join date
23
+ # puts the_full_user_owner.join_date.inspect # "2008-09-30 15:54:26 UTC"
24
+ # @return [FullUser] a mirrored {FullUser} object, containing new information
25
+ # about the user if it has been changed, or if the user is a {LimitedUser}.
26
+ def refresh
27
+ @client.user_from_id(@id)
28
+ end
29
+
30
+ # @example
31
+ # client = Rublox::Client.new
32
+ # user = client.user_from_id(1)
33
+ # puts user.friend_count # -> 0
34
+ # @return [Integer] the count of how many friends the user has
35
+ def friend_count
36
+ @client.http_client.get(
37
+ URL.endpoint("friends", "/v1/users/#{@id}/friends/count")
38
+ )["count"]
39
+ end
40
+
41
+ # @example
42
+ # client = Rublox::Client.new
43
+ # user = client.user_from_id(1)
44
+ # puts user.follower_count # -> around 6 million
45
+ # @return [Integer] the count of how many followers the user has
46
+ def follower_count
47
+ @client.http_client.get(
48
+ URL.endpoint("friends", "/v1/users/#{@id}/followers/count")
49
+ )["count"]
50
+ end
51
+
52
+ # @example
53
+ # client = Rublox::Client.new
54
+ # user = client.user_from_id(1)
55
+ # puts user.followings_count # -> 0
56
+ # @return [Integer] the count of how many users the user has followed
57
+ def followings_count
58
+ @client.http_client.get(
59
+ URL.endpoint("friends", "/v1/users/#{@id}/followings/count")
60
+ )["count"]
61
+ end
62
+
63
+ # @example
64
+ # client = Rublox::Client.new
65
+ # user = client.user_from_id(1)
66
+ # puts user.status # -> "Welcome to Roblox, the Imagination Platform. Make friends, explore, and play games!"
67
+ # @return [String] the user's status
68
+ def status
69
+ @client.http_client.get(
70
+ URL.endpoint("users", "/v1/users/#{@id}/status")
71
+ )["status"]
72
+ end
73
+
74
+ # @example
75
+ # client = Rublox::Client.new
76
+ # user = client.user_from_id(1)
77
+ # presence = user.presence
78
+ # puts presence.last_location # -> "Website"
79
+ # @return [Presence] the presence state of the user
80
+ def presence
81
+ @client.user_presence_from_id(@id)
82
+ end
83
+
84
+ # @return [String] a readable string representation of the user
85
+ def to_s
86
+ "User of ID #{@id}, username: #{@username}"
87
+ end
88
+ end
89
+ end