vegas_insider_scraper 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sports/scraper_league.rb +35 -7
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6d5b8109d37c858c1771927ea47780ef1e0d88be150c5b7ca2f5f7c15384eea
4
- data.tar.gz: 07353f1ed92a2a95f23e2d56991a4145c3721a2d5f22b11d8d1c57c638b56657
3
+ metadata.gz: 7ba21edf08f4a52c18029f0f1d062d427617b2293b67a0645214f41ee22e89ba
4
+ data.tar.gz: 7549b027781a056dfcda8e62fc3eeab95d5c5222b11fd0c82a4cebea00ac97f7
5
5
  SHA512:
6
- metadata.gz: 61de75c4279400ccc3b23e26398c61713780a7e512e11d6b965e4368ebd4f5019674f4540acdcf65a73c6a236015051ba901d1a669a98789a840af3999e933e7
7
- data.tar.gz: 318ef6c5ecffbee93f715aa6807bbc7de2b0cc5665198a6d3b8a928188438881d087f23c150a011211b8b771325f7814dcfc44223aebd0cbb239d82b840f3423
6
+ metadata.gz: 9ee51b96f34259c092c5d5d3af49661d9944e76312c3873717bef8c4c13b089a5ff10c20a5a8907f2d0421b80077596bad6aa685e1d00308ea1173788db6b8e4
7
+ data.tar.gz: 2cade2660c124cbec66de15e3e5f0e4e1ed765585b25c4633a4aa591f8bb4cfdcfeb796af014811ae15cfb3fe14527b026b479adf7534dc0a480520f80888425
@@ -86,13 +86,13 @@ class ScraperLeague
86
86
  # Utility method for scraping standings
87
87
  # * gets the standings table class
88
88
  def standings_table_class
89
- college_sport? ? '.SLTables1' : 'table'
89
+ sport_name == "college-football" ? '.SLTables1' : 'table'
90
90
  end
91
91
 
92
92
  # Utility method for scraping standings
93
93
  # * gets the index of the table
94
94
  def standings_table_index
95
- college_sport? ? 1 : 0
95
+ sport_name == "college-football" ? 1 : 0
96
96
  end
97
97
 
98
98
  # Utility method for scraping standings
@@ -118,7 +118,8 @@ class ScraperLeague
118
118
  def scrape_standings_row(row, grouping, teams_doc)
119
119
  team_shell = { info: {}, record: {} }
120
120
  team = case sport_id
121
- when 0,1 then college_standings_row_parser(row, team_shell, teams_doc)
121
+ when 0 then ncaafb_standings_row_parser(row, team_shell, teams_doc)
122
+ when 1 then ncaabb_standings_row_parser(row, team_shell, teams_doc)
122
123
  when 2 then nfl_standings_row_parser(row, team_shell)
123
124
  when 3,4 then pro_standings_row_parser(row, team_shell)
124
125
  when 5 then hockey_standings_row_parser(row, team_shell)
@@ -128,13 +129,15 @@ class ScraperLeague
128
129
  end
129
130
 
130
131
  # Utility method for scraping standings
131
- # * scrapes a row of the standings, for COLLEGE sports
132
- def college_standings_row_parser(row, team, teams_doc)
132
+ # * scrapes a row of the standings, for NCAAFB
133
+ def ncaafb_standings_row_parser(row, team, teams_doc)
133
134
  row.css('td').each_with_index do |cell, cell_index|
134
135
  value = remove_element_whitespace(cell)
135
136
  case cell_index
136
137
  when 0
137
138
  team[:info] = format_college_team(cell.at_css('a'), teams_doc)
139
+ when 1 then team[:record][:conf_wins] = value.to_i
140
+ when 2 then team[:record][:conf_losses] = value.to_i
138
141
  when 5 then team[:record][:overall_wins] = value.to_i
139
142
  when 6 then team[:record][:overall_losses] = value.to_i
140
143
  when 9 then team[:record][:home_wins] = value.to_i
@@ -146,6 +149,33 @@ class ScraperLeague
146
149
  return team
147
150
  end
148
151
 
152
+ # Utility method for scraping standings
153
+ # * scrapes a row of the standings, for NCAABB
154
+ def ncaabb_standings_row_parser(row, team, teams_doc)
155
+ row.css('td').each_with_index do |cell, cell_index|
156
+ value = remove_element_whitespace(cell)
157
+ case cell_index
158
+ when 0
159
+ team[:info] = format_college_team(cell.at_css('a'), teams_doc)
160
+ when 1 then team[:record][:overall_wins] = value.to_i
161
+ when 2 then team[:record][:overall_losses] = value.to_i
162
+ when 5
163
+ record = RegularExpressions::RECORD_REGEX.match(value) || { wins: 0, losses: 0 }
164
+ team[:record][:home_wins] = record[:wins].to_i
165
+ team[:record][:home_losses] = record[:losses].to_i
166
+ when 6
167
+ record = RegularExpressions::RECORD_REGEX.match(value) || { wins: 0, losses: 0 }
168
+ team[:record][:away_wins] = record[:wins].to_i
169
+ team[:record][:away_losses] = record[:losses].to_i
170
+ when 7
171
+ record = RegularExpressions::RECORD_REGEX.match(value) || { wins: 0, losses: 0 }
172
+ team[:record][:conf_wins] = record[:wins].to_i
173
+ team[:record][:conf_losses] = record[:losses].to_i
174
+ end
175
+ end
176
+ return team
177
+ end
178
+
149
179
  # Utility method for scraping standings
150
180
  # * scrapes a row of the standings, for NFL
151
181
  def nfl_standings_row_parser(row, team)
@@ -358,8 +388,6 @@ class ScraperLeague
358
388
  result[:date] = date
359
389
 
360
390
  games.push(result)
361
- puts result
362
- puts "********************"
363
391
  end
364
392
  end
365
393
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vegas_insider_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Reitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-15 00:00:00.000000000 Z
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: A gem to scrape the web for sports statistics, teams, betting lines,
28
42
  records, and results!
29
43
  email: reitz1994@gmail.com