starcraft2 0.1.1 → 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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/fixtures/cassettes/ladders_999000.yml +1053 -0
  3. data/lib/starcraft2/character.rb +7 -1
  4. data/lib/starcraft2/client.rb +33 -19
  5. data/lib/starcraft2/loader.rb +4 -0
  6. data/lib/starcraft2/profile.rb +5 -1
  7. data/lib/starcraft2/profile/achievement_item.rb +3 -3
  8. data/lib/starcraft2/profile/achievements.rb +2 -2
  9. data/lib/starcraft2/profile/campaign.rb +2 -2
  10. data/lib/starcraft2/profile/career.rb +2 -2
  11. data/lib/starcraft2/profile/detailed_season.rb +17 -0
  12. data/lib/starcraft2/profile/ladder.rb +17 -0
  13. data/lib/starcraft2/profile/ladders.rb +11 -0
  14. data/lib/starcraft2/profile/match.rb +1 -1
  15. data/lib/starcraft2/profile/non_rank.rb +18 -0
  16. data/lib/starcraft2/profile/points.rb +1 -1
  17. data/lib/starcraft2/profile/season.rb +1 -1
  18. data/lib/starcraft2/profile/stats.rb +2 -2
  19. data/spec/starcraft2/achievement_spec.rb +42 -45
  20. data/spec/starcraft2/character_spec.rb +37 -19
  21. data/spec/starcraft2/client_spec.rb +2 -4
  22. data/spec/starcraft2/icon_spec.rb +7 -22
  23. data/spec/starcraft2/member_spec.rb +24 -54
  24. data/spec/starcraft2/profile/achievement_item_spec.rb +48 -0
  25. data/spec/starcraft2/profile/achievements_spec.rb +36 -27
  26. data/spec/starcraft2/profile/campaign_spec.rb +8 -7
  27. data/spec/starcraft2/profile/career_spec.rb +30 -47
  28. data/spec/starcraft2/profile/detailed_season_spec.rb +98 -0
  29. data/spec/starcraft2/profile/ladder_spec.rb +63 -0
  30. data/spec/starcraft2/profile/ladders_spec.rb +197 -0
  31. data/spec/starcraft2/profile/match_spec.rb +41 -22
  32. data/spec/starcraft2/profile/non_rank_spec.rb +48 -0
  33. data/spec/starcraft2/profile/points_spec.rb +22 -0
  34. data/spec/starcraft2/profile/rewards_spec.rb +17 -11
  35. data/spec/starcraft2/profile/season_spec.rb +33 -23
  36. data/spec/starcraft2/profile/stats_spec.rb +49 -0
  37. data/spec/starcraft2/profile/swarm_levels_spec.rb +29 -16
  38. data/spec/starcraft2/profile/swarm_race_spec.rb +25 -0
  39. data/spec/starcraft2/profile_spec.rb +80 -73
  40. data/spec/starcraft2/reward_spec.rb +22 -31
  41. data/spec/starcraft2/utils_spec.rb +30 -0
  42. data/starcraft2.gemspec +1 -1
  43. metadata +15 -2
@@ -12,17 +12,47 @@ describe Starcraft2::Utils do
12
12
  icon = Starcraft2::Icon.new()
13
13
  icon.x.should == nil
14
14
  icon.y.should == nil
15
+
15
16
  Starcraft2::Utils.load(icon, {:x => 2, :y => 3})
16
17
  icon.x.should == 2
17
18
  icon.y.should == 3
18
19
  end
19
20
 
21
+ it 'should convert camelCased to underscored' do
22
+ career = Starcraft2::Profile::Career.new()
23
+ career.protoss_wins.should == nil
24
+
25
+ Starcraft2::Utils.load(career, {'protossWins' => 5})
26
+ career.protoss_wins.should == 5
27
+ end
28
+
20
29
  it 'should allow a key to initialize another class' do
21
30
  member = Starcraft2::Member.new()
31
+ member.points.should == nil
32
+ member.character.should == nil
33
+
22
34
  Starcraft2::Utils.load(member, {:points => 10, :character => {:display_name => 'steve'}}, {:character => Starcraft2::Character})
23
35
  member.points.should == 10
24
36
  member.character.class.should == Starcraft2::Character
