ncaa_scrape 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ncaa_scrape.rb +10 -25
  3. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 960216b48fc4b052115ae15446f45c4c0a4f1f15
4
- data.tar.gz: 894514ada6e1226787af61771457705b8f198b66
3
+ metadata.gz: 7a490a19272a9a0f90ed660ec87d2e275a7c8498
4
+ data.tar.gz: 8a5f6860691b52b438589d96775fcfb8c43ce63b
5
5
  SHA512:
6
- metadata.gz: 6b4c2cf8a0f47ee696406dd8fd2b73b04bd3d4928e04e6e20ee4394d372082d75bc3b7d63fd4f46a00fcb46251146e3ffa1184abb6da4558e5966f9e8c4b8785
7
- data.tar.gz: f7cabcc5a5a56a51f1369bb2ac8747c14e768410a5228853df00be1fb328870e1d07b6048d0ff2c2ba00c0fdb7b4121e5ec4d977cfc423806aeb87e96c199c27
6
+ metadata.gz: 17bca3c8cd435fb123501466a8a188dd4eac5e0db74183543f01e69338839ceafd0cfeb4294cc3ff8a5d016ffeefd31ca57aca6578c6029d05b73dacc1f9fed5
7
+ data.tar.gz: e89c4875948cfdc84f8d8709c861b4c8f7d38e16f13376404cd2b4e83ea608fa2be2ebb396ec77749f229e251b17e1cf488e2ee580a0db178eaa0355126d816f
@@ -2,21 +2,20 @@ require 'nokogiri'
2
2
  require 'open-uri'
3
3
 
4
4
  class NCAABasketball
5
- attr_reader :division_one_data
5
+ attr_reader :standings_page, :division_one_data
6
+ NCAA_RPI_URL = 'http://www.ncaa.com/rankings/basketball-men/d1/ncaa-mens-basketball-rpi'.freeze
6
7
 
7
8
  def initialize
8
- @standings_page = Nokogiri::HTML(open('http://www.ncaa.com/standings/basketball-men/d1'))
9
+ @standings_page = Nokogiri::HTML(open(NCAA_RPI_URL))
9
10
  @division_one_data = team_names.zip(wins).to_h
10
11
  end
11
12
 
12
13
  def team_names
13
- names = []
14
- raw_data.each { |row| names << row[0] }
15
- names
14
+ school_data.map { |row| row[2] }
16
15
  end
17
16
 
18
17
  def team_wins(team_name)
19
- @division_one_data.include?(team_name) ? @division_one_data[team_name] : 0
18
+ division_one_data.include?(team_name) ? division_one_data[team_name] : 0
20
19
  end
21
20
 
22
21
  def pick_five_total(*teams)
@@ -25,30 +24,16 @@ class NCAABasketball
25
24
 
26
25
  private
27
26
 
28
- def even_rows
29
- @standings_page.css('.even')
30
- end
31
-
32
- def odd_rows
33
- @standings_page.css('.odd')
34
- end
35
-
36
27
  def rows
37
- even_rows + odd_rows
28
+ # skip the first row, which is the table header
29
+ standings_page.xpath('//tr')[1..-1]
38
30
  end
39
31
 
40
- def raw_data
41
- data = []
42
- rows.each { |row| data << row.text }
43
- data.delete_if { |row| row.include?('WLPCT') }
44
- data.map { |row| row.partition(/\d/) }
32
+ def school_data
33
+ rows.map { |row| row.children.map(&:text) }
45
34
  end
46
35
 
47
36
  def wins
48
- data = []
49
- rows.each { |row| data << row.css('.conference-boundary').text }
50
- data.reject { |item| item == 'W' }
51
- data.map { |item| item.to_i}
37
+ school_data.map { |row| row[4].split('-').first.to_i }
52
38
  end
53
-
54
39
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncaa_scrape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jen Trudell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-20 00:00:00.000000000 Z
11
+ date: 2017-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: As of November 2016, ncaa_scrape lets you scrape team names and team
14
- wins for Division I Men's college basketball from the NCAA website. This gem uses
15
- nokogiri to scrape data from ncaa.com; if the NCAA website changes, this gem may
16
- fail. For more information, see readme at https://github.com/jtrudell/NCAA-Basketball-Scraper
13
+ description: As of October 2017, ncaa_scrape lets you scrape team names and team wins
14
+ for Division I Men's college basketball from the NCAA RPI Rankings page. This gem
15
+ uses nokogiri to scrape data from ncaa.com; if the NCAA website changes, this gem
16
+ may fail. For more information, see readme at https://github.com/jtrudell/NCAA-Basketball-Scraper
17
17
  email: jtrudell@gmail.com
18
18
  executables: []
19
19
  extensions: []
@@ -40,8 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  version: '0'
41
41
  requirements: []
42
42
  rubyforge_project:
43
- rubygems_version: 2.5.1
43
+ rubygems_version: 2.6.13
44
44
  signing_key:
45
45
  specification_version: 4
46
- summary: Scrapes NCAA Men's Div I Basketball STandings from NCAA.com
46
+ summary: Scrapes NCAA Men's Div I Basketball Team Names and Scores from NCAA.com
47
47
  test_files: []