ahl_scraper 0.3.0 → 0.3.1

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: 285012122b98f5d30bb129fb94766a02405f10217340001caea0627be4422075
4
+ data.tar.gz: f52ca819c0d8c6c7882639aa143695f54cd8d4c8c3f8baac9f1ccf58796e0a6e
5
5
  SHA512:
6
- metadata.gz: 0c3c0faf348050a9e1172f01d25c3f47b363eea83b4b8613688637b18532dfea6102ee7e0388ade687c306c452520be79b69d44702f2cd1b30142b548308b698
7
- data.tar.gz: 70817e1d4a3258850516fe9f28543e04d31ca2c9bbcdba98f382af6152a48c6e59683b21fe49425450cb9c20d71ee2da5b2a03b7a518d3aa2a68265caaed1848
6
+ metadata.gz: 2daa503ec4b26ce5f50979394ca64de5a8b9be4fdb1c9df792ef5746abfcae38fd58613132bdb8de2336643844d8624e12aec70f1b703b5ad9f1dbb5416d8496
7
+ data.tar.gz: 8419279fb2c98a65d54b5103052ee54eb9dfc2a7570db1e29decfac10a635af820fbe2ca369664a3bc0585afb221ec8b92dfafd1130892fc066249f228debd5a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Scoreboards
6
+
7
+ - Add new module for getting the scores seen at the top of the AHL website
8
+ - Retrieve Scoreboards based on a passed in date range
9
+
10
+ ### Game
11
+
12
+ - Add postponed status to possible game statuses
13
+
3
14
  ## 0.3.0
4
15
 
5
16
  ### 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.1)
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/
@@ -103,11 +106,8 @@ PLATFORMS
103
106
  DEPENDENCIES
104
107
  ahl_scraper!
105
108
  byebug (~> 11.1.3)
106
- json (~> 2.5.1)
107
- nokogiri (~> 1.12.4)
108
109
  pry (~> 0.13.1)
109
110
  pry-byebug (~> 3.9.0)
110
- rake (~> 13.0.0)
111
111
  rspec (~> 3.0)
112
112
  rubocop (~> 0.89.0)
113
113
  rubocop-performance (~> 1.8.1)
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
@@ -344,6 +344,7 @@ 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[:details][:status] == "Postponed"
347
348
  # return "forfeited" if game is a forfeit, need to figure this out if it happens
348
349
 
349
350
  return "finished" if @raw_data[:details][:final] == "1"
@@ -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
@@ -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
@@ -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.1"
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jefftcraig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-11-07 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
@@ -41,6 +209,7 @@ files:
41
209
  - lib/ahl_scraper/fetchers/player_data_fetcher.rb
42
210
  - lib/ahl_scraper/fetchers/player_games/data_fetcher.rb
43
211
  - lib/ahl_scraper/fetchers/playoff_bracket_data_fetcher.rb
212
+ - lib/ahl_scraper/fetchers/scoreboards/data_fetcher.rb
44
213
  - lib/ahl_scraper/fetchers/season_data_fetcher.rb
45
214
  - lib/ahl_scraper/fetchers/season_end_date_fetcher.rb
46
215
  - lib/ahl_scraper/fetchers/season_game_ids_fetcher.rb
@@ -90,6 +259,8 @@ files:
90
259
  - lib/ahl_scraper/resources/playoff_brackets/series.rb
91
260
  - lib/ahl_scraper/resources/playoff_brackets/team.rb
92
261
  - lib/ahl_scraper/resources/roster_player.rb
262
+ - lib/ahl_scraper/resources/scoreboard.rb
263
+ - lib/ahl_scraper/resources/scoreboards/team.rb
93
264
  - lib/ahl_scraper/resources/season.rb
94
265
  - lib/ahl_scraper/resources/season_list_item.rb
95
266
  - lib/ahl_scraper/resources/seasons/team.rb
@@ -97,6 +268,7 @@ files:
97
268
  - lib/ahl_scraper/resources/team_game_list_item.rb
98
269
  - lib/ahl_scraper/resources/team_list_item.rb
99
270
  - lib/ahl_scraper/roster_players.rb
271
+ - lib/ahl_scraper/scoreboards.rb
100
272
  - lib/ahl_scraper/seasons.rb
101
273
  - lib/ahl_scraper/services/games/create_skaters_service.rb
102
274
  - lib/ahl_scraper/services/games/on_ice_statlines_service.rb