mlb_headlines 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/bin/console +0 -1
- data/bin/mlb-headlines +6 -0
- data/lib/mlb_headlines/cli.rb +15 -120
- data/lib/mlb_headlines/headline.rb +4 -13
- data/lib/mlb_headlines/scraper.rb +7 -20
- data/lib/mlb_headlines/version.rb +1 -1
- data/lib/mlb_headlines.rb +3 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73f0f4ca3eaf9588a5b472e081c6f927d2ed5a93
|
4
|
+
data.tar.gz: 281fc73d3d314e61317c3fee982a91f006997d15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da092623eaae39633537ccd941281995ff0ef211dceba8ffcb00c2494965e17c5266cc0f93faf4cf55b134f73a0422ae6dd15b8b8a5af6bbb0f4b5e2141e8bc5
|
7
|
+
data.tar.gz: 2a4155e14206c56a0a41774c6923cefddf92a31ddcd4ee07db23bba8ec4fa0e95ed089a9e113264fd074d620785795ad06386135ac61128a2c1c5b12d228c2e4
|
data/README.md
CHANGED
@@ -12,13 +12,9 @@ $ gem install mlb_headlines
|
|
12
12
|
|
13
13
|
Type the below and follow the on screen prompts.
|
14
14
|
|
15
|
-
$
|
15
|
+
$ bundle install
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
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.
|
20
|
-
|
21
|
-
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).
|
17
|
+
$ bin/mlb-headlines
|
22
18
|
|
23
19
|
## Contributing
|
24
20
|
|
data/bin/console
CHANGED
data/bin/mlb-headlines
ADDED
data/lib/mlb_headlines/cli.rb
CHANGED
@@ -24,34 +24,28 @@ class MlbHeadlines::CLI
|
|
24
24
|
puts "Which headline would you like more information on? Enter the number:"
|
25
25
|
puts ""
|
26
26
|
puts "Enter list to see the list again."
|
27
|
+
#puts "Enter refresh to refresh the list"
|
27
28
|
puts "Enter exit to end the program."
|
28
29
|
puts ""
|
29
30
|
input = gets.strip
|
30
31
|
if input == "list"
|
31
32
|
list
|
32
|
-
elsif input ==
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
elsif input == "8"
|
47
|
-
list_articles8
|
48
|
-
elsif input == "9"
|
49
|
-
list_articles9
|
50
|
-
elsif input == "10"
|
51
|
-
list_articles10
|
33
|
+
elsif input.to_i.between?(1,10) == true
|
34
|
+
intro
|
35
|
+
puts MlbHeadlines::Headline.all[input.to_i-1].article
|
36
|
+
# elsif input == "refresh"
|
37
|
+
# MlbHeadlines::Headline.destroy
|
38
|
+
# MlbHeadlines::Headline.all
|
39
|
+
# list
|
40
|
+
elsif input == "exit"
|
41
|
+
sleep 1
|
42
|
+
puts "Goodbye, enjoy today's games!"
|
43
|
+
else
|
44
|
+
puts "Sorry, that is not a valid command"
|
45
|
+
sleep 1
|
46
|
+
list
|
52
47
|
end
|
53
48
|
end
|
54
|
-
puts "Goodbye, enjoy today's games!"
|
55
49
|
end
|
56
50
|
|
57
51
|
def intro
|
@@ -60,105 +54,6 @@ class MlbHeadlines::CLI
|
|
60
54
|
puts ""
|
61
55
|
end
|
62
56
|
|
63
|
-
def list_articles1
|
64
|
-
intro
|
65
|
-
paragraphs = []
|
66
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
67
|
-
paragraphs << headline.title.strip
|
68
|
-
end
|
69
|
-
print paragraphs[0..1].join(" ")
|
70
|
-
puts ""
|
71
|
-
end
|
72
|
-
|
73
|
-
def list_articles2
|
74
|
-
intro
|
75
|
-
paragraphs = []
|
76
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
77
|
-
paragraphs << headline.title.strip
|
78
|
-
end
|
79
|
-
print paragraphs[2..3].join(" ")
|
80
|
-
puts ""
|
81
|
-
end
|
82
|
-
|
83
|
-
def list_articles3
|
84
|
-
intro
|
85
|
-
paragraphs = []
|
86
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
87
|
-
paragraphs << headline.title.strip
|
88
|
-
end
|
89
|
-
print paragraphs[4..5].join(" ")
|
90
|
-
puts ""
|
91
|
-
end
|
92
|
-
|
93
|
-
def list_articles4
|
94
|
-
intro
|
95
|
-
paragraphs = []
|
96
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
97
|
-
paragraphs << headline.title.strip
|
98
|
-
end
|
99
|
-
print paragraphs[6..7].join(" ")
|
100
|
-
puts ""
|
101
|
-
end
|
102
|
-
|
103
|
-
def list_articles5
|
104
|
-
intro
|
105
|
-
paragraphs = []
|
106
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
107
|
-
paragraphs << headline.title.strip
|
108
|
-
end
|
109
|
-
print paragraphs[8..9].join(" ")
|
110
|
-
puts ""
|
111
|
-
end
|
112
57
|
|
113
|
-
def list_articles6
|
114
|
-
intro
|
115
|
-
paragraphs = []
|
116
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
117
|
-
paragraphs << headline.title.strip
|
118
|
-
end
|
119
|
-
print paragraphs[10..11].join(" ")
|
120
|
-
puts ""
|
121
|
-
end
|
122
|
-
|
123
|
-
def list_articles7
|
124
|
-
intro
|
125
|
-
paragraphs = []
|
126
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
127
|
-
paragraphs << headline.title.strip
|
128
|
-
end
|
129
|
-
print paragraphs[12..13].join(" ")
|
130
|
-
puts ""
|
131
|
-
end
|
132
|
-
|
133
|
-
def list_articles8
|
134
|
-
intro
|
135
|
-
paragraphs = []
|
136
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
137
|
-
paragraphs << headline.title.strip
|
138
|
-
end
|
139
|
-
print paragraphs[14..15].join(" ")
|
140
|
-
puts ""
|
141
|
-
end
|
142
|
-
|
143
|
-
def list_articles9
|
144
|
-
intro
|
145
|
-
paragraphs = []
|
146
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
147
|
-
paragraphs << headline.title.strip
|
148
|
-
end
|
149
|
-
print paragraphs[16..17].join(" ")
|
150
|
-
puts ""
|
151
|
-
end
|
152
|
-
|
153
|
-
def list_articles10
|
154
|
-
intro
|
155
|
-
paragraphs = []
|
156
|
-
MlbHeadlines::Scraper.all.each do |headline|
|
157
|
-
paragraphs << headline.title.strip
|
158
|
-
end
|
159
|
-
print paragraphs[18..19].join(" ")
|
160
|
-
puts ""
|
161
|
-
end
|
162
|
-
|
163
58
|
|
164
59
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class MlbHeadlines::Headline
|
2
2
|
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :title, :article
|
4
4
|
|
5
5
|
|
6
6
|
def initialize(title = nil, article = nil)
|
@@ -9,20 +9,11 @@ class MlbHeadlines::Headline
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.all
|
12
|
-
@@all ||=
|
12
|
+
@@all ||= MlbHeadlines::Scraper.scrape
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
16
|
-
|
17
|
-
title = []
|
18
|
-
@doc.css(".player-news-desc a").each do |node|
|
19
|
-
title.push new(node.text.strip)
|
20
|
-
end
|
21
|
-
title
|
22
|
-
end
|
23
|
-
|
24
|
-
def doc
|
25
|
-
@doc ||= Nokogiri::HTML(open('http://www.cbssports.com/fantasy/baseball/players/news/all/both/'))
|
15
|
+
def self.destroy
|
16
|
+
@@all.clear
|
26
17
|
end
|
27
18
|
|
28
19
|
end
|
@@ -1,29 +1,16 @@
|
|
1
1
|
class MlbHeadlines::Scraper
|
2
2
|
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :title, :article
|
4
4
|
|
5
5
|
|
6
|
-
def
|
7
|
-
@title = title
|
8
|
-
@article = article
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.all
|
12
|
-
@@all ||= self.scrape_headlines
|
13
|
-
end
|
14
|
-
|
15
|
-
#this scrapes the descriptions of the headline, the story.
|
16
|
-
def self.scrape_headlines
|
6
|
+
def self.scrape
|
17
7
|
@doc = Nokogiri::HTML(open('http://www.cbssports.com/fantasy/baseball/players/news/all/both/'))
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
@doc.css("ul#playerNewsContent li").map do |headline|
|
9
|
+
title = headline.css("h4").text
|
10
|
+
article = headline.css(".latest-updates p").map(&:text).join(" ")
|
11
|
+
MlbHeadlines::Headline.new(title, article)
|
21
12
|
end
|
22
|
-
title
|
23
|
-
end
|
24
|
-
|
25
|
-
def doc
|
26
|
-
@doc ||= Nokogiri::HTML(open('http://www.cbssports.com/fantasy/baseball/players/news/all/both/'))
|
27
13
|
end
|
28
14
|
|
15
|
+
|
29
16
|
end
|
data/lib/mlb_headlines.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mlb_headlines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaclyn Ciringione
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
98
|
- bin/console
|
99
|
+
- bin/mlb-headlines
|
99
100
|
- bin/setup
|
100
101
|
- lib/mlb_headlines.rb
|
101
102
|
- lib/mlb_headlines/cli.rb
|
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
version: '0'
|
124
125
|
requirements: []
|
125
126
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.4.5.1
|
127
128
|
signing_key:
|
128
129
|
specification_version: 4
|
129
130
|
summary: The Latest player news from the MLB.
|