yahoo_nba 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,7 +35,11 @@ The hash will be in the format:
35
35
 
36
36
  To get nba player stats:
37
37
 
38
- query.get_players_stats_hash_using(players_keys_hash)
38
+ query.get_players_stats_hash_using(player_keys_hash)
39
+
40
+ To get an invidual player's stats:
41
+
42
+ query.get_player_stats_hash_with_player_name("LeBron James")
39
43
 
40
44
  The hash will be in the format returned by the Yahoo Sports API.
41
45
  Note: There will be a request to the Yahoo API for each player so it will take a while to get the stats for all the players.
@@ -0,0 +1,5 @@
1
+ module PlayerIncludes
2
+ def player_key_hash
3
+ {"Kevin Durant"=>"249.p.4244","LeBron James"=>"249.p.3704","Chris Paul"=>"249.p.3930","Pau Gasol"=>"249.p.3513","Dirk Nowitzki"=>"249.p.3252","Dwyane Wade"=>"249.p.3708","Stephen Curry"=>"249.p.4612","Amar'e Stoudemire"=>"249.p.3607","Paul Pierce"=>"249.p.3253","Manu Ginobili"=>"249.p.3380","Al Horford"=>"249.p.4245","LaMarcus Aldridge"=>"249.p.4130","Al Jefferson"=>"249.p.3832","Derrick Rose"=>"249.p.4387","Kevin Love"=>"249.p.4391","Monta Ellis"=>"249.p.3966","Kobe Bryant"=>"249.p.3118","Ray Allen"=>"249.p.3080","Carmelo Anthony"=>"249.p.3706","Russell Westbrook"=>"249.p.4390","Dorell Wright"=>"249.p.3836","Elton Brand"=>"249.p.3324","Danny Granger"=>"249.p.3943","Kevin Martin"=>"249.p.3843","Kevin Garnett"=>"249.p.3007","Josh Smith"=>"249.p.3834","Jason Kidd"=>"249.p.2625","Paul Millsap"=>"249.p.4175","Chauncey Billups"=>"249.p.3174","Channing Frye"=>"249.p.3934","Zach Randolph"=>"249.p.3531","Tim Duncan"=>"249.p.3173","David Lee"=>"249.p.3956","Chris Bosh"=>"249.p.3707","Steve Nash"=>"249.p.3103","Brook Lopez"=>"249.p.4472","Nene Hilario"=>"249.p.3605","Deron Williams"=>"249.p.3929","David West"=>"249.p.3721","Marc Gasol"=>"249.p.4325","Lamar Odom"=>"249.p.3327","Jason Richardson"=>"249.p.3515","Beno Udrih"=>"249.p.3845","Gerald Wallace"=>"249.p.3533","Serge Ibaka"=>"249.p.4486","Raymond Felton"=>"249.p.3931","Luol Deng"=>"249.p.3824","Jason Terry"=>"249.p.3333","Wesley Matthews"=>"249.p.4694","Mike Conley"=>"249.p.4246","Dwight Howard"=>"249.p.3818","Rudy Gay"=>"249.p.4136","Wilson Chandler"=>"249.p.4301","Jrue Holiday"=>"249.p.4622","Andre Miller"=>"249.p.3331","Andre Iguodala"=>"249.p.3826","Kyle Lowry"=>"249.p.4152","Rajon Rondo"=>"249.p.4149","James Harden"=>"249.p.4563","Danilo Gallinari"=>"249.p.4468","Boris Diaw"=>"249.p.3724","Nicolas Batum"=>"249.p.4487","Luis Scola"=>"249.p.3653","Shane Battier"=>"249.p.3516","Shawn Marion"=>"249.p.3332","Amir Johnson"=>"249.p.3982","Jared Dudley"=>"249.p.4300","Grant Hill"=>"249.p.2626","Tony Parker"=>"249.p.3527","Hedo Turkoglu"=>"249.p.3415","Joe Johnson"=>"249.p.3520","Luke Ridnour"=>"249.p.3717","JaVale McGee"=>"249.p.4480","Thaddeus Young"=>"249.p.4290","Arron Afflalo"=>"249.p.4305","J.R. Smith"=>"249.p.3835","Marcin Gortat"=>"249.p.3983","D.J. Augustin"=>"249.p.4471","Andrea Bargnani"=>"249.p.4129","Jeff Green"=>"249.p.4247","Andrei Kirilenko"=>"249.p.3347","George Hill"=>"249.p.4488","Andrew Bogut"=>"249.p.3927","Chuck Hayes"=>"249.p.4023","Stephen Jackson"=>"249.p.3210","Eric Gordon"=>"249.p.4469","Tyson Chandler"=>"249.p.3512","Roy Hibbert"=>"249.p.4479","John Salmons"=>"249.p.3624","Samuel Dalembert"=>"249.p.3534","Darren Collison"=>"249.p.4626","Jose Calderon"=>"249.p.3989","Vince Carter"=>"249.p.3248","Rodney Stuckey"=>"249.p.4293","Andray Blatche"=>"249.p.3975","Toney Douglas"=>"249.p.4634","Trevor Ariza"=>"249.p.3860","Jameer Nelson"=>"249.p.3837","Jamal Crawford"=>"249.p.3407","Richard Jefferson"=>"249.p.3523","Metta World Peace"=>"249.p.3339","Ty Lawson"=>"249.p.4623","Brandon Jennings"=>"249.p.4615","Charlie Villanueva"=>"249.p.3933","DeMar DeRozan"=>"249.p.4614","Landry Fields"=>"249.p.4770","Baron Davis"=>"249.p.3326","Thabo Sefolosha"=>"249.p.4141","Marcus Camby"=>"249.p.3084","Carlos Boozer"=>"249.p.3632","Andrew Bynum"=>"249.p.3936","Kirk Hinrich"=>"249.p.3710","Emeka Okafor"=>"249.p.3819","Joakim Noah"=>"249.p.4287","Michael Beasley"=>"249.p.4388","C.J. Miles"=>"249.p.3960","Kris Humphries"=>"249.p.3831","Ryan Anderson"=>"249.p.4483","Mike Bibby"=>"249.p.3245","Devin Harris"=>"249.p.3822","Rashard Lewis"=>"249.p.3275","DeJuan Blair"=>"249.p.4642","Lou Williams"=>"249.p.3971","Marcus Thornton"=>"249.p.4648","Tony Allen"=>"249.p.3842","Antawn Jamison"=>"249.p.3247","O.J. Mayo"=>"249.p.4389","Rudy Fernandez"=>"249.p.4302","Mike Dunleavy"=>"249.p.3601","Greg Monroe"=>"249.p.4722","Jodie Meeks"=>"249.p.4646","Blake Griffin"=>"249.p.4561","Tayshaun Prince"=>"249.p.3621","Carlos Delfino"=>"249.p.3728","Taj Gibson"=>"249.p.4631","Anthony Morrow"=>"249.p.4527","Courtney Lee"=>"249.p.4484","Marvin Williams"=>"249.p.3928","Derek Fisher"=>"249.p.3125","Chase Budinger"=>"249.p.4649","Tyreke Evans"=>"249.p.4564","Ersan Ilyasova"=>"249.p.3962","Mo Williams"=>"249.p.3750","Anthony Parker"=>"249.p.3171","Ronnie Brewer"=>"249.p.4142","Ramon Sessions"=>"249.p.4333","Shannon Brown"=>"249.p.4153","Ben Gordon"=>"249.p.3820","Carl Landry"=>"249.p.4309","Josh McRoberts"=>"249.p.4314","Nick Young"=>"249.p.4294","Kyle Korver"=>"249.p.3754","Brandon Bass"=>"249.p.3959","John Wall"=>"249.p.4716","Daniel Gibson"=>"249.p.4170","Al Harrington"=>"249.p.3268","Matt Bonner"=>"249.p.3748","Brandon Rush"=>"249.p.4475","Ryan Gomes"=>"249.p.3976","DeAndre Jordan"=>"249.p.4497","Jordan Farmar"=>"249.p.4154","Darrell Arthur"=>"249.p.4489","Francisco Garcia"=>"249.p.3949","Jarrett Jack"=>"249.p.3948","Mario Chalmers"=>"249.p.4496","Marco Belinelli"=>"249.p.4296","J.J. Redick"=>"249.p.4139","Reggie Williams"=>"249.p.4710","Glen Davis"=>"249.p.4313","Spencer Hawes"=>"249.p.4288","Luc Richard Mbah a Moute"=>"249.p.4498","Omri Casspi"=>"249.p.4628","Anthony Tolliver"=>"249.p.4371","Darko Milicic"=>"249.p.3705","Nick Collison"=>"249.p.3715","Aaron Brooks"=>"249.p.4304","J.J. Hickson"=>"249.p.4481","Andris Biedrins"=>"249.p.3828","James Jones"=>"249.p.3752","Brandon Roy"=>"249.p.4134","Wes Johnson"=>"249.p.4719","Vladimir Radmanovic"=>"249.p.3522","Brad Miller"=>"249.p.3305","Austin Daye"=>"249.p.4620","Shawne Williams"=>"249.p.4145","Sasha Vujacic"=>"249.p.3844","Matt Barnes"=>"249.p.3643","Ed Davis"=>"249.p.4728","Randy Foye"=>"249.p.4135","J.J. Barea"=>"249.p.4203","Nenad Krstic"=>"249.p.3622","Anderson Varejao"=>"249.p.3847","Kenyon Martin"=>"249.p.3400","Corey Maggette"=>"249.p.3336","Sam Young"=>"249.p.4641","Tracy McGrady"=>"249.p.3179","Gary Neal"=>"249.p.4796","Leandro Barbosa"=>"249.p.3731","Corey Brewer"=>"249.p.4285","Antonio McDyess"=>"249.p.3004","Raja Bell"=>"249.p.3467","Richard Hamilton"=>"249.p.3330","Jason Thompson"=>"249.p.4474","Dante Cunningham"=>"249.p.4638","Keyon Dooling"=>"249.p.3409","Tyrus Thomas"=>"249.p.4132","Ben Wallace"=>"249.p.3149","Ronny Turiaf"=>"249.p.3963","Earl Watson"=>"249.p.3549","Zydrunas Ilgauskas"=>"249.p.3121","Nazr Mohammed"=>"249.p.3272","Willie Green"=>"249.p.3744","Chris Kaman"=>"249.p.3709","Gilbert Arenas"=>"249.p.3540","Keith Bogans"=>"249.p.3746","Chris Andersen"=>"249.p.3598","Maurice Evans"=>"249.p.3568","Travis Outlaw"=>"249.p.3726","Steve Blake"=>"249.p.3741","Martell Webster"=>"249.p.3932","C.J. Watson"=>"249.p.4354","Gerald Henderson"=>"249.p.4617","Caron Butler"=>"249.p.3608","Paul George"=>"249.p.4725","Shaun Livingston"=>"249.p.3821","Kurt Thomas"=>"249.p.3012","DeMarcus Cousins"=>"249.p.4720","Joel Anthony"=>"249.p.4339","Jamario Moon"=>"249.p.4342","Mickael Pietrus"=>"249.p.3714","Will Bynum"=>"249.p.3999","Jerryd Bayless"=>"249.p.4473","Tyler Hansbrough"=>"249.p.4618","Eddie House"=>"249.p.3436","Al Thornton"=>"249.p.4292","Drew Gooden"=>"249.p.3602","Evan Turner"=>"249.p.4717","Eric Bledsoe"=>"249.p.4749","Robin Lopez"=>"249.p.4477","Peja Stojakovic"=>"249.p.3119","Hakim Warrick"=>"249.p.3945","Derrick Favors"=>"249.p.4718","Quentin Richardson"=>"249.p.3417","Jeff Teague"=>"249.p.4624","Goran Dragic"=>"249.p.4507","Jordan Hill"=>"249.p.4613","Nate Robinson"=>"249.p.3947","Zaza Pachulia"=>"249.p.3745","James Posey"=>"249.p.3341","Earl Boykins"=>"249.p.3311","Trevor Booker"=>"249.p.4754","Troy Murphy"=>"249.p.3524","Mike Miller"=>"249.p.3404","Al-Farouq Aminu"=>"249.p.4723","Eric Maynor"=>"249.p.4625","Patrick Patterson"=>"249.p.4729","Andres Nocioni"=>"249.p.3882","Donte Greene"=>"249.p.4490","Chris Wilcox"=>"249.p.3606","Chris Douglas-Roberts"=>"249.p.4502","Jason Smith"=>"249.p.4298","Sonny Weems"=>"249.p.4501","Bill Walker"=>"249.p.4509","Shelden Williams"=>"249.p.4133","Yi Jianlian"=>"249.p.4284","Brendan Haywood"=>"249.p.3532","Jeff Foster"=>"249.p.3344","Erick Dampier"=>"249.p.3117","Carlos Arroyo"=>"249.p.3585","DeShawn Stevenson"=>"249.p.3422","Ryan Hollins"=>"249.p.4179","Marreese Speights"=>"249.p.4478","Marquis Daniels"=>"249.p.3764","Ekpe Udoh"=>"249.p.4721","Alonzo Gee"=>"249.p.4686","Rasual Butler"=>"249.p.3650","Damien Wilkins"=>"249.p.3900","Wayne Ellington"=>"249.p.4633","James Johnson"=>"249.p.4621","Johan Petro"=>"249.p.3951","Gordon Hayward"=>"249.p.4724","Delonte West"=>"249.p.3841","Daequan Cook"=>"249.p.4299","Dahntay Jones"=>"249.p.3723","Larry Sanders"=>"249.p.4730","Shaquille O'Neal"=>"249.p.847","Jermaine O'Neal"=>"249.p.3120","Kwame Brown"=>"249.p.3511","Julian Wright"=>"249.p.4291","Anthony Randolph"=>"249.p.4476","Craig Smith"=>"249.p.4164","Brian Cardinal"=>"249.p.3443","Mehmet Okur"=>"249.p.3547","Kendrick Perkins"=>"249.p.3730","Christian Eyenga"=>"249.p.4635","Udonis Haslem"=>"249.p.3765","Jonny Flynn"=>"249.p.4611","Jared Jeffries"=>"249.p.3609","DJ White"=>"249.p.4491","Josh Childress"=>"249.p.3823","Rodrigue Beaubois"=>"249.p.4630","T.J. Ford"=>"249.p.3711","Jordan Crawford"=>"249.p.4758","Jeremy Evans"=>"249.p.4786","Nikola Pekovic"=>"249.p.4493","Anthony Carter"=>"249.p.3396","Dominic McGuire"=>"249.p.4338","Pooh Jeter"=>"249.p.4197","Luther Head"=>"249.p.3950","A.J. Price"=>"249.p.4657","Patty Mills"=>"249.p.4660","Juwan Howard"=>"249.p.2628","Jason Williams"=>"249.p.3250","Manny Harris"=>"249.p.4827","Cartier Martin"=>"249.p.4559","Linas Kleiza"=>"249.p.3953","Ronnie Price"=>"249.p.3990","Ian Mahinmi"=>"249.p.3954","Jason Maxiell"=>"249.p.3952","Luke Harangody"=>"249.p.4783","Sebastian Telfair"=>"249.p.3830","Francisco Elson"=>"249.p.3364","Jonas Jerebko"=>"249.p.4644","Chris Duhon"=>"249.p.3855","Rodney Carney"=>"249.p.4144","Jon Brockman"=>"249.p.4643","Acie Law"=>"249.p.4289","Roger Mason"=>"249.p.3628","Gary Forbes"=>"249.p.4805","Matt Carroll"=>"249.p.3785","Omer Asik"=>"249.p.4499","Louis Amundson"=>"249.p.4190","Greivis Vasquez"=>"249.p.4759","Reggie Evans"=>"249.p.3663","Kevin Seraphin"=>"249.p.4748","Brian Cook"=>"249.p.3727","Joey Graham"=>"249.p.3942","Von Wafer"=>"249.p.3965","Quincy Pondexter"=>"249.p.4757","Semih Erden"=>"249.p.4522","Aaron Gray"=>"249.p.4326","Derrick Brown"=>"249.p.4645","Stephen Graham"=>"249.p.4012","Timofey Mozgov"=>"249.p.4794","Jeremy Lin"=>"249.p.4795","Alexis Ajinca"=>"249.p.4482","Steve Novak"=>"249.p.4160","Brandan Wright"=>"249.p.4286","David Andersen"=>"249.p.3634","Tiago Splitter"=>"249.p.4306","DJ Mbenga"=>"249.p.3877","Solomon Jones"=>"249.p.4161","Hilton Armstrong"=>"249.p.4140","Hasheem Thabeet"=>"249.p.4562","Joel Przybilla"=>"249.p.3408","Jermaine Taylor"=>"249.p.4637","Joey Dorsey"=>"249.p.4494","Eduardo Najera"=>"249.p.3437","Dan Gadzuric"=>"249.p.3631","Tony Battie"=>"249.p.3176","Darius Songaila"=>"249.p.3647","Lazar Hayward"=>"249.p.4761","Kosta Koufos"=>"249.p.4485","Charlie Bell"=>"249.p.3570","Terrence Williams"=>"249.p.4616","Sasha Pavlovic"=>"249.p.3722","Damion James"=>"249.p.4755","Ike Diogu"=>"249.p.3935","Josh Howard"=>"249.p.3732","Zabian Dowdell"=>"249.p.4834","Flip Murray"=>"249.p.3639","Devean George"=>"249.p.3346","Darnell Jackson"=>"249.p.4514","Larry Hughes"=>"249.p.3251","Josh Powell"=>"249.p.3774","Jawad Williams"=>"249.p.4010","Hamed Haddadi"=>"249.p.4531","James Singleton"=>"249.p.4055","Sergio Rodriguez"=>"249.p.4155","Jarvis Hayes"=>"249.p.3713","Othyus Jeffers"=>"249.p.4711","Royal Ivey"=>"249.p.3854","Jason Collins"=>"249.p.3530","Melvin Ely"=>"249.p.3610","Ime Udoka"=>"249.p.3501","Josh Boone"=>"249.p.4151","Theo Ratliff"=>"249.p.3020","Greg Oden"=>"249.p.4243","Samardo Samuels"=>"249.p.4799","Earl Clark"=>"249.p.4619","Ben Uzoh"=>"249.p.4792","Antoine Wright"=>"249.p.3941","Chris Hunter"=>"249.p.4560","James Anderson"=>"249.p.4751","Rafer Alston"=>"249.p.3282","Devin Brown"=>"249.p.3673","Luke Walton"=>"249.p.3735","Morris Peterson"=>"249.p.3420","Jason Kapono"=>"249.p.3734","Chris Quinn"=>"249.p.4192","Ishmael Smith"=>"249.p.4800","Larry Owens"=>"249.p.4687","Jerry Stackhouse"=>"249.p.3005","Michael Redd"=>"249.p.3442","Yao Ming"=>"249.p.3599","Derrick Caracter"=>"249.p.4789","DeMarre Carroll"=>"249.p.4632","Danny Green"=>"249.p.4651","Jannero Pargo"=>"249.p.3660","Brian Scalabrine"=>"249.p.3544","Joe Smith"=>"249.p.3003","DeSagana Diop"=>"249.p.3518","Cole Aldrich"=>"249.p.4726","Devin Ebanks"=>"249.p.4774","Rasho Nesterovic"=>"249.p.3260","Mario West"=>"249.p.4362","Jeff Pendergraph"=>"249.p.4636","Allen Iverson"=>"249.p.3094","Malik Allen"=>"249.p.3507","Etan Thomas"=>"249.p.3411","Michael Finley"=>"249.p.3023","Marcus Williams"=>"249.p.4150","Willie Warren"=>"249.p.4785","Oleksiy Pecherov"=>"249.p.4146","Earl Barron"=>"249.p.3908","Sundiata Gaines"=>"249.p.4708","Chris Johnson"=>"249.p.4839","Jeff Adrien"=>"249.p.4802","Sean Marks"=>"249.p.3287","Chucky Atkins"=>"249.p.3391","Kyle Weaver"=>"249.p.4500","Xavier Henry"=>"249.p.4727","Jamaal Tinsley"=>"249.p.3528","Anthony Johnson"=>"249.p.3207","Renaldo Balkman"=>"249.p.4148","Fabricio Oberto"=>"249.p.3988","Trenton Hassell"=>"249.p.3539","Jamaal Magloire"=>"249.p.3418","Tim Thomas"=>"249.p.3170","Garrett Temple"=>"249.p.4682","Quinton Ross"=>"249.p.3767","Kelenna Azubuike"=>"249.p.4030","Leon Powe"=>"249.p.4177","Bobby Simmons"=>"249.p.3551","Dominique Jones"=>"249.p.4756","Marcus Banks"=>"249.p.3716","Bobby Brown"=>"249.p.4525","Jonathan Bender"=>"249.p.3328","Kenny Thomas"=>"249.p.3345","Nathan Jawai"=>"249.p.4503","Lester Hudson"=>"249.p.4663","Sean May"=>"249.p.3939","Malik Hairston"=>"249.p.4510","Mardy Collins"=>"249.p.4157","Kevin Ollie"=>"249.p.3237","Trey Johnson"=>"249.p.4352","Kyrylo Fesenko"=>"249.p.4315","Chris Richard"=>"249.p.4318","Armon Johnson"=>"249.p.4765","Maurice Ager"=>"249.p.4156","Hamady Ndiaye"=>"249.p.4787","J.R. Giddens"=>"249.p.4492","Adam Morrison"=>"249.p.4131","Randolph Morris"=>"249.p.4242","Pops Mensah-Bonsu"=>"249.p.4201","Brian Skinner"=>"249.p.3265","Marcus Cousin"=>"249.p.4812","Marcus Landry"=>"249.p.4689","Antonio Daniels"=>"249.p.3175","Pape Sy"=>"249.p.4784","DaJuan Summers"=>"249.p.4639","Sherron Collins"=>"249.p.4798","Patrick O'Bryant"=>"249.p.4137","Jarron Collins"=>"249.p.3562","Mike Harris"=>"249.p.4230","Coby Karl"=>"249.p.4343","Jason Hart"=>"249.p.3448","Lance Stephenson"=>"249.p.4771","Orien Greene"=>"249.p.3979","Shavlik Randolph"=>"249.p.3992","Oliver Lafayette"=>"249.p.4715","Travis Diener"=>"249.p.3964","Joe Alexander"=>"249.p.4470","Ronald Dupree"=>"249.p.3788","Dwayne Jones"=>"249.p.4002","D.J. Strawberry"=>"249.p.4336","Ryan Reid"=>"249.p.4788","Jon Scheyer"=>"249.p.4813","Chris Kramer"=>"249.p.4821","Thomas Gardner"=>"249.p.4358","Donald Sloan"=>"249.p.4836","Drew Naymick"=>"249.p.4810","James Gist"=>"249.p.4519","Dee Brown"=>"249.p.4174","Jerel McNeal"=>"249.p.4684","Nemanja Bjelica"=>"249.p.4766","Marqus Blakely"=>"249.p.4826","Curtis Jerrells"=>"249.p.4692","Loren Woods"=>"249.p.3555","Longar Longar"=>"249.p.4838","Anthony Roberson"=>"249.p.4001","John Thomas"=>"249.p.3193","Michael Washington"=>"249.p.4830","Tory Jackson"=>"249.p.4820","Anthony Mason Jr."=>"249.p.4824","Matt Rogers"=>"249.p.4837","Dwight Lewis"=>"249.p.4806","Tony Gaffney"=>"249.p.4670","Demetris Nichols"=>"249.p.4330","Russell Hicks"=>"249.p.4811","Daniel Orton"=>"249.p.4760","Trent Plaisted"=>"249.p.4508","Ricardo Marsh"=>"249.p.4818","Tasmin Mitchell"=>"249.p.4828","Cheyne Gadson"=>"249.p.4552","Alexander Johnson"=>"249.p.4173","Latavious Williams"=>"249.p.4779","Jarvis Varnado"=>"249.p.4772","Vernon Hamilton"=>"249.p.4551","Hassan Whiteside"=>"249.p.4764","Seth Tarver"=>"249.p.4807","Connor Atchley"=>"249.p.4835","Darius Miles"=>"249.p.3402","Tre Kelley"=>"249.p.4539","Jordan Eglseder"=>"249.p.4829"}
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module YahooNba
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,5 +1,8 @@
1
+ require_relative 'player_includes'
2
+
1
3
  module YahooNba
