mlb_headlines 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66c9d4e54d93356d9ee28f86473e0e4664974077
4
+ data.tar.gz: 907721955b17b6c027d91b7a8cddabe0e929331a
5
+ SHA512:
6
+ metadata.gz: 54fb377269bb9924721a9a690563333f09d2635de65a72c27ee25cda8682c2d799c0f23f646a6bdf7393b75443db5102fd35bcb16e58547ca2c3754b2a2b2069
7
+ data.tar.gz: 1850fdc371aab5216a33e388042e7e37204e389f7657e3065cb3fa66062de72b1b53057490adf743b0a083413d19d75024d2c6a4cafdc3eb7494c177c6493579
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mlb_headlines.gemspec
4
+ gemspec
5
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 jbok4
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/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # MlbHeadlines
2
+
3
+ This Ruby Gem provides a CLI to view the Latest MLB Player Information, injuries, trades, etc.
4
+
5
+
6
+
7
+ ## Installation
8
+
9
+ $ gem install mlb_headlines
10
+
11
+ ## Usage
12
+
13
+ Type the below and follow the on screen prompts.
14
+
15
+ $ mlb_headlines
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).
22
+
23
+ ## Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jbok4/mlb-headlines.
26
+
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
31
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mlb_headlines"
5
+
6
+ MlbHeadlines::CLI.new.call
7
+
8
+ require "irb"
9
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require "Nokogiri"
2
+ require "pry"
3
+ require "open-uri"
4
+
5
+ require 'mlb_headlines/headline'
6
+ require 'mlb_headlines/scraper'
7
+ require 'mlb_headlines/cli'
8
+ require 'mlb_headlines/version'
9
+
10
+ module MlbHeadlines
11
+ end
@@ -0,0 +1,164 @@
1
+ class MlbHeadlines::CLI
2
+
3
+ def call
4
+ puts ""
5
+ puts "Up To The Minute MLB Player News–Get It While It's Hot!"
6
+ start
7
+ end
8
+
9
+ def list
10
+ puts ""
11
+ puts "---------- Latest MLB Headlines ----------"
12
+ puts ""
13
+ MlbHeadlines::Headline.all.each.with_index(1) do |headline, index|
14
+ puts "#{index}. #{headline.title}"
15
+ end
16
+ puts ""
17
+ end
18
+
19
+ def start
20
+ list
21
+ input = nil
22
+ while input != "exit"
23
+ puts ""
24
+ puts "Which headline would you like more information on? Enter the number:"
25
+ puts ""
26
+ puts "Enter list to see the list again."
27
+ puts "Enter exit to end the program."
28
+ puts ""
29
+ input = gets.strip
30
+ if input == "list"
31
+ 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
52
+ end
53
+ end
54
+ puts "Goodbye, enjoy today's games!"
55
+ end
56
+
57
+ def intro
58
+ puts ""
59
+ puts "---------- More Information ----------"
60
+ puts ""
61
+ end
62
+
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
+
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
+
164
+ end
@@ -0,0 +1,28 @@
1
+ class MlbHeadlines::Headline
2
+
3
+ attr_accessor :player, :position_team, :title, :time, :website_url, :description, :url, :doc, :articles, :article
4
+
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
+ 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/'))
26
+ end
27
+
28
+ end
@@ -0,0 +1,29 @@
1
+ class MlbHeadlines::Scraper
2
+
3
+ attr_accessor :player, :position_team, :title, :time, :website_url, :description, :url, :doc, :articles, :article
4
+
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
17
+ @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)
21
+ 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
+ end
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ module MlbHeadlines
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mlb_headlines/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mlb_headlines"
8
+ spec.version = MlbHeadlines::VERSION
9
+ spec.authors = ["Jaclyn Ciringione"]
10
+ spec.email = ["jbok4@aol.com"]
11
+
12
+ spec.summary = %q{The Latest player news from the MLB.}
13
+ spec.description = %q{The Latest player news from the MLB - Keeping you up to date so you can win your fantasy league.}
14
+ spec.homepage = "https://github.com/jbok4/mlb-headlines/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "pry", ">= 0"
34
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mlb_headlines
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jaclyn Ciringione
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-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: '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
+ description: The Latest player news from the MLB - Keeping you up to date so you can
70
+ win your fantasy league.
71
+ email:
72
+ - jbok4@aol.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/mlb_headlines.rb
87
+ - lib/mlb_headlines/cli.rb
88
+ - lib/mlb_headlines/headline.rb
89
+ - lib/mlb_headlines/scraper.rb
90
+ - lib/mlb_headlines/version.rb
91
+ - mlb_headlines.gemspec
92
+ homepage: https://github.com/jbok4/mlb-headlines/
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.6.3
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: The Latest player news from the MLB.
116
+ test_files: []