ruby-lol 0.0.2 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -0
  3. data/lib/lol.rb +13 -1
  4. data/lib/lol/aggregated_statistic.rb +21 -0
  5. data/lib/lol/champion.rb +0 -4
  6. data/lib/lol/champion_statistic.rb +25 -0
  7. data/lib/lol/champion_statistics_summary.rb +27 -0
  8. data/lib/lol/client.rb +52 -4
  9. data/lib/lol/game.rb +4 -8
  10. data/lib/lol/league.rb +2 -5
  11. data/lib/lol/league_entry.rb +86 -0
  12. data/lib/lol/match_summary.rb +59 -0
  13. data/lib/lol/mini_series.rb +29 -0
  14. data/lib/lol/model.rb +5 -1
  15. data/lib/lol/player.rb +1 -5
  16. data/lib/lol/player_statistic.rb +43 -0
  17. data/lib/lol/ranked_statistics_summary.rb +35 -0
  18. data/lib/lol/{statistic.rb → raw_statistic.rb} +2 -6
  19. data/lib/lol/roster.rb +23 -0
  20. data/lib/lol/team.rb +122 -0
  21. data/lib/lol/team_member.rb +33 -0
  22. data/lib/lol/team_statistic.rb +45 -0
  23. data/lib/lol/version.rb +1 -1
  24. data/spec/fixtures/v1.1/get-ranked_stats.json +1 -0
  25. data/spec/fixtures/v1.1/get-stats.json +1 -0
  26. data/spec/fixtures/v2.1/get-team.json +962 -0
  27. data/spec/lol/aggregated_statistic_spec.rb +19 -0
  28. data/spec/lol/champion_statistic_spec.rb +19 -0
  29. data/spec/lol/champion_statistics_summary_spec.rb +26 -0
  30. data/spec/lol/client_spec.rb +117 -0
  31. data/spec/lol/game_spec.rb +2 -7
  32. data/spec/lol/league_entry_spec.rb +56 -0
  33. data/spec/lol/league_spec.rb +4 -1
  34. data/spec/lol/match_summary_spec.rb +25 -0
  35. data/spec/lol/mini_series_spec.rb +25 -0
  36. data/spec/lol/player_statistic_spec.rb +32 -0
  37. data/spec/lol/ranked_statistics_summary_spec.rb +32 -0
  38. data/spec/lol/{statistic_spec.rb → raw_statistic_spec.rb} +1 -1
  39. data/spec/lol/roster_spec.rb +24 -0
  40. data/spec/lol/team_member_spec.rb +27 -0
  41. data/spec/lol/team_spec.rb +66 -0
  42. data/spec/lol/team_statistic_spec.rb +31 -0
  43. data/spec/support/model_helpers.rb +25 -3
  44. metadata +47 -5
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+ require "lol"
3
+
4
+ include Lol
5
+
6
+ describe TeamMember do
7
+ it_behaves_like 'Lol model' do
8
+ let(:valid_attributes) { { player_id: 1 } }
9
+ end
10
+
11
+ %w(player_id status).each do |attribute|
12
+ describe "#{attribute} attribute" do
13
+ it_behaves_like 'plain attribute' do
14
+ let(:attribute) { attribute }
15
+ let(:attribute_value) { 'asd' }
16
+ end
17
+ end
18
+ end
19
+
20
+ %w(invite_date join_date).each do |attribute|
21
+ describe "#{attribute} attribute" do
22
+ it_behaves_like 'time attribute' do
23
+ let(:attribute) { attribute }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+ require "lol"
3
+
4
+ include Lol
5
+
6
+ describe Team do
7
+ it_behaves_like 'Lol model' do
8
+ let(:valid_attributes) { { timestamp: 1 } }
9
+ end
10
+
11
+ %w(message_of_day name status tag timestamp).each do |attribute|
12
+ describe "#{attribute} attribute" do
13
+ it_behaves_like 'plain attribute' do
14
+ let(:attribute) { attribute }
15
+ let(:attribute_value) { 'asd' }
16
+ end
17
+ end
18
+ end
19
+
20
+ %w(create_date last_game_date last_join_date second_last_join_date third_last_join_date last_joined_ranked_team_queue_date modify_date).each do |attribute|
21
+ describe "#{attribute} attribute" do
22
+ it_behaves_like 'time attribute' do
23
+ let(:attribute) { attribute }
24
+ end
25
+ end
26
+ end
27
+
28
+ describe 'match_history attribute' do
29
+ it_behaves_like 'collection attribute' do
30
+ let(:attribute) { 'match_history' }
31
+ let(:attribute_class) { MatchSummary }
32
+ end
33
+ end
34
+
35
+ describe 'team_stat_summary attribute' do
36
+ it_behaves_like 'collection attribute' do
37
+ let(:attribute) { 'team_stat_summary' }
38
+ let(:attribute_class) { TeamStatistic }
39
+ let(:attribute_value) { { 'teamStatDetails' => [{}, {}] } }
40
+ end
41
+ end
42
+
43
+ describe 'roster attribute' do
44
+ it_behaves_like 'plain attribute' do
45
+ let(:attribute) { 'create_date' }
46
+ let(:attribute_value) { 'asd' }
47
+ end
48
+
49
+ it 'parses the value if it is an Hash' do
50
+ model = Team.new roster: {}
51
+ expect(model.roster).to be_a Roster
52
+ end
53
+ end
54
+
55
+ describe 'team_id attribute' do
56
+ it_behaves_like 'plain attribute' do
57
+ let(:attribute) { 'team_id' }
58
+ let(:attribute_value) { 'asd' }
59
+ end
60
+
61
+ it 'parses the value if it is an Hash' do
62
+ model = Team.new team_id: { 'fullId' => 1 }
63
+ expect(model.team_id).to eq 1
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+ require "lol"
3
+
4
+ include Lol
5
+
6
+ describe TeamStatistic do
7
+ it_behaves_like 'Lol model' do
8
+ let(:valid_attributes) { { losses: 1 } }
9
+ end
10
+
11
+ %w(average_games_played losses max_rating rating seed_rating team_stat_type wins).each do |attribute|
12
+ describe "#{attribute} attribute" do
13
+ it_behaves_like 'plain attribute' do
14
+ let(:attribute) { attribute }
15
+ let(:attribute_value) { 'asd' }
16
+ end
17
+ end
18
+ end
19
+
20
+ describe 'team_id attribute' do
21
+ it_behaves_like 'plain attribute' do
22
+ let(:attribute) { 'team_id' }
23
+ let(:attribute_value) { 'asd' }
24
+ end
25
+
26
+ it 'parses the value if it is an Hash' do
27
+ model = Team.new team_id: { 'fullId' => 1 }
28
+ expect(model.team_id).to eq 1
29
+ end
30
+ end
31
+ end
@@ -49,6 +49,25 @@ shared_examples 'plain attribute' do
49
49
  end
