ahl_scraper 0.3.4 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b20a1f72dc69a61ddd7568c5ef2eeca67f133bbcdd22f0e94d941ada6ee1e479
4
- data.tar.gz: f3d310aee075a7cd08f3a8d329c359e974816287c4f768e231c4e50643dabc35
3
+ metadata.gz: 361ba81452b6f5f3ea306d74730190b602b058636e75c99a803c1873afb3f0d7
4
+ data.tar.gz: 1fea9a929d692523c9dde5f4bd243a6e9bf7bfff0ff38d7173534c199d0b03fc
5
5
  SHA512:
6
- metadata.gz: e4b5912e8c6819fd3f45ff7a6f9919fe307ebdf7d554c27d2cebe6bd59452bb5a7f708f86b02bcee4fe1d2be33305264ef39a794d7d7ae5a8f8152b7a6bc4147
7
- data.tar.gz: e99c4087b80330d517b2f73027e82a31b32941b1b5d36741c4be0f969fa2ce7bf9d1dbc7bf0beb12d0507a0f7bd3b01138d4df99c8b2186d06b2732d58ee5499
6
+ metadata.gz: a41ddd6414132e4c5e825854a1a45042dceab56fba3db9d853387de3630514062c5b059f353ae100e8ef738fb1163b61ef20e1ea1555c537998910d5b6d74237
7
+ data.tar.gz: dc54c30d399a754adfd755a6a83f519dd9ddf602f6281e74411be5c5821f370c137535aea987d9166dc65ddf71148499b00c15a26645dac107ee3db07365cf1a
data/CHANGELOG.md CHANGED
@@ -1,28 +1,55 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.6
4
+
5
+ ### Game
6
+ - Add `suspended` game status
7
+
8
+ ### PlayoffBrackets::Round
9
+
10
+ - Add `started?` for when round has started (even if it is finished)
11
+ - Add `active?` for when round has active series
12
+ - Add `finished?` for when round has started and has no active series
13
+
14
+ ### PlayoffBrackets::Series
15
+
16
+ - Fix `active?` to properly assess `active: "1"` meaning has started but not necessarily currently active
17
+ - Added `started?` which now uses `active: "1"` to determine if the series has started
18
+ - Set round one series win count needed to `2` for season `76`
19
+
20
+ ## 0.3.5
21
+
22
+ ### Developer
23
+
24
+ - Add ability to use `rake console` to access gem in console to do manual testing
25
+
26
+ ### Seasons::Team
27
+
28
+ - Add Coachella Valley Firebirds to naming hash
29
+
3
30
  ## 0.3.4
4
31
 
5
- ## PlayoffBrackets::Series
32
+ ### PlayoffBrackets::Series
6
33
 
7
34
  - Add new series wins required for current playoffs (2022 with id `76`)
8
35
 
9
36
  ## 0.3.3
10
37
 
11
- ## Developer
38
+ ### Developer
12
39
 
13
40
  - Added `.tool-versions` file for `asdf` package manager use
14
41
 
15
- ## PlayoffBrackets::Round
42
+ ### PlayoffBrackets::Round
16
43
 
17
44
  - Add `active?` attribute which checks if any series is active, if so it returns truthy, else falsey
18
45
 
19
- ## PlayoffBrackets::Series
46
+ ### PlayoffBrackets::Series
20
47
 
21
48
  - Add check for existance of team ids for `active?` attribute to be truthy
22
49
 
23
50
  ## 0.3.2
24
51
 
25
- ## General
52
+ ### General
26
53
 
27
54
  - Changed `.split` to `&.split` and use `.dig` more to not fail when fields don't exist (often on games that have not finished)
28
55
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ahl_scraper (0.3.3)
4
+ ahl_scraper (0.3.6)
5
5
  json (~> 2.5.1)
6
6
  nokogiri (~> 1.12.4)
7
7
  rake (~> 13.0.0)
@@ -118,4 +118,4 @@ DEPENDENCIES
118
118
  webmock (>= 3.8.0)
119
119
 
120
120
  BUNDLED WITH
