dota 0.0.20 → 0.0.21

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.
@@ -5,11 +5,12 @@ module Dota
5
5
 
6
6
  attr_reader :id, :name, :full_name
7
7
 
8
+ alias_method :full_name, :name
9
+
8
10
  def initialize(id)
9
11
  @id = id
10
12
  @internal_name = mapping[id][0]
11
- @name = mapping[id][1]
12
- @full_name = mapping[id][2]
13
+ @name = mapping[id][1] || @internal_name
13
14
  end
14
15
 
15
16
  def image_url(type = :lg)
@@ -18,11 +19,7 @@ module Dota
18
19
  # :hp2 - 105x105 PNG image
19
20
  # :lg - 128x128 PNG image
20
21
 
21
- if internal_name == 'stats'
22
- "https://steamcdn-a.akamaihd.net/apps/dota2/images/workshop/itembuilder/stats.png"
23
- else
24
- "http://cdn.dota2.com/apps/dota2/images/abilities/#{internal_name}_#{type}.png"
25
- end
22
+ "http://cdn.dota2.com/apps/dota2/images/abilities/#{internal_name}_#{type}.png"
26
23
  end
27
24
 
28
25
  private
@@ -30,4 +27,4 @@ module Dota
30
27
  attr_reader :internal_name
31
28
  end
32
29
  end
33
- end
30
+ end
@@ -28,7 +28,7 @@ module Dota
28
28
  if options.is_a?(Integer)
29
29
  id = options
30
30
  response = get("IDOTA2Match_570", "GetTeamInfoByTeamID", start_at_team_id: id, teams_requested: 1)["result"]["teams"][0]
31
- Team.new(response) if response
31
+ Team.new(response) if response && id == response["team_id"]
32
32
  else
33
33
  options[:start_at_team_id] = options.delete(:after) if options[:after]
34
34
  options[:teams_requested] = options.delete(:limit) if options[:limit]
@@ -1,3 +1,3 @@
1
1
  module Dota
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
3
3
  end
@@ -4,19 +4,28 @@ RSpec.describe Dota::API::Ability do
4
4
  specify ".all" do
5
5
  abilities = described_class.all
6
6
  expect(abilities.first).to be_a described_class
7
- expect(abilities.count).to eq 570
7
+ expect(abilities.count).to eq 1077
8
8
  end
9
9
 
10
10
  specify "#id" do
11
11
  expect(ability.id).to eq 5003
12
12
  end
13
13
 
14
- specify "#name" do
15
- expect(ability.name).to eq "Mana Break"
14
+ describe "#name" do
15
+ specify "returns a human-friendly name" do
16
+ expect(ability.name).to eq "Mana Break"
17
+ end
18
+
19
+ specify "falls back to internal name" do
20
+ ability = described_class.new(9993)
21
+ expect(ability.name).to eq "roshan_halloween_wave_of_force"
22
+ end
16
23
  end
17
24
 
18
25
  specify "#full_name" do
19
- expect(ability.full_name).to eq "Antimage Mana Break"
26
+ # DEPRECATED: Used to just concatenate hero name
27
+ # with ability (e.g., "Antimage Mana Break")
28
+ expect(ability.full_name).to eq "Mana Break"
20
29
  end
21
30
 
22
31
  specify "#image_url" do
@@ -4,7 +4,7 @@ RSpec.describe Dota::API::Hero do
4
4
  specify ".all" do
5
5
  heroes = described_class.all
6
6
  expect(heroes.first).to be_a described_class
7
- expect(heroes.count).to eq 111
7
+ expect(heroes.count).to eq 113
8
8
  end
9
9
 
10
10
  specify ".find" do
@@ -4,7 +4,7 @@ RSpec.describe Dota::API::Item do
4
4
  specify ".all" do
5
5
  items = described_class.all
6
6
  expect(items.first).to be_a described_class
7
- expect(items.count).to eq 275
7
+ expect(items.count).to eq 282
8
8
  end
