sec_mens_bball 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f104e4e09bf9b122368452ffeee8e5ced3aa4c62
4
- data.tar.gz: 9f838831a87c12a01341a149d018a9860042910c
3
+ metadata.gz: 286370c40adbe2183890e052b8ef86dc3387f362
4
+ data.tar.gz: 52e46b5e79c6fa43b2d52901294871a4a6fd8dc8
5
5
  SHA512:
6
- metadata.gz: 00c149aaff4099aac76abfeaf6a01a31ad8d412445b224c02f269f62297029175c6f53a0d4ba3b3e7ae7f29a5d966944aa5624153b6a90d8b5f899bd7039286a
7
- data.tar.gz: 351ade7e7744a6453602105d2828edaa62b7de5935f4030d06351f3ab9e73e7cf016937243951875ed53e70ee8c6bb47d94cafbbe01a1bad5bc0bb97777b2612
6
+ metadata.gz: 5beddac83f53bdb9094cb9b0a365c6ed891c348ad35d08bfc10bd63f110c58ac90367e30e38f949126c9589b9ce92d7515fd3113c6809b08fd46bc9608bf1434
7
+ data.tar.gz: 848757031f299e05e302ae09a429ee265e0efa62c2729fa898ab7e86b8d4e43bb80b6b67dc684af97300169320f7ee8df0996d9b78a309737d0b54a8f40aee5b
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
3
  # Specify your gem's dependencies in sec_mens_bball.gemspec
