ahl_scraper 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +31 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/lib/ahl_scraper/players.rb +2 -0
- data/lib/ahl_scraper/resources/player.rb +12 -0
- data/lib/ahl_scraper/resources/players/draft_info.rb +47 -0
- data/lib/ahl_scraper/resources/playoff_brackets/series.rb +11 -1
- data/lib/ahl_scraper/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42ad854afa14d8f639b35294da5ee966b60ec6ab335ab4775d01ac00242b9b80
|
4
|
+
data.tar.gz: 8bcd4121376a7dc3aab716a1321b4a1bdfa826923b69ccef386ce1cd23aa22f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6853fbd4cdd9c0491bcc24bf16b4dfbf510ddb62234784bcd0f174dcc9b401899c5b5469493aa8ba1f30ff81ce5158dae052f77f5584b85ddaca096eedd9d847
|
7
|
+
data.tar.gz: f96d7358daa78c9ba2835f5921c027b63a1c380653c81f71cba015631343f9d60312c43d345e4fc067d2e8582058901a4de69968a75337f8dd4e2ad2f4c302a6
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
|
6
|
+
# GitHub recommends pinning actions to a commit SHA.
|
7
|
+
# To get a newer version, you will need to update the SHA.
|
8
|
+
# You can also reference a tag or branch, but the action may change without warning.
|
9
|
+
|
10
|
+
name: Tests
|
11
|
+
|
12
|
+
on:
|
13
|
+
push:
|
14
|
+
branches: [ main ]
|
15
|
+
pull_request:
|
16
|
+
branches: [ '*' ]
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
test:
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v3
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
|
26
|
+
with:
|
27
|
+
ruby-version: '2.7.3'
|
28
|
+
- name: Install dependencies
|
29
|
+
run: bundle install
|
30
|
+
- name: Run tests
|
31
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.3.8
|
4
|
+
|
5
|
+
### Players
|
6
|
+
|
7
|
+
- Add `draft_info` to players (when AHL provides it)
|
8
|
+
|
9
|
+
## 0.3.7
|
10
|
+
|
11
|
+
### PlayoffBrackets::Series
|
12
|
+
|
13
|
+
- Add playoff season `80` to series wins needed dictionary
|
14
|
+
- Add default wins needed to dictionary and use for future seasons
|
15
|
+
|
3
16
|
## 0.3.6
|
4
17
|
|
5
18
|
### Game
|
data/Gemfile.lock
CHANGED
data/lib/ahl_scraper/players.rb
CHANGED
@@ -58,10 +58,22 @@ module AhlScraper
|
|
58
58
|
@weight ||= @raw_data.dig(:info, :weight).to_i
|
59
59
|
end
|
60
60
|
|
61
|
+
def draft_info
|
62
|
+
@draft_info ||= Players::DraftInfo.new(draft_data)
|
63
|
+
end
|
64
|
+
|
61
65
|
private
|
62
66
|
|
63
67
|
def valid_birthdate?
|
64
68
|
@valid_birthdate ||= !@raw_data.dig(:info, :birthDate).empty? && @raw_data.dig(:info, :birthDate) != "0000-00-00"
|
65
69
|
end
|
70
|
+
|
71
|
+
def draft_data
|
72
|
+
nhl_draft = @raw_data.dig(:info, :drafts)&.select { |draft| draft[:draft_league] == "NHL" }&.dig(0)
|
73
|
+
|
74
|
+
return {} if nhl_draft.nil?
|
75
|
+
|
76
|
+
nhl_draft
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
module Players
|
5
|
+
class DraftInfo < Resource
|
6
|
+
def id
|
7
|
+
@id ||= @raw_data[:id]&.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
def league
|
11
|
+
@draft_league ||= @raw_data[:draft_league]
|
12
|
+
end
|
13
|
+
|
14
|
+
def team_name
|
15
|
+
@team_name ||= @raw_data[:draft_team]
|
16
|
+
end
|
17
|
+
|
18
|
+
def team_id
|
19
|
+
@team_id ||= @raw_data[:draft_team_id]&.to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
def year
|
23
|
+
@year ||= @raw_data[:draft_year]&.to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
def round
|
27
|
+
@round ||= @raw_data[:draft_round]&.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
def rank
|
31
|
+
@rank ||= @raw_data[:draft_rank]&.to_i
|
32
|
+
end
|
33
|
+
|
34
|
+
def junior_team
|
35
|
+
@junior_team ||= @raw_data[:draft_junior_team]
|
36
|
+
end
|
37
|
+
|
38
|
+
def team_logo
|
39
|
+
@team_logo ||= @raw_data[:draft_logo]
|
40
|
+
end
|
41
|
+
|
42
|
+
def description
|
43
|
+
@description ||= @raw_data[:draft_text]&.strip
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -14,6 +14,8 @@ module AhlScraper
|
|
14
14
|
"69" => { "1" => 4 },
|
15
15
|
"72" => { "1" => 1, "2" => 1, "3" => 2, "4" => 2 },
|
16
16
|
"76" => { "1" => 2, "2" => 3, "3" => 4, "4" => 4, "5" => 4 },
|
17
|
+
"80" => { "1" => 2, "2" => 3, "3" => 3, "4" => 4, "5" => 4 },
|
18
|
+
"default" => { "1" => 2, "2" => 3, "3" => 3, "4" => 4, "5" => 4 },
|
17
19
|
}.freeze
|
18
20
|
|
19
21
|
def id
|
@@ -85,7 +87,7 @@ module AhlScraper
|
|
85
87
|
end
|
86
88
|
|
87
89
|
def wins_needed
|
88
|
-
@wins_needed ||=
|
90
|
+
@wins_needed ||= find_wins_needed
|
89
91
|
end
|
90
92
|
|
91
93
|
def finished?
|
@@ -95,6 +97,14 @@ module AhlScraper
|
|
95
97
|
|
96
98
|
private
|
97
99
|
|
100
|
+
def find_wins_needed
|
101
|
+
return OVERRIDE_WINS_NEEDED.dig(season_id.to_s, round.to_s) unless OVERRIDE_WINS_NEEDED.dig(season_id.to_s, round.to_s).nil?
|
102
|
+
|
103
|
+
return (round == 1 ? 3 : 4) if season_id.to_i < OVERRIDE_WINS_NEEDED.keys.map(&:to_i).max
|
104
|
+
|
105
|
+
OVERRIDE_WINS_NEEDED.dig("default", round.to_s)
|
106
|
+
end
|
107
|
+
|
98
108
|
def find_season_id
|
99
109
|
dig_season_id = @opts.dig(:bracket_data, :rounds, round - 1, :season_id)
|
100
110
|
|
data/lib/ahl_scraper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahl_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jefftcraig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -185,6 +185,7 @@ executables: []
|
|
185
185
|
extensions: []
|
186
186
|
extra_rdoc_files: []
|
187
187
|
files:
|
188
|
+
- ".github/workflows/ci.yml"
|
188
189
|
- ".gitignore"
|
189
190
|
- ".rspec"
|
190
191
|
- ".rubocop.yml"
|
@@ -254,6 +255,7 @@ files:
|
|
254
255
|
- lib/ahl_scraper/resources/games/team.rb
|
255
256
|
- lib/ahl_scraper/resources/goalie_game_list_item.rb
|
256
257
|
- lib/ahl_scraper/resources/player.rb
|
258
|
+
- lib/ahl_scraper/resources/players/draft_info.rb
|
257
259
|
- lib/ahl_scraper/resources/playoff_bracket.rb
|
258
260
|
- lib/ahl_scraper/resources/playoff_brackets/game.rb
|
259
261
|
- lib/ahl_scraper/resources/playoff_brackets/round.rb
|