ahl_scraper 0.3.5 → 0.3.7
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 +24 -0
- data/Gemfile.lock +2 -2
- data/lib/ahl_scraper/resources/game.rb +6 -1
- data/lib/ahl_scraper/resources/playoff_brackets/round.rb +13 -3
- data/lib/ahl_scraper/resources/playoff_brackets/series.rb +37 -8
- data/lib/ahl_scraper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19ac0b14d0b335af57c72d9a95ddbe1ed7c674990f56a52962e01ecd6112d4f5
|
4
|
+
data.tar.gz: 27eb465a69a64ee0c5171edbed58bea880901c5b9953dc91f6aacd75d01141b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e272f8523db112eabe3c4f1127b83e83593f8685eb567d851941f7f1d81411d5ffabd270a6afc86573af6426d247c83292dbd09e1e71f241d4d93ca3edfcff
|
7
|
+
data.tar.gz: '084d82bd3ca33d37aab4af2fd15a37508af4a67422069a5bed32466ee14bd9b28a194ec8e40dd39c37e42029bb5e55a6f6ba5aa4bf9e00c14eeb5881cc46209d'
|
@@ -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,29 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.3.7
|
4
|
+
|
5
|
+
### PlayoffBrackets::Series
|
6
|
+
|
7
|
+
- Add playoff season `80` to series wins needed dictionary
|
8
|
+
- Add default wins needed to dictionary and use for future seasons
|
9
|
+
|
10
|
+
## 0.3.6
|
11
|
+
|
12
|
+
### Game
|
13
|
+
- Add `suspended` game status
|
14
|
+
|
15
|
+
### PlayoffBrackets::Round
|
16
|
+
|
17
|
+
- Add `started?` for when round has started (even if it is finished)
|
18
|
+
- Add `active?` for when round has active series
|
19
|
+
- Add `finished?` for when round has started and has no active series
|
20
|
+
|
21
|
+
### PlayoffBrackets::Series
|
22
|
+
|
23
|
+
- Fix `active?` to properly assess `active: "1"` meaning has started but not necessarily currently active
|
24
|
+
- Added `started?` which now uses `active: "1"` to determine if the series has started
|
25
|
+
- Set round one series win count needed to `2` for season `76`
|
26
|
+
|
3
27
|
## 0.3.5
|
4
28
|
|
5
29
|
### Developer
|
data/Gemfile.lock
CHANGED
@@ -344,7 +344,12 @@ module AhlScraper
|
|
344
344
|
irregular_game_status = IRREGULAR_GAMES.dig(game_id.to_s, :status)
|
345
345
|
return irregular_game_status if irregular_game_status
|
346
346
|
|
347
|
-
|
347
|
+
game_status = @raw_data.dig(:details, :status)
|
348
|
+
|
349
|
+
return "suspended" unless game_status.match(/Suspended/).nil?
|
350
|
+
|
351
|
+
return "postponed" if game_status == "Postponed"
|
352
|
+
|
348
353
|
# return "forfeited" if game is a forfeit, need to figure this out if it happens
|
349
354
|
|
350
355
|
return "finished" if @raw_data.dig(:details, :final) == "1"
|
@@ -23,13 +23,23 @@ module AhlScraper
|
|
23
23
|
@round_type_name ||= @raw_data[:round_type_name]
|
24
24
|
end
|
25
25
|
|
26
|
+
def series
|
27
|
+
@series ||= @raw_data[:matchups].map { |series| Series.new(series, { bracket_data: @opts[:bracket_data] }) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def started?
|
31
|
+
@started = active? || finished? if @started.nil?
|
32
|
+
@started
|
33
|
+
end
|
34
|
+
|
26
35
|
def active?
|
27
|
-
@active = series.
|
36
|
+
@active = series.map(&:active?).any?(true) if @active.nil?
|
28
37
|
@active
|
29
38
|
end
|
30
39
|
|
31
|
-
def
|
32
|
-
@
|
40
|
+
def finished?
|
41
|
+
@finished = series.map(&:finished?).none?(false) && !active? if @finished.nil?
|
42
|
+
@finished
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -13,7 +13,9 @@ module AhlScraper
|
|
13
13
|
"7" => { "1" => 4 },
|
14
14
|
"69" => { "1" => 4 },
|
15
15
|
"72" => { "1" => 1, "2" => 1, "3" => 2, "4" => 2 },
|
16
|
-
"76" => { "1" =>
|
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
|
@@ -24,6 +26,10 @@ module AhlScraper
|
|
24
26
|
@name ||= @raw_data[:series_name]
|
25
27
|
end
|
26
28
|
|
29
|
+
def season_id
|
30
|
+
@season_id ||= find_season_id
|
31
|
+
end
|
32
|
+
|
27
33
|
def logo_url
|
28
34
|
@logo_url ||= @raw_data[:series_logo]
|
29
35
|
end
|
@@ -32,8 +38,14 @@ module AhlScraper
|
|
32
38
|
@round ||= @raw_data[:round].to_i
|
33
39
|
end
|
34
40
|
|
41
|
+
def started?
|
42
|
+
@started = @raw_data[:active] == "1" if @started.nil?
|
43
|
+
@started
|
44
|
+
end
|
45
|
+
|
35
46
|
def active?
|
36
|
-
@active ||=
|
47
|
+
@active ||= team_ids_present? && team1_wins < wins_needed && team2_wins < wins_needed if @active.nil?
|
48
|
+
@active
|
37
49
|
end
|
38
50
|
|
39
51
|
def home_feeder_series
|
@@ -75,11 +87,32 @@ module AhlScraper
|
|
75
87
|
end
|
76
88
|
|
77
89
|
def wins_needed
|
78
|
-
@wins_needed ||=
|
90
|
+
@wins_needed ||= find_wins_needed
|
91
|
+
end
|
92
|
+
|
93
|
+
def finished?
|
94
|
+
@finished = winning_team_id.present? if @finished.nil?
|
95
|
+
@finished
|
79
96
|
end
|
80
97
|
|
81
98
|
private
|
82
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
|
+
|
108
|
+
def find_season_id
|
109
|
+
dig_season_id = @opts.dig(:bracket_data, :rounds, round - 1, :season_id)
|
110
|
+
|
111
|
+
return if dig_season_id.nil? || dig_season_id.empty?
|
112
|
+
|
113
|
+
dig_season_id.to_i
|
114
|
+
end
|
115
|
+
|
83
116
|
def first_game
|
84
117
|
@first_game ||= @raw_data.dig(:games, 0)
|
85
118
|
end
|
@@ -92,10 +125,6 @@ module AhlScraper
|
|
92
125
|
nil
|
93
126
|
end
|
94
127
|
|
95
|
-
def season_id
|
96
|
-
@opts.dig(:bracket_data, :rounds, round - 1, :season_id)
|
97
|
-
end
|
98
|
-
|
99
128
|
def team1
|
100
129
|
@team1 ||= @raw_data[:team1].to_i.zero? ? nil : @raw_data[:team1].to_i
|
101
130
|
end
|
@@ -105,7 +134,7 @@ module AhlScraper
|
|
105
134
|
end
|
106
135
|
|
107
136
|
def team_ids_present?
|
108
|
-
team1 && team2
|
137
|
+
!team1.nil? && !team2.nil?
|
109
138
|
end
|
110
139
|
|
111
140
|
def team1_wins
|
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.7
|
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-04-20 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"
|