ahl_scraper 0.3.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b50eba6912cfdd78130e062fda2e5714d0899d419d977b92c638378f9f672d4c
4
- data.tar.gz: 0ab43e3f52a2de435ea0ea5f404b752d13ef6ae6eba003e485dd55967d6ab967
3
+ metadata.gz: 96ea396818543dee6748d5ebd32b0db5d72c8901f1fb87b152302065392dd54c
4
+ data.tar.gz: f6885cf29578adc5600be0f126df73dd7ab22db7b5729035bcabaa14a15dc257
5
5
  SHA512:
6
- metadata.gz: 0c3c0faf348050a9e1172f01d25c3f47b363eea83b4b8613688637b18532dfea6102ee7e0388ade687c306c452520be79b69d44702f2cd1b30142b548308b698
7
- data.tar.gz: 70817e1d4a3258850516fe9f28543e04d31ca2c9bbcdba98f382af6152a48c6e59683b21fe49425450cb9c20d71ee2da5b2a03b7a518d3aa2a68265caaed1848
6
+ metadata.gz: 228d84267c85f593994851af53395c878505fd540cea3a94a037ea904a38315f0b86c68404e9a6fb6f096c84a5fb62595b8ee09543e61aa24e502172b83ed4a2
7
+ data.tar.gz: 9bc8c692ee1b2e27df73087d244042a150717f0dd489b417593ecd8ec7e55148c35f00bb7096564f30c6cf6b7263bbb76169f559ce530404d9455f0c7a9d158d
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.3
4
+
5
+ ## Developer
6
+
7
+ - Added `.tool-versions` file for `asdf` package manager use
8
+
9
+ ## PlayoffBrackets::Round
10
+
11
+ - Add `active?` attribute which checks if any series is active, if so it returns truthy, else falsey
12
+
13
+ ## PlayoffBrackets::Series
14
+
15
+ - Add check for existance of team ids for `active?` attribute to be truthy
16
+
17
+ ## 0.3.2
18
+
19
+ ## General
20
+
21
+ - Changed `.split` to `&.split` and use `.dig` more to not fail when fields don't exist (often on games that have not finished)
22
+
23
+ ### Game::Goalie
24
+
25
+ - Fix penalty minutes not being copied to the object because of a typo
26
+
27
+ ## 0.3.1
28
+
29
+ ### Scoreboards
30
+
31
+ - Add new module for getting the scores seen at the top of the AHL website
32
+ - Retrieve Scoreboards based on a passed in date range
33
+
34
+ ### Game
35
+
36
+ - Add postponed status to possible game statuses
37
+
3
38
  ## 0.3.0
4
39
 
5
40
  ### General
data/Gemfile CHANGED
@@ -4,22 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in ahl_scraper.gemspec
6
6
  gemspec
7
-
8
- gem "json", "~> 2.5.1"
9
- gem "nokogiri", "~> 1.12.4"
10
- gem "rake", "~> 13.0.0"
11
-
12
- group :development do
13
- gem "rubocop", "~> 0.89.0", require: false
14
- gem "rubocop-performance", "~> 1.8.1", require: false
15
- gem "solargraph", "~> 0.43.0"
16
- end
17
-
18
- group :development, :test do
19
- gem "byebug", "~> 11.1.3"
20
- gem "pry", "~> 0.13.1"
21
- gem "pry-byebug", "~> 3.9.0"
22
- gem "rspec", "~> 3.0"
23
- gem "vcr", "~> 6.0.0"
24
- gem "webmock", ">= 3.8.0"
25
- end
data/Gemfile.lock CHANGED
@@ -1,7 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ahl_scraper (0.3.0)
4
+ ahl_scraper (0.3.3)
5
+ json (~> 2.5.1)
6
+ nokogiri (~> 1.12.4)
7
+ rake (~> 13.0.0)
5
8
 
6
9
  GEM
7
10
  remote: https://rubygems.org/
@@ -10,25 +13,25 @@ GEM
10
13
  public_suffix (>= 2.0.2, < 5.0)
11
14
  ast (2.4.2)
12
15
  backport (1.2.0)
13
- benchmark (0.1.1)
16
+ benchmark (0.2.0)
14
17
  byebug (11.1.3)
15
18
  coderay (1.1.3)
16
19
  crack (0.4.5)
17
20
  rexml