2
4
  class Query
5
+ include PlayerIncludes
3
6
 
4
7
  def initialize(consumer_key, consumer_secret)
5
8
  consumer = ::OAuth::Consumer.new(consumer_key,
@@ -7,6 +10,7 @@ module YahooNba
7
10
  :site => 'http://fantasysports.yahooapis.com',
8
11
  :http_method => :get)
9
12
  @access_token = OAuth::AccessToken.new(consumer)
13
+ @player_key_hash = player_key_hash
10
14
  end
11
15
 
12
16
  def get_players_info_array_starting_at(num)
@@ -24,14 +28,22 @@ module YahooNba
24
28
 
25
29
  def get_players_stats_hash_using(players_key_hash)
26
30
  players_stats_hash = {}
27
- players_key_hash.each do |player_name, player_id|
28
- player_stats_xml = @access_token.get("/fantasy/v2/player/#{player_id}/stats")
29
- player_stats = Crack::XML.parse(player_stats_xml.body)["fantasy_content"]["player"]
31
+ players_key_hash.each do |player_name, player_key|
32
+ player_stats = get_player_stats_hash_with_player_key(player_key)
30
33
  players_stats_hash[player_name] = player_stats
31
34
  end
32
35
  players_stats_hash
33
36
  end
34
37
 