9
9
 
10
10
  specify "#id" do
@@ -51,7 +51,7 @@ RSpec.describe Dota do
51
51
  end
52
52
  end
53
53
 
54
- describe "#matches" do
54
+ describe "#teams" do
55
55
  context "given an id" do
56
56
  it "returns a single team" do
57
57
  VCR.use_cassette("GetTeamInfoByTeamID") do
@@ -76,8 +76,8 @@ RSpec.describe Dota do
76
76
  after: :start_at_team_id,
77
77
  limit: :teams_requested
78
78
  }
79
- accepted_params.each do |local, remote|
80
79
 
80
+ accepted_params.each do |local, remote|
81
81
  specify ":#{local} should translate to :#{remote}" do
82
82
  random_value = SecureRandom.hex
83
83
  VCR.use_cassette("GetTeamInfoByTeamID") do
@@ -87,6 +87,27 @@ RSpec.describe Dota do
87
87
  end
88
88
  end
89
89
  end
90
+
91
+ context "when team cannot be found" do
92
+ around do |example|
93
+ VCR.use_cassette("GetMatchDetails") do
94
+ example.run
95
+ end
96
+ end
97
+
98
+ it "returns nil when api returns a different team" do
99
+ different_team_id = sample_team_id + 1
100
+ response = {
101
+ "result" => {
102
+ "status" => 1,
103
+ "teams" => [{ "team_id" => different_team_id }],
104
+ },
105
+ }
106
+ expect(api).to receive(:get).with("IDOTA2Match_570", "GetTeamInfoByTeamID", start_at_team_id: sample_team_id, teams_requested: 1) { response }
107
+ team = api.teams(sample_team_id)
108
+ expect(team).to eq nil
109
+ end
110
+ end
90
111
  end
91
112
 
92
113
  specify "#leagues" do
@@ -111,8 +132,8 @@ RSpec.describe Dota do
111
132
  from: :date_min,
112
133
  to: :date_max
113
134
  }
114
- accepted_params.each do |local, remote|
115
135
 
136
+ accepted_params.each do |local, remote|
116
137
  specify ":#{local} should translate to :#{remote}" do
117
138
  random_value = SecureRandom.hex
118
139
  VCR.use_cassette("GetScheduledLeagueGames") do
@@ -139,8 +160,8 @@ RSpec.describe Dota do
139
160
  league_id: :league_id,
140
161
  match_id: :match_id
141
162
  }
142
- accepted_params.each do |local, remote|
143
163
 
164
+ accepted_params.each do |local, remote|
144
165
  specify ":#{local} should translate to :#{remote}" do
145
166
  random_value = SecureRandom.hex
146
167
  VCR.use_cassette("GetLiveLeagueGames") do
@@ -168,9 +189,9 @@ RSpec.describe Dota do
168
189
  end
169
190
  end
170
191
 
171
- describe "#teams" do
192
+ describe "#matches" do
172
193
  context "given an id" do
173
- it "returns a single team" do
194
+ it "returns a single match" do
174
195
  VCR.use_cassette("GetMatchDetails") do
175
196
  match = api.matches(sample_match_id)
176
197
  expect(match).to be_a Dota::API::Match
@@ -201,8 +222,8 @@ RSpec.describe Dota do
201
222
  limit: :matches_requested,
202
223
  league_only: :tournament_games_only
203
224
  }
204
- accepted_params.each do |local, remote|
205
225
 
226
+ accepted_params.each do |local, remote|
206
227
  specify ":#{local} should translate to :#{remote}" do
207
228
  random_value = SecureRandom.hex
208
229
  VCR.use_cassette("GetMatchHistory") do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dota
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinni Carlo Caños
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2017-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets
@@ -171,7 +171,7 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
- - ".env.sample"
174
+ - ".env.example"
175
175
  - ".gitignore"
176
176
  - ".rspec"
177
177
  - ".travis.yml"