bnet_scraper 0.0.1

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.
@@ -0,0 +1,72 @@
1
+ shared_examples 'an SC2 Scraper' do
2
+ describe '#initialize' do
3
+ context 'with url parameter passed' do
4
+ it 'should extract bnet_id from the URL' do
5
+ subject.bnet_id.should == '2377239'
6
+ end
7
+
8
+ it 'should extract account from the URL' do
9
+ subject.account.should == 'Demon'
10
+ end
11
+
12
+ it 'should extract the bnet_index from the URL' do
13
+ subject.bnet_index.should == '1'
14
+ end
15
+
16
+ it 'should extract the region from the URL' do
17
+ subject.region.should == 'na'
18
+ end
19
+ end
20
+
21
+ context 'when bnet_id and account parameters are passed' do
22
+ subject { scraper_class.new(bnet_id: '2377239', account: 'Demon') }
23
+ it 'should set the bnet_id and account parameters' do
24
+ subject.bnet_id.should == '2377239'
25
+ subject.account.should == 'Demon'
26
+ end
27
+
28
+ it 'should default the region to na' do
29
+ subject.region.should == 'na'
30
+ end
31
+
32
+ it 'should assign region if passed' do
33
+ scraper_class.any_instance.should_receive(:set_bnet_index)
34
+ scraper = scraper_class.new(bnet_id: '2377239', account: 'Demon', region: 'fea')
35
+ scraper.region.should == 'fea'
36
+ end
37
+
38
+ it 'should not call set_bnet_index if bnet_index is passed' do
39
+ scraper_class.any_instance.should_not_receive(:set_bnet_index)
40
+ scraper = scraper_class.new(bnet_id: '2377239', account: 'Demon', region: 'fea', bnet_index: '1')
41
+ end
42
+
43
+ it 'should call set_bnet_index_if bnet_index is not passed' do
44
+ scraper_class.any_instance.should_receive(:set_bnet_index)
45
+ scraper = scraper_class.new(bnet_id: '2377239', account: 'Demon', region: 'fea')
46
+ end
47
+ end
48
+ end
49
+
50
+ describe '#region_info' do
51
+ it 'should return information based on the set region' do
52
+ subject.region_info.should == { domain: 'us.battle.net', dir: 'en' }
53
+ end
54
+ end
55
+
56
+ describe '#set_bnet_index' do
57
+ it 'should return the valid integer needed for a proper URL parse from bnet' do
58
+ subject.set_bnet_index
59
+ subject.bnet_index.should == 1
60
+ end
61
+ end
62
+
63
+ describe '#profile_url' do
64
+ it 'should return a string URL for bnet' do
65
+ subject.profile_url.should == 'http://us.battle.net/sc2/en/profile/2377239/1/Demon/'
66
+ end
67
+
68
+ it 'should optionally take a bnet_index to use instead of saved bnet_index' do
69
+ subject.profile_url(2).should == 'http://us.battle.net/sc2/en/profile/2377239/2/Demon/'
70
+ end
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bnet_scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Nordman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: &70293792250420 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70293792250420
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70293792249920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70293792249920
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70293792249320 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70293792249320
47
+ - !ruby/object:Gem::Dependency
48
+ name: fakeweb
49
+ requirement: &70293792247440 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70293792247440
58
+ description: BnetScraper is a Nokogiri-based scraper of Battle.net profile information.
59
+ Currently this only includes Starcraft2.
60
+ email:
61
+ - anordman@majorleaguegaming.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - .rspec
68
+ - .travis.yml
69
+ - Gemfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - benchmarks/sc2_profile_parsing.rb
74
+ - bnet_scraper.gemspec
75
+ - lib/bnet_scraper.rb
76
+ - lib/bnet_scraper/starcraft2.rb
77
+ - lib/bnet_scraper/starcraft2/achievement_scraper.rb
78
+ - lib/bnet_scraper/starcraft2/base_scraper.rb
79
+ - lib/bnet_scraper/starcraft2/league_scraper.rb
80
+ - lib/bnet_scraper/starcraft2/match_history_scraper.rb
81
+ - lib/bnet_scraper/starcraft2/profile_scraper.rb
82
+ - spec/spec_helper.rb
83
+ - spec/starcraft2/achievement_scraper_spec.rb
84
+ - spec/starcraft2/base_scraper_spec.rb
85
+ - spec/starcraft2/league_scraper_spec.rb
86
+ - spec/starcraft2/match_history_scraper_spec.rb
87
+ - spec/starcraft2/profile_scraper_spec.rb
88
+ - spec/starcraft2_spec.rb
89
+ - spec/support/achievements.html
90
+ - spec/support/league.html
91
+ - spec/support/leagues.html
92
+ - spec/support/load_fakeweb.rb
93
+ - spec/support/matches.html
94
+ - spec/support/profile.html
95
+ - spec/support/shared/sc2_scraper.rb
96
+ homepage: https://github.com/agoragames/bnet_scraper/
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
109
+ - 0
110
+ hash: -112157996329556196
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
118
+ - 0
119
+ hash: -112157996329556196
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 1.8.17
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Battle.net Profile Scraper
126
+ test_files:
127
+ - spec/spec_helper.rb
128
+ - spec/starcraft2/achievement_scraper_spec.rb
129
+ - spec/starcraft2/base_scraper_spec.rb
130
+ - spec/starcraft2/league_scraper_spec.rb
131
+ - spec/starcraft2/match_history_scraper_spec.rb
132
+ - spec/starcraft2/profile_scraper_spec.rb
133
+ - spec/starcraft2_spec.rb
134
+ - spec/support/achievements.html
135
+ - spec/support/league.html
136
+ - spec/support/leagues.html
137
+ - spec/support/load_fakeweb.rb
138
+ - spec/support/matches.html
139
+ - spec/support/profile.html
140
+ - spec/support/shared/sc2_scraper.rb