baseline_stats 0.0.1 → 0.0.2
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/lib/baseline_endpoints.rb +2 -2
- data/lib/baseline_request.rb +13 -1
- data/lib/baseline_stats.rb +18 -17
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 328690ae3daab2d83bc5c51246e052166ce17222c0dc0a91f7d15563572a9172
|
4
|
+
data.tar.gz: 5d21e6ac6c31ac42e7d2dda68ccb6b1d9fe8db3936facb8a15316b61c2d11133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b67ae557d5098a5ce445d163cd7be5802d3b830dd431c18d7f9dd170577048462e58845cab7409bbb52a824f50cad6a051bada7ac6c42055cf15c5b98950c5b
|
7
|
+
data.tar.gz: b209bff06bef10048548e2a364f0f5fb9fe75e8bba7640c9cdd3795fea5c7f0665173273e43d7f98b938245337b993545efe8a34a80353b560ced37c837e6bd6
|
data/lib/baseline_endpoints.rb
CHANGED
@@ -352,7 +352,7 @@ module BaselineEndpoints
|
|
352
352
|
"query_params": %w[updatedSince fields],
|
353
353
|
"required_params": [["updatedSince"]],
|
354
354
|
"note": "updatedSince param is a DateTime object",
|
355
|
-
"test_params": {updatedSince:
|
355
|
+
"test_params": {updatedSince: Date.new(2023, 9, 1)},
|
356
356
|
},
|
357
357
|
"people_free_agents": {
|
358
358
|
"url": BASE_URL + "{ver}/people/freeAgents",
|
@@ -644,7 +644,7 @@ module BaselineEndpoints
|
|
644
644
|
}
|
645
645
|
},
|
646
646
|
"query_params": %w[stats playerPool position teamId leagueId limit offset group gameType season sportIds sortStat order hydrate fields personId metrics],
|
647
|
-
"required_params": [["stats", "group"]],
|
647
|
+
"required_params": [["stats"], ["group"]],
|
648
648
|
"note": "Limit defaults to 50 records. `stats` field can be `season` or `career`; `group` can be `hitting`, `pitching`, or `fielding`.",
|
649
649
|
"test_params": {stats: "season", group: "hitting"},
|
650
650
|
},
|
data/lib/baseline_request.rb
CHANGED
@@ -26,7 +26,19 @@ class BaselineRequest
|
|
26
26
|
end
|
27
27
|
|
28
28
|
return error_array unless error_array.empty?
|
29
|
-
HTTParty.get(path, {
|
29
|
+
HTTParty.get(path, {
|
30
|
+
:query => query,
|
31
|
+
:query_string_normalizer => -> (h) {
|
32
|
+
h.map do |key, value|
|
33
|
+
if value.is_a? Array
|
34
|
+
query_string = value.map {|v| "#{key}=#{v}"}.join('&')
|
35
|
+
else
|
36
|
+
query_string = "#{key}=#{value}"
|
37
|
+
end
|
38
|
+
query_string
|
39
|
+
end.join('&')
|
40
|
+
}
|
41
|
+
})
|
30
42
|
end
|
31
43
|
|
32
44
|
def construct_path
|
data/lib/baseline_stats.rb
CHANGED
@@ -7,27 +7,28 @@ require 'baseline_request'
|
|
7
7
|
class Baseline
|
8
8
|
include BaselineEndpoints
|
9
9
|
|
10
|
-
|
11
10
|
MLB_LEAGUE_IDS = [103, 104].freeze
|
12
|
-
def self.team_list(options = {
|
13
|
-
Baseline.teams(options)
|
11
|
+
def self.team_list(options = {})
|
12
|
+
Baseline.teams(options)
|
13
|
+
.set_option("leagueIds", MLB_LEAGUE_IDS, false).call_api
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.team_player_list(options = {})
|
17
|
-
Baseline.team_roster(options)
|
16
|
+
def self.team_player_list(team_id, options = {})
|
17
|
+
Baseline.team_roster(options)
|
18
|
+
.set_option("teamId", team_id, true).call_api
|
18
19
|
end
|
19
20
|
|
20
21
|
def self.all_player_list(options = {})
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
Baseline.sports_players(options)
|
23
|
+
.set_option("sportId", 1, false)
|
24
|
+
.set_option("season", Time.now.year, false).call_api
|
24
25
|
end
|
25
26
|
|
26
27
|
def self.schedule_year(year, options = {})
|
27
|
-
request =
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
request = Baseline.schedule(options)
|
29
|
+
.set_option("sportId", 1, false)
|
30
|
+
.set_option("startDate", "#{year}-03-29")
|
31
|
+
.set_option("endDate", "#{year}-10-02")
|
31
32
|
|
32
33
|
request.call_api["dates"].inject([]) do |result, day|
|
33
34
|
result += day["games"]
|
@@ -36,18 +37,18 @@ class Baseline
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def self.game_at_bats(game_id, options = {})
|
39
|
-
api_response =
|
40
|
+
api_response = Baseline.game_play_by_play(options).set_option("gamePk", game_id).call_api
|
40
41
|
api_response['allPlays'].filter{_1["result"]["type"] == "atBat"}
|
41
42
|
end
|
42
43
|
|
43
44
|
def self.player_stats(player_id, options = {})
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
Baseline.person_stats(options)
|
46
|
+
.set_option("personId", player_id)
|
47
|
+
.set_option("stats", "season", false).call_api
|
47
48
|
end
|
48
49
|
|
49
50
|
def self.player_info(player_id, options = {})
|
50
|
-
|
51
|
+
Baseline.person(options).set_option("personId", player_id).call_api
|
51
52
|
end
|
52
53
|
|
53
54
|
def self.test_endpoints
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baseline_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Woodard
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby wrapper for interacting with the Statcast baseball api.
|
14
14
|
email: mat.james.woodard@gmail.com
|
@@ -22,7 +22,7 @@ files:
|
|
22
22
|
homepage: https://github.com/InsomniMatt/baseline_stats
|
23
23
|
licenses: []
|
24
24
|
metadata: {}
|
25
|
-
post_install_message:
|
25
|
+
post_install_message:
|
26
26
|
rdoc_options: []
|
27
27
|
require_paths:
|
28
28
|
- lib
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubygems_version: 3.1.6
|
41
|
-
signing_key:
|
41
|
+
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Baseball stats through Statcast.
|
44
44
|
test_files: []
|