celly 0.1.0 → 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 +4 -4
- data/celly-0.1.0.gem +0 -0
- data/lib/celly.rb +2 -71
- data/lib/celly/player.rb +71 -0
- data/lib/celly/team.rb +34 -0
- data/lib/celly/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dffec1b6fd49a14de7dc559c5c40e2a36d20180ff33cf4b1a16e5a89a62e7c8
|
4
|
+
data.tar.gz: 32ca767355e8512649403796e7cb71616ea102692dc46c6882c325d9621b12f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d79d0f89bcda3071996494467e26eeff47941afd009f35bf95554e22bc0f2332e11467154d82fff0702e31ba33a381f0f2a23409932488639848c26c4510186
|
7
|
+
data.tar.gz: 32c96e020576923604073bcec57be8ece1ffba2b9526e874a1e4c7b5d121421c99b8c33abb48f7d4dc0497aed28865db9d103249fabbd81edbc81651d0451c1e
|
data/celly-0.1.0.gem
ADDED
Binary file
|
data/lib/celly.rb
CHANGED
@@ -1,76 +1,7 @@
|
|
1
1
|
require "celly/version"
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "celly/player"
|
3
|
+
require "celly/team"
|
4
4
|
|
5
5
|
module Celly
|
6
6
|
class Error < StandardError; end
|
7
|
-
|
8
|
-
class Player
|
9
|
-
BASE_URL = 'https://statsapi.web.nhl.com/api/v1'
|
10
|
-
def profile(id)
|
11
|
-
end_point = "/people/#{id}"
|
12
|
-
uri = URI("#{BASE_URL}#{end_point}")
|
13
|
-
response = Net::HTTP.get_response(uri)
|
14
|
-
|
15
|
-
if response.code == '200'
|
16
|
-
json_response = JSON.parse(response.body)
|
17
|
-
{status: response.code, message: response.message, data: json_response["people"]}
|
18
|
-
else
|
19
|
-
{status: response.code, message: response.message}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def season_stats(player_id, season)
|
24
|
-
end_point = "/people/#{player_id}/stats?stats=statsSingleSeason&season=#{season}"
|
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["stats"][0]["splits"][0]["stat"]}
|
31
|
-
else
|
32
|
-
{status: response.code, message: response.message}
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def regular_season_career_stats(player_id)
|
37
|
-
end_point = "/people/#{player_id}/stats?stats=careerRegularSeason"
|
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["stats"][0]["splits"][0]["stat"]}
|
44
|
-
else
|
45
|
-
{status: response.code, message: response.message}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def playoffs_career_stats(player_id)
|
50
|
-
end_point = "/people/#{player_id}/stats?stats=careerPlayoffs"
|
51
|
-
uri = URI("#{BASE_URL}#{end_point}")
|
52
|
-
response = Net::HTTP.get_response(uri)
|
53
|
-
|
54
|
-
if response.code == '200'
|
55
|
-
json_response = JSON.parse(response.body)
|
56
|
-
{status: response.code, message: response.message, data: json_response["stats"][0]["splits"][0]["stat"]}
|
57
|
-
else
|
58
|
-
{status: response.code, message: response.message}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def playoffs_stats_by_year(player_id)
|
63
|
-
end_point = "/people/#{player_id}/stats?stats=yearByYearPlayoffs"
|
64
|
-
uri = URI("#{BASE_URL}#{end_point}")
|
65
|
-
response = Net::HTTP.get_response(uri)
|
66
|
-
|
67
|
-
if response.code == '200'
|
68
|
-
json_response = JSON.parse(response.body)
|
69
|
-
|
70
|
-
{status: response.code, message: response.message, data: json_response["stats"][0]["splits"]}
|
71
|
-
else
|
72
|
-
{status: response.code, message: response.message}
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
7
|
end
|
data/lib/celly/player.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Celly::Player
|
5
|
+
BASE_URL = 'https://statsapi.web.nhl.com/api/v1'
|
6
|
+
def profile(id)
|
7
|
+
end_point = "/people/#{id}"
|
8
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
9
|
+
response = Net::HTTP.get_response(uri)
|
10
|
+
|
11
|
+
if response.code == '200'
|
12
|
+
json_response = JSON.parse(response.body)
|
13
|
+
{status: response.code, message: response.message, data: json_response["people"]}
|
14
|
+
else
|
15
|
+
{status: response.code, message: response.message}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def season_stats(player_id, season)
|
20
|
+
end_point = "/people/#{player_id}/stats?stats=statsSingleSeason&season=#{season}"
|
21
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
22
|
+
response = Net::HTTP.get_response(uri)
|
23
|
+
|
24
|
+
if response.code == '200'
|
25
|
+
json_response = JSON.parse(response.body)
|
26
|
+
{status: response.code, message: response.message, data: json_response["stats"][0]["splits"][0]["stat"]}
|
27
|
+
else
|
28
|
+
{status: response.code, message: response.message}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def regular_season_career_stats(player_id)
|
33
|
+
end_point = "/people/#{player_id}/stats?stats=careerRegularSeason"
|
34
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
35
|
+
response = Net::HTTP.get_response(uri)
|
36
|
+
|
37
|
+
if response.code == '200'
|
38
|
+
json_response = JSON.parse(response.body)
|
39
|
+
{status: response.code, message: response.message, data: json_response["stats"][0]["splits"][0]["stat"]}
|
40
|
+
else
|
41
|
+
{status: response.code, message: response.message}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def playoffs_career_stats(player_id)
|
46
|
+
end_point = "/people/#{player_id}/stats?stats=careerPlayoffs"
|
47
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
48
|
+
response = Net::HTTP.get_response(uri)
|
49
|
+
|
50
|
+
if response.code == '200'
|
51
|
+
json_response = JSON.parse(response.body)
|
52
|
+
{status: response.code, message: response.message, data: json_response["stats"][0]["splits"][0]["stat"]}
|
53
|
+
else
|
54
|
+
{status: response.code, message: response.message}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def playoffs_stats_by_year(player_id)
|
59
|
+
end_point = "/people/#{player_id}/stats?stats=yearByYearPlayoffs"
|
60
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
61
|
+
response = Net::HTTP.get_response(uri)
|
62
|
+
|
63
|
+
if response.code == '200'
|
64
|
+
json_response = JSON.parse(response.body)
|
65
|
+
|
66
|
+
{status: response.code, message: response.message, data: json_response["stats"][0]["splits"]}
|
67
|
+
else
|
68
|
+
{status: response.code, message: response.message}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/celly/team.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Celly::Team
|
5
|
+
BASE_URL = 'https://statsapi.web.nhl.com/api/v1'
|
6
|
+
|
7
|
+
def roster(id)
|
8
|
+
end_point = "/teams/#{id}/roster"
|
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
|
+
|
15
|
+
{status: response.code, message: response.message, data: json_response["roster"]}
|
16
|
+
else
|
17
|
+
{status: response.code, message: response.message}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def schedule(start_date, end_date, team_id)
|
22
|
+
end_point = "/schedule?startDate=#{start_date}&endDate=#{end_date}&teamId=#{team_id}"
|
23
|
+
uri = URI("#{BASE_URL}#{end_point}")
|
24
|
+
response = Net::HTTP.get_response(uri)
|
25
|
+
|
26
|
+
if response.code == '200'
|
27
|
+
json_response = JSON.parse(response.body)
|
28
|
+
|
29
|
+
{status: response.code, message: response.message, data: json_response["dates"]}
|
30
|
+
else
|
31
|
+
{ status: response.code, message: response.message }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/celly/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rymcmahon
|
@@ -30,8 +30,11 @@ files:
|
|
30
30
|
- Rakefile
|
31
31
|
- bin/console
|
32
32
|
- bin/setup
|
33
|
+
- celly-0.1.0.gem
|
33
34
|
- celly.gemspec
|
34
35
|
- lib/celly.rb
|
36
|
+
- lib/celly/player.rb
|
37
|
+
- lib/celly/team.rb
|
35
38
|
- lib/celly/version.rb
|
36
39
|
homepage: https://github.com/rymcmahon/celly
|
37
40
|
licenses:
|