fantasyCompare 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/nfl-compare +7 -0
- data/bin/setup +8 -0
- data/fantasyCompare.gemspec +29 -0
- data/lib/fantasyCompare.rb +12 -0
- data/lib/fantasyCompare/NFLJSON.rb +102 -0
- data/lib/fantasyCompare/cli.rb +35 -0
- data/lib/fantasyCompare/version.rb +3 -0
- data/spec.md +6 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1cd3ab8457f84d63977ff6a3cb9d02fe5afd60e0
|
4
|
+
data.tar.gz: cc01857fd536475c550b68610596e6d30fd3faaa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f783195581bbee879715d4e41b6f8cdd2edb6fe1ebd74a88dcbb6ca6f814389076c59a42c51b5cf0538f2c99b078b0c9f6cf187734e344b1589e9c78e919a215
|
7
|
+
data.tar.gz: 491730b49a4cb0b3ee033b9b950f165cd62794734de86d61502eaa4c273eb16ae2903c12f2089f9752af4b1d98dda7b0372d159672b26f5f74bfed3b517f87f0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jmverdone@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 jminterwebs
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# FantasyCompare
|
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/fantasyCompare`. 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 'fantasyCompare'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install fantasyCompare
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Gem runs in a console where it first displays a list of fantasy football positions. The console then asks the user for an input(1-6) to pick a valid position and a fantasy football week. The console then displays a list of the 10 ten players for that position and their project points for the selected week. The console then asks the user to pick a player for a more detailed view of that player.
|
26
|
+
|
27
|
+
In the detail view the players status is displayed and the most recent note for that player. The console then ask's if an additional note should be displayed. If yes is selected notes can be displayed until there are no more. If no is selected or if there are no more notes the console finally asks if details for another position should be displayed. A yes input will start the program over and no input will exit.
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fantasyCompare. 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.
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fantasyCompare"
|
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/nfl-compare
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fantasyCompare/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fantasyCompare"
|
8
|
+
spec.version = FantasyCompare::VERSION
|
9
|
+
spec.authors = ["John Verdone"]
|
10
|
+
spec.email = ["jmverdone@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Compares fantasy players stats in a CLI}
|
13
|
+
spec.description = %q{A console Gem that pulls API data from the NFLs fantasy api. It then lets a user select a positon and week. After displaying the top ten players, a player can be selected to see a more detailed view of the given player}
|
14
|
+
spec.homepage = "https://github.com/jminterwebs/fantasyCompare"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
|
5
|
+
class FantasyCompare::NFLJSON
|
6
|
+
attr_accessor :position, :week, :players, :players_hash, :list, :info, :detail
|
7
|
+
|
8
|
+
#modifies url to pull proper JSON data
|
9
|
+
def self.url(position, week)
|
10
|
+
url = "http://api.fantasy.nfl.com/v1/players/stats?statType=weekProjectedStats&season=2016&week=#{week}&position=#{position}&format=json&returnHTML=1"
|
11
|
+
response = HTTParty.get(url)
|
12
|
+
@players_hash = response.parsed_response
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
#modifies url to pull proper JSON data based on user inputs and returns a hashed result
|
17
|
+
def self.detail_url
|
18
|
+
detail_url = "http://api.fantasy.nfl.com/v1/players/details?playerId=#{@playerId}&statType=seasonStatsformat=json"
|
19
|
+
response = HTTParty.get(detail_url)
|
20
|
+
@detail_hash = response.parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
#generates simplefied list of parsed down data from API
|
25
|
+
def self.players
|
26
|
+
@players = []
|
27
|
+
@players_hash["players"].each do |key, value|
|
28
|
+
weekProjectedPts = key["weekProjectedPts"]
|
29
|
+
name = key["name"]
|
30
|
+
playerId = key["id"]
|
31
|
+
@players << {name: name, weekProjectedPts: weekProjectedPts, playerId: playerId}
|
32
|
+
end
|
33
|
+
self.top_ten_list(@players)
|
34
|
+
end
|
35
|
+
|
36
|
+
#take the parsed players hash array, sorts it and returns the top 10 projected players in text format
|
37
|
+
def self.top_ten_list(players)
|
38
|
+
@list = []
|
39
|
+
@top_ten = players.sort_by {|key| key[:weekProjectedPts]}.reverse!.first(10)
|
40
|
+
#parse into strings
|
41
|
+
@top_ten.each do |key, value|
|
42
|
+
name = key[:name]
|
43
|
+
projected = key[:weekProjectedPts]
|
44
|
+
@list << "Name: #{name} Projected Points: #{projected}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# parses info into numbered list
|
49
|
+
def self.list
|
50
|
+
@list.each_with_index do |value, index|
|
51
|
+
puts "#{index + 1}: #{value}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#obtain detail veiw of player
|
56
|
+
def self.detail_player_view(info)
|
57
|
+
info = info.to_i - 1
|
58
|
+
@playerId = @top_ten[info][:playerId]
|
59
|
+
@playerName = @top_ten[info][:name]
|
60
|
+
@projectedPoints = @top_ten[info][:weekProjectedPts]
|
61
|
+
end
|
62
|
+
|
63
|
+
#parses @detail_hash into readable info
|
64
|
+
def self.show_detail_veiw
|
65
|
+
@note = []
|
66
|
+
status = ""
|
67
|
+
injury = ""
|
68
|
+
@detail_hash["players"].each do |key, value|
|
69
|
+
status = key["status"]
|
70
|
+
injury = key["injuryGameStatus"] || "None"
|
71
|
+
key["notes"].each do |key, value|
|
72
|
+
@note << "Date: #{key["timestamp"]}\n #{key["body"] + key["analysis"]}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
@detail = "Status: #{status} \nInjury Status: #{injury} \n #{@note.first}"
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
#used to display addtional notes
|
80
|
+
def self.next_note(note_number)
|
81
|
+
puts "\nWould you like to see additional notes (Y/N)?"
|
82
|
+
addtional_notes = gets.chomp
|
83
|
+
if addtional_notes[0].capitalize == "Y" && note_number <= @note.length-1
|
84
|
+
puts @note[note_number]
|
85
|
+
note_number += 1
|
86
|
+
self.next_note(note_number)
|
87
|
+
elsif note_number > @note.length-1 && addtional_notes[0].capitalize == "Y"
|
88
|
+
puts "There are no more notes"
|
89
|
+
puts "Would You like to see details on another player?"
|
90
|
+
do_again = gets.chomp
|
91
|
+
elsif addtional_notes[0].capitalize == "N"
|
92
|
+
puts "Would You like to see details on another position?"
|
93
|
+
do_again = gets.chomp
|
94
|
+
end
|
95
|
+
|
96
|
+
if do_again[0].capitalize == "Y"
|
97
|
+
FantasyCompare::CLI.new.call
|
98
|
+
else
|
99
|
+
puts "Goodbye"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class FantasyCompare::CLI
|
2
|
+
attr_accessor :list
|
3
|
+
|
4
|
+
def call
|
5
|
+
inputs
|
6
|
+
end
|
7
|
+
|
8
|
+
# Takes input to parse proper JSON Position data by returing proper url link
|
9
|
+
# Mai CLI functionality
|
10
|
+
def inputs
|
11
|
+
positions = ["QB","RB","WR","TE","K","DEF"]
|
12
|
+
puts "Please pick a position (1-6) \n1.QB\n2.RB\n3.WR\n4.Te\n5.K\n6.DEF"
|
13
|
+
pos_input = gets.chomp
|
14
|
+
pos_input = pos_input.to_i-1
|
15
|
+
if !pos_input.between?(0,5)
|
16
|
+
puts "Invalid Input"
|
17
|
+
inputs
|
18
|
+
else
|
19
|
+
@position = positions[pos_input]
|
20
|
+
end
|
21
|
+
puts "Please select a week for stats"
|
22
|
+
@week = gets.chomp
|
23
|
+
FantasyCompare::NFLJSON.url(@position, @week)
|
24
|
+
FantasyCompare::NFLJSON.players
|
25
|
+
puts "Please select a team to find out more info"
|
26
|
+
FantasyCompare::NFLJSON.list
|
27
|
+
@info = gets.chomp
|
28
|
+
FantasyCompare::NFLJSON.detail_player_view(@info)
|
29
|
+
puts "Information for this team is as follows"
|
30
|
+
FantasyCompare::NFLJSON.detail_url
|
31
|
+
puts FantasyCompare::NFLJSON.show_detail_veiw
|
32
|
+
puts @detail
|
33
|
+
FantasyCompare::NFLJSON.next_note(1) #increments notes
|
34
|
+
end
|
35
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fantasyCompare
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Verdone
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-26 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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
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: A console Gem that pulls API data from the NFLs fantasy api. It then
|
56
|
+
lets a user select a positon and week. After displaying the top ten players, a player
|
57
|
+
can be selected to see a more detailed view of the given player
|
58
|
+
email:
|
59
|
+
- jmverdone@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CODE_OF_CONDUCT.md
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/nfl-compare
|
74
|
+
- bin/setup
|
75
|
+
- fantasyCompare.gemspec
|
76
|
+
- lib/fantasyCompare.rb
|
77
|
+
- lib/fantasyCompare/NFLJSON.rb
|
78
|
+
- lib/fantasyCompare/cli.rb
|
79
|
+
- lib/fantasyCompare/version.rb
|
80
|
+
- spec.md
|
81
|
+
homepage: https://github.com/jminterwebs/fantasyCompare
|
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.6.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Compares fantasy players stats in a CLI
|
105
|
+
test_files: []
|