25
37
  member.character.display_name.should == 'steve'
26
38
  end
39
+
40
+ it 'should allow a key to build another class' do
41
+ ladders = Starcraft2::Profile::Ladders.new()
42
+ ladders.current_season.should == nil
43
+
44
+ options = {
45
+ 'currentSeason' => [
46
+ {'ladder' => [{'ladderName' => 'Shuttle Tango'}]},
47
+ {'ladder' => [{'ladderName' => 'Torrasque Upsilon'}]}
48
+ ]
49
+ }
50
+ Starcraft2::Utils.load(ladders, options, {}, {:current_season => Starcraft2::Profile::DetailedSeason})
51
+ ladders.current_season.each do |season|
52
+ season.class.should == Starcraft2::Profile::DetailedSeason
53
+ end
54
+ ladders.current_season.first.ladder.first.ladder_name.should == 'Shuttle Tango'
55
+ ladders.current_season.last.ladder.first.ladder_name.should == 'Torrasque Upsilon'
56
+ end
27
57
  end
28
58
  end
data/starcraft2.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = `git ls-files -- {spec}/*`.split("\n")
15
15
  gem.name = "starcraft2"
16
16
  gem.require_paths = ["lib"]
17
- gem.version = "0.1.1"
17
+ gem.version = "0.2.0"
18
18
 
19
19
  gem.add_development_dependency 'rspec', '~> 2.6.0'
20
20
  gem.add_development_dependency 'rake'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starcraft2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-15 00:00:00.000000000 Z
13
+ date: 2013-08-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -127,6 +127,7 @@ files:
127
127
  - fixtures/cassettes/achievements.yml
128
128
  - fixtures/cassettes/grandmaster.yml
129
129
  - fixtures/cassettes/ladder_148200.yml
130
+ - fixtures/cassettes/ladders_999000.yml
130
131
  - fixtures/cassettes/matches_999000.yml
131
132
  - fixtures/cassettes/profile_999000.yml
132
133
  - fixtures/cassettes/rewards.yml
@@ -148,7 +149,11 @@ files:
148
149
  - lib/starcraft2/profile/achievements.rb
149
150
  - lib/starcraft2/profile/campaign.rb
150
151
  - lib/starcraft2/profile/career.rb
152
+ - lib/starcraft2/profile/detailed_season.rb
153
+ - lib/starcraft2/profile/ladder.rb
154
+ - lib/starcraft2/profile/ladders.rb
151
155
  - lib/starcraft2/profile/match.rb
156
+ - lib/starcraft2/profile/non_rank.rb
152
157
  - lib/starcraft2/profile/points.rb
153
158
  - lib/starcraft2/profile/rewards.rb
154
159
  - lib/starcraft2/profile/season.rb
@@ -164,13 +169,21 @@ files:
164
169
  - spec/starcraft2/icon_spec.rb
165
170
  - spec/starcraft2/ladder_spec.rb
166
171
  - spec/starcraft2/member_spec.rb
172
+ - spec/starcraft2/profile/achievement_item_spec.rb
167
173
  - spec/starcraft2/profile/achievements_spec.rb
168
174
  - spec/starcraft2/profile/campaign_spec.rb
169
175
  - spec/starcraft2/profile/career_spec.rb
176
+ - spec/starcraft2/profile/detailed_season_spec.rb
177
+ - spec/starcraft2/profile/ladder_spec.rb
178
+ - spec/starcraft2/profile/ladders_spec.rb
170
179
  - spec/starcraft2/profile/match_spec.rb
180
+ - spec/starcraft2/profile/non_rank_spec.rb
181
+ - spec/starcraft2/profile/points_spec.rb
171
182
  - spec/starcraft2/profile/rewards_spec.rb
172
183
  - spec/starcraft2/profile/season_spec.rb
184
+ - spec/starcraft2/profile/stats_spec.rb
173
185
  - spec/starcraft2/profile/swarm_levels_spec.rb
186
+ - spec/starcraft2/profile/swarm_race_spec.rb
174
187
  - spec/starcraft2/profile_spec.rb
175
188
  - spec/starcraft2/reward_spec.rb
176
189
  - spec/starcraft2/utils_spec.rb