18
- diff-lcs (1.4.4)
21
+ diff-lcs (1.5.0)
19
22
  e2mmap (0.1.0)
20
23
  hashdiff (1.0.1)
21
24
  jaro_winkler (1.5.4)
22
25
  json (2.5.1)
23
- kramdown (2.3.1)
26
+ kramdown (2.4.0)
24
27
  rexml
25
28
  kramdown-parser-gfm (1.1.0)
26
29
  kramdown (~> 2.0)
27
30
  method_source (1.0.0)
28
- nokogiri (1.12.5-x86_64-darwin)
31
+ nokogiri (1.12.5-arm64-darwin)
29
32
  racc (~> 1.4)
30
- parallel (1.21.0)
31
- parser (3.0.2.0)
33
+ parallel (1.22.1)
34
+ parser (3.1.2.0)
32
35
  ast (~> 2.4.1)
33
36
  pry (0.13.1)
34
37
  coderay (~> 1.1)
@@ -36,27 +39,27 @@ GEM
36
39
  pry-byebug (3.9.0)
37
40
  byebug (~> 11.0)
38
41
  pry (~> 0.13.0)
39
- public_suffix (4.0.6)
40
- racc (1.5.2)
41
- rainbow (3.0.0)
42
+ public_suffix (4.0.7)
43
+ racc (1.6.0)
44
+ rainbow (3.1.1)
42
45
  rake (13.0.6)
43
- regexp_parser (2.1.1)
44
- reverse_markdown (2.0.0)
46
+ regexp_parser (2.3.1)
47
+ reverse_markdown (2.1.1)
45
48
  nokogiri
46
49
  rexml (3.2.5)
47
- rspec (3.10.0)
48
- rspec-core (~> 3.10.0)
49
- rspec-expectations (~> 3.10.0)
50
- rspec-mocks (~> 3.10.0)
51
- rspec-core (3.10.1)
52
- rspec-support (~> 3.10.0)
53
- rspec-expectations (3.10.1)
50
+ rspec (3.11.0)
51
+ rspec-core (~> 3.11.0)
52
+ rspec-expectations (~> 3.11.0)
53
+ rspec-mocks (~> 3.11.0)
54
+ rspec-core (3.11.0)
55
+ rspec-support (~> 3.11.0)
56
+ rspec-expectations (3.11.0)
54
57
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.10.0)
56
- rspec-mocks (3.10.2)
58
+ rspec-support (~> 3.11.0)
59
+ rspec-mocks (3.11.1)
57
60
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.10.0)
59
- rspec-support (3.10.2)
61
+ rspec-support (~> 3.11.0)
62
+ rspec-support (3.11.0)
60
63
  rubocop (0.89.1)
61
64
  parallel (~> 1.10)
62
65
  parser (>= 2.7.1.1)
@@ -87,7 +90,7 @@ GEM
87
90
  thor (~> 1.0)
88
91
  tilt (~> 2.0)
89
92
  yard (~> 0.9, >= 0.9.24)
90
- thor (1.1.0)
93
+ thor (1.2.1)
91
94
  tilt (2.0.10)
92
95
  unicode-display_width (1.8.0)
93
96
  vcr (6.0.0)
@@ -95,19 +98,18 @@ GEM
95
98
  addressable (>= 2.8.0)
96
99
  crack (>= 0.3.2)
97
100
  hashdiff (>= 0.4.0, < 2.0.0)
98
- yard (0.9.26)
101
+ webrick (1.7.0)
102
+ yard (0.9.27)
103
+ webrick (~> 1.7.0)
99
104
 
100
105
  PLATFORMS
101
- x86_64-darwin-19
106
+ arm64-darwin-21
102
107
 
103
108
  DEPENDENCIES
104
109
  ahl_scraper!
105
110
  byebug (~> 11.1.3)
106
- json (~> 2.5.1)
107
- nokogiri (~> 1.12.4)
108
111
  pry (~> 0.13.1)
109
112
  pry-byebug (~> 3.9.0)
110
- rake (~> 13.0.0)
111
113
  rspec (~> 3.0)
112
114
  rubocop (~> 0.89.0)
113
115
  rubocop-performance (~> 1.8.1)
@@ -116,4 +118,4 @@ DEPENDENCIES
116
118
  webmock (>= 3.8.0)
117
119
 
118
120
  BUNDLED WITH
