nbasalaryscrape 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 67907e1014afa3c7c50d893eb22e7f57f7bdcb45
4
+ data.tar.gz: 6c85b8812659a6b5c308b8a3510bb0ac8d1c8c2e
5
+ SHA512:
6
+ metadata.gz: 78ef635b8c4984e235256250af829085375694cb9996febe5cf7cb3817235f50c080178b83d16ed36a3d3364a8faf33effa3eff968f5c6e4708a97d174b47feb
7
+ data.tar.gz: c0e68c9a30b495c4922a683e89783416ac6f22ca12260fa85eb182bfd9d8961c6b584e0ee82ef530316ec016cf67c0a8f74a9e23a53fc3a7499b09c6d85224d9
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ #OS generated files
2
+ .DS_Store
3
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - ruby-head
4
+ - 2.1.0
5
+ - 1.9.3
6
+ - jruby-head
7
+ - jruby-19mode
8
+
9
+ branches:
10
+ only:
11
+ - master
12
+ - /^release-.*$/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem 'nokogiri'
5
+ group :test do
6
+ gem 'rake'
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Amon Bazongo, Clive Augustin & Jevon McKenzie
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
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ task :default => [:spec]
4
+
5
+ desc 'Run specs'
6
+ task :spec do
7
+ sh 'ruby -I lib spec/salaryscrape_spec.rb'
8
+ end
data/ReadMe.md ADDED
@@ -0,0 +1,69 @@
1
+ nbasalaryscrape
2
+ ===============
3
+
4
+ [![Build Status](https://travis-ci.org/CliveIMPISA/nbasalaryscrape.svg?branch=master)](https://travis-ci.org/CliveIMPISA/nbasalaryscrape)
5
+
6
+
7
+ nbasalaryscrape grabs the salary and contract information of National Basketball Association(NBA) players from [basketball-reference.com](http://www.basketball-reference.com). This information is then written to yaml file. Included in this project is a sample of a generated yaml file of one of the teams salary information
8
+ ## About
9
+
10
+ The information (that can be stored in the yaml file) contains a list of the players and their contractual arrangement on any particular NBA team. How is that information useful? Every year, the NBA sets a salary cap- which is the maximum amount of money a team can pay all its players combined without facing any penalties. Knowing contractual agreements can give teams an idea of potential cost cutting measures or cap space available for signing additional players. If you are a just a fan and only want to know what you favorite player is earning, this application can immediately generate this information for you. For more information on the nba salary cap visit [NBA Salary cap](http://en.wikipedia.org/wiki/NBA_salary_cap)
11
+ ## Usage
12
+
13
+ This gem may be used as a command line utility or called from code
14
+
15
+ ###CLI
16
+
17
+ Type nbasalaryscrape and provide one of the team abbreviations. Below is a list of the thirty teams and their abbreviations.
18
+ ````ruby
19
+ % nbasalaryscrape PHO
20
+ ````
21
+ To store the content in a yaml, just add a second argument as a output
22
+ ````ruby
23
+ % nbasalaryscrape BOS your_yaml_file.yml
24
+ ````
25
+ ###Call from ruby code
26
+
27
+ ````ruby
28
+ require 'nbasalaryscrape'
29
+
30
+ team = BasketballReference.new
31
+
32
+ puts team.to_array_of_hashes(PHO) #return players' data in an array of hashes
33
+ puts team.to_yaml(PHO) #return the same data in a yaml format
34
+ ````
35
+
36
+ ##Abbreviations
37
+
38
+ | Team Name |Abbreviation |
39
+ |:---------------:|:-----:|
40
+ |Pheonix Suns|PHO|
41
+ |Miami Heat|MIA|
42
+ |Atlanta Hawks |ATL|
43
+ |Boston Celtics|BOS|
44
+ |Brooklyn Nets|BRK|
45
+ |Chicago Bulls|CHI|
46
+ |Cleveland Cavaliers|CLE|
47
+ |Dallas Mavericks|DAL|
48
+ |Denver Nuggets|DEN|
49
+ |Golden State Warriors|GSW|
50
+ |Detroit Pistons|DET|
51
+ |Los Angeles Lakers|LAL|
52
+ |Los Angeles Clippers|LAC|
53
+ |Houston Rockets|HOU|
54
+ |Indiana Pacers|IND|
55
+ |Minnesota Timberwolves|MIN|
56
+ |Memphis Grizzlies| MEM|
57
+ |Milwuakee Bucks| MIL|
58
+ |New Orleans Pelicans| NOP|
59
+ |New York Knicks|NYK|
60
+ |Oklahoma City Thunder|OKC|
61
+ |Sacramento Kings| SAC|
62
+ |Washington Wizards|WAS|
63
+ |Utah Jazz| UTA|
64
+ |San Antonio Spurs|SAS|
65
+ |Toronto Raptors|TOR|
66
+ |Philadephia 76ers|PHI|
67
+ |Portland TrailBlazers|POR|
68
+ |Orlando Magic|ORL|
69
+ |Charlotte Hornets|CHO|
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/nbasalaryscrape/salaryscrape.rb'
3
+
4
+ # fail ArgumentError, "Usage: nbasalaryscrape [teamname] [filename (optional)]\n
5
+ # Please check the readme file for team names abbreviation\n" if ARGV.count == 0
6
+
7
+ team_name = ARGV[0]
8
+ file_name = ARGV[1]
9
+
10
+ include SalaryScraper
11
+
12
+ code = BasketballReference.new
13
+
14
+ if ARGV.count != 0
15
+ if code.check_if_team_exist(team_name)
16
+ puts code.to_array_of_hashes(team_name) if ARGV.count == 1
17
+
18
+ if ARGV.count == 2
19
+ File.open(file_name, 'w') do |file|
20
+ file.puts code.to_yaml(team_name)
21
+ end
22
+ end
23
+ else
24
+ puts 'This team does not exist.'
25
+ puts "Please check the readme file for team names abbreviation\n
26
+ or use one of the abbreviations below."
27
+ puts BasketballReference::ALL_TEAMS
28
+ end
29
+ else
30
+ puts 'Usage: nbasalaryscrape [teamname] [filename (optional)]'
31
+ puts 'Please check the readme file for team names abbreviation'
32
+
33
+ end
@@ -0,0 +1 @@
1
+ require_relative 'nbasalaryscrape/salaryscrape'
@@ -0,0 +1,87 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'yaml'
4
+
5
+ module SalaryScraper
6
+ # Class Pulls and Manipulates data from basketball-reference.com
7
+ class BasketballReference
8
+ WEBSITE = 'http://www.basketball-reference.com/contracts'
9
+ PAYROLL = "//div[@id='div_payroll']//tbody//tr[@class='']//td"
10
+ HEAD = "//div[@id='div_payroll']//thead//tr[@class='']//th"
11
+ ALL_TEAMS = Array['PHO', 'MIA', 'ATL', 'BOS', 'BRK', 'CHI',
12
+ 'CLE', 'DAL', 'DEN', 'GSW', 'DET', 'LAL',
13
+ 'LAC', 'HOU', 'IND', 'MIN', 'MEM', 'MIL',
14
+ 'NOP', 'NYK', 'OKC', 'SAC', 'WAS', 'UTA',
15
+ 'SAS', 'TOR', 'PHI', 'POR', 'ORL', 'CHO']
16
+ def get_team(team)
17
+ doc = get_page(team)
18
+ doc.xpath(PAYROLL)
19
+ end
20
+
21
+ def get_page(team)
22
+ url = "#{WEBSITE}/#{team}.html"
23
+ Nokogiri::HTML(open(url))
24
+ end
25
+
26
+ def just_text(data)
27
+ textes_array = []
28
+ data.each { |t| textes_array << t.text }
29
+ textes_array
30
+ end
31
+
32
+ def get_column_heads(team)
33
+ doc = get_page(team)
34
+ doc.xpath(HEAD)
35
+ end
36
+
37
+ def head_array(team)
38
+ @head_array = []
39
+ head = get_column_heads(team)
40
+ head.each { |x| @head_array << x.text }
41
+ @head_array
42
+ end
43
+
44
+ def players_data_array(team)
45
+ @players_data_array = []
46
+ players_data = get_team(team)
47
+ players_data.each { |x| @players_data_array << x.text }
48
+ @players_data_array
49
+ end
50
+
51
+ def to_array_of_hashes(team)
52
+ players_array = players_data_array(team)
53
+ header_array = head_array(team)
54
+ assign_key_to_value(number_arrays, players_array, header_array)
55
+ end
56
+
57
+ def assign_key_to_value(number_arrays, players_data_array, head_array)
58
+ data = []
59
+ number_arrays.times do
60
+ piece_of_data = Hash.new
61
+ head_array.each do |x|
62
+ piece_of_data[x] = players_data_array.first
63
+ players_data_array.shift
64
+ end
65
+ data << piece_of_data
66
+ end
67
+ data
68
+ end
69
+
70
+ def number_arrays
71
+ @players_data_array.size / @head_array.size
72
+ end
73
+
74
+ def to_yaml(team)
75
+ data = to_array_of_hashes(team)
76
+ data.to_yaml
77
+ end
78
+
79
+ def check_if_team_exist(team)
80
+ if ALL_TEAMS.include?(team)
81
+ return true
82
+ else
83
+ return false
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,4 @@
1
+ # Version of nbasalarycrape
2
+ module SalaryScraper
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,19 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'nbasalaryscrape/version'
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'nbasalaryscrape'
6
+ gem.version = SalaryScraper::VERSION
7
+ gem.executables << 'nbasalaryscrape'
8
+ gem.add_development_dependency 'minitest'
9
+ gem.add_development_dependency 'minitest-rg'
10
+ gem.date = Date.today.to_s
11
+ gem.summary = 'NBA Player Salary extractor'
12
+ gem.description = 'Extract Player Salary from Basketball-Reference.com'
13
+ gem.authors = ['Clive Augstin, Amon Bazongo, Jevon McKenzie']
14
+ gem.email = 'augustinclive@hotmail.com'
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.homepage = 'https://github.com/soumyaray/citesight'
18
+ gem.license = 'MIT'
19
+ end
@@ -0,0 +1,127 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/nbasalaryscrape.rb'
3
+
4
+ # tests the head of the tables for all the teams
5
+ # tests that the player's value is not empty for all the teams
6
+ # tests the size of the array of hashes for all the teams
7
+ # tests that head_array and players_data_array are not empty when a team exists
8
+
9
+ # data that are expected
10
+
11
+ player = [{ 'Player' => 'Eric Bledsoe', '2014-15' => '$12,173,913',
12
+ '2015-16' => '$13,086,957',
13
+ '2016-17' => '$14,000,001',
14
+ '2017-18' => '$14,913,045', '2018-19' => '$15,826,089',
15
+ 'Signed Using' => 'Bird Rights', 'Guaranteed' => '$70,000,000' },
16
+ { 'Player' => 'Goran Dragic', '2014-15' => '$7,500,000',
17
+ '2015-16' => '$7,500,000', '2016-17' => '',
18
+ '2017-18' => '', '2018-19' => '',
19
+ 'Signed Using' => 'Cap Space', 'Guaranteed' => '$7,500,000' },
20
+ { 'Player' => 'Isaiah Thomas', '2014-15' => '$7,238,606',
21
+ '2015-16' => '$6,912,869', '2016-17' => '$6,587,132',
22
+ '2017-18' => '$6,261,395', '2018-19' => '',
23
+ 'Signed Using' => '', 'Guaranteed' => '$27,000,002' },
24
+ { 'Player' => 'P.J. Tucker', '2014-15' => '$5,700,000',
25
+ '2015-16' => '$5,500,000', '2016-17' => '$5,300,000',
26
+ '2017-18' => '', '2018-19' => '',
27
+ 'Signed Using' => 'Cap Space', 'Guaranteed' => '$12,700,000' },
28
+ { 'Player' => 'Alex Len', '2014-15' => '$3,649,920',
29
+ '2015-16' => '$3,807,120', '2016-17' => '$4,823,621',
30
+ '2017-18' => '', '2018-19' => '',
31
+ 'Signed Using' => '1st Round Pick', 'Guaranteed' => '$3,649,920' },
32
+ { 'Player' => 'Gerald Green', '2014-15' => '$3,500,000',
33
+ '2015-16' => '', '2016-17' => '', '2017-18' => '',
34
+ '2018-19' => '', 'Signed Using' => 'Cap Space',
35
+ 'Guaranteed' => '$3,500,000' },
36
+ { 'Player' => 'Anthony Tolliver', '2014-15' => '$3,000,000',
37
+ '2015-16' => '$3,000,000', '2016-17' => '', '2017-18' => '',
38
+ '2018-19' => '', 'Signed Using' => 'Cap Space',
39
+ 'Guaranteed' => '$3,400,000' },
40
+ { 'Player' => 'Markieff Morris', '2014-15' => '$2,989,239',
41
+ '2015-16' => '$8,000,000', '2016-17' => '$8,000,000',
42
+ '2017-18' => '$8,000,000', '2018-19' => '$8,000,000',
43
+ 'Signed Using' => 'Bird Rights', 'Guaranteed' => '$34,989,239' },
44
+ { 'Player' => 'Marcus Morris', '2014-15' => '$2,943,221',
45
+ '2015-16' => '$5,000,000', '2016-17' => '$5,000,000',
46
+ '2017-18' => '$5,000,000', '2018-19' => '$5,000,000',
47
+ 'Signed Using' => 'Bird Rights', 'Guaranteed' => '$22,943,221' },
48
+ { 'Player' => 'Zoran Dragic', '2014-15' => '$1,962,103',
49
+ '2015-16' => '$2,050,397', '2016-17' => '', '2017-18' => '',
50
+ '2018-19' => '', 'Signed Using' => 'Cap Space',
51
+ 'Guaranteed' => '$4,012,500' },
52
+ { 'Player' => 'T.J. Warren', '2014-15' => '$1,953,120',
53
+ '2015-16' => '$2,041,080', '2016-17' => '$2,128,920',
54
+ '2017-18' => '$3,152,931', '2018-19' => '',
55
+ 'Signed Using' => '1st Round Pick',
56
+ 'Guaranteed' => '$3,994,200' },
57
+ { 'Player' => 'Tyler Ennis', '2014-15' => '$1,590,720',
58
+ '2015-16' => '$1,662,360', '2016-17' => '$1,733,880',
59
+ '2017-18' => '$2,666,707', '2018-19' => '',
60
+ 'Signed Using' => '1st Round Pick', 'Guaranteed' => '$3,253,080' },
61
+ { 'Player' => 'Shavlik Randolph', '2014-15' => '$1,227,985',
62
+ '2015-16' => '', '2016-17' => '', '2017-18' => '', '2018-19' => '',
63
+ 'Signed Using' => 'Minimum Salary', 'Guaranteed' => '' },
64
+ { 'Player' => 'Miles Plumlee', '2014-15' => '$1,169,880',
65
+ '2015-16' => '$2,109,294', '2016-17' => '', '2017-18' => '',
66
+ '2018-19' => '', 'Signed Using' => '1st Round Pick',
67
+ 'Guaranteed' => '$1,169,880' },
68
+ { 'Player' => 'Archie Goodwin', '2014-15' => '$1,112,280',
69
+ '2015-16' => '$1,160,160', '2016-17' => '$2,094,089',
70
+ '2017-18' => '', '2018-19' => '',
71
+ 'Signed Using' => '1st Round Pick',
72
+ 'Guaranteed' => '$1,112,280' },
73
+ { 'Player' => 'Earl Barron', '2014-15' => '$1,310,286',
74
+ '2015-16' => '', '2016-17' => '', '2017-18' => '',
75
+ '2018-19' => '', 'Signed Using' => 'Minimum Salary',
76
+ 'Guaranteed' => '' },
77
+ { 'Player' => 'Josh Childress', '2014-15' => '$7,610,000',
78
+ '2015-16' => '', '2016-17' => '', '2017-18' => '', '2018-19' => '',
79
+ 'Signed Using' => '', 'Guaranteed' => '' },
80
+ { 'Player' => 'Michael Beasley', '2014-15' => '$777,778',
81
+ '2015-16' => '$777,778', '2016-17' => '$777,778', '2017-18' => '',
82
+ '2018-19' => '', 'Signed Using' => '', 'Guaranteed' => '' }]
83
+
84
+ heads_of_tables = ['Player', '2014-15', '2015-16',
85
+ '2016-17', '2017-18', '2018-19',
86
+ 'Signed Using', 'Guaranteed']
87
+
88
+ # data that have to be compared with the expected one
89
+
90
+ players = SalaryScraper::BasketballReference.new
91
+ players_found = players.to_array_of_hashes('PHO')
92
+ heads = players.head_array('PHO')
93
+ players_data = players.players_data_array('PHO')
94
+
95
+ # tests start
96
+
97
+ describe 'Get the head of the tables', 'For all the teams' do
98
+ it 'has the right size' do
99
+ heads.size.must_equal heads_of_tables.size
100
+ end
101
+ it 'has the right values' do
102
+ heads.must_equal heads_of_tables
103
+ end
104
+ end
105
+
106
+ describe 'Get players data' do
107
+ it 'is not empty' do
108
+ players_data.wont_be_empty
109
+ end
110
+ it 'has not empty players name' do
111
+ players_data.first.wont_be_empty
112
+ end
113
+ end
114
+
115
+ describe 'Get all the players' do
116
+ it 'has the right number of players' do
117
+ players_found.size.must_equal player.size
118
+ end
119
+ it 'has all team data' do
120
+ player.each_index do | player_array |
121
+ player[player_array].map do | key, value |
122
+ players_found[player_array][key].must_equal value
123
+ end
124
+ end
125
+ end
126
+
127
+ end
@@ -0,0 +1,140 @@
1
+ require 'minitest/autorun'
2
+ require './lib/salaryscrape.rb'
3
+
4
+ # tests the head of the tables for all the teams
5
+ # tests that the player's value is not empty for all the teams
6
+ # tests the size of the array of hashes for all the teams
7
+ # tests that head_array and players_data_array are not empty when a team exists
8
+
9
+ # data that are expected
10
+
11
+ player = [{ 'Player' => 'Eric Bledsoe', '2014-15' => '$12,173,913',
12
+ '2015-16' => '$13,086,957',
13
+ '2016-17' => '$14,000,001',
14
+ '2017-18' => '$14,913,045', '2018-19' => '$15,826,089',
15
+ 'Signed Using' => 'Bird Rights', 'Guaranteed' => '$70,000,000' },
16
+ { 'Player' => 'Goran Dragic', '2014-15' => '$7,500,000',
17
+ '2015-16' => '$7,500,000', '2016-17' => '',
18
+ '2017-18' => '', '2018-19' => '',
19
+ 'Signed Using' => 'Cap Space', 'Guaranteed' => '$7,500,000' },
20
+ { 'Player' => 'Isaiah Thomas', '2014-15' => '$7,238,606',
21
+ '2015-16' => '$6,912,869', '2016-17' => '$6,587,132',
22
+ '2017-18' => '$6,261,395', '2018-19' => '',
23
+ 'Signed Using' => '', 'Guaranteed' => '$27,000,002' },
24
+ { 'Player' => 'P.J. Tucker', '2014-15' => '$5,700,000',
25
+ '2015-16' => '$5,500,000', '2016-17' => '$5,300,000',
26
+ '2017-18' => '', '2018-19' => '',
27
+ 'Signed Using' => 'Cap Space', 'Guaranteed' => '$12,700,000' },
28
+ { 'Player' => 'Alex Len', '2014-15' => '$3,649,920',
29
+ '2015-16' => '$3,807,120', '2016-17' => '$4,823,621',
30
+ '2017-18' => '', '2018-19' => '',
31
+ 'Signed Using' => '1st Round Pick', 'Guaranteed' => '$3,649,920' },
32
+ { 'Player' => 'Gerald Green', '2014-15' => '$3,500,000',
33
+ '2015-16' => '', '2016-17' => '', '2017-18' => '',
34
+ '2018-19' => '', 'Signed Using' => 'Cap Space',
35
+ 'Guaranteed' => '$3,500,000' },
36
+ { 'Player' => 'Anthony Tolliver', '2014-15' => '$3,000,000',
37
+ '2015-16' => '$3,000,000', '2016-17' => '', '2017-18' => '',
38
+ '2018-19' => '', 'Signed Using' => 'Cap Space',
39
+ 'Guaranteed' => '$3,400,000' },
40
+ { 'Player' => 'Markieff Morris', '2014-15' => '$2,989,239',
41
+ '2015-16' => '$8,000,000', '2016-17' => '$8,000,000',
42
+ '2017-18' => '$8,000,000', '2018-19' => '$8,000,000',
43
+ 'Signed Using' => 'Bird Rights', 'Guaranteed' => '$34,989,239' },
44
+ { 'Player' => 'Marcus Morris', '2014-15' => '$2,943,221',
45
+ '2015-16' => '$5,000,000', '2016-17' => '$5,000,000',
46
+ '2017-18' => '$5,000,000', '2018-19' => '$5,000,000',
47
+ 'Signed Using' => 'Bird Rights', 'Guaranteed' => '$22,943,221' },
48
+ { 'Player' => 'Zoran Dragic', '2014-15' => '$1,962,103',
49
+ '2015-16' => '$2,050,397', '2016-17' => '', '2017-18' => '',
50
+ '2018-19' => '', 'Signed Using' => 'Cap Space',
51
+ 'Guaranteed' => '$4,012,500' },
52
+ { 'Player' => 'T.J. Warren', '2014-15' => '$1,953,120',
53
+ '2015-16' => '$2,041,080', '2016-17' => '$2,128,920',
54
+ '2017-18' => '$3,152,931', '2018-19' => '',
55
+ 'Signed Using' => '1st Round Pick',
56
+ 'Guaranteed' => '$3,994,200' },
57
+ { 'Player' => 'Tyler Ennis', '2014-15' => '$1,590,720',
58
+ '2015-16' => '$1,662,360', '2016-17' => '$1,733,880',
59
+ '2017-18' => '$2,666,707', '2018-19' => '',
60
+ 'Signed Using' => '1st Round Pick', 'Guaranteed' => '$3,253,080' },
61
+ { 'Player' => 'Earl Barron', '2014-15' => '$1,310,286',
62
+ '2015-16' => '', '2016-17' => '', '2017-18' => '',
63
+ '2018-19' => '', 'Signed Using' => 'Minimum Salary',
64
+ 'Guaranteed' => '' },
65
+ { 'Player' => 'Shavlik Randolph', '2014-15' => '$1,227,985',
66
+ '2015-16' => '', '2016-17' => '', '2017-18' => '', '2018-19' => '',
67
+ 'Signed Using' => 'Minimum Salary', 'Guaranteed' => '' },
68
+ { 'Player' => 'Miles Plumlee', '2014-15' => '$1,169,880',
69
+ '2015-16' => '$2,109,294', '2016-17' => '', '2017-18' => '',
70
+ '2018-19' => '', 'Signed Using' => '1st Round Pick',
71
+ 'Guaranteed' => '$1,169,880' },
72
+ { 'Player' => 'Archie Goodwin', '2014-15' => '$1,112,280',
73
+ '2015-16' => '$1,160,160', '2016-17' => '$2,094,089',
74
+ '2017-18' => '', '2018-19' => '',
75
+ 'Signed Using' => '1st Round Pick',
76
+ 'Guaranteed' => '$1,112,280' },
77
+ { 'Player' => 'Josh Childress', '2014-15' => '$7,610,000',
78
+ '2015-16' => '', '2016-17' => '', '2017-18' => '', '2018-19' => '',
79
+ 'Signed Using' => '', 'Guaranteed' => '' },
80
+ { 'Player' => 'Michael Beasley', '2014-15' => '$777,778',
81
+ '2015-16' => '$777,778', '2016-17' => '$777,778', '2017-18' => '',
82
+ '2018-19' => '', 'Signed Using' => '', 'Guaranteed' => '' }]
83
+
84
+ heads_of_tables = ['Player', '2014-15', '2015-16',
85
+ '2016-17', '2017-18', '2018-19',
86
+ 'Signed Using', 'Guaranteed']
87
+
88
+ # data that have to be compared with the expected one
89
+
90
+ heads = []
91
+ players_data = []
92
+ players = SalaryScraper::BasketballReference.new
93
+ players_found = players.to_array_of_hashes('PHO')
94
+
95
+ SalaryScraper::BasketballReference::ALL_TEAMS.each do |team|
96
+ heads << players.head_array(team)
97
+ players_data << players.players_data_array(team)
98
+ end
99
+
100
+ # tests start
101
+
102
+ describe 'Get the head of the tables', 'For all the teams' do
103
+ heads.each do |head_for_a_team|
104
+ it 'has the right size' do
105
+ head_for_a_team.size.must_equal heads_of_tables.size
106
+ end
107
+
108
+ head_for_a_team.each_index do |i|
109
+ it 'has the right values' do
110
+ head_for_a_team[i].must_equal heads_of_tables[i]
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ describe 'Get players data' do
117
+ players_data.each do |players_for_a_team|
118
+ it 'is not empty' do
119
+ players_for_a_team.wont_be_empty
120
+ end
121
+ it 'has not empty players name' do
122
+ players_for_a_team.first.wont_be_empty
123
+ end
124
+ end
125
+
126
+ end
127
+
128
+ describe 'Get all the players' do
129
+ it 'has the right number of players' do
130
+ players_found.size.must_equal player.size
131
+ end
132
+ it 'has all team data' do
133
+ player.each_index do | player_array |
134
+ player[player_array].map do | key, value |
135
+ players_found[player_array][key].must_equal value
136
+ end
137
+ end
138
+ end
139
+
140
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nbasalaryscrape
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Clive Augstin, Amon Bazongo, Jevon McKenzie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest-rg
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Extract Player Salary from Basketball-Reference.com
42
+ email: augustinclive@hotmail.com
43
+ executables:
44
+ - nbasalaryscrape
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE
53
+ - Rakefile
54
+ - ReadMe.md
55
+ - bin/nbasalaryscrape
56
+ - lib/nbasalaryscrape.rb
57
+ - lib/nbasalaryscrape/salaryscrape.rb
58
+ - lib/nbasalaryscrape/version.rb
59
+ - nbasalaryscrape.gemspec
60
+ - spec/salaryscrape_spec.rb
61
+ - spec/spec_files/all_teams_tests.rb
62
+ homepage: https://github.com/soumyaray/citesight
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.2.2
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: NBA Player Salary extractor
86
+ test_files:
87
+ - spec/salaryscrape_spec.rb
88
+ - spec/spec_files/all_teams_tests.rb