nfl_data 0.0.11 → 0.1.1
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 +5 -5
- data/.envrc +7 -0
- data/.gitignore +3 -3
- data/.rspec +1 -0
- data/.standard.yml +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/README.md +94 -22
- data/Rakefile +5 -6
- data/bin/console +1 -1
- data/bin/setup +8 -0
- data/lib/nfl_data.rb +9 -18
- data/lib/nfl_data/api/player.rb +8 -26
- data/lib/nfl_data/api/schedule.rb +19 -0
- data/lib/nfl_data/api/statline.rb +8 -22
- data/lib/nfl_data/game.rb +5 -0
- data/lib/nfl_data/my_sports_feeds/client.rb +45 -0
- data/lib/nfl_data/my_sports_feeds/players_feed.rb +18 -0
- data/lib/nfl_data/my_sports_feeds/seasonal_games_feed.rb +22 -0
- data/lib/nfl_data/my_sports_feeds/weekly_player_gamelogs.rb +21 -0
- data/lib/nfl_data/parsers/player_parser.rb +21 -77
- data/lib/nfl_data/parsers/schedule_parser.rb +20 -0
- data/lib/nfl_data/parsers/statline_parser.rb +27 -71
- data/lib/nfl_data/player.rb +13 -0
- data/lib/nfl_data/schedule.rb +12 -0
- data/lib/nfl_data/statline.rb +20 -0
- data/lib/nfl_data/version.rb +1 -1
- data/nfl_data.gemspec +23 -22
- data/spec/api/player_spec.rb +24 -0
- data/spec/api/schedule_spec.rb +20 -0
- data/spec/api/statline_spec.rb +31 -0
- data/spec/models/game_spec.rb +15 -0
- data/spec/models/player_spec.rb +42 -0
- data/spec/models/schedule_spec.rb +17 -0
- data/spec/models/statline_spec.rb +63 -0
- data/spec/my_sports_feeds/client_spec.rb +17 -0
- data/spec/my_sports_feeds/players_feed_spec.rb +50 -0
- data/spec/my_sports_feeds/seasonal_games_feed_spec.rb +41 -0
- data/spec/my_sports_feeds/weekly_player_gamelogs_spec.rb +144 -0
- data/spec/parsers/player_parser_spec.rb +63 -0
- data/spec/parsers/schedule_parser_spec.rb +41 -0
- data/spec/parsers/statline_parser_spec.rb +68 -0
- data/spec/spec_helper.rb +55 -0
- metadata +98 -52
- data/.codeclimate.yml +0 -5
- data/.rubocop.yml +0 -2
- data/lib/nfl_data/api/team.rb +0 -23
- data/lib/nfl_data/models/player.rb +0 -20
- data/lib/nfl_data/models/statline.rb +0 -21
- data/lib/nfl_data/models/team.rb +0 -38
- data/lib/nfl_data/parsers/parser_helper.rb +0 -6
- data/lib/nfl_data/parsers/team_parser.rb +0 -94
- data/test/nfl_data/api/player_test.rb +0 -25
- data/test/nfl_data/api/statline_test.rb +0 -21
- data/test/nfl_data/api/team_test.rb +0 -13
- data/test/nfl_data/models/player_test.rb +0 -79
- data/test/nfl_data/models/statline_test.rb +0 -121
- data/test/nfl_data/models/team_test.rb +0 -43
- data/test/nfl_data/parsers/player_parser_test.rb +0 -86
- data/test/nfl_data/parsers/statline_parser_test.rb +0 -34
- data/test/nfl_data/parsers/team_parser_test.rb +0 -41
- data/test/test_helper.rb +0 -14
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Team do
|
4
|
-
before do
|
5
|
-
@team = Team.new
|
6
|
-
end
|
7
|
-
|
8
|
-
after do
|
9
|
-
@team = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'has a name' do
|
13
|
-
@team.must_respond_to :name
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has a short name' do
|
17
|
-
@team.must_respond_to :short_name
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'has a schedule' do
|
21
|
-
@team.must_respond_to :schedule
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'to_hash' do
|
25
|
-
before do
|
26
|
-
@team.name = 'Denver Broncos'
|
27
|
-
@team.short_name = 'DEN'
|
28
|
-
@team.schedule = Team::Schedule.new
|
29
|
-
end
|
30
|
-
|
31
|
-
def valid_player_hash
|
32
|
-
{
|
33
|
-
name: 'Denver Broncos',
|
34
|
-
short_name: 'DEN',
|
35
|
-
schedule: []
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'can return itself as hash' do
|
40
|
-
@team.to_hash.must_equal valid_player_hash
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe PlayerParser do
|
4
|
-
before do
|
5
|
-
@parser = PlayerParser.new
|
6
|
-
end
|
7
|
-
|
8
|
-
after do
|
9
|
-
@parser = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should know the correct base url' do
|
13
|
-
expected_base_url = 'http://www.nfl.com/players/search?category=' \
|
14
|
-
'position&conferenceAbbr=null&playerType=current' \
|
15
|
-
'&conference=ALL&filter='
|
16
|
-
|
17
|
-
@parser.base_url.must_equal expected_base_url
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'get_by_position' do
|
21
|
-
it 'should get quarterbacks' do
|
22
|
-
VCR.use_cassette('quarterbacks') do
|
23
|
-
response = @parser.get_by_position(:quarterbacks)
|
24
|
-
|
25
|
-
response.keys.must_include :quarterbacks
|
26
|
-
response[:quarterbacks].count.must_equal 118
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should get runningbacks' do
|
31
|
-
VCR.use_cassette('runningbacks') do
|
32
|
-
response = @parser.get_by_position(:runningbacks)
|
33
|
-
|
34
|
-
response.keys.must_include :runningbacks
|
35
|
-
response[:runningbacks].count.must_equal 243
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should get wide receivers' do
|
40
|
-
VCR.use_cassette('wide_receivers') do
|
41
|
-
response = @parser.get_by_position(:wide_receivers)
|
42
|
-
|
43
|
-
response.keys.must_include :wide_receivers
|
44
|
-
response[:wide_receivers].count.must_equal 339
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should get tight ends' do
|
49
|
-
VCR.use_cassette('tight_ends') do
|
50
|
-
response = @parser.get_by_position(:tight_ends)
|
51
|
-
|
52
|
-
response.keys.must_include :tight_ends
|
53
|
-
response[:tight_ends].count.must_equal 188
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should get all the players' do
|
58
|
-
VCR.use_cassette('all_players') do
|
59
|
-
response = @parser.get_by_position(:all)
|
60
|
-
|
61
|
-
{
|
62
|
-
quarterbacks: 118,
|
63
|
-
runningbacks: 243,
|
64
|
-
wide_receivers: 339,
|
65
|
-
tight_ends: 188
|
66
|
-
}.each do |position, player_count|
|
67
|
-
response.keys.must_include position
|
68
|
-
response[position].count.must_equal player_count
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should use JAX as Jacksonville abbreviation for all JAX team players' do
|
74
|
-
VCR.use_cassette('all_players') do
|
75
|
-
response = @parser.get_by_position(:all)
|
76
|
-
|
77
|
-
players =
|
78
|
-
[response[:quarterbacks], response[:runningbacks],
|
79
|
-
response[:wide_receivers], response[:tight_ends]].flatten
|
80
|
-
|
81
|
-
players.any? { |player| player[:team] == 'JAX' }.must_equal true
|
82
|
-
players.none? { |player| player[:team] == 'JAC' }.must_equal true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe StatlineParser do
|
4
|
-
before do
|
5
|
-
@parser = StatlineParser.new
|
6
|
-
end
|
7
|
-
|
8
|
-
after do
|
9
|
-
@parser = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'get' do
|
13
|
-
it 'should get passing statlines' do
|
14
|
-
VCR.use_cassette('passing') do
|
15
|
-
response = @parser.get(4, 2014, :passing)
|
16
|
-
response.count.must_equal 34
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should get rushing statlines' do
|
21
|
-
VCR.use_cassette('rushing') do
|
22
|
-
response = @parser.get(4, 2014, :rushing)
|
23
|
-
response.count.must_equal 106
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should get receiving statlines' do
|
28
|
-
VCR.use_cassette('receiving') do
|
29
|
-
response = @parser.get(4, 2014, :receiving)
|
30
|
-
response.count.must_equal 210
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe TeamParser do
|
4
|
-
before do
|
5
|
-
@parser = TeamParser.new
|
6
|
-
end
|
7
|
-
|
8
|
-
after do
|
9
|
-
@parser = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should know the correct base url' do
|
13
|
-
@parser.base_url.must_equal 'http://www.nfl.com/standings?category=league&split=Overall&season='
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'get_by_year' do
|
17
|
-
it 'should get all the teams for year without schedule' do
|
18
|
-
VCR.use_cassette('teams_without_schedule') do
|
19
|
-
@parser.get_by_year(2014, false).count.must_equal 32
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should get all the teams for year with schedule' do
|
24
|
-
VCR.use_cassette('teams_with_schedule') do
|
25
|
-
result = @parser.get_by_year(2014, true)
|
26
|
-
result.count.must_equal 32
|
27
|
-
result.each do |team|
|
28
|
-
team[:schedule].count.must_equal 17 # includes bye weeks
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should use JAX as the abbreviation for Jacksonville' do
|
34
|
-
VCR.use_cassette('teams_with_schedule') do
|
35
|
-
result = @parser.get_by_year(2014, true)
|
36
|
-
result.any? { |team| team[:short_name] == 'JAX' }.must_equal true
|
37
|
-
result.none? { |team| team[:short_name] == 'JAC' }.must_equal true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/test_helper.rb
DELETED