119
- 2.2.17
121
+ 2.3.12
data/ahl_scraper.gemspec CHANGED
@@ -18,6 +18,20 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata["source_code_uri"] = "https://github.com/notnotjeff/ahl_scraper"
19
19
  spec.metadata["changelog_uri"] = "https://github.com/notnotjeff/ahl_scraper"
20
20
 
21
+ spec.add_dependency "json", "~> 2.5.1"
22
+ spec.add_dependency "nokogiri", "~> 1.12.4"
23
+ spec.add_dependency "rake", "~> 13.0.0"
24
+
25
+ spec.add_development_dependency "byebug", "~> 11.1.3"
26
+ spec.add_development_dependency "pry", "~> 0.13.1"
27
+ spec.add_development_dependency "pry-byebug", "~> 3.9.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "rubocop", "~> 0.89.0"
30
+ spec.add_development_dependency "rubocop-performance", "~> 1.8.1"
31
+ spec.add_development_dependency "solargraph", "~> 0.43.0"
32
+ spec.add_development_dependency "vcr", "~> 6.0.0"
33
+ spec.add_development_dependency "webmock", ">= 3.8.0"
34
+
21
35
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
36
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
37
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AhlScraper
4
+ module Scoreboards
5
+ class DataFetcher
6
+ def initialize(start_date:, end_date:)
7
+ @start_date = start_date
8
+ @end_date = end_date
9
+ end
10
+
11
+ def call
12
+ JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)&.dig(:SiteKit, :Scorebar)&.filter do |game|
13
+ game_date = Date.parse(game[:Date])
14
+ game_date >= @start_date && game_date <= @end_date
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def url
21
+ "https://lscluster.hockeytech.com/feed/index.php?feed=modulekit&key=ccb91f29d6744675&client_code=ahl&view=scorebar&numberofdaysahead=#{days_ahead}&numberofdaysback=#{days_back}&fmt=json&site_id=3&lang=en&league_id=4&division_id=undefined&callback=json" # rubocop:disable Layout/LineLength
22
+ end
23
+
24
+ def days_back
25
+ date_today > @start_date ? (date_today - @start_date).to_i : 0
26
+ end
27
+
28
+ def days_ahead
29
+ date_today < @end_date ? (@end_date - date_today).to_i : 0
30
+ end
31
+
32
+ def date_today
33
+ @date_today ||= Date.today
34
+ end
35
+ end
36
+ end
37
+ end
@@ -9,7 +9,9 @@ module AhlScraper
9
9
  end
10
10
 
11
11
  def to_seconds
12
- ice_time = time.split(":")
12
+ return unless time
13
+
14
+ ice_time = time&.split(":")
13
15
  ice_time[0].to_i * 60 + ice_time[1].to_i
14
16
  end
15
17
 
@@ -10,12 +10,16 @@ module AhlScraper
10
10
  end
11
11
 
12
12
  def to_period_seconds
13
- period_time = time.split(":")
13
+ return unless time
14
+
15
+ period_time = time&.split(":")
14
16
  period_time[0].to_i * 60 + period_time[1].to_i
15
17
  end
16
18
 
17
19
  def to_time_elapsed
18
- period_time = time.split(":")
20
+ return unless time
21
+
22
+ period_time = time&.split(":")
19
23
  period_time[0].to_i * 60 + period_time[1].to_i + ((period - 1) * 1200)
20
24
  end
21
25
 
@@ -344,11 +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
348
  # return "forfeited" if game is a forfeit, need to figure this out if it happens
348
349
 
349
- return "finished" if @raw_data[:details][:final] == "1"
350
+ return "finished" if @raw_data.dig(:details, :final) == "1"
350
351
 
351
- return "in_progress" if @raw_data[:details][:started] == "1"
352
+ return "in_progress" if @raw_data.dig(:details, :started) == "1"
352
353
 
353
354
  "not_started"
354
355
  end
@@ -44,7 +44,7 @@ module AhlScraper
44
44
  goals: @raw_data[:stats][:goals],
45
45
  assists: @raw_data[:stats][:assists],
46
46
  points: @raw_data[:stats][:points],
47
- penalty_minutes: @raw_data[:stats][:penaltyMinute],
47
+ penalty_minutes: @raw_data[:stats][:penaltyMinutes],
48
48
  toi: @raw_data[:stats][:timeOnIce],
