brawlstars 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 763265f76f26d40ab424441dc63d27b8726a8619a6cb3cd058c1f8a96d1d7cb3
4
- data.tar.gz: c376541c3e05472efb43ac3fd4f39e7c69c7d9177ca98368141cf164a45a645b
3
+ metadata.gz: e014fba4cb97cf0e7469fdd6e38e510060b8dbdc9bf5d13060b46d348f1c7f45
4
+ data.tar.gz: dc5157bbcfed8868af7d81dfac164902381bee9cfbdacf84d8959080bdbafb37
5
5
  SHA512:
6
- metadata.gz: 3c01b703b4385a58d1d5bc954e9e1f018e9bef313de4703ea12d036774553dbe8fe2b6e0c898a4dcdf130fbad7c8e396fc53df4c8991e3500cfc900beacb5a16
7
- data.tar.gz: cb184d9dba17c1a54cb8c023006d1f9ec664b78cbeef881d0b996c378760f5c30721c8d823561263e8897827f285b2f4a3630249a008ea3dc0aa0d21fefd9f11
6
+ metadata.gz: 07b7169bdeba67241bb5ba75408e1254b28a0376f95e39f1c98057291f8013b0609607e10755b7d90143907d187d597ec0cc694db704e778d0aff4a97740f5a3
7
+ data.tar.gz: d25fc5a83c01fc732a1de31bfd809b7754dc8a6f7dea563f1fce7303db5abbe03e820701ca9071a52d23cea3b912ed4e39b82b135d0c1b5dc9f96962de99ff45
@@ -1,4 +1,13 @@
1
1
  # Changelog
2
+ ## [1.3.0]
3
+ ### Added
4
+ - `Player` class
5
+ - `getClub` and `getBattleLog` methods under player class
6
+
7
+ ### Changed
8
+ - `getPlayer` now returns a `Player` object
9
+ - All methods that are supposed to return a hash now actually return one, instead of `HTTParty::Response`
10
+
2
11
  ## [1.2.1]
3
12
  ### Added
4
13
  - Actual region code checking
@@ -23,6 +32,7 @@
23
32
  ## [1.0.0]
24
33
  Initial version
25
34
 
35
+ [1.3.0]: https://github.com/Karthik99999/brawlstarsrb/tree/v1.3.0
26
36
  [1.2.1]: https://github.com/Karthik99999/brawlstarsrb/tree/v1.2.1
27
37
  [1.2.0]: https://github.com/Karthik99999/brawlstarsrb/tree/v1.2.0
28
38
  [1.1.0]: https://github.com/Karthik99999/brawlstarsrb/tree/v1.1.0
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # brawlstarsrb
2
+ [![Gem Version](https://img.shields.io/gem/v/brawlstars.svg?color=red&label=brawlstars&logo=rubygems&style=flat-square)](https://rubygems.org/gems/brawlstars)
3
+ [![License](https://img.shields.io/github/license/Karthik99999/brawlstarsrb.svg?style=flat-square)](../master/LICENSE)
4
+ [![Discord Server Invite](https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat-square)](https://discord.me/brawlapi)
2
5
 
3
6
  brawlstarsrb is a Ruby implementation of [BrawlAPI](https://docs.brawlapi.cf), the unofficial Brawl Stars API.
4
7
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "brawlapirb"
4
+ require "brawlstars"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
  spec.required_ruby_version = '>= 2.0.0'
22
- spec.post_install_message = "Brawlstarsrb is my name, GETting is my game!"
22
+ spec.post_install_message = "Brawlstarsrb is my name, making API requests is my game!"
23
23
  spec.metadata = {
24
24
  "bug_tracker_uri" => "https://github.com/Karthik99999/brawlstarsrb/issues",
25
25
  "changelog_uri" => "https://github.com/Karthik99999/brawlstarsrb/blob/master/CHANGELOG.md",
@@ -56,11 +56,11 @@ module Brawlstars
56
56
  # Get a player by their tag
57
57
  #
58
58
  # @param tag [String] tag of the player to get.
59
- # @return [Hash] data of the player that was searched.
59
+ # @return [Brawlstars::Player] data of the player that was searched.
60
60
 
61
61
  def getPlayer(tag)
62
62
  tag = validateTag(tag)
63
- get("/player?tag=#{tag}")
63
+ Player.new(self, get("/player?tag=#{tag}"))
64
64
  end
65
65
 
66
66
  # Search for players by their name
@@ -168,7 +168,7 @@ module Brawlstars
168
168
  end
169
169
  case res.code
170
170
  when 200
171
- res
171
+ res.parsed_response
172
172
  when 401
173
173
  raise Error::Unauthorized
174
174
  when 404
@@ -182,4 +182,34 @@ module Brawlstars
182
182
  end
183
183
  end
184
184
  end
185
+ class Player
186
+ def initialize(client, data)
187
+ @client = client
188
+ @data = data
189
+ end
190
+
191
+ def method_missing(name, *args, &block)
192
+ if @data.respond_to?(name)
193
+ @data.send(name, *args, &block)
194
+ else
195
+ super
196
+ end
197
+ end
198
+
199
+ def getClub
200
+ if !@data["club"]
201
+ nil
202
+ else
203
+ @client.getClub(@data["club"]["tag"])
204
+ end
205
+ end
206
+
207
+ def getBattleLog
208
+ @client.getBattleLog(@data["tag"])
209
+ end
210
+
211
+ def to_s
212
+ "#{@data}"
213
+ end
214
+ end
185
215
  end
@@ -10,6 +10,6 @@ end
10
10
 
11
11
  def validateTag(tag)
12
12
  tag = cleanTag(tag)
13
- raise Brawlstars::Error::TagError if !tag.match(/^[0289CGJLPQRUVY]+$/)
13
+ raise Brawlstars::Error::TagError if (!tag.match(/^[0289CGJLPQRUVY]+$/) or tag.length < 3)
14
14
  tag
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module Brawlstars
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brawlstars
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karthik99999
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-07 00:00:00.000000000 Z
11
+ date: 2019-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -80,7 +80,7 @@ metadata:
80
80
  changelog_uri: https://github.com/Karthik99999/brawlstarsrb/blob/master/CHANGELOG.md
81
81
  documentation_uri: https://www.rubydoc.info/github/Karthik99999/brawlstarsrb
82
82
  source_code_uri: https://github.com/Karthik99999/brawlstarsrb
83
- post_install_message: Brawlstarsrb is my name, GETting is my game!
83
+ post_install_message: Brawlstarsrb is my name, making API requests is my game!
84
84
  rdoc_options: []
85
85
  require_paths:
86
86
  - lib