hypixel-ruby 1.0.0 → 1.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hypixel-ruby.rb +23 -5
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03310bf31abcc8b3fd172d40c046a0347f0cd0542ae7f139100838fa571c670b
4
- data.tar.gz: ca6c15aa02c0605d77cebb11b05c1be37b0e320363b770655e1bef655eab753c
3
+ metadata.gz: cc5eef1661db8a5bd9f65bc7407b90124836a659239a3c1b9a09e3fc7d764b7c
4
+ data.tar.gz: 60a506fd7596bc5a2cdde04cc98e1f301eccd969c40c384543d50ab6d9dd3e33
5
5
  SHA512:
6
- metadata.gz: 77d1414e90c8a2f20ec6c16b8c8cd073c82a6989742983280ecabb6c9886b325ebf59a36351db1baa4d364cda7cac8f92401c781e909fe6d9943cac265dcc115
7
- data.tar.gz: 45578ab2a79d9c0daf223c712678b3c3cc954cc306eb921a244241c1e70e4a004e4cf502c1c8dfc69411a08722760dbafd279534c31fdf3cc8158b1a3868b975
6
+ metadata.gz: a5c4092b762ae93a4b8ba66a31866ae958897d6e27b434b04186c6284f6419ced6aac01b3d0356cedf4e1444bf59fcf21de7c7193365978dfa00982e6b17d9d9
7
+ data.tar.gz: 4cc8bfd084722f502e357d0f973934c998bc67ac19c402f8cb73eb759d6abb421c43d2b7656eefdafb7e3c6d4490ee71009f84ad2decdc3d7a277c2dd076a9b0
@@ -1,21 +1,34 @@
1
1
  require 'open-uri'
2
2
  require 'json'
3
+ require 'hashie'
3
4
 
4
- # Base object for the api. Only create one for the entire build as it will one day keep track of your request limits. *All methods are avaible at https://github.com/HypixelDev/PublicAPI/tree/master/Documentation/methods, use arguments are parms.*
5
+ # Base object for the api. Only create one for the entire build as it keeps track of your request limits. <b>All methods are avaible at https://github.com/HypixelDev/PublicAPI/tree/master/Documentation/methods, use arguments are parms.</b>
5
6
  class HypixelAPI
6
7
 
8
+ @min = 60
9
+ @requests = 0
10
+
7
11
  # Parses url to Rubyfiy the request, internal so you won't need to use it for much.
8
12
  def fetch(url)
9
- source = (open URI(url)).read
10
- return JSON.parse(source, :symbolize_names => true)
13
+ if @min != Time.now.min
14
+ @min = Time.now.min
15
+ @requests = 0
16
+ end
17
+ if @requests < 120
18
+ @requests += 1
19
+ source = (open URI(url)).read
20
+ x = JSON.parse(source, :symbolize_names => true)
21
+ x.extend Hashie::Extensions::DeepFind
22
+ return x
23
+ end
11
24
  end
12
25
 
13
- # Creates a new object with your API key. *If requests are failing for you, remember to check your key.*
26
+ # Creates a new object with your API key. <b>If requests are failing for you, remember to check your key.</b>
14
27
  def initialize(api_key)
15
28
  @key = api_key
16
29
  end
17
30
 
18
- # Builds a url from the request type and parameters. *Do not specify your key in the parameters.*
31
+ # Builds a url from the request type and parameters. <b>Do not specify your key in the parameters.</b>
19
32
  def url(type, hash)
20
33
  url = "https://api.hypixel.net/"
21
34
  url << type.to_s
@@ -79,3 +92,8 @@ class HypixelAPI
79
92
  end
80
93
 
81
94
  end
95
+
96
+ if ENV['TRAVIS']
97
+ api = HypixelAPI.new ENV['HYPIXEL_KEY']
98
+ puts api.player( :uuid => ENV['UUID'] ).deep_find(:bedwars_level)
99
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypixel-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PenguinOwl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-09 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Robust, but powerful. Source avaible at https://github.com/PenguinOwl/hypixel-rubyed/
14
28
  email:
15
29
  executables: []