49
49
  toi_in_seconds: set_time_on_ice_in_seconds,
50
50
  shots_against: @raw_data[:stats][:shotsAgainst],
@@ -72,11 +72,6 @@ module AhlScraper
72
72
  def period_time
73
73
  @period_time ||= PeriodTimeHelper.new(time, period)
74
74
  end
75
-
76
- def convert_time(game_time)
77
- time = game_time.split(":")
78
- time[0].to_i * 60 + time[1].to_i
79
- end
80
75
  end
81
76
  end
82
77
  end
@@ -11,7 +11,7 @@ module AhlScraper
11
11
  end
12
12
 
13
13
  def rounds
14
- @rounds ||= @raw_data[:rounds].map { |round| PlayoffBrackets::Round.new(round, { raw_data: @raw_data }) }
14
+ @rounds ||= @raw_data[:rounds].map { |round| PlayoffBrackets::Round.new(round, { bracket_data: @raw_data }) }
15
15
  end
16
16
 
17
17
  def logo_url
@@ -23,6 +23,11 @@ module AhlScraper
23
23
  @round_type_name ||= @raw_data[:round_type_name]
24
24
  end
25
25
 
26
+ def active?
27
+ @active = series.filter(&:active?).any? if @active.nil?
28
+ @active
29
+ end
30
+
26
31
  def series
27
32
  @series ||= @raw_data[:matchups].map { |series| Series.new(series, { bracket_data: @opts[:bracket_data] }) }
28
33
  end
@@ -32,7 +32,7 @@ module AhlScraper
32
32
  end
33
33
 
34
34
  def active?
35
- @active ||= @raw_data[:active] == "1" && team1_wins < wins_needed && team2_wins < wins_needed
35
+ @active ||= @raw_data[:active] == "1" && team_ids_present? && team1_wins < wins_needed && team2_wins < wins_needed
36
36
  end
37
37
 
38
38
  def home_feeder_series
@@ -48,11 +48,13 @@ module AhlScraper
48
48
  end
49
49
 
50
50
  def home_team_id
51
- @home_team_id ||= first_game[:home_team].to_i
51
+ @home_team_id = first_game&.dig(:home_team)&.to_i if @home_team_id.nil?
52
+ @home_team_id
52
53
  end
53
54
 
54
55
  def away_team_id
55
- @away_team_id ||= first_game[:visiting_team].to_i
56
+ @away_team_id = first_game&.dig(:visiting_team)&.to_i if @away_team_id.nil?
57
+ @away_team_id
56
58
  end
57
59
 
58
60
  def home_team_wins
@@ -78,7 +80,7 @@ module AhlScraper
78
80
  private
79
81
 
80
82
  def first_game
81
- @first_game ||= @raw_data[:games][0]
83
+ @first_game ||= @raw_data.dig(:games, 0)
82
84
  end
83
85
 
84
86
  def find_winner
@@ -90,23 +92,27 @@ module AhlScraper
90
92
  end
91
93
 
92
94
  def season_id
93
- @opts[:bracket_data]&.dig(:rounds, round - 1, :season_id)
95
+ @opts.dig(:bracket_data, :rounds, round - 1, :season_id)
94
96
  end
95
97
 
96
98
  def team1
97
- @team1 ||= @raw_data[:team1].to_i
99
+ @team1 ||= @raw_data[:team1].to_i.zero? ? nil : @raw_data[:team1].to_i
98
100
  end
99
101
 
100
102
  def team2
101
- @team2 ||= @raw_data[:team2].to_i
103
+ @team2 ||= @raw_data[:team2].to_i.zero? ? nil : @raw_data[:team2].to_i
104
+ end
105
+
106
+ def team_ids_present?
107
+ team1 && team2
102
108
  end
103
109
 
104
110
  def team1_wins
105
- @team1_wins ||= @raw_data[:team1_wins]
111
+ @team1_wins ||= @raw_data[:team1_wins].to_i
106
112
  end
107
113
 
108
114
  def team2_wins
109
- @team2_wins ||= @raw_data[:team2_wins]
115
+ @team2_wins ||= @raw_data[:team2_wins].to_i
110
116
  end
111
117
  end
112
118
  end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AhlScraper
