hypixel-ruby 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hypixel-ruby.rb +23 -5
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc5eef1661db8a5bd9f65bc7407b90124836a659239a3c1b9a09e3fc7d764b7c
|
4
|
+
data.tar.gz: 60a506fd7596bc5a2cdde04cc98e1f301eccd969c40c384543d50ab6d9dd3e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5c4092b762ae93a4b8ba66a31866ae958897d6e27b434b04186c6284f6419ced6aac01b3d0356cedf4e1444bf59fcf21de7c7193365978dfa00982e6b17d9d9
|
7
|
+
data.tar.gz: 4cc8bfd084722f502e357d0f973934c998bc67ac19c402f8cb73eb759d6abb421c43d2b7656eefdafb7e3c6d4490ee71009f84ad2decdc3d7a277c2dd076a9b0
|
data/lib/hypixel-ruby.rb
CHANGED
@@ -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
|
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
|
-
|
10
|
-
|
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.
|
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.
|
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.
|
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-
|
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: []
|