nba_information 1.1.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daad143ea22bb9b17c41bc03bb2aa2b71862804565ad18f537b19104f253a13d
4
- data.tar.gz: 1baece7a2e38055f45c25c232a6c24cf94cf80e19568ec10123bab13bacb0082
3
+ metadata.gz: eec97c071d40f2e8f4c8d82a48a1252c4086d18089aa2f36684883b2d66a5777
4
+ data.tar.gz: 24fe748bd3e0f93195ed84687238523a4e1f079a261904457538ec2db202ba54
5
5
  SHA512:
6
- metadata.gz: f9903e01dae1d434422fd4341f8c21d917e04b29d18cee9789cd3b31a3d446902819dac9f0b7d3a56ea755eae7748be07377880fcb1c653e68d6f886a8b338be
7
- data.tar.gz: 6b34576e31078f47382f02f92a594ec7622c70b243132c2f0cfc37caf68eb0742e226b9d148215e1be8582460bcace7e52df16fbc5e37a59c093db3d560c5db4
6
+ metadata.gz: eabcfb355c840261af0226906bfe70f890e5203acb7602cc193735b0f1ba3f1ce3b408956962d167005b5698294dbc05ae04abc3094b9e5c4c561798af0af888
7
+ data.tar.gz: 49387460189007a972055792166c039012cbc2fd1e273aff94487b252bf9ccdfff6ae9894f1e140ead7b02c8bcf51f279c09e5c5996dd913d832fe5d3db316fe
@@ -1,21 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nba_information (1.0.1)
5
- nokogiri
4
+ nba_information (1.2.0)
5
+ httparty (~> 0.18.1)
6
+ nokogiri (~> 1.0)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  coderay (1.1.2)
11
- method_source (0.9.2)
12
+ httparty (0.18.1)
13
+ mime-types (~> 3.0)
14
+ multi_xml (>= 0.5.2)
15
+ method_source (0.8.2)
16
+ mime-types (3.3.1)
17
+ mime-types-data (~> 3.2015)
18
+ mime-types-data (3.2020.0512)
12
19
  mini_portile2 (2.4.0)
13
- nokogiri (1.10.1)
20
+ multi_xml (0.6.0)
21
+ nokogiri (1.10.10)
14
22
  mini_portile2 (~> 2.4.0)
15
- pry (0.12.2)
23
+ pry (0.10.3)
16
24
  coderay (~> 1.1.0)
17
- method_source (~> 0.9.0)
18
- rake (10.5.0)
25
+ method_source (~> 0.8.1)
26
+ slop (~> 3.4)
27
+ rake (13.0.1)
28
+ slop (3.6.0)
19
29
 
20
30
  PLATFORMS
21
31
  ruby
@@ -23,8 +33,8 @@ PLATFORMS
23
33
  DEPENDENCIES
24
34
  bundler (~> 1.16)
25
35
  nba_information!
26
- pry
27
- rake (~> 10.0)
36
+ pry (~> 0.10.3)
37
+ rake (~> 13.0)
28
38
 
29
39
  BUNDLED WITH
30
40
  1.17.3
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  NBA Information Gem
2
2
 
3
3
  This is a CLI gem for the NBA. Check the current conference standings, view the schedule of games for today,
4
- or view your favorite teams stats. All standings, stats, and schedules are updated in realtime from espn and sports illustrated.
4
+ or view your favorite teams stats. All standings, stats, and schedules are updated in realtime from ESPN and CBSsports.
5
5
 
6
6
  ## Installation
7
7
  From the command line:
@@ -17,6 +17,7 @@ and follow the instructions from there.
17
17
 
18
18
  Runtime Dependencies:
19
19
  - nokogiri
20
+ - HTTParty
20
21
 
21
22
  ## License
22
23
 
@@ -1,8 +1,9 @@
1
1
  require 'nokogiri'
2
2
  require 'open-uri'
3
3
  require 'pry'
4
+ require 'httparty'
4
5
 
5
6
  require_relative "./nba_info/version"
6
7
  require_relative "./nba_info/cli"
7
8
  require_relative "./nba_info/team"
8
- require_relative "./nba_info/scraper"
9
+ require_relative "./nba_info/scraper"
@@ -2,27 +2,27 @@ class NbaInfo::CLI
2
2
 
3
3
  def call
4
4
  instruct
5
- input = gets.strip.capitalize
6
- until input == "Exit"
5
+ input = gets.strip.downcase
6
+ until input == "exit"
7
7
  case input
8
- when "Commands"
8
+ when "commands"
9
9
  instruct
10
- input = gets.strip.capitalize
11
- when "Key"
10
+ input = gets.strip.downcase
11
+ when "key"
12
12
  key
13
- input = gets.strip.capitalize
14
- when "Schedule"
13
+ input = gets.strip.downcase
14
+ when "schedule"
15
15
  schedule
16
- input = gets.strip.capitalize
17
- when "Standings"
16
+ input = gets.strip.downcase
17
+ when "standings"
18
18
  standings
