nba_today_gem 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 808beadb9237e6bde68c368b6d0ce35e6df7124e
4
- data.tar.gz: 71dd51fa36291d51e702fdc069f332c531148c43
3
+ metadata.gz: 4d2fb4724d116b3f8007c2a52b6e076f2e33075f
4
+ data.tar.gz: 59857b9fb97d8d0bb78316ce2bf6a3d9446d6715
5
5
  SHA512:
6
- metadata.gz: 5d3ef5c21f8e7ca79029ec4ab6aa6c17854f683d977cb4cc731dd07aad3f5f8df10d4572f6ad5f2a6e981b7126aaf5053533c5ec21f7ab378c2e00b7414394c0
7
- data.tar.gz: 1359014eb2f74a077888c00c74897eed8d4b0212cecf374478ef1f8ad5ff3bf7e6d6a3da5dab108416b1b2e91d2faa0178faf399596d2bfc80b2ba23915078b6
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
- TODO: Write usage instructions here
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')
@@ -1,16 +1,15 @@
1
- class Game
2
- attr_accessor :status, :score, :venue, :top_peformers, :league, :home_team, :away_team, :url, :recap, :date
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(league)
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
@@ -1,4 +1,4 @@
1
- class NbaPlayer
1
+ class NbaTodayGem::NbaPlayer
2
2
  attr_accessor :name, :points, :rebounds, :assists
3
3
 
4
4
  def initialize(name)
@@ -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("nba")
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, "nba")
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, "nba")
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
@@ -1,20 +1,8 @@
1
- class Team
2
- attr_accessor :name, :score, :league
1
+ class NbaTodayGem::Team
2
+ attr_accessor :name, :score
3
3
 
4
- def initialize(name, league)
4
+ def initialize(name)
5
5
  @name = name
6
- @league = league
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
@@ -1,3 +1,3 @@
1
1
  module NbaTodayGem
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.0
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