4
+ class Scoreboard < Resource
5
+ def initialize(raw_data)
6
+ super(raw_data, {})
7
+ end
8
+
9
+ def id
10
+ @id ||= @raw_data[:ID].to_i
11
+ end
12
+
13
+ def season_id
14
+ @season_id ||= @raw_data[:SeasonID].to_i
15
+ end
16
+
17
+ def game_number
18
+ @game_number ||= @raw_data[:game_number].to_i
19
+ end
20
+
21
+ def game_date
22
+ @game_date ||= @raw_data[:Date]
23
+ end
24
+
25
+ def htv_game_id
26
+ @htv_game_id ||= @raw_data[:HtvGameID].to_i
27
+ end
28
+
29
+ def game_date_words
30
+ @game_date_words ||= @raw_data[:GameDate]
31
+ end
32
+
33
+ def game_date_ISO8601
34
+ @game_date_ISO8601 ||= @raw_data[:GameDateISO8601]
35
+ end
36
+
37
+ def scheduled_time
38
+ @scheduled_time ||= @raw_data[:ScheduledTime]
39
+ end
40
+
41
+ def scheduled_time_formatted
42
+ @scheduled_time_formatted ||= @raw_data[:ScheduledFormattedTime]
43
+ end
44
+
45
+ def timezone
46
+ @timezone ||= @raw_data[:Timezone]
47
+ end
48
+
49
+ def ticket_url
50
+ @ticket_url ||= @raw_data[:TicketUrl]
51
+ end
52
+
53
+ def period
54
+ @period ||= @raw_data[:Period].to_i
55
+ end
56
+
57
+ def period_long_name
58
+ @period_long_name ||= @raw_data[:PeriodNameLong]
59
+ end
60
+
61
+ def game_clock
62
+ @game_clock ||= @raw_data[:GameClock]
63
+ end
64
+
65
+ def intermission?
66
+ @intermission ||= @raw_data[:Intermission] == "1"
67
+ end
68
+
69
+ def game_status
70
+ @game_status ||= @raw_data[:GameStatusString]
71
+ end
72
+
73
+ def game_status_string_long
74
+ @game_status_string_long ||= @raw_data[:GameStatusStringLong]
75
+ end
76
+
77
+ def venue_name
78
+ @venue_name ||= @raw_data[:venue_name]
79
+ end
80
+
81
+ def venue_location
82
+ @venue_location ||= @raw_data[:venue_location]
83
+ end
84
+
85
+ def timezone_short
86
+ @timezone_short ||= @raw_data[:TimezoneShort]
87
+ end
88
+
89
+ def home_score
90
+ @home_score ||= @raw_data[:HomeGoals].to_i
91
+ end
92
+
93
+ def home_team
94
+ @home_team ||= Scoreboards::Team.new(home_team_data)
95
+ end
96
+
97
+ def away_score
98
+ @away_score ||= @raw_data[:VisitorGoals].to_i
99
+ end
100
+
101
+ def away_team
102
+ @away_team ||= Scoreboards::Team.new(away_team_data)
103
+ end
104
+
105
+ private
106
+
107
+ def away_team_data
108
+ {
109
+ id: @raw_data[:VisitorID],
110
+ abbreviation: @raw_data[:VisitorCode],
111
+ city: @raw_data[:VisitorCity],
112
+ name: @raw_data[:VisitorNickname],
113
+ full_name: @raw_data[:VisitorLongName],
114
+ division: @raw_data[:VisitingDivision],
115
+ score: @raw_data[:VisitorGoals],
116
+ audio_url: @raw_data[:VisitorAudioUrl],
117
+ video_url: @raw_data[:VisitorVideoUrl],
118
+ webcasts_url: @raw_data[:VisitorWebcastUrl],
119
+ wins: @raw_data[:VisitorWins],
120
+ regulation_losses: @raw_data[:VisitorRegulationLosses],
121
+ ot_losses: @raw_data[:VisitorOTLosses],
122
+ shootout_losses: @raw_data[:VisitorShootoutLosses],
123
+ logo: @raw_data[:VisitorLogo],
124
+ }
125
+ end
126
+
127
+ def home_team_data
128
+ {
129
+ id: @raw_data[:HomeID],
130
+ abbreviation: @raw_data[:HomeCode],
131
+ city: @raw_data[:HomeCity],
132
+ name: @raw_data[:HomeNickname],
133
+ full_name: @raw_data[:HomeLongName],
134
+ division: @raw_data[:HomeDivision],
135
+ score: @raw_data[:HomeGoals],
136
+ audio_url: @raw_data[:HomeAudioUrl],
137
+ video_url: @raw_data[:HomeVideoUrl],
138
+ webcasts_url: @raw_data[:HomeWebcastUrl],
139
+ wins: @raw_data[:HomeWins],
140
+ regulation_losses: @raw_data[:HomeRegulationLosses],
141
+ ot_losses: @raw_data[:HomeOTLosses],
142
+ shootout_losses: @raw_data[:HomeShootoutLosses],
143
+ logo: @raw_data[:HomeLogo],
144
+ }
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AhlScraper
4
+ module Scoreboards
5
+ class Team < Resource
6
+ def id
7
+ @id ||= @raw_data[:id].to_i
8
+ end
9
+
10
+ def abbreviation
11
+ @abbreviation ||= @raw_data[:abbreviation]
12
+ end
13
+
14
+ def city
15
+ @city ||= @raw_data[:city]
16
+ end
17
+
18
+ def name
19
+ @name ||= @raw_data[:name]
20
+ end
21
+
22
+ def full_name
23
+ @full_name ||= @raw_data[:full_name]
24
+ end
25
+
26
+ def division
27
+ @division ||= @raw_data[:division]
28
+ end
29
+
30
+ def score
31
+ @score ||= @raw_data[:score].to_i
32
+ end
33
+
34
+ def audio_url
35
+ @audio_url ||= @raw_data[:audio_url]
36
+ end
37
+
38
+ def video_url
39
+ @video_url ||= @raw_data[:video_url]
40
+ end
41
+
42
+ def webcasts_url
43
+ @webcasts_url ||= @raw_data[:webcasts_url]
44
+ end
45
+
46
+ def wins
47
+ @wins ||= @raw_data[:wins].to_i
48
+ end
49
+
50
+ def regulation_losses
51
+ @regulation_losses ||= @raw_data[:regulation_losses].to_i
52
+ end
53
+
54
+ def ot_losses
55
+ @ot_losses ||= @raw_data[:ot_losses].to_i
56
+ end
57
+
58
+ def shootout_losses
59
+ @shootout_losses ||= @raw_data[:shootout_losses].to_i
60
+ end
61
+
62
+ def logo
63
+ @logo ||= @raw_data[:logo]
64
+ end
65
+ end
66
+ end
67
+ end
@@ -51,11 +51,11 @@ module AhlScraper
51
51
  end