19
- input = gets.strip.capitalize
20
- when "Team"
19
+ input = gets.strip.downcase
20
+ when "team"
21
21
  team
22
- input = gets.strip.capitalize
22
+ input = gets.strip.downcase
23
23
  else
24
24
  puts "Not a valid command"
25
- input = gets.strip.capitalize
25
+ input = gets.strip.downcase
26
26
  end
27
27
  end
28
28
  end
@@ -44,7 +44,7 @@ class NbaInfo::CLI
44
44
  sched = NbaInfo::Scraper.scrape_schedule
45
45
  puts "All times are Eastern Standard"
46
46
  sched.each do |game|
47
- puts "#{game[:away].ljust(4)} @ #{game[:home].ljust(4)} - #{game[:time]}"
47
+ puts "#{game[:away].ljust(4)} @ #{game[:home].ljust(4)} - #{game[:time]}/#{game[:tv]}"
48
48
  end
49
49
  ""
50
50
  end
@@ -53,20 +53,20 @@ class NbaInfo::CLI
53
53
  nba = NbaInfo::Team.add_stats
54
54
  puts <<-DOC.gsub /^\s*/, ''
55
55
  EASTERN CONFERENCE
56
- Team |Record | GB
57
- ----------------------------------------
56
+ Team | Record | Win % | GB
57
+ ------------------------------------------------
58
58
  DOC
59
59
  nba[:east].each do |team|
60
- puts "#{team.name.ljust(23)} #{team.record.ljust(9)} #{team.gb}"
60
+ puts "#{team.name.ljust(23)}| #{team.record.ljust(9)}| #{team.win_pct.ljust(6)}| #{team.gb}"
61
61
  end
62
62
  puts <<-DOC.gsub /^\s*/, ''
63
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
64
  WESTERN CONFERENCE
65
- Team |Record | GB
66
- ----------------------------------------
65
+ Team | Record | Win % | GB
66
+ ------------------------------------------------
67
67
  DOC
68
68
  nba[:west].each do |team|
69
- puts "#{team.name.ljust(23)} #{team.record.ljust(9)} #{team.gb}"
69
+ puts "#{team.name.ljust(23)}| #{team.record.ljust(9)}| #{team.win_pct.ljust(6)}| #{team.gb}"
70
70
  end
71
71
  ""
72
72
  end
@@ -77,10 +77,10 @@ class NbaInfo::CLI
77
77
  input = gets.strip.capitalize
78
78
  if nba[:east].any?{|team| team.name.include?(input)}
79
79
  team = nba[:east].detect{|t| t.name.include?(input)}
80
- puts "#{team.name}(#{team.record}) -- PPG: #{team.ppg} -- OPP PPG: #{team.opp_ppg} -- L10: #{team.l_ten} -- Strk: #{team.streak}"
80
+ puts "#{team.name}(#{team.record}) -- PPG: #{team.ppg} -- OPP PPG: #{team.opp_ppg} -- Diff: #{team.diff} -- L10: #{team.l_ten} -- Strk: #{team.streak}"
81
81
  elsif nba[:west].any?{|team| team.name.include?(input)}
82
82
  team = nba[:west].detect{|t| t.name.include?(input)}
83
- puts "#{team.name}(#{team.record}) -- PPG: #{team.ppg} -- OPP PPG: #{team.opp_ppg} -- L10: #{team.l_ten} -- Strk: #{team.streak}"
83
+ puts "#{team.name}(#{team.record}) -- PPG: #{team.ppg} -- OPP PPG: #{team.opp_ppg} -- Diff: #{team.diff} -- L10: #{team.l_ten} -- Strk: #{team.streak}"
84
84
  else
85
85
  "Make sure you omitted the city and spelled the team name correctly"
86
86
  end
@@ -93,7 +93,7 @@ class NbaInfo::CLI
93
93
  PPG - points per game
94
94
  OPP PPG - opponents points per game
95
95
  L10 - last 10
96
- Strk - streak
96
+ Strk - current winning/losing streak
97
97
  DOC
98
98
  end
99
99
 
@@ -1,7 +1,7 @@
1
1
  class NbaInfo::Scraper
2
2
 
3
3
  def self.scrape_team
4
- html = open("http://www.espn.com/nba/standings")
4
+ html = HTTParty.get('http://www.espn.com/nba/standings')
5
5
  doc = Nokogiri::HTML(html)
6
6
  nba = {:east => [], :west => []}
7
7
  names = doc.css('span.hide-mobile a')
@@ -22,34 +22,40 @@ class NbaInfo::Scraper
22
22
  end
23
23
 
24
24
  def self.scrape_stats
25
- html = open("http://www.espn.com/nba/standings")
25
+ html = HTTParty.get("http://www.espn.com/nba/standings")
26
26
  doc = Nokogiri::HTML(html)
27
27
  nba = {:east => [], :west => []}
