nfl-top-stories 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 +9 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +32 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/nfl-top-stories +6 -0
- data/bin/setup +8 -0
- data/lib/nfl_top_stories/cli.rb +49 -0
- data/lib/nfl_top_stories/concerns/headline_choice.rb +66 -0
- data/lib/nfl_top_stories/headline.rb +82 -0
- data/lib/nfl_top_stories/story.rb +137 -0
- data/lib/nfl_top_stories/version.rb +3 -0
- data/lib/nfl_top_stories.rb +8 -0
- data/nfl_top_stories.gemspec +29 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3bf5dbe88200f227c3c110de885270aed346b43b
|
4
|
+
data.tar.gz: 64aa00d3aa80ebfecf0be2b91b111548fd7661fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7910f71a006f8392d24f2ab3e528385e731a7330c0b0f263012ad8b1039dd4069b5004e46ebe11707a2c3e70664f5a049ef79123b8022a6ca0b9b787091c2d4
|
7
|
+
data.tar.gz: cf48c28f62cb88ccb9df11014745504c4d0072a871806ce87533fad6442f6f5829a9b25901a6104aa7c6369d2afff9d705b3d2640b8ad052cf98c87e55dddf9b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at the@brianemory.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 thebrianemory
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/NOTES.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
How to Build a CLI Gem
|
2
|
+
|
3
|
+
1. Plan your gem, imagine your interface
|
4
|
+
2. Start with the project structure - google
|
5
|
+
3. Start with the entry point - the file run
|
6
|
+
4. force that to build the CLI interface
|
7
|
+
5. stub out the interface
|
8
|
+
6. start making things real
|
9
|
+
7. discover objects.
|
10
|
+
8. program
|
11
|
+
|
12
|
+
- A command line interface for top NFL stories from ESPN, NFL.com, CBS Sports FOX Sports, and USA Today.
|
13
|
+
|
14
|
+
user types top-stories
|
15
|
+
|
16
|
+
Show a list of news sites
|
17
|
+
|
18
|
+
1. ESPN
|
19
|
+
2. NFL.com
|
20
|
+
3. CBS Sports
|
21
|
+
4. FOX Sports
|
22
|
+
5. USA Today
|
23
|
+
|
24
|
+
Which news site would you like to see top NFL stories for?
|
25
|
+
Type search to see top stories by topic.
|
26
|
+
|
27
|
+
|
28
|
+
- A Story has a headline
|
29
|
+
- A Story has a URL
|
30
|
+
-- A Story has an author
|
31
|
+
-- A Story has a posted date/time
|
32
|
+
-- A Story has a story
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# NFL Top Stories
|
2
|
+
|
3
|
+
NFL Top Stories will pull headlines and stories from ESPN, NFL.com, CBS Sports, Fox Sports, and USA Today. Upon choosing your media outlet, you will get a list of their top NFL stories pulled from the NFL news portion of their website and display them. You can choose your story which will show its title, author, and a five paragraph preview of the story with the URL for the full story.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'nfl_top_stories'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install nfl_top_stories
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
From the directory execute:
|
24
|
+
|
25
|
+
$ ./bin/nfl-top-stories
|
26
|
+
|
27
|
+
and follow the prompts to get your news.
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/thebrianemory/nfl-top-stories-cli-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nfl_top_stories"
|
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 "pry"
|
14
|
+
Pry.start
|
data/bin/nfl-top-stories
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
class CLI
|
2
|
+
|
3
|
+
def call
|
4
|
+
puts ""
|
5
|
+
puts "Welcome to NFL Top Stories!"
|
6
|
+
puts "View the top headlines from the following sites:"
|
7
|
+
puts ""
|
8
|
+
list_stories
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_stories
|
12
|
+
puts <<~DOC
|
13
|
+
1. ESPN.com
|
14
|
+
2. NFL.com
|
15
|
+
3. CBSSports.com
|
16
|
+
4. FoxSports.com
|
17
|
+
5. USAToday.com
|
18
|
+
DOC
|
19
|
+
menu
|
20
|
+
end
|
21
|
+
|
22
|
+
def menu
|
23
|
+
puts "Enter the number for the site you want to see headlines from.\nYou can also type list to display sites or exit to cancel."
|
24
|
+
input = gets.strip.downcase
|
25
|
+
puts ""
|
26
|
+
if input == "1"
|
27
|
+
Headline.get_headlines("espn")
|
28
|
+
elsif input == "2"
|
29
|
+
Headline.get_headlines("nfl")
|
30
|
+
elsif input == "3"
|
31
|
+
Headline.get_headlines("cbs")
|
32
|
+
elsif input == "4"
|
33
|
+
Headline.get_headlines("fox")
|
34
|
+
elsif input == "5"
|
35
|
+
Headline.get_headlines("usa")
|
36
|
+
elsif input == "list"
|
37
|
+
list_stories
|
38
|
+
elsif input == "exit"
|
39
|
+
goodbye
|
40
|
+
else
|
41
|
+
puts "\033[0;33mInvalid entry...\033[0m"
|
42
|
+
menu
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def goodbye
|
47
|
+
puts "\033[0;33mSee you next time!\033[0m"
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module HeadlineChoice
|
2
|
+
|
3
|
+
def get_headlines(source)
|
4
|
+
@headlines = []
|
5
|
+
case source.to_s
|
6
|
+
when "espn"
|
7
|
+
self.scrape_espn
|
8
|
+
get_choice("espn")
|
9
|
+
when "nfl"
|
10
|
+
self.scrape_nfl
|
11
|
+
get_choice("nfl")
|
12
|
+
when "cbs"
|
13
|
+
self.scrape_cbs
|
14
|
+
get_choice("cbs")
|
15
|
+
when "fox"
|
16
|
+
self.scrape_fox
|
17
|
+
get_choice("fox")
|
18
|
+
when "usa"
|
19
|
+
self.scrape_usa
|
20
|
+
get_choice("usa")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_choice(source)
|
25
|
+
puts "\033[0;36mWhich story would you like to read?\033[0m"
|
26
|
+
puts "0. Back to the main menu"
|
27
|
+
@headlines.each.with_index(1) do |headline, i|
|
28
|
+
puts "#{i}. #{headline.title}"
|
29
|
+
end
|
30
|
+
|
31
|
+
case source
|
32
|
+
when "espn"
|
33
|
+
get_source = "espn_stories"
|
34
|
+
when "nfl"
|
35
|
+
get_source = "nfl_stories"
|
36
|
+
when "cbs"
|
37
|
+
get_source = "cbs_stories"
|
38
|
+
when "fox"
|
39
|
+
get_source = "fox_stories"
|
40
|
+
when "usa"
|
41
|
+
get_source = "usa_stories"
|
42
|
+
end
|
43
|
+
|
44
|
+
input = gets.strip.downcase
|
45
|
+
if input == "0"
|
46
|
+
puts ""
|
47
|
+
CLI.new.call
|
48
|
+
elsif input == "1"
|
49
|
+
Story.send(get_source, @headlines[0].url)
|
50
|
+
elsif input == "2"
|
51
|
+
Story.send(get_source, @headlines[1].url)
|
52
|
+
elsif input == "3"
|
53
|
+
Story.send(get_source, @headlines[2].url)
|
54
|
+
elsif input == "4"
|
55
|
+
Story.send(get_source, @headlines[3].url)
|
56
|
+
elsif input == "5"
|
57
|
+
Story.send(get_source, @headlines[4].url)
|
58
|
+
elsif input == "6"
|
59
|
+
Story.send(get_source, @headlines[5].url)
|
60
|
+
else
|
61
|
+
puts ""
|
62
|
+
puts "\033[0;33mInvalid entry...\033[0m"
|
63
|
+
get_choice(source)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class Headline
|
2
|
+
attr_accessor :title, :url
|
3
|
+
extend HeadlineChoice
|
4
|
+
|
5
|
+
@headlines = []
|
6
|
+
|
7
|
+
## ------------------- ESPN Headlines ------------------- ##
|
8
|
+
def self.scrape_espn
|
9
|
+
main_url = "http://espn.go.com"
|
10
|
+
doc = Nokogiri::HTML(open("http://espn.go.com/nfl/"))
|
11
|
+
|
12
|
+
i = 0
|
13
|
+
while i < 6
|
14
|
+
espn_headline = self.new
|
15
|
+
espn_headline.title = doc.search("div.headlines ul li a")[i].text
|
16
|
+
espn_headline.url = main_url + doc.search("div.headlines ul li a")[i].attributes["href"].value
|
17
|
+
@headlines << espn_headline
|
18
|
+
i += 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
## ------------------- NFL.com Headlines ------------------- ##
|
23
|
+
def self.scrape_nfl
|
24
|
+
main_url = "http://www.nfl.com"
|
25
|
+
doc = Nokogiri::HTML(open("http://www.nfl.com/news"))
|
26
|
+
|
27
|
+
i = 0
|
28
|
+
while i < 6
|
29
|
+
nfl_headline = self.new
|
30
|
+
nfl_headline.title = doc.search("div#headlines-latest li a")[i].text
|
31
|
+
nfl_headline.url = main_url + doc.search("div#headlines-latest li a")[i].attributes["href"].value
|
32
|
+
@headlines << nfl_headline
|
33
|
+
i += 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
## ------------------- CBS Sports Headlines ------------------- ##
|
38
|
+
def self.scrape_cbs
|
39
|
+
main_url = "http://www.cbssports.com"
|
40
|
+
doc = Nokogiri::HTML(open("http://www.cbssports.com/nfl"))
|
41
|
+
|
42
|
+
i = 0
|
43
|
+
while i < 6
|
44
|
+
cbs_headline = self.new
|
45
|
+
cbs_headline.title = doc.search("ul#homeArenaHeadlines span")[i].text
|
46
|
+
cbs_headline.url = doc.search("ul#homeArenaHeadlines a")[i].attributes["href"].value
|
47
|
+
@headlines << cbs_headline
|
48
|
+
i += 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
## ------------------- Fox Sports Headlines ------------------- ##
|
53
|
+
def self.scrape_fox
|
54
|
+
main_url = "http://www.foxsports.com"
|
55
|
+
doc = Nokogiri::HTML(open("http://www.foxsports.com/nfl"))
|
56
|
+
|
57
|
+
i = 0
|
58
|
+
while i < 6
|
59
|
+
fox_headline = self.new
|
60
|
+
fox_headline.title = doc.search("h3.buzzer-title")[i].text
|
61
|
+
fox_headline.url = doc.search("div.buzzer-header a")[i].attributes["href"].value
|
62
|
+
@headlines << fox_headline
|
63
|
+
i += 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
## ------------------- USA Today Headlines ------------------- ##
|
68
|
+
def self.scrape_usa
|
69
|
+
main_url = "http://www.usatoday.com"
|
70
|
+
doc = Nokogiri::HTML(open("http://www.usatoday.com/sports/nfl"))
|
71
|
+
|
72
|
+
i = 0
|
73
|
+
while i < 6
|
74
|
+
usa_headline = self.new
|
75
|
+
usa_headline.title = doc.search("li span.js-asset-headline")[i].text
|
76
|
+
usa_headline.url = main_url + doc.search("li a.js-asset-link")[i].attributes["href"].value
|
77
|
+
@headlines << usa_headline
|
78
|
+
i += 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
class Story
|
2
|
+
attr_accessor :title, :author, :posted, :body
|
3
|
+
|
4
|
+
def self.keep_reading(source)
|
5
|
+
puts ""
|
6
|
+
puts "Would you like to read more stories?"
|
7
|
+
input = gets.strip.downcase
|
8
|
+
puts ""
|
9
|
+
if input == "yes" || input == "y"
|
10
|
+
case source.to_s
|
11
|
+
when "espn"
|
12
|
+
Headline.get_choice("espn")
|
13
|
+
when "nfl"
|
14
|
+
Headline.get_choice("nfl")
|
15
|
+
when "cbs"
|
16
|
+
Headline.get_choice("cbs")
|
17
|
+
when "fox"
|
18
|
+
Headline.get_choice("fox")
|
19
|
+
when "usa"
|
20
|
+
Headline.get_choice("usa")
|
21
|
+
end
|
22
|
+
else
|
23
|
+
CLI.new.goodbye
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.display_story(source)
|
28
|
+
puts <<~DOC
|
29
|
+
\033[1;34m#{@story.title}\033[0m
|
30
|
+
\033[0;31mStory #{@story.author}\033[0m
|
31
|
+
DOC
|
32
|
+
@new_stories[0,5].each do |para|
|
33
|
+
puts <<~DOC
|
34
|
+
#{para}\n
|
35
|
+
DOC
|
36
|
+
end
|
37
|
+
puts <<~DOC
|
38
|
+
Read the rest of the story at \033[4;35m#{@url}\033[0m
|
39
|
+
DOC
|
40
|
+
self.keep_reading(source)
|
41
|
+
end
|
42
|
+
|
43
|
+
## ------------------- ESPN Stories ------------------- ##
|
44
|
+
def self.espn_stories(url)
|
45
|
+
doc = Nokogiri::HTML(open(url))
|
46
|
+
doc.search("aside").remove
|
47
|
+
@url = url
|
48
|
+
@story = self.new
|
49
|
+
@story.title = doc.search("header.article-header h1").text
|
50
|
+
@story.author = "By " + doc.search("div.author span").text
|
51
|
+
@story.body = doc.search("div.article-body p")
|
52
|
+
@new_stories = []
|
53
|
+
@story.body.each do |x|
|
54
|
+
@new_stories << x.text unless x.text == ""
|
55
|
+
end
|
56
|
+
self.display_story("espn")
|
57
|
+
end
|
58
|
+
|
59
|
+
## ------------------- NFL.com Stories ------------------- ##
|
60
|
+
def self.nfl_stories(url)
|
61
|
+
doc = Nokogiri::HTML(open(url))
|
62
|
+
@url = url
|
63
|
+
@story = self.new
|
64
|
+
@story.title = doc.search("div#article-hdr h1").text
|
65
|
+
@story.author = doc.search("li#article-hdr-meta-author").text.strip
|
66
|
+
@story.body = doc.search("div.articleText p")
|
67
|
+
@new_stories = []
|
68
|
+
@story.body.each do |x|
|
69
|
+
if x.content.strip.empty?
|
70
|
+
x.remove
|
71
|
+
else
|
72
|
+
@new_stories << x.text
|
73
|
+
end
|
74
|
+
end
|
75
|
+
self.display_story("nfl")
|
76
|
+
end
|
77
|
+
|
78
|
+
## ------------------- CBS Sports Stories ------------------- ##
|
79
|
+
def self.cbs_stories(url)
|
80
|
+
doc = Nokogiri::HTML(open(url))
|
81
|
+
@url = url
|
82
|
+
@story = self.new
|
83
|
+
@story.title = doc.search("div#storyContent h1").text
|
84
|
+
@story.author = "By " + doc.search("span.name").text
|
85
|
+
@story.body = doc.search("div.storyCopy p")
|
86
|
+
@new_stories = []
|
87
|
+
@story.body.each do |x|
|
88
|
+
@new_stories << x.text unless x.text == ""
|
89
|
+
end
|
90
|
+
self.display_story("cbs")
|
91
|
+
end
|
92
|
+
|
93
|
+
## ------------------- Fox Sports Stories ------------------- ##
|
94
|
+
def self.fox_stories(url)
|
95
|
+
doc = Nokogiri::HTML(open(url))
|
96
|
+
@url = url
|
97
|
+
@story = self.new
|
98
|
+
@story.title = doc.search("h1.story-headline").text
|
99
|
+
@story.author = doc.search("span.byline-name").text
|
100
|
+
@story.body = doc.search("div.story-body p")
|
101
|
+
@new_stories = []
|
102
|
+
@story.body.each do |x|
|
103
|
+
if x.content.strip.empty?
|
104
|
+
x.remove
|
105
|
+
else
|
106
|
+
@new_stories << x.text
|
107
|
+
end
|
108
|
+
end
|
109
|
+
self.display_story("fox")
|
110
|
+
end
|
111
|
+
|
112
|
+
## ------------------- USA Today Stories ------------------- ##
|
113
|
+
def self.usa_stories(url)
|
114
|
+
doc = Nokogiri::HTML(open(url))
|
115
|
+
doc.search("video").remove
|
116
|
+
doc.search("aside").remove
|
117
|
+
doc.search("p.video-desc").remove
|
118
|
+
doc.search("p.pluto-share-overlay-title").remove
|
119
|
+
doc.search("p.pluto-embed-overlay-title").remove
|
120
|
+
doc.search("p.oembed-link-title").remove
|
121
|
+
doc.search("p.oembed-link-desc").remove
|
122
|
+
@url = url
|
123
|
+
@story = self.new
|
124
|
+
@story.title = doc.search("h1.asset-headline").text
|
125
|
+
@story.author = "By " + doc.search("span.asset-metabar-author").text.strip
|
126
|
+
@story.body = doc.search("div.asset-double-wide p")
|
127
|
+
@new_stories = []
|
128
|
+
@story.body.each do |x|
|
129
|
+
if x.content.strip.empty?
|
130
|
+
x.remove
|
131
|
+
else
|
132
|
+
@new_stories << x.text
|
133
|
+
end
|
134
|
+
end
|
135
|
+
self.display_story("usa")
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'Nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
require_relative './nfl_top_stories/concerns/headline_choice'
|
5
|
+
require_relative './nfl_top_stories/version'
|
6
|
+
require_relative './nfl_top_stories/story'
|
7
|
+
require_relative './nfl_top_stories/headline'
|
8
|
+
require_relative './nfl_top_stories/cli'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nfl_top_stories/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nfl-top-stories"
|
8
|
+
spec.version = NflTopStories::VERSION
|
9
|
+
spec.authors = ["thebrianemory"]
|
10
|
+
spec.email = ["the@brianemory.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{NFL Top Stories}
|
13
|
+
spec.description = %q{NFL Top Stories will pull NFL headlines and stories from ESPN, NFL.com, CBS Sports, Fox Sports, and USA Today.}
|
14
|
+
spec.homepage = "https://github.com/thebrianemory/nfl-top-stories-cli-gem"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
|
28
|
+
spec.add_dependency "nokogiri"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nfl-top-stories
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- thebrianemory
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-30 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: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: NFL Top Stories will pull NFL headlines and stories from ESPN, NFL.com,
|
84
|
+
CBS Sports, Fox Sports, and USA Today.
|
85
|
+
email:
|
86
|
+
- the@brianemory.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- NOTES.md
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/nfl-top-stories
|
101
|
+
- bin/setup
|
102
|
+
- lib/nfl_top_stories.rb
|
103
|
+
- lib/nfl_top_stories/cli.rb
|
104
|
+
- lib/nfl_top_stories/concerns/headline_choice.rb
|
105
|
+
- lib/nfl_top_stories/headline.rb
|
106
|
+
- lib/nfl_top_stories/story.rb
|
107
|
+
- lib/nfl_top_stories/version.rb
|
108
|
+
- nfl_top_stories.gemspec
|
109
|
+
homepage: https://github.com/thebrianemory/nfl-top-stories-cli-gem
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.6.4
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: NFL Top Stories
|
133
|
+
test_files: []
|