sports_news_scraper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +59 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/sports_news_scraper +8 -0
- data/lib/ESPNScraper.rb +10 -0
- data/lib/ESPNScraper/article.rb +21 -0
- data/lib/ESPNScraper/cli.rb +125 -0
- data/lib/ESPNScraper/scraper.rb +43 -0
- data/lib/ESPNScraper/teams.rb +158 -0
- data/lib/ESPNScraper/version.rb +3 -0
- data/sports_news_scraper.gemspec +37 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dc85b3362487b40527fde6aab4d2358813f059425946e0e8712892807b278f1c
|
4
|
+
data.tar.gz: 34420da7b52fbf165e28b80ebd084e08a3e06806147fc6c378a801af4c16589c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86ecd698cd34a97a961fc8ca37d775361a352142c33de3cd21c2fdd255926b66ab3281018dc348b43ba3743acdb4780d49144c521bf31758ccda1946d12f4e0f
|
7
|
+
data.tar.gz: 351805de7f8eab9402817e943e0f6f44c07e83b277313faf4b694e8c01622d4968270c8303b4786287ef93239270426553aefda678b2f0ecab3cc9a25406f64a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ESPNScraper (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
colorize (0.8.1)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
equatable (0.6.1)
|
12
|
+
mini_portile2 (2.4.0)
|
13
|
+
necromancer (0.5.1)
|
14
|
+
nokogiri (1.10.7)
|
15
|
+
mini_portile2 (~> 2.4.0)
|
16
|
+
pastel (0.7.3)
|
17
|
+
equatable (~> 0.6)
|
18
|
+
tty-color (~> 0.5)
|
19
|
+
rake (10.5.0)
|
20
|
+
rspec (3.9.0)
|
21
|
+
rspec-core (~> 3.9.0)
|
22
|
+
rspec-expectations (~> 3.9.0)
|
23
|
+
rspec-mocks (~> 3.9.0)
|
24
|
+
rspec-core (3.9.1)
|
25
|
+
rspec-support (~> 3.9.1)
|
26
|
+
rspec-expectations (3.9.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.9.0)
|
29
|
+
rspec-mocks (3.9.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.9.0)
|
32
|
+
rspec-support (3.9.2)
|
33
|
+
tty-color (0.5.1)
|
34
|
+
tty-cursor (0.7.1)
|
35
|
+
tty-prompt (0.20.0)
|
36
|
+
necromancer (~> 0.5.0)
|
37
|
+
pastel (~> 0.7.0)
|
38
|
+
tty-reader (~> 0.7.0)
|
39
|
+
tty-reader (0.7.0)
|
40
|
+
tty-cursor (~> 0.7)
|
41
|
+
tty-screen (~> 0.7)
|
42
|
+
wisper (~> 2.0.0)
|
43
|
+
tty-screen (0.7.1)
|
44
|
+
wisper (2.0.1)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
ESPNScraper!
|
51
|
+
bundler (~> 2.0)
|
52
|
+
colorize
|
53
|
+
nokogiri
|
54
|
+
rake (~> 10.0)
|
55
|
+
rspec (~> 3.0)
|
56
|
+
tty-prompt
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.0.2
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# ESPNScraper
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ESPN_Scraper`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ESPN_Scraper'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ESPN_Scraper
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ESPN_Scraper.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ESPNScraper"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/ESPNScraper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative "./ESPNScraper/version"
|
2
|
+
require_relative "./ESPNScraper/cli"
|
3
|
+
require_relative "./ESPNScraper/article"
|
4
|
+
require_relative "./ESPNScraper/scraper"
|
5
|
+
require_relative "./ESPNScraper/teams"
|
6
|
+
require "open-uri"
|
7
|
+
require "nokogiri"
|
8
|
+
require "colorize"
|
9
|
+
require "pry"
|
10
|
+
require 'tty-prompt'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Article
|
2
|
+
attr_accessor :content
|
3
|
+
attr_reader :title, :description, :url
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def initialize(title, description, url)
|
7
|
+
@title = title
|
8
|
+
@description = description
|
9
|
+
@url = url
|
10
|
+
@@all << self
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all
|
14
|
+
@@all
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.destroy_all
|
18
|
+
@@all = []
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# CLI Controller
|
2
|
+
class ESPNScraper::CLI
|
3
|
+
attr_accessor :sport, :team, :url, :article
|
4
|
+
|
5
|
+
def run
|
6
|
+
@prompt = TTY::Prompt.new
|
7
|
+
welcome
|
8
|
+
end
|
9
|
+
|
10
|
+
def welcome
|
11
|
+
system "clear"
|
12
|
+
puts "Welcome to the ESPN Scraper, your source for all the latest news for the MLB, NFL, NHL, and NBA!".colorize(:blue)
|
13
|
+
options = ["MLB", "NBA", "NFL", "NHL", "Exit"]
|
14
|
+
input = @prompt.select("Select the sport you'd like to read about...", options).downcase
|
15
|
+
if input == "exit"
|
16
|
+
puts "Ending the program. See you again soon!".colorize(:yellow)
|
17
|
+
exit
|
18
|
+
else
|
19
|
+
@sport = input
|
20
|
+
list_teams
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def list_teams
|
25
|
+
system "clear"
|
26
|
+
case self.sport
|
27
|
+
when "mlb"
|
28
|
+
all_teams = Teams.mlb_teams
|
29
|
+
when "nba"
|
30
|
+
all_teams = Teams.nba_teams
|
31
|
+
when "nfl"
|
32
|
+
all_teams = Teams.nfl_teams
|
33
|
+
when "nhl"
|
34
|
+
all_teams = Teams.nhl_teams
|
35
|
+
end
|
36
|
+
all_teams.each do |division, teams|
|
37
|
+
puts division.to_s.sub(/_/, ' ').upcase.colorize(:magenta).bold
|
38
|
+
teams.each do |team|
|
39
|
+
team.each{|key,value| puts " #{key.to_s.upcase} - #{value}"}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
menu
|
43
|
+
end
|
44
|
+
|
45
|
+
def menu
|
46
|
+
options = Teams.team_abbreviations(self.sport).collect{|team| team.upcase} + ["Select New Sport", "Exit"]
|
47
|
+
input = @prompt.select("Select the team you'd like to read about.", options, filter: true).downcase
|
48
|
+
if Teams.team_abbreviations(self.sport).include?(input)
|
49
|
+
@team = input
|
50
|
+
build_url
|
51
|
+
self.sport == "nhl" ? Scraper.scrape_new_nhl_articles(self.url) : Scraper.scrape_new_articles(self.url)
|
52
|
+
display_articles
|
53
|
+
elsif input == "select new sport"
|
54
|
+
Article.destroy_all
|
55
|
+
run
|
56
|
+
elsif input == "exit"
|
57
|
+
puts "Ending the program. See you again soon!".colorize(:yellow)
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def display_articles
|
63
|
+
system "clear"
|
64
|
+
Article.all.slice(0,5).each_with_index do |article, index|
|
65
|
+
puts "#{index + 1}. #{article.title}".colorize(:light_blue).bold
|
66
|
+
puts " #{article.description} \n \n"
|
67
|
+
end
|
68
|
+
article_menu
|
69
|
+
end
|
70
|
+
|
71
|
+
def article_menu
|
72
|
+
options = ["1", "2", "3", "4", "5",
|
73
|
+
"Select New Sport", "Select New Team", "Exit"]
|
74
|
+
input = @prompt.select("Which article would you like to read?", options)
|
75
|
+
if input.to_i.between?(1, 5)
|
76
|
+
article_index = input.to_i - 1
|
77
|
+
@article = Article.all[article_index]
|
78
|
+
show_article_content
|
79
|
+
exit_menu
|
80
|
+
elsif input == "Select New Sport"
|
81
|
+
Article.destroy_all
|
82
|
+
run
|
83
|
+
elsif input == "Select New Team"
|
84
|
+
Article.destroy_all
|
85
|
+
list_teams
|
86
|
+
menu
|
87
|
+
elsif input == "Exit"
|
88
|
+
puts "Ending the program. See you again soon!".colorize(:yellow)
|
89
|
+
exit
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def show_article_content
|
94
|
+
system "clear"
|
95
|
+
Scraper.get_content(self.article)
|
96
|
+
puts "#{self.article.title} \n \n".colorize(:light_blue).bold
|
97
|
+
if self.article.content.size > 0
|
98
|
+
self.article.content.each {|p| puts "#{p.text} \n \n"}
|
99
|
+
else
|
100
|
+
puts "This is a link to an ESPN Radio report. To listen to the report vist: #{self.article.url}".colorize(:red)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def exit_menu
|
105
|
+
options = ["Return to articles", "Select a new sport", "Select a new team in this league", "Exit"]
|
106
|
+
input = @prompt.select("What would you like to do now?", options)
|
107
|
+
if input == "Return to articles"
|
108
|
+
display_articles
|
109
|
+
article_menu
|
110
|
+
elsif input == "Select a new sport"
|
111
|
+
Article.destroy_all
|
112
|
+
run
|
113
|
+
elsif input == "Select a new team in this league"
|
114
|
+
list_teams
|
115
|
+
elsif input == "Exit"
|
116
|
+
puts "Ending the program. See you again soon!".colorize(:yellow)
|
117
|
+
exit
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
def build_url
|
123
|
+
@url = "https://www.espn.com/" + "#{@sport}" + "/team/_/name/" + "#{@team}"
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Scraper
|
2
|
+
|
3
|
+
def self.scrape_new_articles(url)
|
4
|
+
html = open(url)
|
5
|
+
doc = Nokogiri::HTML(html)
|
6
|
+
stories = doc.css("div.item-info-wrap")
|
7
|
+
stories.each do |story|
|
8
|
+
title = story.css("h1").text
|
9
|
+
description = story.css("p").text
|
10
|
+
if story.css("a").attribute("href").value.start_with?("http")
|
11
|
+
url = story.css("a").attribute("href").value
|
12
|
+
else
|
13
|
+
url = "https://www.espn.com#{story.css("a").attribute("href").value}"
|
14
|
+
end
|
15
|
+
Article.new(title, description, url)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.scrape_new_nhl_articles(url)
|
20
|
+
html = open(url)
|
21
|
+
doc = Nokogiri::HTML(html)
|
22
|
+
stories = doc.css("article").select{|story| story.css('a.contentItem__content').attribute('href')}
|
23
|
+
stories.each do |story|
|
24
|
+
title = story.css("h2.contentItem__title").text
|
25
|
+
description = nil
|
26
|
+
if story.css('a.contentItem__content').attribute('href').value.start_with?("http")
|
27
|
+
url = story.css('a.contentItem__content').attribute('href').value
|
28
|
+
else
|
29
|
+
url = "https://www.espn.com#{story.css('a.contentItem__content').attribute('href').value}"
|
30
|
+
end
|
31
|
+
Article.new(title, description, url)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.get_content(article)
|
36
|
+
html = open(article.url)
|
37
|
+
doc = Nokogiri::HTML(html)
|
38
|
+
#for ESPN Radio links, this will return an empty array
|
39
|
+
article.content = doc.css("div.article-body p")
|
40
|
+
article.content = doc.css("div.Story__Body p") if article.content.size == 0
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
class Teams
|
2
|
+
|
3
|
+
def self.mlb_teams
|
4
|
+
{al_east: [{bal: "Baltimore Orioles"},
|
5
|
+
{bos: "Boston Red Sox"},
|
6
|
+
{nyy: "New York Yankees"},
|
7
|
+
{tb: "Tampa Bay Rays"},
|
8
|
+
{tor: "Toronto Blue Jays"}],
|
9
|
+
al_central: [{chw: "Chicago White Sox"},
|
10
|
+
{cle: "Cleveland Indians"},
|
11
|
+
{det: "Detroit Tigers"},
|
12
|
+
{kan: "Kansas City Royals"},
|
13
|
+
{min: "Minnesota Twins"}],
|
14
|
+
al_west: [{hou: "Houston Astros"},
|
15
|
+
{laa: "Los Angeles Angels"},
|
16
|
+
{oak: "Oakland Athletics"},
|
17
|
+
{sea: "Seattle Mariners"},
|
18
|
+
{tex: "Texas Rangers"}],
|
19
|
+
nl_east: [{atl: "Atlanta Braves"},
|
20
|
+
{mia: "Miami Marlins"},
|
21
|
+
{nym: "New York Mets"},
|
22
|
+
{phi: "Philadelphia Phillies"},
|
23
|
+
{was: "Washington Nationals"}],
|
24
|
+
nl_central: [{chc: "Chicago Cubs"},
|
25
|
+
{cin: "Cincinnati Reds"},
|
26
|
+
{mil: "Milwaukee Brewers"},
|
27
|
+
{pit: "Pitsburgh Pirates"},
|
28
|
+
{stl: "St Louis Cardinals"}],
|
29
|
+
nl_west: [{ari: "Arizona Diamondbacks"},
|
30
|
+
{col: "Colorado Rockies"},
|
31
|
+
{lad: "Los Angeles Dodgers"},
|
32
|
+
{sd: "San Diego Padres"},
|
33
|
+
{sf: "San Fransisco Giants"}]}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.nba_teams
|
37
|
+
{atlantic: [{bos: "Boston Celtics"},
|
38
|
+
{bkn: "Brooklyn Nets"},
|
39
|
+
{nyk: "New York Knicks"},
|
40
|
+
{phi: "Philadelphia 76ers"},
|
41
|
+
{tor: "Toronto Raptors"}],
|
42
|
+
central: [{chi: "Chicago Bulls"},
|
43
|
+
{cle: "Cleveland Cavaliers"},
|
44
|
+
{det: "Detroit Pistons"},
|
45
|
+
{ind: "Indiana Pacers"},
|
46
|
+
{mil: "Milwaukee Bucks"}],
|
47
|
+
southeast: [{atl: "Atlanta Hawks"},
|
48
|
+
{cha: "Charlotte Hornets"},
|
49
|
+
{mia: "Miami Heat"},
|
50
|
+
{orl: "Orlando Magic"},
|
51
|
+
{wsh: "Washington Wizards"}],
|
52
|
+
northwest: [{den: "Denver Nuggets"},
|
53
|
+
{min: "Minnesota Timberwolves"},
|
54
|
+
{okc: "Oklahoma City Thunder"},
|
55
|
+
{por: "Portland Trail Blazers"},
|
56
|
+
{utah: "Utah Jazz"}],
|
57
|
+
pacific: [{gsw: "Golden State Warriors"},
|
58
|
+
{lac: "LA Clippers"},
|
59
|
+
{lal: "LA Lakers"},
|
60
|
+
{phx: "Phoenix Suns"},
|
61
|
+
{sac: "Sacramento Kings"}],
|
62
|
+
Southwest: [{dal: "Dallas Mavericks"},
|
63
|
+
{hou: "Houston Rockets"},
|
64
|
+
{mem: "Memphis Grizzlies"},
|
65
|
+
{nop: "New Orleans Pelicans"},
|
66
|
+
{sas: "San Antonio Spurs"}]}
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.nhl_teams
|
70
|
+
{atlantic: [{bos: "Boston Bruins"},
|
71
|
+
{buf: "Buffalo Sabres"},
|
72
|
+
{det: "Detroit Redwings"},
|
73
|
+
{fla: "Florida Panthers"},
|
74
|
+
{mtl: "Montreal Canadiens"},
|
75
|
+
{ott: "Ottowa Senators"},
|
76
|
+
{tb: "Tampa Bay Lightning"},
|
77
|
+
{tor: "Toronto Maple Leafs"}],
|
78
|
+
central: [{chi: "Chicago Blackhawks"},
|
79
|
+
{col: "Colorado Avalanche"},
|
80
|
+
{dal: "Dallas Stars"},
|
81
|
+
{min: "Minnesota Wild"},
|
82
|
+
{nsh: "Nashville Predators"},
|
83
|
+
{stl: "St. Louis Blues"},
|
84
|
+
{wpg: "Winnipeg Jets"}],
|
85
|
+
metropolitan: [{car: "Carolina Hurricanes"},
|
86
|
+
{cbj: "Columbus Blue Jackets"},
|
87
|
+
{nj: "New Jersey Devils"},
|
88
|
+
{nyi: "New York Islanders"},
|
89
|
+
{nyr: "New York Rangers"},
|
90
|
+
{phi: "Philadelphi Flyers"},
|
91
|
+
{pit: "Pittsburgh Penguins"},
|
92
|
+
{wsh: "Washington Capitals"}],
|
93
|
+
pacific: [{ana: "Anaheim Ducks"},
|
94
|
+
{ari: "Arizona Coyotes"},
|
95
|
+
{cgy: "Calgary Flames"},
|
96
|
+
{edm: "Edmonton Oilers"},
|
97
|
+
{la: "Los Angeles Kings"},
|
98
|
+
{sj: "San Jose Sharks"},
|
99
|
+
{van: "Vancouver Canucks"},
|
100
|
+
{vgs: "Vegas Golden Knights"}]}
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.nfl_teams
|
104
|
+
{afc_east: [{buf: "Buffalo Bills"},
|
105
|
+
{mia: "Miami Dolfins"},
|
106
|
+
{ne: "New England Patriots"},
|
107
|
+
{nyj: "New York Jets"}],
|
108
|
+
afc_north: [{bal: "Baltimore Ravens"},
|
109
|
+
{cin: "Cincinnati Bengals"},
|
110
|
+
{cle: "Cleveland Browns"},
|
111
|
+
{pit: "Pitsburgh Steelers"}],
|
112
|
+
afc_south: [{hou: "Houston Texans"},
|
113
|
+
{ind: "Indianapolis Colts"},
|
114
|
+
{jax: "Jacksonville Jaguars"},
|
115
|
+
{ten: "Tennessee Titans"}],
|
116
|
+
afc_west: [{den: "Denver Broncos"},
|
117
|
+
{kc: "Kansas City Chiefs"},
|
118
|
+
{lac: "Los Angeles Chargers"},
|
119
|
+
{oak: "Oakland Raiders"}],
|
120
|
+
nfc_east: [{dal: "Dallas Cowboys"},
|
121
|
+
{nyg: "New York Giants"},
|
122
|
+
{phi: "Philadelphia Eagles"},
|
123
|
+
{wsh: "Washington Redskins"}],
|
124
|
+
nfc_north: [{chi: "Chicago Bears"},
|
125
|
+
{det: "Detroit Lions"},
|
126
|
+
{gb: "Green Bay Packers"},
|
127
|
+
{min: "Minnesota Vikings"}],
|
128
|
+
nfc_south: [{atl: "Atlanta Falcons"},
|
129
|
+
{car: "Carolina Panthers"},
|
130
|
+
{no: "New Orleans Saints"},
|
131
|
+
{tb: "Tampa Bay Buccaneers"}],
|
132
|
+
nfc_west: [{ari: "Arizona Cardinals"},
|
133
|
+
{lar: "Los Angeles Rams"},
|
134
|
+
{sf: "San Fransisco 49ers"},
|
135
|
+
{sea: "Seattle Seahawks"}]}
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.team_abbreviations(sport)
|
139
|
+
abbr_teams = []
|
140
|
+
|
141
|
+
case sport
|
142
|
+
when "mlb"
|
143
|
+
teams = mlb_teams
|
144
|
+
when "nba"
|
145
|
+
teams = nba_teams
|
146
|
+
when "nfl"
|
147
|
+
teams = nfl_teams
|
148
|
+
when "nhl"
|
149
|
+
teams = nhl_teams
|
150
|
+
end
|
151
|
+
|
152
|
+
teams.each do |division, teams|
|
153
|
+
teams.each {|team| team.each {|abbr, full| abbr_teams << abbr.to_s}}
|
154
|
+
end
|
155
|
+
abbr_teams
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "ESPNScraper/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "sports_news_scraper"
|
7
|
+
spec.version = ESPNScraper::VERSION
|
8
|
+
spec.authors = ["Dave Van Fleet"]
|
9
|
+
spec.email = ["dvfleet413@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{ESPN Scraper is a CLI gem designed to provide quick access to articles on ESPN.com
|
12
|
+
for your favorite MLB team.}
|
13
|
+
spec.description = %q{ESPN Scraper is a CLI gem designed to provide quick access to articles on ESPN.com
|
14
|
+
for your favorite MLB team}
|
15
|
+
spec.homepage = "https://github.com/dvfleet413/espn-scraper"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/dvfleet413/espn-scraper"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/dvfleet413/espn-scraper/blob/master/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
|
29
|
+
spec.bindir = "bin"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.executables << "sports_news_scraper"
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sports_news_scraper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Van Fleet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: |-
|
56
|
+
ESPN Scraper is a CLI gem designed to provide quick access to articles on ESPN.com
|
57
|
+
for your favorite MLB team
|
58
|
+
email:
|
59
|
+
- dvfleet413@gmail.com
|
60
|
+
executables:
|
61
|
+
- sports_news_scraper
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".travis.yml"
|
68
|
+
- CHANGELOG.md
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- bin/sports_news_scraper
|
76
|
+
- lib/ESPNScraper.rb
|
77
|
+
- lib/ESPNScraper/article.rb
|
78
|
+
- lib/ESPNScraper/cli.rb
|
79
|
+
- lib/ESPNScraper/scraper.rb
|
80
|
+
- lib/ESPNScraper/teams.rb
|
81
|
+
- lib/ESPNScraper/version.rb
|
82
|
+
- sports_news_scraper.gemspec
|
83
|
+
homepage: https://github.com/dvfleet413/espn-scraper
|
84
|
+
licenses: []
|
85
|
+
metadata:
|
86
|
+
homepage_uri: https://github.com/dvfleet413/espn-scraper
|
87
|
+
source_code_uri: https://github.com/dvfleet413/espn-scraper
|
88
|
+
changelog_uri: https://github.com/dvfleet413/espn-scraper/blob/master/CHANGELOG.md
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.0.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: ESPN Scraper is a CLI gem designed to provide quick access to articles on
|
108
|
+
ESPN.com for your favorite MLB team.
|
109
|
+
test_files: []
|