28
- records = doc.css('table.Table2__table-scroller tbody.Table2__tbody tr')
28
+ records = doc.css('div.Table__ScrollerWrapper table tbody tr')
29
29
  records.each_with_index do |r, i|
30
30
  wins = r.css('td:first-child span').text
31
31
  loss = r.css('td:nth-child(2) span').text
32
+ win_pct = r.css('td:nth-child(3) span').text
32
33
  record = "#{wins} - #{loss}"
33
34
  gb = r.css('td:nth-child(4) span').text
34
35
  ppg = r.css('td:nth-child(9) span').text
35
36
  opp_ppg = r.css('td:nth-child(10) span').text
37
+ diff = r.css('td:nth-child(11) span').text
36
38
  strk = r.css('td:nth-child(12) span').text
37
39
  l_ten = r.css('td:last-child span').text
38
40
  if i < 15
39
41
  nba[:east] << {
40
42
  record: record,
43
+ win_pct: win_pct,
41
44
  gb: gb,
42
45
  ppg: ppg,
43
46
  opp_ppg: opp_ppg,
47
+ diff: diff,
44
48
  streak: strk,
45
49
  l_ten: l_ten
46
50
  }
47
51
  else
48
52
  nba[:west] << {
49
53
  record: record,
54
+ win_pct: win_pct,
50
55
  gb: gb,
51
56
  ppg: ppg,
52
57
  opp_ppg: opp_ppg,
58
+ diff: diff,
53
59
  streak: strk,
54
60
  l_ten: l_ten
55
61
  }
@@ -59,15 +65,16 @@ class NbaInfo::Scraper
59
65
  end
60
66
 
61
67
  def self.scrape_schedule
62
- html = open("https://www.si.com/nba/schedule")
68
+ html = HTTParty.get("https://www.cbssports.com/nba/schedule/")
63
69
  doc = Nokogiri::HTML(html)
64
70
  schedule = []
65
- games = doc.css('table')[0].css('tr:not(:first-child)')
71
+ games = doc.css('table.TableBase-table tbody tr')
66
72
  games.each do |game|
67
73
  schedule << {
68
- away: game.css('td:first-child span.team-abbreviation')[0].text.gsub(/\s+/, ""),
69
- home: game.css('td:nth-child(2) span.team-abbreviation')[0].text.gsub(/\s+/, ""),
70
- time: game.css('td:nth-child(3)').text.strip
74
+ away: game.css('td:first-child span.TeamName a').text,
75
+ home: game.css('td:nth-child(2) span.TeamName a').text,
76
+ time: game.css('td:nth-child(3) div.CellGame a').text,
77
+ tv: game.css('td:nth-child(3) div.CellGame div.CellGameTv').text.strip
71
78
  }
72
79
  end
73
80
  schedule
@@ -1,6 +1,6 @@
1
1
  class NbaInfo::Team
2
2
 
3
- attr_accessor :name, :place, :record, :gb, :streak, :ppg, :opp_ppg, :l_ten
3
+ attr_accessor :name, :place, :record, :win_pct, :gb, :ppg, :opp_ppg, :diff, :streak, :l_ten
4
4
 
5
5
  @@nba = {:east => [], :west => []}
6
6
 
@@ -1,3 +1,3 @@
1
1
  module NbaInfo
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["richard.schaubeck@gmail.com"]
11
11
 
12
12
  spec.summary = "nba info"
13
- spec.description =
13
+ spec.description = "An NBA CLI gem to check current standings, team stats, and the current day's schedule"
14
14
  spec.homepage = "https://github.com/RSchaubeck/nba-info-gem"
15
15
  spec.license = "MIT"
16
16
 
@@ -24,9 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.16"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
28
  spec.add_development_dependency "pry", "~> 0.10.3"
29
29
 
30
30
  spec.add_dependency "nokogiri", "~> 1.0"
31
+ spec.add_dependency "httparty", "~> 0.18.1"
31
32
 
32
33
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nba_information
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RSchaubeck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,22 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
- description: https://github.com/RSchaubeck/nba-info-gem
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.18.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.18.1
83
+ description: An NBA CLI gem to check current standings, team stats, and the current
84
+ day's schedule
70
85
  email:
71
86
  - richard.schaubeck@gmail.com
72
87
  executables:
@@ -89,7 +104,7 @@ files:
89
104
  - lib/nba_info/team.rb
90
105
  - lib/nba_info/version.rb
91
106
  - nba_info.gemspec
92
- - nba_information-1.0.1.gem
107
+ - nba_information-1.1.0.gem
93
108
  homepage: https://github.com/RSchaubeck/nba-info-gem
94
109
  licenses:
95
110
  - MIT
@@ -109,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
124
  - !ruby/object:Gem::Version
110
125
  version: '0'
111
126
  requirements: []
112
- rubygems_version: 3.0.2
127
+ rubygems_version: 3.0.3
113
128
  signing_key:
114
129
  specification_version: 4
115
130
  summary: nba info
Binary file