gameday_cli_gem 0.1.6

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: 6a80b46612f884986160b3f1ea720ce49b1cd7b6
4
+ data.tar.gz: eaff099440d23cc24aeb0c42db0e9ddd16e6982b
5
+ SHA512:
6
+ metadata.gz: cd4d470a7fcb8b2a670f5173a9324a7b3d4f9aeeb28c57b67c23e26c613fa3c430214ef2f67bafc0f5435736a7a8d80e566883b37d69bc3f7ced4d649c79d1ce
7
+ data.tar.gz: 90df989e7e6e2b08849a4077906af77b6559f33062cd6418b362bf2b6db18612992428966ef004e99bb5e7636a183eb0ffdbb70c5031b0632b3cb6aa1a3e15ca
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/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at 'mdjurdj1@binghamton.edu'. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gameday_cli_gem.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 'Michael Djurdjevic'
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,26 @@
1
+ # Gameday Cli Gem
2
+
3
+ This Ruby gem provides a list of all of the days' major sporting events using SportsIllustrated's live scoreboards and recaps! Finished events can be accessed for final scores and brief recaps.
4
+
5
+ ## Installation
6
+
7
+ $ gem install gameday_cli_gem
8
+
9
+ ## Usage
10
+
11
+ Simply run the game-day executable from bin to get started.
12
+
13
+ ## Development
14
+
15
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
16
+
17
+ 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).
18
+
19
+ ## Contributing
20
+
21
+ Bug reports and pull requests are welcome on GitHub at https://github.com/'Michael Djurdjevic'/gameday_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.
22
+
23
+
24
+ ## License
25
+
26
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gameday_cli_gem"
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/game-day ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'gameday_cli_gem'
5
+
6
+ GamedayCliGem::CLI.new.call
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,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gameday_cli_gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gameday_cli_gem"
8
+ spec.version = GamedayCliGem::VERSION
9
+ spec.authors = ["'Michael Djurdjevic'"]
10
+ spec.email = ["'mdjurdj1@binghamton.edu'"]
11
+
12
+ spec.summary = %q{A Ruby CLI gem which lists the days' upcoming and in-progress sporting events.}
13
+ spec.homepage = "https://github.com/mdjurdj1/gameday_cli_gem"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "bin"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+ spec.executables << "game-day"
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.14"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "pry", "~>0.10.4"
37
+ spec.add_development_dependency "nokogiri", "~>1.7"
38
+ end
@@ -0,0 +1,11 @@
1
+ require 'open-uri'
2
+ require 'pry'
3
+ require 'nokogiri'
4
+
5
+ require_relative "./gameday_cli_gem/version"
6
+ require_relative "./gameday_cli_gem/cli"
7
+ require_relative "./gameday_cli_gem/game"
8
+ require_relative "./gameday_cli_gem/scraper"
9
+
10
+ module GamedayCliGem
11
+ end
@@ -0,0 +1,85 @@
1
+ class GamedayCliGem::CLI
2
+
3
+ def call #Main program loop
4
+ GamedayCliGem::Scraper.new.make_games
5
+ start
6
+ end
7
+
8
+ def list_games
9
+ GamedayCliGem::Game.all.each_with_index do |game, index|
10
+ if !game.news_url.nil?
11
+ puts "#{index+1}. | #{game.league} | #{game.team1} vs. #{game.team2} - #{game.start_time} - News Available"
12
+ elsif game.start_time.length < 1
13
+ puts "#{index+1}. | #{game.league} | #{game.team1} vs. #{game.team2} - ONGOING "
14
+ else
15
+ puts "#{index+1}. | #{game.league} | #{game.team1} vs. #{game.team2} - #{game.start_time} "
16
+ end
17
+ end
18
+ end
19
+
20
+ def start #menu interface. navigates to individual games, or daily games listing
21
+ puts "-------------------"
22
+ puts "Welcome to Gameday!"
23
+ puts "-------------------"
24
+ puts "Today is #{DateTime.now.strftime('%m/%d/%Y')} -"
25
+ puts "Here are Today's Games:"
26
+ puts
27
+ list_games
28
+ puts ""
29
+ puts "Select any game with 'News Available' for more info. Or, type [Exit] to leave."
30
+ input = gets.chomp.downcase
31
+ if input == "exit"
32
+ goodbye
33
+ else
34
+ system "clear"
35
+ if GamedayCliGem::Game.find(input.to_i) && GamedayCliGem::Game.find(input.to_i).news_url.nil? #found game, but no news url to dig into
36
+ puts "No news is currently available for that game. Please check back later tonight!"
37
+ puts ""
38
+ puts ""
39
+ puts "------------------------------"
40
+ puts "Press enter to return to main menu."
41
+ input = gets.chomp
42
+ start
43
+ elsif !GamedayCliGem::Game.find(input.to_i) #did not find game by number
44
+ puts "Invalid game selection! Please input a valid game number. [1 - #{GamedayCliGem::Game.all.length}]"
45
+ puts ""
46
+ puts ""
47
+ puts "------------------------------"
48
+ puts "Press enter to return to main menu."
49
+ input = gets.chomp
50
+ start
51
+ elsif GamedayCliGem::Game.find(input.to_i) && !GamedayCliGem::Game.find(input.to_i).news_url.nil? #found game and it has a news_url to dig into
52
+ game = GamedayCliGem::Game.find(input.to_i)
53
+ puts "------------------------------"
54
+ puts game.headline
55
+ puts "------------------------------"
56
+ game.final_score
57
+ puts ""
58
+ puts game.recap
59
+ puts "------------------------------"
60
+ puts "Enter [List] to return to today's games, or [Exit] to quit."
61
+ input = gets.chomp.downcase
62
+ case input
63
+ when "list"
64
+ system "clear"
65
+ start
66
+ when "exit"
67
+ goodbye
68
+ else
69
+ system "clear"
70
+ start
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ def goodbye #exit program method
77
+ system "clear"
78
+ puts ""
79
+ puts "See you tomorrow for the next game!"
80
+ puts ""
81
+ sleep 0.5
82
+ end
83
+
84
+
85
+ end
@@ -0,0 +1,90 @@
1
+ class GamedayCliGem::Game
2
+
3
+ attr_accessor :league, :team1, :team2, :start_time, :news_url, :headline
4
+
5
+ @@all = []
6
+
7
+ def initialize(team1 = nil, team2 = nil, league = nil, start_time = nil, news_url = nil)
8
+ @team1 = team1
9
+ @team2 = team2
10
+ @league = league
11
+ @start_time = start_time
12
+ @news_url = news_url
13
+ self.class.all << self unless self.class.all.include?(self)
14
+ end
15
+
16
+ def self.new_from_index_page(game) # Instantiates game objects from XML code passed by Scraper class. Conditionals determine initialize params
17
+ if game.css(".game-link").text == "Preview" #selects for upcoming games with previews
18
+ self.new(
19
+ game.css("div.media-body")[0].css("span").text,
20
+ game.css("div.media-body")[1].css("span").text,
21
+ game.attribute("data-league").text.upcase,
22
+ game.css(".status-pregame").text.gsub(" ", "").gsub(/\n/, ""),
23
+ "http://www.si.com#{game.css(".game-link").attribute("href").text}"
24
+ )
25
+ elsif game.css(".game-link").text.include?("Recap") #selects for games with recap, which must be finished
26
+ self.new(
27
+ game.css("div.media-body")[0].css("span").text,
28
+ game.css("div.media-body")[1].css("span").text,
29
+ game.attribute("data-league").text.upcase,
30
+ "FIN",
31
+ "http://www.si.com#{game.css(".game-link").attribute("href").text}"
32
+ )
33
+ elsif game.at_css(".status-pregame") #selects for games with a visible start time
34
+ self.new(
35
+ game.css("div.media-body")[0].css("span").text,
36
+ game.css("div.media-body")[1].css("span").text,
37
+ game.attribute("data-league").text.upcase,
38
+ game.css(".status-pregame").text.gsub(" ", "").gsub(/\n/, "")
39
+ )
40
+ elsif game.at_css(".status-active") #selects for games which are active
41
+ self.new(
42
+ game.css("div.media-body")[0].css("span").text,
43
+ game.css("div.media-body")[1].css("span").text,
44
+ game.attribute("data-league").text.upcase,
45
+ game.css(".status-active").text.gsub(/\s+/, "").split("|").join("| ")
46
+ )
47
+ elsif game.at_css(".status-final") #selects for any other completed games with no recap/preview or start time
48
+ self.new(
49
+ game.css("div.media-body")[0].css("span").text,
50
+ game.css("div.media-body")[1].css("span").text,
51
+ game.attribute("data-league").text.upcase,
52
+ "FIN"
53
+ )
54
+ end
55
+ end
56
+
57
+ def self.all
58
+ @@all
59
+ end
60
+
61
+ def self.find(index)
62
+ self.all[index.to_i-1]
63
+ end
64
+
65
+ def recap #puts a truncated recap article to terminal
66
+ puts doc.css(".article p")[0].text
67
+ puts doc.css(".article p")[1].text
68
+ puts doc.css(".article p")[2].text
69
+ puts doc.css(".article p")[3].text
70
+ end
71
+
72
+ def final_score #puts the final score of a completed game
73
+ if doc.at_css(".team-score")
74
+ puts "Final Score >> #{doc.css(".team-name")[0].text}: #{doc.css(".team-score")[0].text.strip} || #{doc.css(".team-name")[1].text}: #{doc.css(".team-score")[1].text.strip}"
75
+ else
76
+ puts "Here's a quick preview!"
77
+ puts ""
78
+ end
79
+ end
80
+
81
+ def headline #headline selector from doc
82
+ @headline = doc.css(".article h1").text
83
+ end
84
+
85
+ def doc #document of the recap_url for games with an available recap
86
+ Nokogiri::HTML(open(self.news_url))
87
+ end
88
+
89
+
90
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../gameday_cli_gem.rb'
2
+
3
+ class GamedayCliGem::Scraper
4
+
5
+ def get_page
6
+ Nokogiri::HTML(open("http://www.si.com/scoreboard"))
7
+ end
8
+
9
+ def scrape_games_index
10
+ self.get_page.css("div.game")
11
+ end
12
+
13
+ def make_games
14
+ scrape_games_index.each do |game|
15
+ GamedayCliGem::Game.new_from_index_page(game)
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,3 @@
1
+ module GamedayCliGem
2
+ VERSION = "0.1.6"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,14 @@
1
+ Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+
5
+ [X] Have a CLI for interfacing with the application
6
+ My app has a complete CLI which lists all of the days' games, then prompts the user if they wish for a recap of a completed game.
7
+ Inputs are validated each time, and the terminal is kept uncluttered between invalid results.
8
+
9
+ [X] Pull data from an external source
10
+ My app pulls data from the SportsIllustrated live Scoreboard. It lists all of the pulled games.
11
+ These games are listed by league, with participating team records displayed, and the option to access recaps for completed games.
12
+
13
+ [X] Implement both list and detail views
14
+ CLI initially puts a list view. Detailed views are only available for completed games with recaps written for them.
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gameday_cli_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - "'Michael Djurdjevic'"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-12 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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.10.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ description:
84
+ email:
85
+ - "'mdjurdj1@binghamton.edu'"
86
+ executables:
87
+ - game-day
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - CODE_OF_CONDUCT.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/game-day
99
+ - bin/setup
100
+ - gameday_cli_gem.gemspec
101
+ - lib/gameday_cli_gem.rb
102
+ - lib/gameday_cli_gem/cli.rb
103
+ - lib/gameday_cli_gem/game.rb
104
+ - lib/gameday_cli_gem/scraper.rb
105
+ - lib/gameday_cli_gem/version.rb
106
+ - spec.md
107
+ homepage: https://github.com/mdjurdj1/gameday_cli_gem
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.6.10
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: A Ruby CLI gem which lists the days' upcoming and in-progress sporting events.
132
+ test_files: []