Skip to content

Commit 1bf49b2

Browse files
committed
Adds Highest and Current Team League
1 parent dc2f0b2 commit 1bf49b2

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

lib/bnet_scraper/starcraft2/profile_scraper.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module Starcraft2
2222
# }
2323
class ProfileScraper < BaseScraper
2424
attr_reader :achievement_points, :career_games, :race, :leagues, :most_played,
25-
:games_this_season, :highest_solo_league, :current_solo_league
25+
:games_this_season, :highest_solo_league, :current_solo_league, :highest_team_league,
26+
:current_team_league
2627

2728
def initialize options = {}
2829
super
@@ -49,12 +50,20 @@ def get_profile_data
4950
@most_played = html.css(".stat-block:nth-child(2) h2").inner_html()
5051
@games_this_season = html.css(".stat-block:nth-child(1) h2").inner_html()
5152

52-
if solo_league_finishes = html.css("#best-finish-SOLO div")[0]
53+
if html.css("#best-finish-SOLO div")[0]
5354
@highest_solo_league = html.css("#best-finish-SOLO div")[0].children[2].inner_text.strip
5455
@current_solo_league = html.css("#best-finish-SOLO div")[0].children[8].inner_text.strip
5556
else
56-
@highest_solo_league = "Unranked"
57-
@current_solo_league = "Unranked"
57+
@highest_solo_league = "Not Yet Ranked"
58+
@current_solo_league = "Not Yet Ranked"
59+
end
60+
61+
if html.css("#best-finish-TEAM div")[0]
62+
@highest_team_league = html.css("#best-finish-TEAM div")[0].children[2].inner_text.strip
63+
@current_team_league = html.css("#best-finish-TEAM div")[0].children[8].inner_text.strip
64+
else
65+
@highest_team_league = "Not Yet Ranked"
66+
@current_team_league = "Not Yet Ranked"
5867
end
5968

6069
else
@@ -88,6 +97,8 @@ def output
8897
race: @race,
8998
current_solo_league: @current_solo_league,
9099
highest_solo_league: @highest_solo_league,
100+
current_team_league: @current_team_league,
101+
highest_team_league: @highest_team_league,
91102
career_games: @career_games,
92103
games_this_season: @games_this_season,
93104
most_played: @most_played,

spec/starcraft2/profile_scraper_spec.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,27 @@
99
subject { BnetScraper::Starcraft2::ProfileScraper.new(bnet_id: '2377239', account: 'Demon') }
1010

1111
describe '#get_profile_data' do
12-
it 'should set the race, wins, and achievements attributes' do
13-
subject.race.should be_nil
14-
subject.achievement_points.should be_nil
15-
12+
before do
1613
subject.get_profile_data
17-
18-
subject.race.should == 'Protoss'
19-
subject.achievement_points.should == '3660'
2014
end
15+
16+
its(:race) { should == 'Protoss' }
17+
its(:achievement_points) { should == '3660' }
18+
its(:current_solo_league) { should == 'Not Yet Ranked' }
19+
its(:highest_solo_league) { should == 'Platinum' }
20+
its(:current_team_league) { should == 'Not Yet Ranked' }
21+
its(:highest_team_league) { should == 'Diamond' }
22+
its(:career_games) { should == '1568' }
23+
its(:games_this_season) { should == '0' }
24+
its(:most_played) { should == '4v4' }
2125
end
2226

2327
describe 'get_league_list' do
2428
it 'should set an array of leagues' do
2529
subject.should have(0).leagues
2630
subject.get_league_list
2731

28-
subject.instance_variable_get(:@leagues).should have(12).leagues
32+
subject.should have(12).leagues
2933
end
3034
end
3135

@@ -75,6 +79,8 @@
7579
games_this_season: '0',
7680
highest_solo_league: 'Platinum',
7781
current_solo_league: 'Not Yet Ranked',
82+
highest_team_league: 'Diamond',
83+
current_team_league: 'Not Yet Ranked',
7884
most_played: '4v4',
7985
achievement_points: '3660',
8086
leagues: [
@@ -151,6 +157,8 @@
151157
most_played: nil,
152158
highest_solo_league: nil,
153159
current_solo_league: nil,
160+
highest_team_league: nil,
161+
current_team_league: nil,
154162
achievement_points: nil,
155163
leagues: []
156164
}

spec/starcraft2_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
:most_played => '4v4',
1414
:current_solo_league => 'Not Yet Ranked',
1515
:highest_solo_league => 'Platinum',
16+
:current_team_league => 'Not Yet Ranked',
17+
:highest_team_league => 'Diamond',
1618
:achievement_points=>"3660",
1719
:leagues=>[
1820
{:season=>"6", :size=>"4v4", :name=>"Aleksander Pepper", :division=>"Diamond", :random=>false, :bnet_id=>"2377239", :account=>"Demon"},

0 commit comments

Comments
 (0)