50
50
  end
51
51
 
52
+ shared_examples 'time attribute' do
53
+ let(:subject_class) { subject.class }
54
+ let(:setter) { "#{attribute}=" }
55
+
56
+ it_behaves_like 'plain attribute' do
57
+ let(:attribute_value) { Time.now }
58
+ end
59
+
60
+ it "does not parse the value is it isn't a Numeric value" do
61
+ model = subject_class.new(attribute => Date.today)
62
+ expect(model.send attribute).to be_a Date
63
+ end
64
+
65
+ it "works with LoL format" do
66
+ model = subject_class.new(attribute => 1386804971247)
67
+ expect(model.send(attribute).year).to eq 2013
68
+ end
69
+ end
70
+
52
71
  shared_examples 'collection attribute' do
53
72
  let(:subject_class) { subject.class }
54
73
  let(:setter) { "#{attribute}=" }
@@ -56,12 +75,14 @@ shared_examples 'collection attribute' do
56
75
  it_behaves_like 'attribute'
57
76
 
58
77
  it 'is sets if the hash contains the attribute name "underscored"' do
59
- model = subject_class.new({ attribute => [{}, {}] })
78
+ value = respond_to?(:attribute_value) && attribute_value || [{}, {}]
79
+ model = subject_class.new({ attribute => value })
60
80
  expect(model.send(attribute).size).to eq 2
61
81
  end
62
82
 
63
83
  it 'is set if the hash contains the attribute name "camelized"' do
64
- model = subject_class.new({ camelize(attribute) => [{}, {}] })
84
+ value = respond_to?(:attribute_value) && attribute_value || [{}, {}]
85
+ model = subject_class.new({ camelize(attribute) => value })
65
86
  expect(model.send(attribute).size).to eq 2
66
87
  end
67
88
 
@@ -76,7 +97,8 @@ shared_examples 'collection attribute' do
76
97
  context 'if the value is enumerable' do
77
98
  context 'and contains items as Hash' do
78
99
  it 'parses the item' do
79
- model = subject_class.new attribute => [{}]
100
+ value = respond_to?(:attribute_value) && attribute_value || [{}, {}]
101
+ model = subject_class.new attribute => value
80
102
  expect(model.send(attribute).map(&:class).uniq).to eq [attribute_class]
