lolbase 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 708c18aa4e274519bc08c3a9deae56e6dc099668
4
- data.tar.gz: 068468dbe4dc6666386c5769326b96a52012be06
3
+ metadata.gz: 7a49ed32c4c1ccd4718531f24d30f594c52df75d
4
+ data.tar.gz: 9bbe4fcafbbc4a328f657cf5a3284c4174e13b17
5
5
  SHA512:
6
- metadata.gz: f990c2b130ff55f39f7df452a6495a77b365980aaab9253a53916ffa39ae8cb1f166ddf9f1cc7751f9e79f4f64ca542777f7faa771aabbba928b2038b79d481a
7
- data.tar.gz: b1531ccfe5e5f3fa317aed49902cb19fd3822a5271606514a029d52500ca0e23c573a35facabab0c39c2d708755b3bf9ad26267410a49002e637bfb8fdfcadb2
6
+ metadata.gz: d878ba2e3a051d84c832c479354dfbd8c8c7149d0dbf7bf50ce1de12dd50ee27d2d2ec5cd2a26ef4007cdc5456f96e5df63ef20dee3e95b2a6f29426632150f3
7
+ data.tar.gz: 2bfefaf72317eea4cc9ebc1adb53445413bec405b915cb6b2ddb84e367b0d6f1d2de6963ba6735c87eb2b349bcf0b85386bc4b35d82ab3931af070fff17b7286
data/README.md CHANGED
@@ -25,14 +25,16 @@ LoLBase can be globally configured through the *LoLBase::configure* method. The
25
25
  config.default_region = "na" # Default region for summoner lookup
26
26
  config.default_key = nil # Default API key
27
27
 
28
- # Latest versions of the API provided by Riot. These values can
29
- # be changed for backward compatibility.
28
+ # Determines which API version to use
30
29
  config.version_champion = "1.1"
31
- config.version_game = "1.1"
32
- config.version_league = "2.1"
33
- config.version_stats = "1.1"
34
- config.version_summoner = "1.1"
35
- config.version_team = "2.1"
30
+ config.version_game = "1.2"
31
+ config.version_league = "2.2"
32
+ config.version_stats = "1.2"
33
+ config.version_summoner = "1.2"
34
+ config.version_team = "2.2"
35
+
36
+ # Current season - used as a default value for ranked stats
37
+ config.current_season = "3"
36
38
  end
37
39
 
38
40
  ### 2. Connection
@@ -62,6 +64,16 @@ All connections begin by calling *LoLBase::new* which takes an API key as an arg
62
64
 
63
65
  summoner.profile_icon.id
64
66
 
67
+ #### 3.3 Statistics
68
+
69
+ # A specified ranked season is passed - defaults to LoLBase.config.current_season
70
+ summary = summoner.stats.summary(3)
71
+ ranked = summoner.stats.ranked(3)
72
+
73
+ # JSON data from the API is returned, parsed as a Ruby object
74
+ summary["playerStatSummaries"]
75
+ ranked["champions"]
76
+
65
77
  ## Resources
66
78
 