52
52
 
53
53
  def city
54
- @city ||= full_name.split.length > 2 ? exception_split_object&.dig(:city) : full_name.split[0]
54
+ @city ||= full_name&.split.length > 2 ? exception_split_object&.dig(:city) : full_name&.split[0]
55
55
  end
56
56
 
57
57
  def name
58
- @name ||= full_name.split.length > 2 ? exception_split_object&.dig(:name) : full_name.split[1]
58
+ @name ||= full_name&.split.length > 2 ? exception_split_object&.dig(:name) : full_name&.split[1]
59
59
  end
60
60
 
61
61
  def game_file_city
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ahl_scraper/fetchers/scoreboards/data_fetcher"
4
+
5
+ require "ahl_scraper/resources/scoreboards/team"
6
+
7
+ module AhlScraper
8
+ module Scoreboards
9
+ class << self
10
+ def list(start_date, end_date)
11
+ DataFetcher.new(start_date: start_date, end_date: end_date).call&.map { |game| Scoreboard.new(game) }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -17,14 +17,9 @@ module AhlScraper
17
17
 
18
18
  def ordered_penalty_shots
19
19
  @ordered_penalty_shots ||= penalty_shot_data.sort do |a, b|
20
- [a[:period][:id].to_i, convert_time(a[:time])] <=> [b[:period][:id].to_i, convert_time(b[:time])]
20
+ [a[:period][:id].to_i, IceTimeHelper.new(a[:time]).to_sec] <=> [b[:period][:id].to_i, IceTimeHelper.new(b[:time]).to_sec]
21
21
  end
22
22
  end
23
-
24
- def convert_time(game_time)
25
- time = game_time.split(":")
26
- time[0].to_i * 60 + time[1].to_i
27
- end
28
23
  end
29
24
  end
30
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AhlScraper
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.3"
5
5
  end