81
103
  end
82
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Intini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -242,24 +242,51 @@ files:
242
242
  - README.md
243
243
  - Rakefile
244
244
  - lib/lol.rb
245
+ - lib/lol/aggregated_statistic.rb
245
246
  - lib/lol/champion.rb
247
+ - lib/lol/champion_statistic.rb
248
+ - lib/lol/champion_statistics_summary.rb
246
249
  - lib/lol/client.rb
247
250
  - lib/lol/game.rb
248
251
  - lib/lol/league.rb
252
+ - lib/lol/league_entry.rb
253
+ - lib/lol/match_summary.rb
254
+ - lib/lol/mini_series.rb
249
255
  - lib/lol/model.rb
250
256
  - lib/lol/player.rb
251
- - lib/lol/statistic.rb
257
+ - lib/lol/player_statistic.rb
258
+ - lib/lol/ranked_statistics_summary.rb
259
+ - lib/lol/raw_statistic.rb
260
+ - lib/lol/roster.rb
261
+ - lib/lol/team.rb
262
+ - lib/lol/team_member.rb
263
+ - lib/lol/team_statistic.rb
252
264
  - lib/lol/version.rb
253
265
  - ruby-lol.gemspec
254
266
  - spec/fixtures/v1.1/get-champion.json
255
267
  - spec/fixtures/v1.1/get-game.json
268
+ - spec/fixtures/v1.1/get-ranked_stats.json
269
+ - spec/fixtures/v1.1/get-stats.json
256
270
  - spec/fixtures/v2.1/get-league.json
271
+ - spec/fixtures/v2.1/get-team.json
272
+ - spec/lol/aggregated_statistic_spec.rb
257
273
  - spec/lol/champion_spec.rb
274
+ - spec/lol/champion_statistic_spec.rb
275
+ - spec/lol/champion_statistics_summary_spec.rb
258
276
  - spec/lol/client_spec.rb
259
277
  - spec/lol/game_spec.rb
278
+ - spec/lol/league_entry_spec.rb
260
279
  - spec/lol/league_spec.rb
280
+ - spec/lol/match_summary_spec.rb
281
+ - spec/lol/mini_series_spec.rb
261
282
  - spec/lol/player_spec.rb
262
- - spec/lol/statistic_spec.rb
283
+ - spec/lol/player_statistic_spec.rb
284
+ - spec/lol/ranked_statistics_summary_spec.rb
285
+ - spec/lol/raw_statistic_spec.rb
286
+ - spec/lol/roster_spec.rb
287
+ - spec/lol/team_member_spec.rb
288
+ - spec/lol/team_spec.rb
289
+ - spec/lol/team_statistic_spec.rb
263
290
  - spec/spec_helper.rb
264
291
  - spec/support/model_helpers.rb
265
292
  homepage: https://github.com/mikamai/ruby-lol
@@ -289,13 +316,28 @@ summary: Ruby wrapper to Riot Games API
289
316
  test_files:
290
317
  - spec/fixtures/v1.1/get-champion.json
291
318
  - spec/fixtures/v1.1/get-game.json
319
+ - spec/fixtures/v1.1/get-ranked_stats.json
320
+ - spec/fixtures/v1.1/get-stats.json
292
321
  - spec/fixtures/v2.1/get-league.json
322
+ - spec/fixtures/v2.1/get-team.json
323
+ - spec/lol/aggregated_statistic_spec.rb
293
324
  - spec/lol/champion_spec.rb
325
+ - spec/lol/champion_statistic_spec.rb
326
+ - spec/lol/champion_statistics_summary_spec.rb
294
327
  - spec/lol/client_spec.rb
295
328
  - spec/lol/game_spec.rb
329
+ - spec/lol/league_entry_spec.rb
296
330
  - spec/lol/league_spec.rb
331
+ - spec/lol/match_summary_spec.rb
332
+ - spec/lol/mini_series_spec.rb
297
333
  - spec/lol/player_spec.rb
298
- - spec/lol/statistic_spec.rb
334
+ - spec/lol/player_statistic_spec.rb
335
+ - spec/lol/ranked_statistics_summary_spec.rb
336
+ - spec/lol/raw_statistic_spec.rb
337
+ - spec/lol/roster_spec.rb
338
+ - spec/lol/team_member_spec.rb
339
+ - spec/lol/team_spec.rb
340
+ - spec/lol/team_statistic_spec.rb
299
341
  - spec/spec_helper.rb
300
342
  - spec/support/model_helpers.rb
301
343
  has_rdoc: