ff_data 0.1.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 83174d5a4ad4e4e61a48f4e616503ae78f3b2ae1
4
+ data.tar.gz: e135fa9cbf2cfc1ac5ec0cefa42ef3adf51633f6
5
+ SHA512:
6
+ metadata.gz: 98c5d00e7e3c6c6e8f75c559d04d12d3073d80c0aa06392dea6ca3d3e40afa50cd48b1aa7fb583fd3b1c83d650ccabf80472de859c8a89a1b34ea9859ddd33da
7
+ data.tar.gz: 29e5115babc72808681a8075ba255265cbc62742b29c5ffb6fff4484c68d4a18ef8eb4120ba06ce5aa5a0eb430e44ef9acc371b24124072b133862ec21f39079
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ CODE_OF_CONDUCT.md
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ff_data.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ryan Waits
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
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # FfData
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ff_data`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ff_data'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ff_data
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ff_data. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ff_data"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/ff_data.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ff_data/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ff_data"
8
+ spec.version = FfData::VERSION
9
+ spec.authors = ["Ryan Waits"]
10
+ spec.email = ["ryan.waits@gmail.com"]
11
+
12
+ spec.summary = %q{A ruby wrapper for the FantasyData API used to retrieve seasonal player and team statistics in the NFL}
13
+ spec.description = %q{Comprehensive team and player stats for the NFL}
14
+ spec.homepage = "https://github.com/ryanwaits/ff_data"
15
+ spec.license = "MIT"
16
+
17
+ # # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
@@ -0,0 +1,24 @@
1
+ require 'httparty'
2
+ require_relative 'initializer'
3
+
4
+ module API
5
+ module Request
6
+ include HTTParty
7
+ def base_url
8
+ "https://api.fantasydata.net/nfl/v2"
9
+ end
10
+
11
+ def headers
12
+ {'Ocp-Apim-Subscription-Key' => FantasyData.api_key}
13
+ end
14
+
15
+ def build_url(service, extras = [])
16
+ [base_url, "json", service, extras].join("/").gsub(/\/$/, '')
17
+ end
18
+
19
+ def request_service(service, extras = [])
20
+ url = build_url(service, extras)
21
+ HTTParty.get(url, {headers: headers})
22
+ end
23
+ end
24
+ end
data/lib/extensions.rb ADDED
@@ -0,0 +1,17 @@
1
+ module CoreExtensions
2
+ module Fantasy
3
+ module Date
4
+ def self.current_date
5
+ Time.now.year.to_s + '-' + Time.now.asctime.split(' ')[1] + '-' + Time.now.day.to_s
6
+ end
7
+
8
+ def self.regular_season
9
+ Time.now.year.to_s + 'REG'
10
+ end
11
+
12
+ def self.last_season
13
+ ((Time.now.year) -1).to_s
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/ff_data.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "ff_data/version"
2
+ require_relative 'initializer'
3
+
4
+ class FantasyData
5
+ extend API::Request
6
+
7
+ @@api_key = nil
8
+
9
+ # set api key
10
+ def self.api_key
11
+ @@api_key ||= ENV['FANTASY_DATA_KEY']
12
+ end
13
+
14
+ end
@@ -0,0 +1,3 @@
1
+ module FfData
2
+ VERSION = "0.1.3"
3
+ end
data/lib/game.rb ADDED
@@ -0,0 +1,29 @@
1
+ require_relative 'initializer'
2
+
3
+ class Game
4
+ extend API::Request
5
+
6
+ # returns a box score for a particular team
7
+ def self.box_score team, week
8
+ data = request_service('BoxScore', [CoreExtensions::Fantasy::Date.regular_season, week, team])['Score']
9
+ # puts "#{data['AwayTeam']} vs. #{data['HomeTeam']}"
10
+ end
11
+
12
+ # returns all box scores
13
+ def self.box_scores week
14
+ request_service('BoxScores', [CoreExtensions::Fantasy::Date.regular_season, week])
15
+ end
16
+
17
+ # returns box scores for games that are in progress
18
+ def self.in_progress
19
+ in_progress = request_service('ActiveBoxScores')
20
+ in_progress.nil? ? in_progress : "No games in progress."
21
+ end
22
+
23
+ # returns box scores for finishes games
24
+ def self.final
25
+ final = request_service('FinalBoxScores')
26
+ final.nil? ? final : "No finished games yet."
27
+ end
28
+
29
+ end
@@ -0,0 +1,6 @@
1
+ require 'httparty'
2
+ require_relative 'api_request'
3
+ require_relative 'extensions'
4
+ require_relative 'game'
5
+ require_relative 'player'
6
+ require_relative 'team'
data/lib/player.rb ADDED
@@ -0,0 +1,68 @@
1
+ require_relative 'initializer'
2
+
3
+ class Player
4
+ extend API::Request
5
+
6
+ # returns daily fantasy players with salaries by ADP
7
+ def self.all
8
+ request_service('FantasyPlayers')
9
+ end
10
+
11
+ ## TODO set week to default to current week without having to use parameter
12
+
13
+ # returns players with injuries
14
+ def self.injuries week
15
+ request_service('Injuries', [CoreExtensions::Fantasy::Date.last_season, week])
16
+ end
17
+
18
+ # returns inactive players
19
+ def self.inactive
20
+ self.injuries(5).select { |player| player['DeclaredInactive'] if player['DeclaredInactive'] == true}
21
+ end
22
+
23
+ # returns news about a player
24
+ def self.news id
25
+ request_service('NewsByPlayerID', id)
26
+ end
27
+
28
+ # returns recent news
29
+ def self.recent_news
30
+ request_service('News')
31
+ end
32
+
33
+ # returns players and projections for the current week
34
+ def self.daily_players
35
+ request_service('DailyFantasyPlayers', CoreExtensions::Fantasy::Date.current_date)
36
+ end
37
+
38
+ # returns players and points scored for the week
39
+ def self.fantasy_points options = {}
40
+ request_service('DailyFantasyPoints', CoreExtensions::Fantasy::Date.current_date)
41
+ end
42
+
43
+ # returns league leaders in fantasy points based on position
44
+ def self.point_leaders position, type
45
+ request_service('SeasonLeagueLeaders', [CoreExtensions::Fantasy::Date.last_season, position, type])
46
+ end
47
+
48
+ # retuns league leaders by week in fantasy points by position
49
+ def self.point_leaders_by_week position, week
50
+ request_service('GameLeagueLeaders', [CoreExtensions::Fantasy::Date.last_season, week, position, 'FantasyPoints'])
51
+ end
52
+
53
+ # returns player projections by game
54
+ def self.player_projections_by_game id, week
55
+ request_service('PlayerGameProjectionStatsByPlayerID', [CoreExtensions::Fantasy::Date.last_season, week, id])
56
+ end
57
+
58
+ # returns player projections for season
59
+ def self.player_projections_by_season
60
+ request_service('PlayerSeasonProjectionStats', CoreExtensions::Fantasy::Date.regular_season)
61
+ end
62
+
63
+ # returns player projections by player
64
+ def self.player_projections_by_player id
65
+ request_service('PlayerSeasonProjectionStatsByPlayerID', [CoreExtensions::Fantasy::Date.regular_season, id])
66
+ end
67
+
68
+ end
data/lib/team.rb ADDED
@@ -0,0 +1,67 @@
1
+ require_relative 'initializer'
2
+
3
+ class Team
4
+ extend API::Request
5
+
6
+ # returns news about a team
7
+ def self.news team
8
+ request_service('NewsByTeam', team)
9
+ end
10
+
11
+ # returns teams and their bye weeks
12
+ def self.byes
13
+ request_service('Byes', CoreExtensions::Fantasy::Date.regular_season)
14
+ end
15
+
16
+ # returns teams based on week
17
+ def self.bye_week week, teams = []
18
+ self.byes.each { |team| teams.push(team) if team['Week'] == week }
19
+ teams
20
+ end
21
+
22
+ # returns all team defense statistics for the week
23
+ def self.defenses week
24
+ request_service('FantasyDefenseByGame', [CoreExtensions::Fantasy::Date.last_season, week])
25
+ end
26
+
27
+ # returns a teams defense statistics for the week
28
+ def self.defense team, week
29
+ request_service('FantasyDefenseByGameByTeam', [CoreExtensions::Fantasy::Date.last_season, week, team])
30
+ end
31
+
32
+ # returns defense scoring statistics for the season
33
+ def self.defense_scoring
34
+ request_service('FantasyDefenseBySeason', CoreExtensions::Fantasy::Date.last_season)
35
+ end
36
+
37
+ # returns defense projections for the season
38
+ def self.defense_projections
39
+ request_service('FantasyDefenseProjectionsBySeason', CoreExtensions::Fantasy::Date.last_season)
40
+ end
41
+
42
+ # returns defense scoring statistics by team
43
+ def self.defense_scoring_by_team team
44
+ request_service('FantasyDefenseBySeasonByTeam', [CoreExtensions::Fantasy::Date.last_season, team])
45
+ end
46
+
47
+ # returns schedule for given season
48
+ def self.schedule
49
+ request_service('Schedules', CoreExtensions::Fantasy::Date.regular_season)
50
+ end
51
+
52
+ # returns scores for given season
53
+ def self.scores
54
+ request_service('Scores', CoreExtensions::Fantasy::Date.last_season)
55
+ end
56
+
57
+ # returns scores for given week
58
+ def self.scores_by_week week
59
+ request_service('ScoresByWeek', [CoreExtensions::Fantasy::Date.last_season, week])
60
+ end
61
+
62
+ # returns standings
63
+ def self.standings
64
+ request_service('Standings', CoreExtensions::Fantasy::Date.last_season)
65
+ end
66
+
67
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ff_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Waits
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Comprehensive team and player stats for the NFL
56
+ email:
57
+ - ryan.waits@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - ff_data.gemspec
73
+ - lib/api_request.rb
74
+ - lib/extensions.rb
75
+ - lib/ff_data.rb
76
+ - lib/ff_data/version.rb
77
+ - lib/game.rb
78
+ - lib/initializer.rb
79
+ - lib/player.rb
80
+ - lib/team.rb
81
+ homepage: https://github.com/ryanwaits/ff_data
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.5.1
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: A ruby wrapper for the FantasyData API used to retrieve seasonal player and
105
+ team statistics in the NFL
106
+ test_files: []