celly 0.1.2 → 0.5.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +49 -6
- data/celly.gemspec +1 -1
- data/lib/celly.rb +2 -0
- data/lib/celly/leaders.rb +72 -0
- data/lib/celly/scores.rb +48 -0
- data/lib/celly/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85c078dd92911270d18417d6d8e4c30482f3a7ada4189e01482574b07f267501
|
4
|
+
data.tar.gz: 9f9ff41762eaab28c9651f62ac4b61a4ea4f09144c0cc8a9077a7040fd8efb54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046b403f0d08c73215f08bba3839ca1ff98b7e086c5b5783fc25686e10ea42243d19a5b8007db8aedfa6e82681e82a80b448f0bee3d76d61272a5aa3bcaebc5b
|
7
|
+
data.tar.gz: 3d809c5445078eea86ecc05aad72f46085f4ddd4a5e4dee6ec7967492f91c5bacb9b72c9e95bbec8055c800a112ff0dc8d7305f0f83ba2981b23df4f0ce883fb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
## Celly 0.1.2 (Feb. 23, 2021)
|
2
|
+
* Added Schedule all and team methods
|
3
|
+
* Added Standings overall method
|
4
|
+
* Added Team find method
|
5
|
+
* Added tests for all new methods
|
6
|
+
|
7
|
+
## Celly 0.5.0 (Feb. 26, 2021)
|
8
|
+
* Added Leaders (goals, assists, points, etc.)
|
9
|
+
* Added Scores (today, yesterday, by date)
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
1
|
+

