open_dota_api 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -0
- data/lib/open_dota_api.rb +1 -0
- data/lib/open_dota_api/entity.rb +7 -0
- data/lib/open_dota_api/hero.rb +1 -30
- data/lib/open_dota_api/league.rb +0 -2
- data/lib/open_dota_api/match.rb +5 -1
- data/lib/open_dota_api/team.rb +1 -30
- data/lib/open_dota_api/version.rb +1 -1
- data/spec/lib/open_dota_api/match_spec.rb +2 -2
- data/spec/lib/open_dota_api/matches/player_spec.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46e4d4e73a745680d8a4c2e06fa6e300886ccb53
|
4
|
+
data.tar.gz: 60b2b5404aa7125b2a805c9a69bc59ae0ad949e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b2fac68e691847a93f71fdfa20e80dd3fab5aeeecc925600ce71076d396510f47fd7573e3e63ada57de605b9874cbd2cecd74f6e6d9e9e1e467f7da4c233777
|
7
|
+
data.tar.gz: c9d7a4c6122c944e09569c69e7f608b3f8ea6f4de9f770d4b3b3a812e1af89dd5acdebfb9a8678b36bd46da945a74434944794334ce3f10660cf44a1dd161d5a
|
data/Rakefile
ADDED
data/lib/open_dota_api.rb
CHANGED
data/lib/open_dota_api/entity.rb
CHANGED
@@ -3,8 +3,15 @@ require 'hashable'
|
|
3
3
|
|
4
4
|
module OpenDotaApi
|
5
5
|
class Entity
|
6
|
+
include Entities::Instantiatable
|
6
7
|
include ::Hashable
|
7
8
|
|
9
|
+
def self.define_adder(attributes)
|
10
|
+
attributes.each do |attribute|
|
11
|
+
define_method(attribute) { data[attribute] }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
def initialize(data)
|
9
16
|
@data = data
|
10
17
|
end
|
data/lib/open_dota_api/hero.rb
CHANGED
@@ -2,36 +2,7 @@ require 'open_dota_api/entity'
|
|
2
2
|
|
3
3
|
module OpenDotaApi
|
4
4
|
class Hero < Entity
|
5
|
-
include Entities::Instantiatable
|
6
|
-
|
7
5
|
ENDPOINT = 'heroes'.freeze
|
8
|
-
|
9
|
-
def id
|
10
|
-
data['id']
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
data['name']
|
15
|
-
end
|
16
|
-
|
17
|
-
def localized_name
|
18
|
-
data['localized_name']
|
19
|
-
end
|
20
|
-
|
21
|
-
def primary_attr
|
22
|
-
data['primary_attr']
|
23
|
-
end
|
24
|
-
|
25
|
-
def attack_type
|
26
|
-
data['attack_type']
|
27
|
-
end
|
28
|
-
|
29
|
-
def roles
|
30
|
-
data['roles']
|
31
|
-
end
|
32
|
-
|
33
|
-
def legs
|
34
|
-
data['legs']
|
35
|
-
end
|
6
|
+
define_adder(%w[id name localized_name primary_attr attack_type roles legs])
|
36
7
|
end
|
37
8
|
end
|
data/lib/open_dota_api/league.rb
CHANGED
data/lib/open_dota_api/match.rb
CHANGED
@@ -5,6 +5,10 @@ module OpenDotaApi
|
|
5
5
|
class Match < Entity
|
6
6
|
ENDPOINT = 'matches'.freeze
|
7
7
|
|
8
|
+
def self.instantiate(_ = nil)
|
9
|
+
raise NotImplementedError
|
10
|
+
end
|
11
|
+
|
8
12
|
def match_id
|
9
13
|
data['match_id']
|
10
14
|
end
|
@@ -62,7 +66,7 @@ module OpenDotaApi
|
|
62
66
|
end
|
63
67
|
|
64
68
|
def players
|
65
|
-
data['players']
|
69
|
+
Player.instantiate(data['players'])
|
66
70
|
end
|
67
71
|
|
68
72
|
class Player < Matches::Player; end
|
data/lib/open_dota_api/team.rb
CHANGED
@@ -2,36 +2,7 @@ require 'open_dota_api/entity'
|
|
2
2
|
|
3
3
|
module OpenDotaApi
|
4
4
|
class Team < Entity
|
5
|
-
include Entities::Instantiatable
|
6
|
-
|
7
5
|
ENDPOINT = 'teams'.freeze
|
8
|
-
|
9
|
-
def team_id
|
10
|
-
data['team_id']
|
11
|
-
end
|
12
|
-
|
13
|
-
def rating
|
14
|
-
data['rating']
|
15
|
-
end
|
16
|
-
|
17
|
-
def wins
|
18
|
-
data['wins']
|
19
|
-
end
|
20
|
-
|
21
|
-
def losses
|
22
|
-
data['losses']
|
23
|
-
end
|
24
|
-
|
25
|
-
def last_match_time
|
26
|
-
data['last_match_time']
|
27
|
-
end
|
28
|
-
|
29
|
-
def name
|
30
|
-
data['name']
|
31
|
-
end
|
32
|
-
|
33
|
-
def tag
|
34
|
-
data['tag']
|
35
|
-
end
|
6
|
+
define_adder(%w[team_id rating wins losses last_match_time name tag])
|
36
7
|
end
|
37
8
|
end
|
@@ -30,8 +30,8 @@ describe OpenDotaApi::Match do
|
|
30
30
|
expect(match).to be_a OpenDotaApi::Entity
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'is instantiable' do
|
34
|
-
expect
|
33
|
+
it 'is not instantiable' do
|
34
|
+
expect{ described_class.instantiate }.to raise_error NotImplementedError
|
35
35
|
end
|
36
36
|
|
37
37
|
describe 'default attributes' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_dota_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Oslavskiy
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Ruby wrapper for Open Dota API
|
112
126
|
email:
|
113
127
|
- osyaroslav@gmail.com.com
|
@@ -116,6 +130,7 @@ extensions: []
|
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
118
132
|
- MIT-LICENSE
|
133
|
+
- Rakefile
|
119
134
|
- lib/open_dota_api.rb
|
120
135
|
- lib/open_dota_api/client.rb
|
121
136
|
- lib/open_dota_api/connection.rb
|
@@ -160,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
175
|
version: '0'
|
161
176
|
requirements: []
|
162
177
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.5.1
|
164
179
|
signing_key:
|
165
180
|
specification_version: 4
|
166
181
|
summary: Ruby wrapper for Open Dota API
|