rublox 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/rublox.gemspec CHANGED
@@ -1,32 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/rublox/version"
4
-
5
3
  Gem::Specification.new do |spec|
6
- spec.name = "rublox"
7
- spec.version = Rublox::VERSION
8
- spec.authors = %w[Zamdie Keef]
9
- spec.email = "rorg.devv@gmail.com"
10
- spec.summary = "A Roblox web API wrapper written in Ruby"
11
- spec.description = "This gem allows easy interaction with the Roblox web API via class models."
12
- spec.homepage = "https://github.com/roblox-api-wrappers/rublox"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.0"
15
- spec.files = Dir[
16
- "LICENSE",
17
- "CHANGELOG.MD",
18
- "lib/**/*.rb",
19
- "rublox.gemspec",
20
- "Gemfile",
21
- "Rakefile"
22
- ]
23
- spec.extra_rdoc_files = ["README.md"]
4
+ spec.name = "rublox"
5
+ spec.version = "0.3.1"
6
+ spec.authors = %w[zmλdie keef]
7
+ spec.email = "rorg.devv@gmail.com"
8
+ spec.summary = "A Roblox web API wrapper written in Ruby"
9
+ spec.description = "This gem allows easy interaction with the Roblox web API via modules and classes."
10
+ spec.homepage = "https://github.com/roblox-api-wrappers/rublox"
11
+ spec.metadata = {
12
+ "Documentation" => "https://rubydoc.info/gems/rublox",
13
+ "rubygems_mfa_required" => "true"
14
+ }
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.7.0"
17
+ spec.files = Dir[
18
+ "README.md",
19
+ "LICENSE",
20
+ "lib/**/*.rb",
21
+ "rublox.gemspec"
22
+ ]
24
23
 
25
- spec.add_dependency "http", "~> 5.0.2"
24
+ spec.add_dependency "http", "~> 5.1.1"
26
25
 
27
- spec.add_development_dependency "dotenv", "~> 2.7"
28
- spec.add_development_dependency "rake", "~> 13.0.6"
29
- spec.add_development_dependency "rubocop", "~> 1.21.0"
30
- spec.add_development_dependency "rubocop-performance", "~> 1.11.5"
31
- spec.add_development_dependency "yard", "~> 0.9.26"
26
+ spec.add_development_dependency "rubocop", "~> 1.44.1"
27
+ spec.add_development_dependency "rubocop-performance", "~> 1.15.2"
28
+ spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
29
+ spec.add_development_dependency "yard", "~> 0.9.28"
32
30
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rublox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
- - Zamdie
8
- - Keef
7
+ - zmλdie
8
+ - keef
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-11-10 00:00:00.000000000 Z
12
+ date: 2023-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
@@ -17,116 +17,99 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 5.0.2
20
+ version: 5.1.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 5.0.2
27
+ version: 5.1.1
28
28
  - !ruby/object:Gem::Dependency
29
- name: dotenv
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '2.7'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '2.7'
42
- - !ruby/object:Gem::Dependency
43
- name: rake
29
+ name: rubocop
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
32
  - - "~>"
47
33
  - !ruby/object:Gem::Version
48
- version: 13.0.6
34
+ version: 1.44.1
49
35
  type: :development
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
39
  - - "~>"
54
40
  - !ruby/object:Gem::Version
55
- version: 13.0.6
41
+ version: 1.44.1
56
42
  - !ruby/object:Gem::Dependency
57
- name: rubocop
43
+ name: rubocop-performance
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - "~>"
61
47
  - !ruby/object:Gem::Version
62
- version: 1.21.0
48
+ version: 1.15.2
63
49
  type: :development
64
50
  prerelease: false
65
51
  version_requirements: !ruby/object:Gem::Requirement
66
52
  requirements:
67
53
  - - "~>"
68
54
  - !ruby/object:Gem::Version
69
- version: 1.21.0
55
+ version: 1.15.2
70
56
  - !ruby/object:Gem::Dependency
71
- name: rubocop-performance
57
+ name: rubocop-rake
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
60
  - - "~>"
75
61
  - !ruby/object:Gem::Version
76
- version: 1.11.5
62
+ version: 0.6.0
77
63
  type: :development
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
67
  - - "~>"
82
68
  - !ruby/object:Gem::Version