data/lib/ahl_scraper.rb CHANGED
@@ -39,6 +39,7 @@ require "ahl_scraper/resources/goalie_game_list_item"
39
39
  require "ahl_scraper/resources/season_list_item"
40
40
  require "ahl_scraper/resources/skater_game_list_item"
41
41
  require "ahl_scraper/resources/roster_player"
42
+ require "ahl_scraper/resources/scoreboard"
42
43
  require "ahl_scraper/resources/player"
43
44
 
44
45
  require "ahl_scraper/games"
@@ -49,6 +50,7 @@ require "ahl_scraper/player_games"
49
50
  require "ahl_scraper/players"
50
51
  require "ahl_scraper/playoff_brackets"
51
52
  require "ahl_scraper/roster_players"
53
+ require "ahl_scraper/scoreboards"
52
54
 
53
55
  module AhlScraper
54
56
  class Error < StandardError; end
metadata CHANGED
@@ -1,15 +1,183 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahl_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jefftcraig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.5.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.5.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.12.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.12.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 13.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 13.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 11.1.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 11.1.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.13.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.13.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.9.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.9.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.89.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.89.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-performance
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.8.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.8.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: solargraph
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.43.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.43.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: vcr
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 6.0.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 6.0.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: webmock
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 3.8.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 3.8.0
13
181
  description: Allows users to gather game, season, and player data from the AHL website
14
182
  email:
15
183
  - jeffcraig35@gmail.com
@@ -22,6 +190,7 @@ files:
22
190
  - ".rubocop.yml"
23
191
  - ".ruby-version"
24
192
  - ".solargraph.yml"
193
+ - ".tool-versions"
25
194
  - ".travis.yml"
26
195
  - ".vscode/settings.json"
27
196
  - CHANGELOG.md
@@ -41,6 +210,7 @@ files:
41
210
  - lib/ahl_scraper/fetchers/player_data_fetcher.rb
42
211
  - lib/ahl_scraper/fetchers/player_games/data_fetcher.rb
43
212
  - lib/ahl_scraper/fetchers/playoff_bracket_data_fetcher.rb
213
+ - lib/ahl_scraper/fetchers/scoreboards/data_fetcher.rb
44
214
  - lib/ahl_scraper/fetchers/season_data_fetcher.rb
45
215
  - lib/ahl_scraper/fetchers/season_end_date_fetcher.rb
46
216
  - lib/ahl_scraper/fetchers/season_game_ids_fetcher.rb
@@ -90,6 +260,8 @@ files:
90
260
  - lib/ahl_scraper/resources/playoff_brackets/series.rb
91
261
  - lib/ahl_scraper/resources/playoff_brackets/team.rb
92
262
  - lib/ahl_scraper/resources/roster_player.rb
263
+ - lib/ahl_scraper/resources/scoreboard.rb
264
+ - lib/ahl_scraper/resources/scoreboards/team.rb
93
265
  - lib/ahl_scraper/resources/season.rb
94
266
  - lib/ahl_scraper/resources/season_list_item.rb
95
267
  - lib/ahl_scraper/resources/seasons/team.rb
@@ -97,6 +269,7 @@ files:
97
269
  - lib/ahl_scraper/resources/team_game_list_item.rb
98
270
  - lib/ahl_scraper/resources/team_list_item.rb
99
271
  - lib/ahl_scraper/roster_players.rb
272
+ - lib/ahl_scraper/scoreboards.rb
100
273
  - lib/ahl_scraper/seasons.rb
101
274
  - lib/ahl_scraper/services/games/create_skaters_service.rb
102
275
  - lib/ahl_scraper/services/games/on_ice_statlines_service.rb
@@ -118,7 +291,7 @@ metadata:
118
291
  homepage_uri: https://github.com/notnotjeff/ahl_scraper
119
292
  source_code_uri: https://github.com/notnotjeff/ahl_scraper
120
293
  changelog_uri: https://github.com/notnotjeff/ahl_scraper
121
- post_install_message:
294
+ post_install_message:
122
295
  rdoc_options: []
123
296
  require_paths:
124
297
  - lib
@@ -134,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
307
  version: '0'
135
308
  requirements: []
136
309
  rubygems_version: 3.1.6
137
- signing_key:
310
+ signing_key:
138
311
  specification_version: 4
139
312
  summary: Scrape data from the AHL website
140
313
  test_files: []