38
+ def get_player_stats_hash_with_player_key(player_key)
39
+ player_stats_xml = @access_token.get("/fantasy/v2/player/#{player_key}/stats")
40
+ player_stats = Crack::XML.parse(player_stats_xml.body)["fantasy_content"]["player"]
41
+ end
42
+
43
+ def get_player_stats_hash_with_player_name(player_name)
44
+ get_player_stats_hash_with_player_key(@player_key_hash[player_name])
45
+ end
46
+
35
47
  def get_all_player_keys_hash
36
48
  combined_array = []
37
49
  0.step(500, 25) do |n|
@@ -30,6 +30,17 @@ describe YahooNba do
30
30
  query.instance_variable_get(:@access_token).should_not equal(nil)
31
31
  end
32
32
 
33
+ it "should set instance variable player_keys_hash with value from file" do
34
+ query = YahooNba::Query.new(@consumer_key, @consumer_secret)
35
+ query.instance_variable_get(:@player_key_hash).should_not equal(nil)
36
+ end
37
+
38
+ it "should set instance variable player_keys_hash with value from file" do
39
+ query = YahooNba::Query.new(@consumer_key, @consumer_secret)
40
+ player_key_hash = query.instance_variable_get(:@player_key_hash)
41
+ player_key_hash["LeBron James"].should == "249.p.3704"
42
+ end
43
+
33
44
  end