83
- version: 1.11.5
69
+ version: 0.6.0
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: yard
86
72
  requirement: !ruby/object:Gem::Requirement
87
73
  requirements:
88
74
  - - "~>"
89
75
  - !ruby/object:Gem::Version
90
- version: 0.9.26
76
+ version: 0.9.28
91
77
  type: :development
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - "~>"
96
82
  - !ruby/object:Gem::Version
97
- version: 0.9.26
98
- description: This gem allows easy interaction with the Roblox web API via class models.
83
+ version: 0.9.28
84
+ description: This gem allows easy interaction with the Roblox web API via modules
85
+ and classes.
99
86
  email: rorg.devv@gmail.com
100
87
  executables: []
101
88
  extensions: []
102
- extra_rdoc_files:
103
- - README.md
89
+ extra_rdoc_files: []
104
90
  files:
105
- - Gemfile
106
91
  - LICENSE
107
92
  - README.md
108
- - Rakefile
109
93
  - lib/rublox.rb
94
+ - lib/rublox/bases/base_group.rb
95
+ - lib/rublox/bases/base_user.rb
110
96
  - lib/rublox/derive/group.rb
97
+ - lib/rublox/derive/model.rb
111
98
  - lib/rublox/derive/user.rb
112
99
  - lib/rublox/models/full_group.rb
113
100
  - lib/rublox/models/full_user.rb
114
- - lib/rublox/models/group_member.rb
115
- - lib/rublox/models/group_role.rb
116
101
  - lib/rublox/models/group_shout.rb
117
- - lib/rublox/models/limited_user.rb
118
102
  - lib/rublox/models/presence.rb
119
- - lib/rublox/util/cache.rb
103
+ - lib/rublox/models/skinny_user.rb
104
+ - lib/rublox/util/api_helper.rb
120
105
  - lib/rublox/util/errors.rb
121
- - lib/rublox/util/http_client.rb
122
- - lib/rublox/util/pages.rb
123
- - lib/rublox/util/url.rb
124
- - lib/rublox/version.rb
125
106
  - rublox.gemspec
126
107
  homepage: https://github.com/roblox-api-wrappers/rublox
127
108
  licenses:
128
109
  - MIT
129
- metadata: {}
110
+ metadata:
111
+ Documentation: https://rubydoc.info/gems/rublox
112
+ rubygems_mfa_required: 'true'
130
113
  post_install_message:
131
114
  rdoc_options: []
132
115
  require_paths:
@@ -135,14 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
118
  requirements:
136
119
  - - ">="
137
120
  - !ruby/object:Gem::Version
138
- version: '3.0'
121
+ version: 2.7.0
139
122
  required_rubygems_version: !ruby/object:Gem::Requirement
140
123
  requirements:
141
124
  - - ">="
142
125
  - !ruby/object:Gem::Version
143
126
  version: '0'
144
127
  requirements: []
145
- rubygems_version: 3.2.29
128
+ rubygems_version: 3.1.2
146
129
  signing_key:
147
130
  specification_version: 4