|
2
2
|
|
3
|
-
|
3
|
+
# Celly
|
4
4
|
|
5
|
-
|
5
|
+
Celly is a Ruby wrapper for the NHL Stats API, a little-known, undocumented API maintained by the National Hockey League. Celly aims to provide an easy-to-use DSL for making requests to the NHL Stats API and retrieving data about Teams, Players, Schedules, and Standings.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
|
-
```
|
11
|
+
```bash
|
12
12
|
gem 'celly'
|
13
13
|
```
|
14
14
|
|
@@ -22,7 +22,46 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Celly has six classes (as of now)—Player, Leaders, Scores, Team, Standings, and Schedule. Using the gem is a simple as instantiating a class and calling the available methods:
|
26
|
+
|
27
|
+
Get a player's profile:
|
28
|
+
```bash
|
29
|
+
irb(main):002:0> player = Celly::Player.new
|
30
|
+
=> #<Celly::Player:0x000000011db23776>
|
31
|
+
|
32
|
+
irb(main):003:0> player.profile(8478402)
|
33
|
+
=> {:status=>"200", :message=>"OK", :data=>[{"id"=>8478402, "fullName"=>"Connor McDavid", "link"=>"/api/v1/people/8478402", "firstName"=>"Connor", "lastName"=>"McDavid", "primaryNumber"=>"97", "birthDate"=>"1997-01-13", "currentAge"=>24, "birthCity"=>"Richmond Hill", "birthStateProvince"=>"ON", "birthCountry"=>"CAN", "nationality"=>"CAN", "height"=>"6' 1\"", "weight"=>193, "active"=>true, "alternateCaptain"=>false, "captain"=>true, "rookie"=>false, "shootsCatches"=>"L", "rosterStatus"=>"Y", "currentTeam"=>{"id"=>22, "name"=>"Edmonton Oilers", "link"=>"/api/v1/teams/22"}, "primaryPosition"=>{"code"=>"C", "name"=>"Center", "type"=>"Forward", "abbreviation"=>"C"}}]}
|
34
|
+
```
|
35
|
+
|
36
|
+
Get a team's stats:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
irb(main):004:0> team = Celly::Team.new
|
40
|
+
=> #<Celly::Team:0x000000011dc25123>
|
41
|
+
|
42
|
+
irb(main):005:0> team.stats(7)
|
43
|
+
=> {:status=>"200", :message=>"OK", :data=>[{"type"=>{"displayName"=>"statsSingleSeason", "gameType"=>{"id"=>"R", "description"=>"Regular season", "postseason"=>false}}, "splits"=>[{"stat"=>{"gamesPlayed"=>15, "wins"=>5, "losses"=>8, "ot"=>2, "pts"=>12, "ptPctg"=>"40.0", "goalsPerGame"=>2.333, "goalsAgainstPerGame"=>3.0, "evGGARatio"=>0.6, "powerPlayPercentage"=>"32.6", "powerPlayGoals"=>16.0, "powerPlayGoalsAgainst"=>8.0, "powerPlayOpportunities"=>49.0, "penaltyKillPercentage"=>"75.8", "shotsPerGame"=>30.0667, "shotsAllowed"=>28.5333, "winScoreFirst"=>0.6, "winOppScoreFirst"=>0.2, "winLeadFirstPer"=>0.667, "winLeadSecondPer"=>1.0, "winOutshootOpp"=>0.429, "winOutshotByOpp"=>0.25, "faceOffsTaken"=>833.0, "faceOffsWon"=>450.0, "faceOffsLost"=>383.0, "faceOffWinPercentage"=>"54.0", "shootingPctg"=>7.8, "savePctg"=>0.895}, "team"=>{"id"=>7, "name"=>"Buffalo Sabres", "link"=>"/api/v1/teams/7"}}]}, {"type"=>{"displayName"=>"regularSeasonStatRankings", "gameType"=>nil}, "splits"=>[{"stat"=>{"wins"=>"30th", "losses"=>"25th", "ot"=>"20th", "pts"=>"30th", "ptPctg"=>"28th", "goalsPerGame"=>"28th", "goalsAgainstPerGame"=>"21st", "evGGARatio"=>"30th", "powerPlayPercentage"=>"4th", "powerPlayGoals"=>"8th", "powerPlayGoalsAgainst"=>"8th", "powerPlayOpportunities"=>"26th", "penaltyKillOpportunities"=>"1st", "penaltyKillPercentage"=>"23rd", "shotsPerGame"=>"16th", "shotsAllowed"=>"8th", "winScoreFirst"=>"30th", "winOppScoreFirst"=>"25th", "winLeadFirstPer"=>"23rd", "winLeadSecondPer"=>"13th", "winOutshootOpp"=>"24th", "winOutshotByOpp"=>"24th", "faceOffsTaken"=>"28th", "faceOffsWon"=>"22nd", "faceOffsLost"=>"2nd", "faceOffWinPercentage"=>"2nd", "savePctRank"=>"24th", "shootingPctRank"=>"26th"}, "team"=>{"id"=>7, "name"=>"Buffalo Sabres", "link"=>"/api/v1/teams/7"}}]}]}
|
44
|
+
```
|
45
|
+
|
46
|
+
Want today's scores?
|
47
|
+
|
48
|
+
```bash
|
49
|
+
irb(main):006:0> scores = Celly::Scores.new
|
50
|
+
=> #<Celly::Scores:0x000000011db23776>
|
51
|
+
|
52
|
+
irb(main):007:0> scores.today
|
53
|
+
=> {:status=>"200", :message=>"OK", :data=>[{"date"=>"2021-02-26", "totalItems"=>1, "totalEvents"=>0, "totalGames"=>3, "totalMatches"=>0, "games"=>[{"gamePk"=>2020020323, "link"=>"/api/v1/game/2020020323/feed/live", "gameType"=>"R", "season"=>"20202021", "gameDate"=>"2021-02-27T00:00:00Z", "status"=>{"abstractGameState"=>"Live", "codedGameState"=>"3", "detailedState"=>"In Progress", "statusCode"=>"3", "startTimeTBD"=>false}, "teams"=>{"away"=>{"leagueRecord"=>{"wins"=>11, "losses"=>4, "ot"=>2, "type"=>"league"}, "score"=>0, "team"=>{"id"=>6, "name"=>"Boston Bruins", "link"=>"/api/v1/teams/6"}}, "home"=>{"leagueRecord"=>{"wins"=>6, "losses"=>8, "ot"=>3, "type"=>"league"}, "score"=>0, "team"=>{"id"=>3, "name"=>"New York Rangers", "link"=>"/api/v1/teams/3"}}}, "venue"=>{"id"=>5054, "name"=>"Madison Square Garden", "link"=>"/api/v1/venues/5054"}, "content"=>{"link"=>"/api/v1/game/2020020323/content"}}], "events"=>[], "matches"=>[]}]}
|
54
|
+
```
|
55
|
+
|
56
|
+
Get the current scoring leaders:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
irb(main):005:0> leaders = Celly::Leaders.new
|
60
|
+
=> #<Celly::Leaders:0x000000013b6913b0>
|
61
|
+
|
62
|
+
irb(main):006:0> leaders.points(20202021)
|
63
|
+
=> {:status=>"200", :message=>"OK", :data=>[{"leaderCategory"=>"points", "depth"=>"singleSeason", "playerStatus"=>"allPlayers", "season"=>"2020-2021", "gameType"=>{"id"=>"R", "description"=>"Regular season", "postseason"=>false}, "limitMetadata"=>{"limit"=>5, "offset"=>0, "additionalTies"=>0}, "leaders"=>[{"rank"=>1, "value"=>"40", "team"=>{"id"=>22, "name"=>"Edmonton Oilers", "link"=>"/api/v1/teams/22"}, "person"=>{"id"=>8478402, "fullName"=>"Connor McDavid", "link"=>"/api/v1/people/8478402"}}, {"rank"=>2, "value"=>"34", "team"=>{"id"=>22, "name"=>"Edmonton Oilers", "link"=>"/api/v1/teams/22"}, "person"=>{"id"=>8477934, "fullName"=>"Leon Draisaitl", "link"=>"/api/v1/people/8477934"}}, {"rank"=>3, "value"=>"31", "team"=>{"id"=>10, "name"=>"Toronto Maple Leafs", "link"=>"/api/v1/teams/10"}, "person"=>{"id"=>8479318, "fullName"=>"Auston Matthews", "link"=>"/api/v1/people/8479318"}}, {"rank"=>3, "value"=>"31", "team"=>{"id"=>16, "name"=>"Chicago Blackhawks", "link"=>"/api/v1/teams/16"}, "person"=>{"id"=>8474141, "fullName"=>"Patrick Kane", "link"=>"/api/v1/people/8474141"}}, {"rank"=>5, "value"=>"30", "team"=>{"id"=>10, "name"=>"Toronto Maple Leafs", "link"=>"/api/v1/teams/10"}, "person"=>{"id"=>8478483, "fullName"=>"Mitchell Marner", "link"=>"/api/v1/people/8478483"}}]}]}
|
64
|
+
```
|
26
65
|
|
27
66
|
## Development
|
28
67
|
|
@@ -30,9 +69,13 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
30
69
|
|
31
70
|
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
71
|
|
72
|
+
## Testing
|
73
|
+
|
74
|
+
Celly uses RSpec for testing. To run the tests, run `bundle exec rspec`
|
75
|
+
|
33
76
|
## Contributing
|
34
77
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rymcmahon/celly.
|
36
79
|
|
37
80
|
|
38
81
|
## License
|
data/celly.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/rymcmahon/celly"
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/rymcmahon/celly/CHANGELOG.md"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/rymcmahon/celly/blob/master/CHANGELOG.md"
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/celly.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Celly::Leaders
|
5
|
+
BASE_URL = 'https://statsapi.web.nhl.com/api/v1'
|
6
|
+
|
7
|
+
def goals(season)
|
8
|
+
end_point = "/stats/leaders?leaderCategories=goals&season#{season}"
|
9
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
10
|
+
response = Net::HTTP.get_response(uri)
|
11
|
+
|
12
|
+
if response.code == '200'
|
13
|
+
json_response = JSON.parse(response.body)
|
14
|
+
{status: response.code, message: response.message, data: json_response["leagueLeaders"]}
|
15
|
+
else
|
16
|
+
{status: response.code, message: response.message}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def assists(season)
|
21
|
+
end_point = "/stats/leaders?leaderCategories=assists&season#{season}"
|
22
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
23
|
+
response = Net::HTTP.get_response(uri)
|
24
|
+
|
25
|
+
if response.code == '200'
|
26
|
+
json_response = JSON.parse(response.body)
|
27
|
+
{status: response.code, message: response.message, data: json_response["leagueLeaders"]}
|
28
|
+
else
|
29
|
+
{status: response.code, message: response.message}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def points(season)
|
34
|
+
end_point = "/stats/leaders?leaderCategories=points&season#{season}"
|
35
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
36
|
+
response = Net::HTTP.get_response(uri)
|
37
|
+
|
38
|
+
if response.code == '200'
|
39
|
+
json_response = JSON.parse(response.body)
|
40
|
+
{status: response.code, message: response.message, data: json_response["leagueLeaders"]}
|
41
|
+
else
|
42
|
+
{status: response.code, message: response.message}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def shutouts(season)
|
47
|
+
end_point = "/stats/leaders?leaderCategories=shutouts&season#{season}"
|
48
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
49
|
+
response = Net::HTTP.get_response(uri)
|
50
|
+
|
51
|
+
if response.code == '200'
|
52
|
+
json_response = JSON.parse(response.body)
|
53
|
+
{status: response.code, message: response.message, data: json_response["leagueLeaders"]}
|
54
|
+
else
|
55
|
+
{status: response.code, message: response.message}
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def wins(season)
|
61
|
+
end_point = "/stats/leaders?leaderCategories=wins&season#{season}"
|
62
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
63
|
+
response = Net::HTTP.get_response(uri)
|
64
|
+
|
65
|
+
if response.code == '200'
|
66
|
+
json_response = JSON.parse(response.body)
|
67
|
+
{status: response.code, message: response.message, data: json_response["leagueLeaders"]}
|
68
|
+
else
|
69
|
+
{status: response.code, message: response.message}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/celly/scores.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
class Celly::Scores
|
6
|
+
BASE_URL = 'https://statsapi.web.nhl.com/api/v1'
|
7
|
+
|
8
|
+
def today
|
9
|
+
today = Date.today.strftime("%Y-%m-%d")
|
10
|
+
end_point = "/schedule?startDate=#{today}&endDate=#{today}"
|
11
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
12
|
+
response = Net::HTTP.get_response(uri)
|
13
|
+
|
14
|
+
if response.code == '200'
|
15
|
+
json_response = JSON.parse(response.body)
|
16
|
+
{status: response.code, message: response.message, data: json_response["dates"]}
|
17
|
+
else
|
18
|
+
{status: response.code, message: response.message}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def yesterday
|
23
|
+
yesterday = Date.today.prev_day.strftime("%Y-%m-%d")
|
24
|
+
end_point = "/schedule?startDate=#{yesterday}&endDate=#{yesterday}"
|
25
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
26
|
+
response = Net::HTTP.get_response(uri)
|
27
|
+
|
28
|
+
if response.code == '200'
|
29
|
+
json_response = JSON.parse(response.body)
|
30
|
+
{status: response.code, message: response.message, data: json_response["dates"]}
|
31
|
+
else
|
32
|
+
{status: response.code, message: response.message}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def on(date)
|
37
|
+
end_point = "/schedule?startDate=#{date}&endDate=#{date}"
|
38
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
39
|
+
response = Net::HTTP.get_response(uri)
|
40
|
+
|
41
|
+
if response.code == '200'
|
42
|
+
json_response = JSON.parse(response.body)
|
43
|
+
{status: response.code, message: response.message, data: json_response["dates"]}
|
44
|
+
else
|
45
|
+
{status: response.code, message: response.message}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/celly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rymcmahon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides an easy-to-use DSL for retrieving player and team statistics
|
14
14
|
from the National Hockey League's API. Simple methods calls will give access to
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- ".gitignore"
|
24
24
|
- ".rspec"
|
25
25
|
- ".travis.yml"
|
26
|
+
- CHANGELOG.md
|
26
27
|
- Gemfile
|
27
28
|
- Gemfile.lock
|
28
29
|
- LICENSE.txt
|
@@ -32,8 +33,10 @@ files:
|
|
32
33
|
- bin/setup
|
33
34
|
- celly.gemspec
|
34
35
|
- lib/celly.rb
|
36
|
+
- lib/celly/leaders.rb
|
35
37
|
- lib/celly/player.rb
|
36
38
|
- lib/celly/schedule.rb
|
39
|
+
- lib/celly/scores.rb
|
37
40
|
- lib/celly/standings.rb
|
38
41
|
- lib/celly/team.rb
|
39
42
|
- lib/celly/version.rb
|
@@ -44,7 +47,7 @@ metadata:
|
|
44
47
|
allowed_push_host: https://rubygems.org
|
45
48
|
homepage_uri: https://github.com/rymcmahon/celly
|
46
49
|
source_code_uri: https://github.com/rymcmahon/celly
|
47
|
-
changelog_uri: https://github.com/rymcmahon/celly/CHANGELOG.md
|
50
|
+
changelog_uri: https://github.com/rymcmahon/celly/blob/master/CHANGELOG.md
|
48
51
|
post_install_message:
|
49
52
|
rdoc_options: []
|
50
53
|
require_paths:
|