sportify 0.1.0 → 0.2.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 +4 -4
- data/lib/cli/cli.rb +2 -4
- data/lib/leagues/mlb_teams.rb +3 -1
- data/lib/scrapers/mlb_scraper.rb +12 -24
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df846ec020824028a0fdcd73e19c520966faaff5
|
|
4
|
+
data.tar.gz: 3b5b34d9da2e045ec7e7907e1102428ae7f335e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c6fe292bb3dcce5cd6e6e5402c2f8c15a818f7427a0413f8af4f0e484ce2c1096ae621cae9d4b821123c6a6a31cf6d19efedcea2339d901d39e33c1f20e0740
|
|
7
|
+
data.tar.gz: 436a804c080d3e91a0e410d281abcf3f35d6df55e00038bd0d2bd7724199ea7e22aa107d49133382b92c014ceebc9cbf8dd866e5c5de425c3c8c510f994c7054
|
data/lib/cli/cli.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require "pry"
|
|
2
|
-
|
|
3
1
|
class Sportify::CLI
|
|
4
2
|
|
|
5
3
|
def initialize
|
|
@@ -53,7 +51,6 @@ class Sportify::CLI
|
|
|
53
51
|
puts "***** Active Roster *****"
|
|
54
52
|
puts ""
|
|
55
53
|
active_roster_display(team)
|
|
56
|
-
team_menu(team)
|
|
57
54
|
when 2
|
|
58
55
|
Sportify::CLI.new
|
|
59
56
|
when 3
|
|
@@ -66,7 +63,7 @@ class Sportify::CLI
|
|
|
66
63
|
|
|
67
64
|
def active_roster_display(team)
|
|
68
65
|
@mlb.roster(team).each_with_index do |player, index|
|
|
69
|
-
puts "#{index + 1}) #{player[:
|
|
66
|
+
puts "#{index + 1}) #{player[:name]}"
|
|
70
67
|
end
|
|
71
68
|
player_selector(team)
|
|
72
69
|
end
|
|
@@ -79,6 +76,7 @@ class Sportify::CLI
|
|
|
79
76
|
puts ""
|
|
80
77
|
if input.to_i.between?(1, @mlb.roster(team).length)
|
|
81
78
|
player_display(@mlb.roster(team)[input.to_i - 1])
|
|
79
|
+
team_menu(team)
|
|
82
80
|
elsif input.downcase == "menu"
|
|
83
81
|
team_menu(team)
|
|
84
82
|
else
|
data/lib/leagues/mlb_teams.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
|
|
1
3
|
class Sportify::MLBteams
|
|
2
4
|
|
|
3
5
|
def initialize
|
|
@@ -9,7 +11,7 @@ class Sportify::MLBteams
|
|
|
9
11
|
end
|
|
10
12
|
|
|
11
13
|
def roster(team)
|
|
12
|
-
|
|
14
|
+
@scraper.roster(team).zip(@scraper.player_urls(team)).map { |name, player_url| {name: name, player_url: player_url}}
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
def player_builder(player)
|
data/lib/scrapers/mlb_scraper.rb
CHANGED
|
@@ -20,36 +20,24 @@ class Sportify::MLBscraper
|
|
|
20
20
|
team_urls
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def roster_url(team_url)
|
|
24
|
-
html = open(team_url)
|
|
25
|
-
doc = Nokogiri::HTML(html)
|
|
26
|
-
if team_url == "https://www.mlb.com/reds" || team_url == "https://www.mlb.com/dodgers" || team_url == "https://www.mlb.com/giants"
|
|
27
|
-
roster_url = doc.css("div.megamenu-navbar").css("a.megamenu-static-navbar__menu-item.megamenu-static-navbar__menu-item--roster").attribute("href").value
|
|
28
|
-
else
|
|
29
|
-
roster_url = doc.css("div.megamenu-navbar").css("a.megamenu-static-navbar__menu-item.megamenu-static-navbar__menu-item--team").attribute("href").value
|
|
30
|
-
end
|
|
31
|
-
roster_url
|
|
32
|
-
end
|
|
33
|
-
|
|
34
23
|
def roster_doc(team)
|
|
35
|
-
|
|
36
|
-
Nokogiri::HTML(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
roster_doc(team).css("table.data.roster_table").css("td.dg-jersey_number").each do |player|
|
|
42
|
-
player_numbers << player.text
|
|
24
|
+
team_html = open(team[:team_url])
|
|
25
|
+
team_doc = Nokogiri::HTML(team_html)
|
|
26
|
+
if team[:team_url] == "https://www.mlb.com/reds" || team[:team_url] == "https://www.mlb.com/dodgers" || team[:team_url] == "https://www.mlb.com/giants"
|
|
27
|
+
roster_url = team_doc.css("div.megamenu-navbar").css("a.megamenu-static-navbar__menu-item.megamenu-static-navbar__menu-item--roster").attribute("href").value
|
|
28
|
+
else
|
|
29
|
+
roster_url = team_doc.css("div.megamenu-navbar").css("a.megamenu-static-navbar__menu-item.megamenu-static-navbar__menu-item--team").attribute("href").value
|
|
43
30
|
end
|
|
44
|
-
|
|
31
|
+
roster_html = open(roster_url)
|
|
32
|
+
Nokogiri::HTML(roster_html)
|
|
45
33
|
end
|
|
46
34
|
|
|
47
|
-
def
|
|
48
|
-
|
|
35
|
+
def roster(team)
|
|
36
|
+
roster = []
|
|
49
37
|
roster_doc(team).css("td.dg-name_display_first_last").css("a").each do |player|
|
|
50
|
-
|
|
38
|
+
roster << player.text
|
|
51
39
|
end
|
|
52
|
-
|
|
40
|
+
roster
|
|
53
41
|
end
|
|
54
42
|
|
|
55
43
|
def player_urls(team)
|