6
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sec_mens_bball (0.1.0)
4
+ sec_mens_bball (0.1.1)
5
5
  nokogiri
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SecMensBball
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sec_mens_bball`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Welcome to SecMensBball. This gem displays the current mens' basketball standings in the Southeastern Conference. It ranks the teams (1-14) by conference record, and also gives the teams' overall record. Select a particular team and it displays a team page that has the scheduling data for that teams entire season, including dates, opponents, and the score if the game has already been played.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,7 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ After installation, go to the directory the gem was installed in and enter "bin/bball". The current Southeastern Conference Mens' Basketball Standings is then displayed in rank order from 1-14. Enter the number of a team to display that teams season's schedule. Included in the display is the game's date, matchup, and result, if game has already been played and time, if game is yet to be played. Matchup includes opponents name and whether the game is home (vs) or away (@). Result includes win or loss and the score. Once a number has been entered to see a team's season schedule, enter another number to see a different team's schedule. Enter the word "league" to see the league standings again, and enter 'exit' to leave.
26
24
 
27
25
  ## Development
28
26
 
data/bin/bball CHANGED
@@ -1,7 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ #run Bundler and setup my gems and their dependencies
3
4
  require "bundler/setup"
4
- require "sec_mens_bball"
5
5
 
6
+ #require the file that contains all my other requires
7
+ require "sec_mens_bball"
6
8
 
9
+ #start the CLI gem
7
10
  CLI.new.call
@@ -3,6 +3,7 @@ require 'pry'
3
3
  class CLI
4
4
 
5
5
  def call
6
+ #give a brief welcoming statement, then display the latest league standings, then prompt for a team choice
6
7
  welcome
7
8
  display_league
8
9
  choose
@@ -16,13 +17,17 @@ class CLI
16
17
  end
17
18
 
18
19
  def display_league
20
+ #display a header
19
21
  puts
20
22
  puts "No. Team League Record Overall Record"
21
23
  puts "----------------------------------------------------------------"
24
+ # scrape the entire standings page
22
25
  @standings = Scraper.scrape_standings_page
23
26
  rank = 0
27
+ #go through each line of the standings and build a team object
24
28
  @standings.each do |team|
25
29
  rank += 1
30
+ #print out team information with proper formatting to make info align
26
31
  print rank.to_s.rjust(2)
27
32
  print team.name.rjust(20)
28
33
  print team.conf_record.rjust(15)
@@ -31,36 +36,42 @@ class CLI
31
36
  end
32
37
 
33
38
  def choose
34
- puts
35
- loop do
36
- puts "Enter a team's number to see its schedule, type 'league' to see league standings again, or type 'exit' to leave site"
37
- input = gets.strip
38
- if input == "exit"
39
+ puts #print a blank line for readability
40
+ loop do #continuously loop until user inputs 'exit'
41
+ #prompt user
42
+ puts
43
+ puts "Enter a team's number to see its schedule, type 'league' to see league standings again,"
44
+ puts "or type 'exit' to leave site"
45
+ puts
46
+ input = gets.strip #get user's input and put it into the variable 'input'
47
+ if input == "exit" #if 'exit', print a short goodbye message and break from if statement to end program
39
48
  goodbye
40
49
  break
41
- elsif (1..14).cover?(input.to_i)
42
- team = @standings[input.to_i - 1]
43
- Scraper.scrape_team_page(team)
44
- display_team_schedule(team)
45
- elsif input == "league"
50
+ elsif (1..14).cover?(input.to_i) #change string input to an integer and check to see the number is between 1 and 14
51
+ team = @standings[input.to_i - 1] # @standings is an array of previously scraped team objects
52
+ Scraper.scrape_team_page(team) # scrape the team page that corresponds to the input number
53
+ display_team_schedule(team) #display the schedule attributes of the input team
54
+ elsif input == "league" # if 'league' call 'display_league' method to display the standings of the league
46
55
  display_league
47
- else
48
- puts "Please type a number between 1 and 14."
56
+ else # if the input is anything else, tell user what the acceptable inputs are
57
+ puts "Please type a number between 1 and 14"
58
+ puts
49
59
  end
50
60
  end
51
61
  end
52
62
 
53
63
  def display_team_schedule(team)
64
+ # this method accepts a team input, prints a header, and prints schedule attributes for that team
54
65
  puts
55
66
  puts "#{team.name} Men's Basketball Team Schedule 2018"
56
67
  puts " Date Matchup Result/Time "
57
68
  puts "--------------------------------------------------------"
58
- team.games.each do |game|
69
+ team.games.each do |game| # print each game on a teams schedule
59
70
  print game.date.rjust(13)
60
71
  print game.opponent.rjust(25)
61
72
  puts game.result.rjust(15)
62
73
  end
63
- puts "* Game Played At Neutral Venue"
74
+ puts "* Game Played At Neutral Venue" # print this line to explain the asterisks that show up in the schedule
64
75
  end
65
76
 
66
77
  def goodbye
@@ -68,6 +79,7 @@ class CLI
68
79
  end
69
80
 
70
81
  def find_team_url(input)
82
+ # this method changes the input from the command line to an index for the @standings array
71
83
  index = input.to_i - 1
72
84
  team = @standings[index]
73
85
  team.url
@@ -4,28 +4,33 @@ require 'pry'
4
4
 
5
5
  class Scraper
6
6
 
7
- def self.scrape_standings_page
8
- doc = Nokogiri::HTML(open("http://www.secsports.com/standings/mens-basketball"))
9
- standings = doc.css("#wrapper > div > main > section > div > section > div > div > div > div.panel-body > div > table > tbody")
10
- league = []
7
+ def self.scrape_standings_page
8
+ # open is an open-URI method that takes an URL and outputs the HTML from that page
9
+ # Nokogiri::HTML changes HTML to a nodeset
10
+ doc = Nokogiri::HTML(open("http://www.secsports.com/standings/mens-basketball"))
11
+ standings = doc.css("tbody") # nodeset of the table of 14 teams
12
+ league = [] # create an empty array
11
13
  standings.css("tr").each do |team_table|
14
+ # take data from each row of the table and build a team object
12
15
  t = Team.new
13
16
  t.name = team_table.css("a:first").text
14
17
  t.url = team_table.css("a:first").attr("href").text.strip
15
18
  t.conf_record = team_table.css("td")[1].text
16
19
  t.overall_record = team_table.css("td")[2].text
17
- league << t
20
+ league << t # insert each team object into the array called league
18
21
  end
19
- league
22
+ league #return the league array
20
23
  end
21
24
 
22
25
  def self.scrape_team_page(team)
26
+ # build up the schedul_url for a given team
23
27
  schedule_url = ("http://www.secsports.com" + team.url).gsub("clubhouse", "schedule")
24
28
  doc = Nokogiri::HTML(open(schedule_url))
25
- schedule = doc.css("#wrapper > div > main > section > div > section > div > div > div > div.panel-body > div > table > tbody")
29
+ schedule = doc.css("tbody") # scrape the schedule for that team
26
30
  team.games = []
27
- schedule.css("tr").each do |game|
28
- unless game.css("td")[0].text.strip == "* Game Played At Neutral Venue"
31
+ schedule.css("tr").each do |game| #iterate the schedule game by game
32
+ unless game.css("td")[0].text.strip == "* Game Played At Neutral Venue" #if you see this string you have gone to far
33
+ #build a game object for each line of game data
29
34
  g = Game.new
30
35
  g.date = game.css("td")[0].text
31
36
  g.opponent = game.css("td")[1].text
@@ -1,3 +1,3 @@
1
1
  module SecMensBball
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sec_mens_bball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - halfields
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-12 00:00:00.000000000 Z
11
+ date: 2018-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler