nba_today_gem 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/README.md +4 -2
- data/lib/nba_today_gem/commandline.rb +5 -0
- data/lib/nba_today_gem/game.rb +5 -6
- data/lib/nba_today_gem/nba_player.rb +1 -1
- data/lib/nba_today_gem/scraper.rb +9 -9
- data/lib/nba_today_gem/team.rb +4 -16
- data/lib/nba_today_gem/version.rb +1 -1
- data/nba_today_gem-0.1.0.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d2fb4724d116b3f8007c2a52b6e076f2e33075f
|
|
4
|
+
data.tar.gz: 59857b9fb97d8d0bb78316ce2bf6a3d9446d6715
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7eb7aaece3e06350c290f1f028931b9f6ce85ae86b12db99c78670608ca54f77b149c650c2d0748dd1ff6c45c577cf39a1e96151494bd94f9ba4af180d1fdb1
|
|
7
|
+
data.tar.gz: fcf0713d74a2594a01467dd88b7b60b3f7c604515b3c3a8168fc8f9ff7bb2f5a447fe9febd057aa78d8ac90adfc6797a741f5a7578c0bacd314b6532229c5046
|
data/.DS_Store
CHANGED
|
Binary file
|
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# NBA Today Gem
|
|
2
2
|
|
|
3
3
|
The NBA Today Gem is a simple gem that allows you to get the latest NBA scores right through your terminal.
|
|
4
|
+
Data is scraped from MSN Sports.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -12,7 +13,8 @@ gem 'nba_today_gem'
|
|
|
12
13
|
|
|
13
14
|
And then execute:
|
|
14
15
|
|
|
15
|
-
$ bundle
|
|
16
|
+
$ bundle install
|
|
17
|
+
$ ./bin/nba_today_gem
|
|
16
18
|
|
|
17
19
|
Or install it yourself as:
|
|
18
20
|
|
|
@@ -20,7 +22,7 @@ Or install it yourself as:
|
|
|
20
22
|
|
|
21
23
|
## Usage
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
NBA Today Gem is a simple gem that gives you game information on the latest NBA games.
|
|
24
26
|
|
|
25
27
|
## Development
|
|
26
28
|
|
|
@@ -156,6 +156,11 @@ class NbaTodayGem::CommandLine
|
|
|
156
156
|
header :title => 'TOP PERFORMERS', :width => 100, :align => 'center', :rule => true, :color => 'green', :bold => true
|
|
157
157
|
|
|
158
158
|
table(:border => true) do
|
|
159
|
+
row do
|
|
160
|
+
column("#{self.games[index].away_team.name}", :width => 35, :align => 'center')
|
|
161
|
+
column('', :align => 'center')
|
|
162
|
+
column("#{self.games[index].home_team.name}", :width => 35, :align => 'center')
|
|
163
|
+
end
|
|
159
164
|
row do
|
|
160
165
|
column("#{self.games[index].top_peformers[:points][0].name}: #{self.games[index].top_peformers[:points][0].points}", :width => 35, :align => 'center')
|
|
161
166
|
column('POINTS', :align => 'center')
|
data/lib/nba_today_gem/game.rb
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
class Game
|
|
2
|
-
attr_accessor :status, :score, :venue, :top_peformers, :
|
|
1
|
+
class NbaTodayGem::Game
|
|
2
|
+
attr_accessor :status, :score, :venue, :top_peformers, :home_team, :away_team, :url, :recap, :date
|
|
3
3
|
|
|
4
4
|
@@all = []
|
|
5
5
|
|
|
6
|
-
def initialize
|
|
7
|
-
@league = league
|
|
6
|
+
def initialize
|
|
8
7
|
@top_peformers = {}
|
|
9
8
|
@@all << self
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
def away_team=(away_team)
|
|
13
|
-
if !away_team.is_a?(Team)
|
|
12
|
+
if !away_team.is_a?(NbaTodayGem::Team)
|
|
14
13
|
raise TypeError, "must be a Team object"
|
|
15
14
|
else
|
|
16
15
|
@away_team = away_team
|
|
@@ -18,7 +17,7 @@ class Game
|
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
def home_team=(home_team)
|
|
21
|
-
if !home_team.is_a?(Team)
|
|
20
|
+
if !home_team.is_a?(NbaTodayGem::Team)
|
|
22
21
|
raise TypeError, "must be a Team object"
|
|
23
22
|
else
|
|
24
23
|
@home_team = home_team
|
|
@@ -19,20 +19,20 @@ class NbaTodayGem::Scraper
|
|
|
19
19
|
|
|
20
20
|
report do
|
|
21
21
|
self.doc.css("table tbody").each do |game|
|
|
22
|
-
new_nba_game = Game.new
|
|
22
|
+
new_nba_game = NbaTodayGem::Game.new
|
|
23
23
|
|
|
24
24
|
new_nba_game.status = game.css("td.matchstatus.orangeText.hidedownlevel.size4.alignleft div").text
|
|
25
25
|
new_nba_game.venue = game.css("td.venue.size4").text
|
|
26
26
|
new_nba_game.url = "https://www.msn.com/#{game.attribute("data-link").value}"
|
|
27
27
|
|
|
28
|
-
new_nba_game.away_team = Team.new(game.css("td.teamname.teamlineup.alignright.size234").text
|
|
28
|
+
new_nba_game.away_team = NbaTodayGem::Team.new(game.css("td.teamname.teamlineup.alignright.size234").text)
|
|
29
29
|
new_nba_game.away_team.score[0] = game.css("td.totalscore.teamlineup").text.gsub(/[\n _]/, "") # Total score
|
|
30
30
|
new_nba_game.away_team.score[1] = game.css("tr:nth-child(1) td:nth-child(7)").text.gsub(/[\n _]/, "") # Quarter 1 score
|
|
31
31
|
new_nba_game.away_team.score[2] = game.css("tr:nth-child(1) td:nth-child(8)").text.gsub(/[\n _]/, "") # Quarter 2 score
|
|
32
32
|
new_nba_game.away_team.score[3] = game.css("tr:nth-child(1) td:nth-child(9)").text.gsub(/[\n _]/, "") # Quarter 3 score
|
|
33
33
|
new_nba_game.away_team.score[4] = game.css("tr:nth-child(1) td:nth-child(10)").text.gsub(/[\n _]/, "") # Quarter 4 score
|
|
34
34
|
|
|
35
|
-
new_nba_game.home_team = Team.new(game.css("td.teamname.teamlinedown.alignright.size234").text
|
|
35
|
+
new_nba_game.home_team = NbaTodayGem::Team.new(game.css("td.teamname.teamlinedown.alignright.size234").text)
|
|
36
36
|
new_nba_game.home_team.score[0] = game.css("td.totalscore.teamlinedown").text.gsub(/[\n _]/, "") # Total score
|
|
37
37
|
new_nba_game.home_team.score[1] = game.css("tr:nth-child(2) td:nth-child(5)").text.gsub(/[\n _]/, "") # Quarter 1 score
|
|
38
38
|
new_nba_game.home_team.score[2] = game.css("tr:nth-child(2) td:nth-child(6)").text.gsub(/[\n _]/, "") # Quarter 2 score
|
|
@@ -56,24 +56,24 @@ class NbaTodayGem::Scraper
|
|
|
56
56
|
game.recap = get_game_info.css("#matchuprecapmodule header h1").text
|
|
57
57
|
|
|
58
58
|
point_leaders = [
|
|
59
|
-
NbaPlayer.new(get_game_info.css("div.leaders div.points a:nth-child(3) div div.board span div.playername span").text),
|
|
60
|
-
NbaPlayer.new(get_game_info.css("div.leaders div.points a:nth-child(5) div div.board span div.playername span").text)
|
|
59
|
+
NbaTodayGem::NbaPlayer.new(get_game_info.css("div.leaders div.points a:nth-child(3) div div.board span div.playername span").text),
|
|
60
|
+
NbaTodayGem::NbaPlayer.new(get_game_info.css("div.leaders div.points a:nth-child(5) div div.board span div.playername span").text)
|
|
61
61
|
]
|
|
62
62
|
|
|
63
63
|
point_leaders[0].points = get_game_info.css("div.leaders div.points a:nth-child(3) div div.board span div.stats span").text
|
|
64
64
|
point_leaders[1].points = get_game_info.css("div.leaders div.points a:nth-child(5) div div.board span div.stats span").text
|
|
65
65
|
|
|
66
66
|
rebound_leaders = [
|
|
67
|
-
NbaPlayer.new(get_game_info.css("div.leaders div.rebounds a:nth-child(3) div div.board span div.playername span").text),
|
|
68
|
-
NbaPlayer.new(get_game_info.css("div.leaders div.rebounds a:nth-child(5) div div.board span div.playername span").text)
|
|
67
|
+
NbaTodayGem::NbaPlayer.new(get_game_info.css("div.leaders div.rebounds a:nth-child(3) div div.board span div.playername span").text),
|
|
68
|
+
NbaTodayGem::NbaPlayer.new(get_game_info.css("div.leaders div.rebounds a:nth-child(5) div div.board span div.playername span").text)
|
|
69
69
|
]
|
|
70
70
|
|
|
71
71
|
rebound_leaders[0].rebounds = get_game_info.css("div.leaders div.rebounds a:nth-child(3) div div.board span div.stats span").text
|
|
72
72
|
rebound_leaders[1].rebounds = get_game_info.css("div.leaders div.rebounds a:nth-child(5) div div.board span div.stats span").text
|
|
73
73
|
|
|
74
74
|
assist_leaders = [
|
|
75
|
-
NbaPlayer.new(get_game_info.css("div.leaders div.assists a:nth-child(3) div div.board span div.playername span").text),
|
|
76
|
-
NbaPlayer.new(get_game_info.css("div.leaders div.assists a:nth-child(5) div div.board span div.playername span").text)
|
|
75
|
+
NbaTodayGem::NbaPlayer.new(get_game_info.css("div.leaders div.assists a:nth-child(3) div div.board span div.playername span").text),
|
|
76
|
+
NbaTodayGem::NbaPlayer.new(get_game_info.css("div.leaders div.assists a:nth-child(5) div div.board span div.playername span").text)
|
|
77
77
|
]
|
|
78
78
|
|
|
79
79
|
assist_leaders[0].assists = get_game_info.css("div.leaders div.assists a:nth-child(3) div div.board span div.stats span").text
|
data/lib/nba_today_gem/team.rb
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
class Team
|
|
2
|
-
attr_accessor :name, :score
|
|
1
|
+
class NbaTodayGem::Team
|
|
2
|
+
attr_accessor :name, :score
|
|
3
3
|
|
|
4
|
-
def initialize(name
|
|
4
|
+
def initialize(name)
|
|
5
5
|
@name = name
|
|
6
|
-
@
|
|
7
|
-
|
|
8
|
-
# score is equal to an array of innings/periods/quarters
|
|
9
|
-
# the first element (@score[0]) is the TOTAL/FINAL score
|
|
10
|
-
# subsequent elements are the inning/period/quarter totals
|
|
11
|
-
case @league
|
|
12
|
-
when "mlb"
|
|
13
|
-
@score = [0,0,0,0,0,0,0,0,0,0]
|
|
14
|
-
when "nhl"
|
|
15
|
-
@score = [0,0,0,0]
|
|
16
|
-
else
|
|
17
|
-
@score = [0,0,0,0,0]
|
|
18
|
-
end
|
|
6
|
+
@score = [0,0,0,0,0]
|
|
19
7
|
end
|
|
20
8
|
end
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nba_today_gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergio Mendoza
|
|
@@ -77,6 +77,7 @@ files:
|
|
|
77
77
|
- lib/nba_today_gem/scraper.rb
|
|
78
78
|
- lib/nba_today_gem/team.rb
|
|
79
79
|
- lib/nba_today_gem/version.rb
|
|
80
|
+
- nba_today_gem-0.1.0.gem
|
|
80
81
|
- nba_today_gem.gemspec
|
|
81
82
|
- spec.md
|
|
82
83
|
homepage: https://github.com/smendoza787/nba-today-gem
|