121
- 2.3.12
121
+ 2.3.20
data/Rakefile CHANGED
@@ -6,3 +6,7 @@ require "rspec/core/rake_task"
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  task default: :spec
9
+
10
+ task :console do
11
+ exec "irb -r ahl_scraper -I ./lib"
12
+ end
@@ -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
- return "postponed" if @raw_data.dig(:details, :status) == "Postponed"
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.filter(&:active?).any? if @active.nil?
36
+ @active = series.map(&:active?).any?(true) if @active.nil?
28
37
  @active
29
38
  end
30
39
 
31
- def series
32
- @series ||= @raw_data[:matchups].map { |series| Series.new(series, { bracket_data: @opts[:bracket_data] }) }
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,7 @@ 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" => 3, "2" => 3, "3" => 4, "4" => 4, "5" => 4 },
16
+ "76" => { "1" => 2, "2" => 3, "3" => 4, "4" => 4, "5" => 4 },
17
17
  }.freeze
18
18
 
19
19
  def id
@@ -24,6 +24,10 @@ module AhlScraper
24
24
  @name ||= @raw_data[:series_name]
25
25
  end
26
26
 
27
+ def season_id
28
+ @season_id ||= find_season_id
29
+ end
30
+
27
31
  def logo_url
28
32
  @logo_url ||= @raw_data[:series_logo]
29
33
  end
@@ -32,8 +36,14 @@ module AhlScraper
32
36
  @round ||= @raw_data[:round].to_i
33
37
  end
34
38
 
39
+ def started?
40
+ @started = @raw_data[:active] == "1" if @started.nil?
41
+ @started
42
+ end
43
+
35
44
  def active?
36
- @active ||= @raw_data[:active] == "1" && team_ids_present? && team1_wins < wins_needed && team2_wins < wins_needed
45
+ @active ||= team_ids_present? && team1_wins < wins_needed && team2_wins < wins_needed if @active.nil?
46
+ @active
37
47
  end
38
48
 
39
49
  def home_feeder_series
@@ -75,11 +85,24 @@ module AhlScraper
75
85
  end
76
86
 
77
87
  def wins_needed
78
- @wins_needed ||= OVERRIDE_WINS_NEEDED.dig(season_id, round.to_s) || (round == 1 ? 3 : 4)
88
+ @wins_needed ||= OVERRIDE_WINS_NEEDED.dig(season_id.to_s, round.to_s) || (round == 1 ? 3 : 4)
89
+ end
90
+
91
+ def finished?
92
+ @finished = winning_team_id.present? if @finished.nil?
93
+ @finished
79
94
  end
80
95
 
81
96
  private
82
97
 
98
+ def find_season_id
99
+ dig_season_id = @opts.dig(:bracket_data, :rounds, round - 1, :season_id)
100
+
101
+ return if dig_season_id.nil? || dig_season_id.empty?
102
+
103
+ dig_season_id.to_i
104
+ end
105
+
83
106
  def first_game
84
107
  @first_game ||= @raw_data.dig(:games, 0)
85
108
  end
@@ -92,10 +115,6 @@ module AhlScraper
92
115
  nil
93
116
  end
94
117
 
95
- def season_id
96
- @opts.dig(:bracket_data, :rounds, round - 1, :season_id)
97
- end
98
-
99
118
  def team1
100
119
  @team1 ||= @raw_data[:team1].to_i.zero? ? nil : @raw_data[:team1].to_i
101
120
  end
@@ -105,7 +124,7 @@ module AhlScraper
105
124
  end
106
125
 
107
126
  def team_ids_present?
108
- team1 && team2
127
+ !team1.nil? && !team2.nil?
109
128
  end
110
129
 
111
130
  def team1_wins
@@ -26,6 +26,7 @@ module AhlScraper
26
26
  "wilkes-barre-scranton-penguins" => { city: "Wilkes-Barre/Scranton", name: "Penguins", game_file_city: "W-B/Scranton" },
27
27
  "edmonton-road-runners" => { city: "Edmonton", name: "Road Runners" },
28
28
  "henderson-silver-knights" => { city: "Henderson", name: "Silver Knights" },
29
+ "coachella-valley-firebirds" => { city: "Coachella Valley", name: "Firebirds" },
29
30
  }.freeze
30
31
 
31
32
  def initialize(raw_data, division, opts = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AhlScraper
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.6"
5
5
  end
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
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jefftcraig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-01 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json