mlb_headlines 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 761216be24da4ed7999e57961603bb4a6923c3fd
4
- data.tar.gz: be77284817ebda2ea03708c27cfa613837bbfd55
3
+ metadata.gz: 73f0f4ca3eaf9588a5b472e081c6f927d2ed5a93
4
+ data.tar.gz: 281fc73d3d314e61317c3fee982a91f006997d15
5
5
  SHA512:
6
- metadata.gz: d6f25727a3bea6b0f8670da6cdec18a7eed7d4afadfb6cbfef4f03a4084965cc0ce3a2510f092c96d56c806728e98068df0557f6f61ab1cb82772582093bd542
7
- data.tar.gz: f86f0780acb345f309d0eb723aad92e0c3c13567e74b4f637735f0df16cd30baae0772fb56cc2144cc36fac60c2fd2c3b4ed5f95c6779bc9d911476527b183ce
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
- $ mlb_headlines
15
+ $ bundle install
16
16
 
17
- ## Development
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
@@ -3,7 +3,6 @@
3
3
  require "bundler/setup"
4
4
  require "mlb_headlines"
5
5
 
6
- MlbHeadlines::CLI.new.call
7
6
 
8
7
  require "irb"
9
8
  IRB.start
data/bin/mlb-headlines ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mlb_headlines"
5
+
6
+ MlbHeadlines::CLI.new.call
@@ -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 == "1"
33
- list_articles1
34
- elsif input == "2"
35
- list_articles2
36
- elsif input == "3"
37
- list_articles3
38
- elsif input == "4"
39
- list_articles4
40
- elsif input == "5"
41
- list_articles5
42
- elsif input == "6"
43
- list_articles6
44
- elsif input == "7"
45
- list_articles7
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 :player, :position_team, :title, :time, :website_url, :description, :url, :doc, :articles, :article
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 ||= self.scrape_headlines
12
+ @@all ||= MlbHeadlines::Scraper.scrape
13
13
  end
14
14
 
15
- def self.scrape_headlines
16
- @doc = Nokogiri::HTML(open('http://www.cbssports.com/fantasy/baseball/players/news/all/both/'))
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 :player, :position_team, :title, :time, :website_url, :description, :url, :doc, :articles, :article
3
+ attr_accessor :title, :article
4
4
 
5
5
 
6
- def initialize(title = nil, article = nil)
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
- title = []
19
- @doc.css(".latest-updates p").each do |node|
20
- title.push new(node.text.strip)
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
@@ -1,3 +1,3 @@
1
1
  module MlbHeadlines
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/mlb_headlines.rb CHANGED
@@ -2,10 +2,10 @@ require "Nokogiri"
2
2
  require "pry"
3
3
  require "open-uri"
4
4
 
5
+ module MlbHeadlines
6
+ end
7
+
5
8
  require 'mlb_headlines/headline'
6
9
  require 'mlb_headlines/scraper'
7
10
  require 'mlb_headlines/cli'
8
11
  require 'mlb_headlines/version'
9
-
10
- module MlbHeadlines
11
- end
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.2
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-04-11 00:00:00.000000000 Z
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.6.3
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.