nba-draft-2017 0.1.4 → 0.1.5
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/nba_draft_2017/cli.rb +40 -12
- data/lib/nba_draft_2017/player.rb +35 -4
- data/lib/nba_draft_2017/scraper.rb +2 -4
- data/lib/nba_draft_2017/version.rb +1 -1
- data/nba-draft-2017-0.1.4.gem +0 -0
- data/nba_draft_2017.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0860395f6b4272bc732a95350ae287f197287f5
|
4
|
+
data.tar.gz: 9e2bc38aa3abb6f232976276b5a09aecf51a8f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61dd9ad70ba4e7cc91d04261e528de03d7bf3e7b07478e60eca52b085f3a99ee1e17367a4d8200a69ce057f2fcf74a6385a19d7561934c8206eca644b3ab09cb
|
7
|
+
data.tar.gz: e90da45d5cc371a03a3551d3cea252fcf79425ab5925b39758bc3d73caf6453565c13c3fa2eb3c597e575cbcfab39492ad0aa071c78ce5431087fcac7dedf3b4
|
data/lib/nba_draft_2017/cli.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
class NbaDraft2017::Cli
|
2
2
|
|
3
|
+
@@key_stats = ['ppg', 'rpg', 'apg', 'tpg', 'spg', 'bpg', 'mpg', 'fg', 'three', 'ft']
|
4
|
+
|
3
5
|
def call
|
4
6
|
puts 'Welcome to the 2017 NBA Draft!'
|
5
7
|
make_players
|
@@ -49,15 +51,13 @@ class NbaDraft2017::Cli
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def make_players
|
52
|
-
|
53
|
-
NbaDraft2017::Player.create_from_collection(players_array)
|
54
|
+
NbaDraft2017::Scraper.scrape_draft
|
54
55
|
end
|
55
56
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
player
|
57
|
+
def add_attributes_to_players
|
58
|
+
NbaDraft2017::Player.all.each do |player|
|
59
|
+
add_attributes_to_player(player.name)
|
60
|
+
end
|
61
61
|
end
|
62
62
|
|
63
63
|
def menu
|
@@ -78,6 +78,8 @@ class NbaDraft2017::Cli
|
|
78
78
|
list_draft_picks_by_nba_team
|
79
79
|
elsif input == 'former team' || input == 'former'
|
80
80
|
list_draft_picks_by_former_team
|
81
|
+
elsif input == 'compare stats'
|
82
|
+
compare_stats
|
81
83
|
elsif input == 'exit'
|
82
84
|
good_bye
|
83
85
|
else
|
@@ -97,6 +99,7 @@ class NbaDraft2017::Cli
|
|
97
99
|
puts "Enter #{player.colorize(:green)} to see player details and stats"
|
98
100
|
puts "Enter #{nba_team.colorize(:green)} to show players drafted by a NBA team"
|
99
101
|
puts "Enter #{former_team.colorize(:green)} to show players drated out of colleges or clubs"
|
102
|
+
puts "Enter " + "'compare stats'".colorize(:green) + " to see player with stat average above number specified by user"
|
100
103
|
puts "To quit, type" + " 'exit'".colorize(:green)
|
101
104
|
end
|
102
105
|
|
@@ -106,17 +109,21 @@ class NbaDraft2017::Cli
|
|
106
109
|
|
107
110
|
if lookup.to_i.between?(1, NbaDraft2017::Player.all.size)
|
108
111
|
player = NbaDraft2017::Player.find_player_by_pick(lookup)
|
109
|
-
list_player_details(player
|
110
|
-
elsif NbaDraft2017::Player.find_player_by_name(lookup)
|
111
|
-
list_player_details(
|
112
|
+
list_player_details(player)
|
113
|
+
elsif player ||= NbaDraft2017::Player.find_player_by_name(lookup)
|
114
|
+
list_player_details(player)
|
112
115
|
else
|
113
116
|
error
|
114
117
|
end
|
115
118
|
player
|
116
119
|
end
|
117
120
|
|
118
|
-
def list_player_details(
|
119
|
-
|
121
|
+
def list_player_details(player)
|
122
|
+
if NbaDraft2017::Player.all_attributes
|
123
|
+
player
|
124
|
+
else
|
125
|
+
player = NbaDraft2017::Player.add_attributes_to_player(player)
|
126
|
+
end
|
120
127
|
|
121
128
|
puts "#{player.name.upcase.bold.underline}".colorize(:green).bold
|
122
129
|
puts " Round:".bold.colorize(:red) +" #{player.round}" + " Pick:".bold.colorize(:red) +" #{player.pick}"
|
@@ -143,6 +150,27 @@ class NbaDraft2017::Cli
|
|
143
150
|
end
|
144
151
|
end
|
145
152
|
|
153
|
+
def compare_stats
|
154
|
+
puts "This might take a minute for first comaprison.".bold.colorize(:green)
|
155
|
+
puts "To proceed enter a stat category from #{@@key_stats} or 'menu' to return to menu"
|
156
|
+
stat_category = gets.downcase.strip
|
157
|
+
if @@key_stats.include?(stat_category)
|
158
|
+
puts "Enter a number to see players that have a higher average for #{stat_category.colorize(:green)} and make sure to enter a decimal for fg%, three%, and ft%"
|
159
|
+
stat_num = gets.strip
|
160
|
+
if stat_num.to_f.between?(0.001,40)
|
161
|
+
NbaDraft2017::Player.stat_greater_than(stat_category, stat_num)
|
162
|
+
elsif stat_num == 'menu' || stat_num == 'exit'
|
163
|
+
menu
|
164
|
+
else
|
165
|
+
error
|
166
|
+
end
|
167
|
+
elsif stat_category == 'menu' || stat_category == 'exit'
|
168
|
+
menu
|
169
|
+
else
|
170
|
+
error
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
146
174
|
def list_draft_picks_by_nba_team
|
147
175
|
puts NbaDraft2017::Player.nba_teams.sort
|
148
176
|
puts 'Enter an NBA team (name only) as in list above:'.colorize(:green)
|
@@ -6,16 +6,13 @@ class NbaDraft2017::Player
|
|
6
6
|
@@all = []
|
7
7
|
@@nba_teams = []
|
8
8
|
@@former_teams = []
|
9
|
+
@@all_attributes = nil
|
9
10
|
|
10
11
|
def initialize(player_hash)
|
11
12
|
player_hash.each {|attribute, value| self.send("#{attribute}=", value) }
|
12
13
|
@@all << self
|
13
14
|
end
|
14
15
|
|
15
|
-
def self.create_from_collection(players_array)
|
16
|
-
players_array.each { |player| NbaDraft2017::Player.new(player) }
|
17
|
-
end
|
18
|
-
|
19
16
|
def add_player_attributes(attributes_hash)
|
20
17
|
attributes_hash.each { |attribute, value| self.send("#{attribute}=", value) }
|
21
18
|
end
|
@@ -28,6 +25,36 @@ class NbaDraft2017::Player
|
|
28
25
|
NbaDraft2017::Player.all.detect { |player| player.pick == pick.to_s }
|
29
26
|
end
|
30
27
|
|
28
|
+
|
29
|
+
def self.add_attributes_to_player(player)
|
30
|
+
attributes = NbaDraft2017::Scraper.scrape_player("http://www.nba.com/draft/2017/prospects/" + player.profile_url)
|
31
|
+
player.add_player_attributes(attributes)
|
32
|
+
player
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.add_attributes_to_players
|
36
|
+
@@all_attributes = self.all.each do |player|
|
37
|
+
add_attributes_to_player(player)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def self.stat_greater_than(stat_category, stat_num)
|
43
|
+
@@all_attributes ||= self.add_attributes_to_players
|
44
|
+
puts "Players with a higher average #{stat_category} include:".colorize(:green)
|
45
|
+
puts "------------------------------------------------------------".bold.colorize(:red)
|
46
|
+
|
47
|
+
players = self.all.select.with_index(1) do |player, idx|
|
48
|
+
if player.send(stat_category) && player.send(stat_category) > stat_num.to_f
|
49
|
+
puts "Pick: #{idx.to_s.colorize(:green)}. #{player.name.colorize(:green)} - #{player.send(stat_category).to_s.colorize(:red)} #{stat_category}"
|
50
|
+
player
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
puts "Nobody!".bold.colorize(:red) if players.empty?
|
55
|
+
puts "------------------------------------------------------------".bold.colorize(:red)
|
56
|
+
end
|
57
|
+
|
31
58
|
def self.nba_teams
|
32
59
|
self.all.each do |player|
|
33
60
|
@@nba_teams << player.nba_team.downcase.strip
|
@@ -63,6 +90,10 @@ class NbaDraft2017::Player
|
|
63
90
|
end
|
64
91
|
end
|
65
92
|
|
93
|
+
def self.all_attributes
|
94
|
+
@@all_attributes
|
95
|
+
end
|
96
|
+
|
66
97
|
def self.all
|
67
98
|
@@all
|
68
99
|
end
|
@@ -41,12 +41,10 @@ class NbaDraft2017::Scraper
|
|
41
41
|
else
|
42
42
|
player[:profile_url] = player[:first_name].gsub(/\W/, '').downcase + '_' + player[:last_name].gsub(/\W/, '').downcase
|
43
43
|
end
|
44
|
-
|
45
|
-
players << player
|
44
|
+
NbaDraft2017::Player.new(player)
|
46
45
|
pick = pick.to_i + 1
|
47
46
|
i += 1
|
48
47
|
end
|
49
|
-
players
|
50
48
|
end
|
51
49
|
|
52
50
|
def self.scrape_player(profile_url)
|
@@ -111,7 +109,7 @@ class NbaDraft2017::Scraper
|
|
111
109
|
elsif stat.downcase.include?('mpg')
|
112
110
|
player[:mpg] = stat.split(' ')[0].strip.to_f
|
113
111
|
player[:mpg].to_s + ' ' + stat.split(' ')[1].strip
|
114
|
-
|
112
|
+
elsif stat.downcase.include?('fg')
|
115
113
|
player[:fg] = stat.split(' ')[0].strip.to_f
|
116
114
|
player[:FG].to_s + ' ' + stat.split(' ')[1].strip
|
117
115
|
elsif stat.downcase.include?('3pt')
|
Binary file
|
data/nba_draft_2017.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
spec.add_development_dependency "pry"
|
25
25
|
|
26
|
-
spec.add_runtime_dependency "nokogiri", "~>1.
|
26
|
+
spec.add_runtime_dependency "nokogiri", "~> 1.0"
|
27
27
|
spec.add_runtime_dependency "colorize"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nba-draft-2017
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Snider
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: '1.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: colorize
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/nba_draft_2017/player.rb
|
119
119
|
- lib/nba_draft_2017/scraper.rb
|
120
120
|
- lib/nba_draft_2017/version.rb
|
121
|
+
- nba-draft-2017-0.1.4.gem
|
121
122
|
- nba_draft_2017.gemspec
|
122
123
|
- spec/nba_draft_spec.rb
|
123
124
|
- spec/spec_helper.rb
|