148
131
  summary: A Roblox web API wrapper written in Ruby
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "http://rubygems.org"
4
- ruby ">= 3.0"
5
-
6
- gemspec
data/Rakefile DELETED
@@ -1,33 +0,0 @@
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,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rublox
4
- # @note This class is handled internally by the public interface such as
5
- # such as {Group#member_by_user}. You should not be creating it yourself.
6
- # The {GroupMember} class corresponds to a member response, which contains
7
- # information about the user, their role and group.
8
- class GroupMember
9
- # @return [LimitedUser] the user object tied to this member
10
- attr_reader :user
11
-
12
- # @return {GroupRole} the role object tied to this member
13
- attr_reader :role
14
-
15
- # @return [FullGroup] the group object tied to this member
16
- attr_reader :group
17
-
18
- # @param user [FullUser, LimitedUser]
19
- # @param role [GroupRole]
20
- # @param group [FullGroup]
21
- # @param client [Client]
22
- def initialize(user, role, group, client)
23
- @user = user
24
- @role = role
25
- @group = group
26
- @client = client
27
- end
28
-
29
- # @note Use this if you need the state of the member changed. If you only
30
- # want the role's state updated without updating the member's state, use
31
- # {GroupRole#refresh}
32
- # @example
33
- # client = Rublox::Client.new
34
- # group = client.group_from_id(7384468)
35
- # member = group.member_by_id(1)
36
- # puts member.role.rank # -> 1
37
- # # Assume Roblox now has the Owner role
38
- # updated_member = member.refresh_role
39
- # puts updated_member.role.rank # -> 255
40
- # @return [GroupMember] a new {GroupMember} with a new {#role}, if it has been changed.
41
- def refresh_role
42
- data = @client.http_client.get(
43
- URL.endpoint("groups", "/v2/users/#{@user.id}/groups/roles")
44
- )["data"].find { |role| role["group"]["id"] == @group.id }
45
-
46
- GroupMember.new(
47
- @user,
48
- GroupRole.new(data["role"], @group, @client),
49
- @group,
50
- @client
51
- )
52
- end
53
- end
54
- end
@@ -1,355 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rublox/util/errors"
4
-
5
- module Rublox
6
- # This class is used to set a role's permissions. It uses the builder pattern to assign permissions.
7
- # @example (see Rublox::RolePermissions#initialize)
8
- class RolePermissions # rubocop:disable Metrics/ClassLength
9
- # @!visibility private
10
- PERMISSIONS = {
11
- permissions: {
12
- DeleteFromWall: nil,
13
- PostToWall: nil,
14
- InviteMembers: nil,
15
- PostToStatus: nil,
16
- RemoveMembers: nil,
17
- ViewStatus: nil,
18
- ViewWall: nil,
19
- ChangeRank: nil,
20
- AdvertiseGroup: nil,
21
- ManageRelationships: nil,
22
- AddGroupPlaces: nil,
23
- ViewAuditLogs: nil,
24
- CreateItems: nil,
25
- ManageItems: nil,
26
- SpendGroupFunds: nil,
27
- ManageClan: nil,
28
- ManageGroupGames: nil,
29
- UseCloudAuthentication: nil,
30
- AdministerCloudAuthentication: nil
31
- }
32
- }.freeze
33
-
34
- # Initialize a RolePermissions object from an endpoint's data
35
- # @!visibility private
36
- # @param data [Hash]
37
- # @return [RolePermissions]
38
- def self.from_data(data) # rubocop:disable Metrics/AbcSize
39
- permissions_data = data["permissions"]
40
- group_posts_permissions = permissions_data["groupPostsPermissions"]
41
- group_membership_permissions = permissions_data["groupMembershipPermissions"]
42
- group_management_permissions = permissions_data["groupManagementPermissions"]
43
- group_economy_permissions = permissions_data["groupEconomyPermissions"]
44
- # group_open_cloud_permissions = permissions_data["groupOpenCloudPermissions"]
45
-
46
- object = new
47
- object._permissions = {
48
- permissions: {
49
- DeleteFromWall: group_posts_permissions["deleteFromWall"],
50
- PostToWall: group_posts_permissions["postToWall"],
51
- InviteMembers: group_membership_permissions["inviteMembers"],
52
- PostToStatus: group_posts_permissions["postToStatus"],
53
- RemoveMembers: group_membership_permissions["removeMembers"],
54
- ViewStatus: group_posts_permissions["viewStatus"],
55
- ViewWall: group_posts_permissions["viewWall"],
56
- ChangeRank: group_membership_permissions["changeRank"],
57
- AdvertiseGroup: group_economy_permissions["advertiseGroup"],
58
- ManageRelationships: group_management_permissions["manageRelationships"],
59
- AddGroupPlaces: group_economy_permissions["addGroupPlaces"],
60
- ViewAuditLogs: group_management_permissions["viewAuditLogs"],
61
- CreateItems: group_economy_permissions["createItems"],
62
- ManageItems: group_economy_permissions["manageItems"],
63
- SpendGroupFunds: group_economy_permissions["spendGroupFunds"],
64
- ManageClan: group_management_permissions["manageClan"],
65
- ManageGroupGames: group_economy_permissions["manageGroupGames"]
66
- # UseCloudAuthentication: group_open_cloud_permissions["useCloudAuthentication"],
67
- # AdministerCloudAuthentication: group_open_cloud_permissions["administerCloudAuthentication"]
68
- }
69
- }
70
-
71
- object
72
- end
73
-
74
- # @example
75
- # # give permissions to view and delete messages from the group wall
76
- # role_permissions = Rublox::RolePermissions.new
77
- # .view_wall
78
- # .delete_from_wall
79
- def initialize
80
- @permissions = PERMISSIONS.clone
81
- end
82
-
83
- # Private getter for permissions
84
- # @!visibility private
85
- # @return [Hash]
86
- def _permissions
87
- @permissions
88
- end
89
-
90
- # Private setter for permissions
91
- # @!visibility private
92
- # @return [nil]
93
- def _permissions=(value)
94
- @permissions = value
95
- end
96
-
97
- # Allow members with the role to view the group wall
98
- # @return [RolePermissions]
99
- def delete_from_wall
100
- @permissions[:permissions][:DeleteFromWall] = true
101
- self
102
- end
103
-
104
- # Allow members with the role to invite members
105
- # @return [RolePermissions]
106
- def invite_members
107
- @permissions[:permissions][:InviteMembers] = true
108
- self
109
- end
110
-
111
- # Allow members with the role to post to the group's status
112
- # @return [RolePermissions]
113
- def post_to_status
114
- @permissions[:permissions][:PostToStatus] = true
115
- self
116
- end
117
-
118
- # Allow members with the role to remove members
119
- # @return [RolePermissions]
120
- def remove_members
121
- @permissions[:permissions][:RemoveMembers] = true
122
- self
123
- end
124
-
125
- # Allow members with the role to view the group's status
126
- # @return [RolePermissions]
127
- def view_status
128
- @permissions[:permissions][:ViewStatus] = true
129
- self
130
- end
131
-
132
- # Allow members with the role to view the group's wall
133
- # @return [RolePermissions]
134
- def view_wall
135
- @permissions[:permissions][:ViewWall] = true
136
- self
137
- end
138
-
139
- # Allow members with the role to change the rank of other members
140
- # @return [RolePermissions]
141
- def change_rank
142
- @permissions[:permissions][:ChangeRank] = true
143
- self
144
- end
145
-
146
- # Allow members with the role to advertise the group
147
- # @return [RolePermissions]
148
- def advertise_group
149
- @permissions[:permissions][:AdvertiseGroup] = true
150
- self
151
- end
152
-
153
- # Allow members with the role to manage the group's relationships with other groups
154
- # @return [RolePermissions]
155
- def manage_relationships
156
- @permissions[:permissions][:ManageRelationships] = true
157
- self
158
- end
159
-
160
- # Allow members with the role to create group places
161
- # @return [RolePermissions]
162
- def add_group_places
163
- @permissions[:permissions][:AddGroupPlaces] = true
164
- self
165
- end
166
-
167
- # Allow members with the role to view audit logs
168
- # @return [RolePermissions]
169
- def view_audit_logs
170
- @permissions[:permissions][:ViewAuditLogs] = true
171
- self
172
- end
173
-
174
- # Allow members with the role to create items
175
- # @return [RolePermissions]
176
- def create_items
177
- @permissions[:permissions][:ViewStatus] = true
178
- self
179
- end
180
-
181
- # Allow members with the role to manage items
182
- # @return [RolePermissions]
183
- def manage_items
184
- @permissions[:permissions][:ViewStatus] = true
185
- self
186
- end
187
-
188
- # Allow members with the role to spend group funds
189
- # @return [RolePermissions]
190
- def spend_group_funds
191
- @permissions[:permissions][:SpendGroupFunds] = true
192
- self
193
- end
194
-
195
- # Allow members with the role to manage the clan
196
- # @return [RolePermissions]
197
- def manage_clan
198
- @permissions[:permissions][:ManageClan] = true
199
- self
200
- end
201
-
202
- # Allow members with the role to manage group games
203
- # @return [RolePermissions]
204
- def manage_group_games
205
- @permissions[:permissions][:ManageGroupGames] = true
206
- self
207
- end
208
-
209
- # @!visibility private
210
- # @todo find out what this does (open cloud?)
211
- # @return [RolePermissions]
212
- def use_cloud_authentication
213
- @permissions[:permissions][:UseCloudAuthentication] = true
214
- self
215
- end
216
-
217
- # (see #use_cloud_authentication)
218
- def administer_cloud_authentication
219
- @permissions[:permissions][:AdministerCloudAuthentication] = true
220
- self
221
- end
222
- end
223
-
224
- # @note This class is handled internally by the public interface such as
225
- # {Group#roles}. You should not be creating it yourself.
226
- # The {GroupRole} class corresponds to a group's role. You can use it to get
227
- # and set information about roles.
228
- class GroupRole
229
- # @return [Integer] the role's ID
230
- attr_reader :id
231
-
232
- # @return [String] the role's name
233
- attr_reader :name
234
-
235
- # @return [String, nil] the role's description. Can be nil if the authenticated
236
- # user does not have access to the group's role settings.
237
- attr_reader :description
238
-
239
- # @return [Integer] the role's rank (0-255)
240
- attr_reader :rank
241
-
242
- # @return [Integer] the count of how many users have the role
243
- attr_reader :member_count
244
-
245
- # @return [Group] the group tied to this role
246
- attr_reader :group
247
-
248
- # @param data [Hash]
249
- # @param group [FullGroup]
250
- # @param client [Client]
251
- def initialize(data, group, client)
252
- @id = data["id"]
253
- @name = data["name"]
254
- @description = data["description"]
255
- @rank = data["rank"]
256
- @member_count = data["memberCount"]
257
- @group = group
258
-
259
- @client = client
260
- end
261
-
262
- # @example
263
- # client = Rublox::Client.new
264
- # client.group_from_id(7384468)
265
- # role = client
266
- # .group_from_id(7384468)
267
- # .member_by_id(1)
268
- # .role
269
- # puts role.rank # -> 1
270
- # # Assume Roblox now has the Owner role
271
- # updated_role = role.refresh
272
- # puts updated_role.rank # -> 255
273
- # @return [GroupRole] a mirrored {GroupRole} object, containing new information
274
- # about the role if it has been changed.
275
- def refresh
276
- data = @client.http_client.get(
277
- URL.endpoint("groups", "/v1/groups/#{@group.id}/roles")
278
- )["roles"].find { |role| role["id"] == @id }
279
- raise Errors::RoleNotFoundError.new(@id, @group.id) unless data
280
-
281
- GroupRole.new(
282
- data,
283
- @group,
284
- @client
285
- )
286
- end
287
-
288
- # Change the role's permissions
289
- # @example
290
- # client = Rublox::Client.new("COOKIE")
291
- # permissions = Rublox::RolePermissions.new
292
- # .manage_items
293
- # .create_items
294
- #
295
- # role = client
296
- # .group_from_id(1)
297
- # .member_by_id(1)
298
- # .role
299
- # role.change_permissions(permissions)
300
- # @param permissions [RolePermissions]
301
- # @return [nil]
302
- def change_permissions(permissions)
303
- @client.http_client.patch(
304
- URL.endpoint("groups", "v1/groups/#{@group.id}/roles/#{@id}/permissions"),
305
- json: permissions._permisions
306
- )
307
-
308
- nil
309
- end
310
-
311
- # Get the role's permissions
312
- # @example
313
- # client = Rublox::Client.new("COOKIE")
314
- #
315
- # role = client
316
- # .group_from_id(1)
317
- # .member_by_id(1)
318
- # .role
319
- # permissions = role.permissions
320
- # @return [RolePermissions]
321
- def permissions
322
- RolePermissions.from_data(
323
- @client.http_client.get(
324
- URL.endpoint("groups", "v1/groups/#{@group.id}/roles/#{@id}/permissions")
325
- )
326
- )
327
- end
328
-
329
- # Edit the role's information
330
- # @example
331
- # role = client
332
- # .group_from_id(1)
333
- # .member_by_id(1)
334
- # .role
335
- #
336
- # role.edit(name: "cool epic name", rank: 255)
337
- # role.edit(name: "some better name", description: "cool role")
338
- # @param name [String, nil]
339
- # @param description [String, nil]
340
- # @param rank [Integer, nil]
341
- # @return [nil]
342
- def edit(name: nil, description: nil, rank: nil)
343
- @client.http_client.patch(
344
- URL.endpoint("groups", "v1/groups/#{@group.id}/rolesets/#{@id}"),
345
- json: {
346
- name: name || @name,
347
- description: description || @description,
348
- rank: rank || @rank
349
- }
350
- )
351
-
352
- nil
353
- end
354
- end
355
- end