67
79
  * Official API Reference: [https://developer.riotgames.com/api/methods](https://developer.riotgames.com/api/methods)
@@ -4,4 +4,5 @@ require "lolbase/error"
4
4
  require "lolbase/version"
5
5
 
6
6
  require "lolbase/data/summoner"
7
- require "lolbase/data/profile_icon"
7
+ require "lolbase/data/profile_icon"
8
+ require "lolbase/data/stats"
@@ -15,7 +15,8 @@ module LoLBase
15
15
  :version_league,
16
16
  :version_stats,
17
17
  :version_summoner,
18
- :version_team
18
+ :version_team,
19
+ :current_season
19
20
  end
20
21
 
21
22
  # Default config values
@@ -23,10 +24,12 @@ module LoLBase
23
24
  config.default_region = "na"
24
25
 
25
26
  config.version_champion = "1.1"
26
- config.version_game = "1.1"
27
- config.version_league = "2.1"
28
- config.version_stats = "1.1"
29
- config.version_summoner = "1.1"
30
- config.version_team = "2.1"
27
+ config.version_game = "1.2"
28
+ config.version_league = "2.2"
29
+ config.version_stats = "1.2"
30
+ config.version_summoner = "1.2"
31
+ config.version_team = "2.2"
32
+
33
+ config.current_season = "3"
31
34
  end
32
35
  end
@@ -5,6 +5,7 @@ module LoLBase
5
5
  def initialize(id, summoner)
6
6
  @id = id
7
7
  @summoner = summoner
8
+ self
8
9
  end
9
10
  end
10
11
  end
@@ -0,0 +1,32 @@
1
+ require "json"
2
+
3
+ module LoLBase
4
+ class Stats
5
+ # Input
6
+ # - summoner - A Summoner object
7
+ # - connection - Current connection to Riot's API
8
+ #
9
+ # Output: Returns a Stats object for further chaining
10
+ def initialize(summoner, connection)
11
+ @summoner = summoner
12
+ @connection = connection
13
+ self
14
+ end
15
+
16
+ def summary(season = LoLBase.config.current_season)
17
+ response = @connection.get(
18
+ "/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/summary",
19
+ { query: { season: "SEASON#{season}" } }
20
+ )
21
+ JSON.parse response
22
+ end
23
+
24
+ def ranked(season = LoLBase.config.current_season)
25
+ response = @connection.get(
26
+ "/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/ranked",
27
+ { query: { season: "SEASON#{season}" } }
28
+ )
29
+ JSON.parse response
30
+ end
31
+ end
32
+ end
@@ -2,29 +2,33 @@ require "json"
2
2
 
3
3
  module LoLBase
4
4
  class Summoner
5
- attr_reader :id, :name, :profile_icon, :last_modified, :level, :region
5
+ attr_reader :id, :name, :last_modified, :level, :region
6
6
 
7
7
  # Input
8
- # - params - A hash containing either a summoner name or ID and the region that they belong to
9
- # (e.g. { id: 123, region: "na" })
8
+ # - params - A hash containing either a summoner name or ID, the region that they belong to,
9
+ # and whether to preload the object with Riot's data (e.g. { id: 123, region: "na", preload: false })
10
10
  # - connection - Current connection to the Riot API
11
11
  #
12
- # Effects: Calls the Riot API to retrieve data for the given summoner
13
- #
14
- # Output: Returns the Summoner class for further chaining
12
+ # Output: Returns a Summoner object for further chaining
15
13
  def initialize(params, connection)
16
14
  @id = params[:id]
17
15
  @name = params[:name]
18
16
  @region = params[:region]
19
17
  @connection = connection
20
18
 
19
+ load unless params[:preload] == false
20
+
21
+ self
22
+ end
23
+
24
+ def load
21
25
  response =
22
26
  if !@id.nil?
23
27
  # Find summoner by ID
24
- connection.get "/api/lol/#{@region}/v#{LoLBase.config.version_summoner}/summoner/#{@id}"
28
+ @connection.get "/api/lol/#{@region}/v#{LoLBase.config.version_summoner}/summoner/#{@id}"
25
29
  else
26
30
  # Find summoner by name
27
- connection.get "/api/lol/#{@region}/v#{LoLBase.config.version_summoner}/summoner/by-name/#{@name}"
31
+ @connection.get "/api/lol/#{@region}/v#{LoLBase.config.version_summoner}/summoner/by-name/#{@name}"
28
32
  end
29
33
 
30
34
  # Populate object with response data
@@ -34,8 +38,14 @@ module LoLBase
34
38
  @profile_icon = ProfileIcon.new data["profileIconId"], self
35
39
  @last_modified = Time.at(data["revisionDate"] / 1000)
36
40
  @level = data["summonerLevel"]
41
+ end
37
42
 
38
- self
43
+ def profile_icon
44
+ return @profile_icon || ProfileIcon.new(nil, self)
45
+ end
46
+
47
+ def stats
48
+ return @stats || Stats.new(self, @connection)
39
49
  end
40
50
  end
41
51
  end
@@ -1,3 +1,3 @@
1
1
  module LoLBase
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,341 @@
1
+ {
2
+ "modifyDate": 1384212356000,
3
+ "champions": [
4
+ {
5
+ "id": 40,
6
+ "stats": {
7
+ "totalSessionsPlayed": 8,
8
+ "totalDamageTaken": 106866,
9
+ "totalQuadraKills": 0,
10
+ "totalTripleKills": 0,
11
+ "totalMinionKills": 153,
12
+ "maxChampionsKilled": 3,
13
+ "totalDoubleKills": 1,
14
+ "totalPhysicalDamageDealt": 53461,
15
+ "totalChampionKills": 8,
16
+ "totalAssists": 91,
17
+ "mostChampionKillsPerSession": 3,
18
+ "totalDamageDealt": 134591,
19
+ "totalFirstBlood": 0,
20
+ "totalSessionsLost": 5,
21
+ "totalSessionsWon": 3,
22
+ "totalMagicDamageDealt": 80671,
23
+ "totalGoldEarned": 64568,
24
+ "totalPentaKills": 0,
25
+ "totalTurretsKilled": 6,
26
+ "mostSpellsCast": 0,
27
+ "totalUnrealKills": 0
28
+ },
29
+ "name": "Janna"
30
+ },
31
+ {
32
+ "id": 53,
33
+ "stats": {
34
+ "totalSessionsPlayed": 1,
35
+ "totalDamageTaken": 26581,
36
+ "totalQuadraKills": 0,
37
+ "totalTripleKills": 0,
38
+ "totalMinionKills": 53,
39
+ "maxChampionsKilled": 2,
40
+ "totalDoubleKills": 0,
41
+ "totalPhysicalDamageDealt": 11064,
42
+ "totalChampionKills": 2,
43
+ "totalAssists": 13,
44
+ "mostChampionKillsPerSession": 2,
45
+ "totalDamageDealt": 53751,
46
+ "totalFirstBlood": 0,
47
+ "totalSessionsLost": 1,
48
+ "totalSessionsWon": 0,
49
+ "totalMagicDamageDealt": 42686,
50
+ "totalGoldEarned": 8241,
51
+ "totalPentaKills": 0,
52
+ "totalTurretsKilled": 0,
53
+ "mostSpellsCast": 0,
54
+ "totalUnrealKills": 0
55
+ },
56
+ "name": "Blitzcrank"
57
+ },
58
+ {
59
+ "id": 25,
60
+ "stats": {
61
+ "totalSessionsPlayed": 1,
62
+ "totalDamageTaken": 5219,
63
+ "totalQuadraKills": 0,
64
+ "totalTripleKills": 0,
65
+ "totalMinionKills": 124,
66
+ "maxChampionsKilled": 0,
67
+ "totalDoubleKills": 0,
68
+ "totalPhysicalDamageDealt": 13275,
69
+ "totalChampionKills": 0,
70
+ "totalAssists": 2,
71
+ "mostChampionKillsPerSession": 0,
72
+ "totalDamageDealt": 67455,
73
+ "totalFirstBlood": 0,
74
+ "totalSessionsLost": 0,
75
+ "totalSessionsWon": 1,
76
+ "totalMagicDamageDealt": 54179,
77
+ "totalGoldEarned": 6253,
78
+ "totalPentaKills": 0,
79
+ "totalTurretsKilled": 1,
80
+ "mostSpellsCast": 0,
81
+ "totalUnrealKills": 0
82
+ },
83
+ "name": "Morgana"
84
+ },
85
+ {
86
+ "id": 37,
87
+ "stats": {
88
+ "totalSessionsPlayed": 3,
89
+ "totalDamageTaken": 43589,
90
+ "totalQuadraKills": 0,
91
+ "totalTripleKills": 0,
92
+ "totalMinionKills": 55,
93
+ "maxChampionsKilled": 2,
94
+ "totalDoubleKills": 1,
95
+ "totalPhysicalDamageDealt": 21015,
96
+ "totalChampionKills": 3,
97
+ "totalAssists": 28,
98
+ "mostChampionKillsPerSession": 2,
99
+ "totalDamageDealt": 61897,
100
+ "totalFirstBlood": 0,
101
+ "totalSessionsLost": 2,
102
+ "totalSessionsWon": 1,
103
+ "totalMagicDamageDealt": 40272,
104
+ "totalGoldEarned": 21253,
105
+ "totalPentaKills": 0,
106
+ "totalTurretsKilled": 0,
107
+ "mostSpellsCast": 0,
108
+ "totalUnrealKills": 0
109
+ },
110
+ "name": "Sona"
111
+ },
112
+ {
113
+ "id": 64,
114
+ "stats": {
115
+ "totalSessionsPlayed": 1,
116
+ "totalDamageTaken": 14803,
117
+ "totalQuadraKills": 0,
118
+ "totalTripleKills": 0,
119
+ "totalMinionKills": 15,
120
+ "maxChampionsKilled": 0,
121
+ "totalDoubleKills": 0,
122
+ "totalPhysicalDamageDealt": 24779,
123
+ "totalChampionKills": 0,
124
+ "totalAssists": 0,
125
+ "mostChampionKillsPerSession": 0,
126
+ "totalDamageDealt": 59879,
127
+ "totalFirstBlood": 0,
128
+ "totalSessionsLost": 1,
129
+ "totalSessionsWon": 0,
130
+ "totalMagicDamageDealt": 25946,
131
+ "totalGoldEarned": 4612,
132
+ "totalPentaKills": 0,
133
+ "totalTurretsKilled": 0,
134
+ "mostSpellsCast": 0,
135
+ "totalUnrealKills": 0
136
+ },
137
+ "name": "LeeSin"
138
+ },
139
+ {
140
+ "id": 102,
141
+ "stats": {
142
+ "totalSessionsPlayed": 2,
143
+ "totalDamageTaken": 23885,
144
+ "totalQuadraKills": 0,
145
+ "totalTripleKills": 0,
146
+ "totalMinionKills": 64,
147
+ "maxChampionsKilled": 5,
148
+ "totalDoubleKills": 1,
149
+ "totalPhysicalDamageDealt": 41614,
150
+ "totalChampionKills": 6,
151
+ "totalAssists": 2,
152
+ "mostChampionKillsPerSession": 5,
153
+ "totalDamageDealt": 146809,
154
+ "totalFirstBlood": 0,
155
+ "totalSessionsLost": 2,
156
+ "totalSessionsWon": 0,
157
+ "totalMagicDamageDealt": 91924,
158
+ "totalGoldEarned": 11081,
159
+ "totalPentaKills": 0,
160
+ "totalTurretsKilled": 0,
161
+ "mostSpellsCast": 0,
162
+ "totalUnrealKills": 0
163
+ },
164
+ "name": "Shyvana"
165
+ },
166
+ {
167
+ "id": 99,
168
+ "stats": {
169
+ "totalSessionsPlayed": 17,
170
+ "totalDamageTaken": 179934,
171
+ "totalQuadraKills": 0,
172
+ "totalTripleKills": 0,
173
+ "totalMinionKills": 2643,
174
+ "maxChampionsKilled": 13,
175
+ "totalDoubleKills": 11,
176
+ "totalPhysicalDamageDealt": 321832,
177
+ "totalChampionKills": 88,
178
+ "totalAssists": 165,
179
+ "mostChampionKillsPerSession": 13,
180
+ "totalDamageDealt": 2199434,
181
+ "totalFirstBlood": 0,
182
+ "totalSessionsLost": 7,
183
+ "totalSessionsWon": 10,
184
+ "totalMagicDamageDealt": 1873423,
185
+ "totalGoldEarned": 190994,
186
+ "totalPentaKills": 0,
187
+ "totalTurretsKilled": 13,
188
+ "mostSpellsCast": 0,
189
+ "totalUnrealKills": 0
190
+ },
191
+ "name": "Lux"
192
+ },
193
+ {
194
+ "id": 105,
195
+ "stats": {
196
+ "totalSessionsPlayed": 1,
197
+ "totalDamageTaken": 9619,
198
+ "totalQuadraKills": 0,
199
+ "totalTripleKills": 0,
200
+ "totalMinionKills": 76,
201
+ "maxChampionsKilled": 2,
202
+ "totalDoubleKills": 0,
203
+ "totalPhysicalDamageDealt": 17500,
204
+ "totalChampionKills": 2,
205
+ "totalAssists": 2,
206
+ "mostChampionKillsPerSession": 2,
207
+ "totalDamageDealt": 44702,
208
+ "totalFirstBlood": 0,
209
+ "totalSessionsLost": 1,
210
+ "totalSessionsWon": 0,
211
+ "totalMagicDamageDealt": 27164,
212
+ "totalGoldEarned": 4833,
213
+ "totalPentaKills": 0,
214
+ "totalTurretsKilled": 0,
215
+ "mostSpellsCast": 0,
216
+ "totalUnrealKills": 0
217
+ },
218
+ "name": "Fizz"
219
+ },
220
+ {
221
+ "id": 51,
222
+ "stats": {
223
+ "totalSessionsPlayed": 8,
224
+ "totalDamageTaken": 112996,
225
+ "totalQuadraKills": 0,
226
+ "totalTripleKills": 0,
227
+ "totalMinionKills": 1265,
228
+ "maxChampionsKilled": 17,
229
+ "totalDoubleKills": 12,
230
+ "totalPhysicalDamageDealt": 1075380,
231
+ "totalChampionKills": 69,
232
+ "totalAssists": 65,
233
+ "mostChampionKillsPerSession": 17,
234
+ "totalDamageDealt": 1096010,
235
+ "totalFirstBlood": 0,
236
+ "totalSessionsLost": 1,
237
+ "totalSessionsWon": 7,
238
+ "totalMagicDamageDealt": 13193,
239
+ "totalGoldEarned": 93276,
240
+ "totalPentaKills": 0,
241
+ "totalTurretsKilled": 19,
242
+ "mostSpellsCast": 0,
243
+ "totalUnrealKills": 0
244
+ },
245
+ "name": "Caitlyn"
246
+ },
247
+ {
248
+ "id": 18,
249
+ "stats": {
250
+ "totalSessionsPlayed": 2,
251
+ "totalDamageTaken": 25091,
252
+ "totalQuadraKills": 0,
253
+ "totalTripleKills": 0,
254
+ "totalMinionKills": 320,
255
+ "maxChampionsKilled": 8,
256
+ "totalDoubleKills": 1,
257
+ "totalPhysicalDamageDealt": 154508,
258
+ "totalChampionKills": 11,
259
+ "totalAssists": 5,
260
+ "mostChampionKillsPerSession": 8,
261
+ "totalDamageDealt": 215724,
262
+ "totalFirstBlood": 0,
263
+ "totalSessionsLost": 1,
264
+ "totalSessionsWon": 1,
265
+ "totalMagicDamageDealt": 61024,
266
+ "totalGoldEarned": 20094,
267
+ "totalPentaKills": 0,
268
+ "totalTurretsKilled": 2,
269
+ "mostSpellsCast": 0,
270
+ "totalUnrealKills": 0
271
+ },
272
+ "name": "Tristana"
273
+ },
274
+ {
275
+ "id": 31,
276
+ "stats": {
277
+ "totalSessionsPlayed": 2,
278
+ "totalDamageTaken": 35275,
279
+ "totalQuadraKills": 0,
280
+ "totalTripleKills": 0,
281
+ "totalMinionKills": 72,
282
+ "maxChampionsKilled": 5,
283
+ "totalDoubleKills": 0,
284
+ "totalPhysicalDamageDealt": 32486,
285
+ "totalChampionKills": 7,
286
+ "totalAssists": 6,
287
+ "mostChampionKillsPerSession": 5,
288
+ "totalDamageDealt": 160179,
289
+ "totalFirstBlood": 0,
290
+ "totalSessionsLost": 1,
291
+ "totalSessionsWon": 1,
292
+ "totalMagicDamageDealt": 103447,
293
+ "totalGoldEarned": 13325,
294
+ "totalPentaKills": 0,
295
+ "totalTurretsKilled": 0,
296
+ "mostSpellsCast": 0,
297
+ "totalUnrealKills": 0
298
+ },
299
+ "name": "Chogath"
300
+ },
301
+ {
302
+ "id": 0,
303
+ "stats": {
304
+ "totalDamageTaken": 583858,
305
+ "totalTripleKills": 0,
306
+ "totalMinionKills": 4840,
307
+ "maxChampionsKilled": 17,
308
+ "maxLargestCriticalStrike": 1359,
309
+ "totalChampionKills": 196,
310
+ "totalPhysicalDamageDealt": 1766914,
311
+ "rankedPremadeGamesPlayed": 0,
312
+ "totalSessionsLost": 22,
313
+ "totalNeutralMinionsKilled": 691,
314
+ "totalSessionsWon": 24,
315
+ "totalMagicDamageDealt": 2413929,
316
+ "maxLargestKillingSpree": 17,
317
+ "totalPentaKills": 0,
318
+ "maxTimeSpentLiving": 2122,
319
+ "totalQuadraKills": 0,
320
+ "totalSessionsPlayed": 46,
321
+ "totalDoubleKills": 27,
322
+ "totalAssists": 379,
323
+ "maxTimePlayed": 3391,
324
+ "mostChampionKillsPerSession": 17,
325
+ "totalDamageDealt": 4240431,
326
+ "botGamesPlayed": 0,
327
+ "killingSpree": 126,
328
+ "totalFirstBlood": 0,
329
+ "rankedSoloGamesPlayed": 0,
330
+ "totalHeal": 46462,
331
+ "totalGoldEarned": 438530,
332
+ "mostSpellsCast": 0,
333
+ "totalTurretsKilled": 41,
334
+ "totalUnrealKills": 0,
335
+ "normalGamesPlayed": 0
336
+ },
337
+ "name": "Combined"
338
+ }
339
+ ],
340
+ "summonerId": 19578577
341
+ }
@@ -0,0 +1,131 @@
1
+ {
2
+ "playerStatSummaries": [
3
+ {
4
+ "playerStatSummaryType": "AramUnranked5x5",
5
+ "aggregatedStats": {
6
+ "totalChampionKills": 4183,
7
+ "totalAssists": 8838,
8
+ "totalTurretsKilled": 217
9
+ },
10
+ "losses": 0,
11
+ "modifyDate": 1387446729000,
12
+ "wins": 209
13
+ },
14
+ {
15
+ "playerStatSummaryType": "CoopVsAI",
16
+ "aggregatedStats": {
17
+ "averageNodeCaptureAssist": 1,
18
+ "maxNodeNeutralizeAssist": 1,
19
+ "totalMinionKills": 120366,
20
+ "maxChampionsKilled": 17,
21
+ "totalChampionKills": 18605,
22
+ "averageChampionsKilled": 8,
23
+ "averageNumDeaths": 5,
24
+ "maxNodeCapture": 11,
25
+ "maxObjectivePlayerScore": 999,
26
+ "totalNeutralMinionsKilled": 15515,
27
+ "maxAssists": 14,
28
+ "averageCombatPlayerScore": 389,
29
+ "maxNodeCaptureAssist": 1,
30
+ "averageObjectivePlayerScore": 714,
31
+ "maxTeamObjective": 2,
32
+ "totalAssists": 16829,
33
+ "averageNodeCapture": 6,
34
+ "averageTotalPlayerScore": 1105,
35
+ "averageTeamObjective": 1,
36
+ "averageNodeNeutralize": 5,
37
+ "maxNodeNeutralize": 8,
38
+ "averageNodeNeutralizeAssist": 1,
39
+ "averageAssists": 11,
40
+ "maxTotalPlayerScore": 1634,
41
+ "maxCombatPlayerScore": 676,
42
+ "totalTurretsKilled": 2317,
43
+ "totalNodeNeutralize": 45,
44
+ "totalNodeCapture": 59
45
+ },
46
+ "losses": 0,
47
+ "modifyDate": 1302601118000,
48
+ "wins": 1177
49
+ },
50
+ {
51
+ "playerStatSummaryType": "OdinUnranked",
52
+ "aggregatedStats": {
53
+ "averageNodeCaptureAssist": 2,
54
+ "maxNodeNeutralizeAssist": 4,
55
+ "maxChampionsKilled": 11,
56
+ "totalChampionKills": 53,
57
+ "averageChampionsKilled": 5,
58
+ "averageNumDeaths": 8,
59
+ "maxNodeCapture": 8,
60
+ "maxObjectivePlayerScore": 895,
61
+ "maxAssists": 16,
62
+ "averageCombatPlayerScore": 258,
63
+ "maxNodeCaptureAssist": 2,
64
+ "averageObjectivePlayerScore": 538,
65
+ "maxTeamObjective": 2,
66
+ "totalAssists": 90,
67
+ "averageNodeCapture": 4,
68
+ "maxNodeNeutralize": 7,
69
+ "averageTotalPlayerScore": 797,
70
+ "averageTeamObjective": 1,
71
+ "averageNodeNeutralize": 4,
72
+ "averageNodeNeutralizeAssist": 2,
73
+ "maxTotalPlayerScore": 1206,
74
+ "averageAssists": 8,
75
+ "maxCombatPlayerScore": 434,
76
+ "totalNodeNeutralize": 35,
77
+ "totalNodeCapture": 44
78
+ },
79
+ "losses": 0,
80
+ "modifyDate": 1340153285000,
81
+ "wins": 5
82
+ },
83
+ {
84
+ "playerStatSummaryType": "RankedSolo5x5",
85
+ "aggregatedStats": {
86
+ "totalNeutralMinionsKilled": 691,
87
+ "totalMinionKills": 4840,
88
+ "totalChampionKills": 196,
89
+ "totalAssists": 379,
90
+ "totalTurretsKilled": 41
91
+ },
92
+ "losses": 22,
93
+ "modifyDate": 1384212356000,
94
+ "wins": 24
95
+ },
96
+ {
97
+ "playerStatSummaryType": "RankedTeam5x5",
98
+ "aggregatedStats": {
99
+ "totalNeutralMinionsKilled": 0,
100
+ "totalMinionKills": 37,
101
+ "totalChampionKills": 3,
102
+ "totalAssists": 8,
103
+ "totalTurretsKilled": 0
104
+ },
105
+ "losses": 1,
106
+ "modifyDate": 1342655228000,
107
+ "wins": 0
108
+ },
109
+ {
110
+ "playerStatSummaryType": "Unranked",
111
+ "aggregatedStats": {
112
+ "totalNeutralMinionsKilled": 7131,
113
+ "totalMinionKills": 43281,
114
+ "totalChampionKills": 1857,
115
+ "totalAssists": 3486,
116
+ "totalTurretsKilled": 250
117
+ },
118
+ "losses": 0,
119
+ "modifyDate": 1373852681000,
120
+ "wins": 210
121
+ },
122
+ {
123
+ "playerStatSummaryType": "Unranked3x3",
124
+ "aggregatedStats": {},
125
+ "losses": 0,
126
+ "modifyDate": 1351133157000,
127
+ "wins": 0
128
+ }
129
+ ],
130
+ "summonerId": 19578577
131
+ }
@@ -1,8 +1,7 @@
1
1
  {
2
- "revisionDateStr": "12/14/2013 02:28 AM UTC",
3
2
  "id": 19578577,
4
3
  "name": "Illianthe",
5
4
  "profileIconId": 539,
6
- "revisionDate": 1386988105000,
5
+ "revisionDate": 1387446729000,
7
6
  "summonerLevel": 30
8
7
  }
@@ -1,2 +1,25 @@
1
1
  require "webmock/rspec"
2
- require "lolbase"
2
+ require "lolbase"
3
+
4
+ RSpec.configure do |config|
5
+ config.before(:each) do
6
+ stub_info = [
7
+ {
8
+ file: File.read(File.expand_path("../json/summoner/1.2/summoner.json", __FILE__)),
9
+ url: "https://prod.api.pvp.net/api/lol/na/v1.2/summoner/by-name/illianthe?api_key=random-key"
10
+ },
11
+ {
12
+ file: File.read(File.expand_path("../json/stats/1.2/summary_s3.json", __FILE__)),
13
+ url: "https://prod.api.pvp.net/api/lol/na/v1.2/stats/by-summoner/19578577/summary?api_key=random-key&season=SEASON3"
14
+ },
15
+ {
16
+ file: File.read(File.expand_path("../json/stats/1.2/ranked_s3.json", __FILE__)),
17
+ url: "https://prod.api.pvp.net/api/lol/na/v1.2/stats/by-summoner/19578577/ranked?api_key=random-key&season=SEASON3"
18
+ }
19
+ ]
20
+
21
+ stub_info.each do |stub|
22
+ stub_request(:get, stub[:url]).to_return(status: 200, body: stub[:file])
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe LoLBase::Stats do
4
+ before do
5
+ @connection = LoLBase.new "random-key"
6
+ end
7
+
8
+ it "should return a summoner's stats summary when requested" do
9
+ summary = @connection.summoner("illianthe").stats.summary
10
+ expect(summary["playerStatSummaries"].count).to eq(7)
11
+ end
12
+
13
+ it "should return a summoner's ranked stats when requested" do
14
+ ranked = @connection.summoner("illianthe").stats.ranked
15
+ expect(ranked["modifyDate"]).to eq(1384212356000)
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe LoLBase::Summoner do
4
+ before do
5
+ @connection = LoLBase.new "random-key"
6
+ end
7
+
8
+ it "should return basic summoner data when requested" do
9
+ illianthe = @connection.summoner("illianthe")
10
+
11
+ expect(illianthe.id).to eq(19578577)
12
+ expect(illianthe.name).to eq("Illianthe")
13
+ expect(illianthe.region).to eq("na")
14
+ expect(illianthe.level).to eq(30)
15
+ expect(illianthe.last_modified).to eq(Time.at(1387446729))
16
+
17
+ expect(illianthe.profile_icon.id).to eq(539)
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Regan Chan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-15 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,14 +97,18 @@ files:
97
97
  - lib/lolbase/configuration.rb
98
98
  - lib/lolbase/connection.rb
99
99
  - lib/lolbase/data/profile_icon.rb
100
+ - lib/lolbase/data/stats.rb
100
101
  - lib/lolbase/data/summoner.rb
101
102
  - lib/lolbase/error.rb
102
103
  - lib/lolbase/version.rb
103
104
  - lolbase.gemspec
104
105
  - spec/connection_spec.rb
105
- - spec/data_spec.rb
106
- - spec/json/summoner.json
106
+ - spec/json/stats/1.2/ranked_s3.json
107
+ - spec/json/stats/1.2/summary_s3.json
108
+ - spec/json/summoner/1.2/summoner.json
107
109
  - spec/spec_helper.rb
110
+ - spec/stats_data_spec.rb
111
+ - spec/summoner_data_spec.rb
108
112
  homepage: https://github.com/Illianthe/lolbase
109
113
  licenses:
110
114
  - MIT
@@ -131,7 +135,10 @@ specification_version: 4
131
135
  summary: A basic Ruby wrapper for the League of Legends API.
132
136
  test_files:
133
137
  - spec/connection_spec.rb
134
- - spec/data_spec.rb
135
- - spec/json/summoner.json
138
+ - spec/json/stats/1.2/ranked_s3.json
139
+ - spec/json/stats/1.2/summary_s3.json
140
+ - spec/json/summoner/1.2/summoner.json
136
141
  - spec/spec_helper.rb
142
+ - spec/stats_data_spec.rb
143
+ - spec/summoner_data_spec.rb
137
144
  has_rdoc:
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "LoLBase Data" do
4
- before do
5
- @connection = LoLBase.new "random-key"
6
- end
7
-
8
- context "Summoner" do
9
- it "should return summoner data when requested" do
10
- file = File.read(File.expand_path("../json/summoner.json", __FILE__))
11
- stub_request(:get, "https://prod.api.pvp.net/api/lol/na/v1.1/summoner/by-name/illianthe?api_key=random-key").to_return(status: 200, body: file)
12
-
13
- illianthe = @connection.summoner("illianthe")
14
- expect(illianthe.id).to eq(19578577)
15
- expect(illianthe.name).to eq("Illianthe")
16
- expect(illianthe.profile_icon.id).to eq(539)
17
- expect(illianthe.last_modified).to eq(Time.at(1386988105))
18
- expect(illianthe.level).to eq(30)
19
- expect(illianthe.region).to eq("na")
20
- end
21
- end
22
- end