dota_leagues_api 1.0.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 +7 -0
- data/lib/dota_leagues_api.rb +14 -0
- data/lib/dota_leagues_api_client.rb +21 -0
- data/lib/models/league.rb +21 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 777ebf434ee6f5296ac8a0ccbd2dda395ae9bdd087dd0febc10e4739f09efe53
|
4
|
+
data.tar.gz: db0c74b33d681278dbd53ec21d75ca0c13f46eb2c7f1675e7fcfd63460b02432
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fbe460e39b4e24b9bd93e085d5db2c5486cf66ec9b9a57f78843bc4408233bddf18fbb38f1fc951d1cda35adbc0faea076e6022200104d4e452c615eff0e0b4c
|
7
|
+
data.tar.gz: 30ceffd4674d5fef34cf2c39195fbeda7e3d1a412d2ab632d2667b9eef1694c14391b644e82708091b9f278a33f011b23e12c3cfd1042e35a8004b7b9e8f09eb
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
require_relative 'models/league'
|
5
|
+
require_relative 'dota_leagues_api_client'
|
6
|
+
|
7
|
+
module DotaLeaguesApi
|
8
|
+
DOTALEAGUESAPICLIENT = DotaLeaguesApiClient.new
|
9
|
+
|
10
|
+
def self.leagues
|
11
|
+
leagues = DOTALEAGUESAPICLIENT.call
|
12
|
+
leagues.map { |league| League.new(league) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DotaLeaguesApi
|
2
|
+
class DotaLeaguesApiClient
|
3
|
+
|
4
|
+
URL = 'https://dota-leagues.27n.gg/leagues?offset=0&limit=100'
|
5
|
+
|
6
|
+
def call
|
7
|
+
leagues = get_dota_leagues_api
|
8
|
+
|
9
|
+
if leagues.headers['x-ratelimit-remaining'].to_i < 0
|
10
|
+
sleep leagues.headers['x-ratelimit-reset'].to_i
|
11
|
+
call
|
12
|
+
else
|
13
|
+
leagues['results']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_dota_leagues_api
|
18
|
+
HTTParty.get(URL)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module DotaLeaguesApi
|
2
|
+
class League
|
3
|
+
|
4
|
+
attr_reader :league_id, :name, :tier, :region, :url, :description, :start_timestamp,
|
5
|
+
:end_timestamp, :status, :total_prize_pool, :is_live
|
6
|
+
|
7
|
+
def initialize(attributes)
|
8
|
+
@total_prize_pool = attributes['total_prize_pool']
|
9
|
+
@start_timestamp = attributes['start_timestamp']
|
10
|
+
@end_timestamp = attributes['end_timestamp']
|
11
|
+
@description = attributes['description']
|
12
|
+
@league_id = attributes['league_id']
|
13
|
+
@is_live = attributes['is_live']
|
14
|
+
@region = attributes['region']
|
15
|
+
@status = attributes['status']
|
16
|
+
@name = attributes['name']
|
17
|
+
@tier = attributes['tier']
|
18
|
+
@url = attributes['url']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dota_leagues_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleksii Protsenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/dota_leagues_api.rb
|
20
|
+
- lib/dota_leagues_api_client.rb
|
21
|
+
- lib/models/league.rb
|
22
|
+
homepage: https://github.com/railkun/dota_leagues_api
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.0.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: DotaLeaguesApi - Simple gem for parse dota leagues
|
45
|
+
test_files: []
|