34
45
 
35
46
  describe "get_players_starting_at" do
@@ -128,6 +139,40 @@ describe YahooNba do
128
139
  end
129
140
  end
130
141
 
142
+ describe "get_player_stats_hash_with_player_key" do
143
+ it "should use the player key to get the stats for the player" do
144
+ query = YahooNba::Query.new(@consumer_key, @consumer_secret)
145
+ access_token = query.instance_variable_get(:@access_token)
146
+ mock_xml = mock
147
+ mock_player_stats_xml = mock(:body => mock_xml)
148
+ Crack::XML.should_receive(:parse).with(mock_xml).and_return(
149
+ {'fantasy_content' =>
150
+ {'player' =>
151
+ 'correct'
152
+ }
153
+ })
154
+ access_token.should_receive(:get).with("/fantasy/v2/player/249.p.4244/stats").and_return(mock_player_stats_xml)
155
+ query.get_player_stats_hash_with_player_key("249.p.4244").should == "correct"
156
+ end
157
+ end
158
+
159
+ describe "get_player_stats_hash_with_player_name" do
160
+ it "should use the player key to get the stats for the player when given the player name" do
161
+ query = YahooNba::Query.new(@consumer_key, @consumer_secret)
162
+ access_token = query.instance_variable_get(:@access_token)
163
+ mock_xml = mock
164
+ mock_player_stats_xml = mock(:body => mock_xml)
165
+ Crack::XML.should_receive(:parse).with(mock_xml).and_return(
166
+ {'fantasy_content' =>
167
+ {'player' =>
168
+ 'correct'
169
+ }
170
+ })
171
+ access_token.should_receive(:get).with("/fantasy/v2/player/249.p.4244/stats").and_return(mock_player_stats_xml)
172
+ query.get_player_stats_hash_with_player_name("Kevin Durant")
173
+ end
174
+ end
175
+
131
176
  end
132
177
 
133
178
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo_nba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-08 00:00:00.000000000 Z
12
+ date: 2012-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
@@ -90,6 +90,7 @@ files:
90
90
  - README.md
91
91
  - Rakefile
92
92
  - lib/yahoo_nba.rb
93
+ - lib/yahoo_nba/player_includes.rb
93
94
  - lib/yahoo_nba/version.rb
94
95
  - lib/yahoo_nba/yahoo_nba.rb
95
96
  - spec/spec_helper.rb