ahl_scraper 0.1.1 → 0.2.0

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: f6e565f0a3b14eb3c5d568b3012407bbcb3439dc4d1447938e6f4c2618ebf65f
4
- data.tar.gz: ff93eaf9c4ae5fd738f2445ab2644162411679a07b00912e5bde5a35a31079e5
3
+ metadata.gz: 878af541d3e623e6e74955e4edb4fcb713b1ea05b6c536eac092508fce031914
4
+ data.tar.gz: bf55cecdad52ef86b8a133ae920cbd1c40d0fd95beffe75a804f03e3163091bc
5
5
  SHA512:
6
- metadata.gz: 34b7c1208b927e5801670427ee12642e86d31ff078463ba188ff5a31e431b5c6e7ea65d9705371c7a87dc77a1b7f2b13e37992a156494e0e2b73372accc00b9d
7
- data.tar.gz: 48f9dfc8a50cc7dcf5cf7be3944eb965f14e34d3d991e65163a9f030894a29015bcab485214488178bce2a4bcccf904253d9c2b7132e1c8230cd8bec6974df88
6
+ metadata.gz: 7d0270faf84de38e464e30aebc1e8db595f2310b3bf2a950573c538acee01cf766b3e06b4293f3aacfe2db1177a4f08164bc610a13a6e4406ca3dac3351f69fa
7
+ data.tar.gz: e603bcb1f39ff49d68968a325aaa044d8287d9e0b40c1c72d9e61d79033d83d2cc03ca31717e28096516f9b05700922042a3679342a64b59c71ad9cdda5b6e24
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.2.0
4
+
5
+ ### RosterPlayers
6
+
7
+ - Changed `shoots` to `handedness` and fixed value so that goalies get a proper handedness
8
+
9
+ ### Players
10
+
11
+ - Merged `shoots` and `catches` into `handedness` attribute
12
+
13
+ ### Penalties
14
+
15
+ - Uses AHL id under the `id` attribute
16
+ - Add `penalty_shot` type
17
+ - Add `bench?` for bench related penalties
18
+ - Add `invalid?` for tagging broken penalties that can be skipped
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ahl_scraper (0.1.0)
4
+ ahl_scraper (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -111,4 +111,4 @@ DEPENDENCIES
111
111
  webmock (>= 3.8.0)
112
112
 
113
113
  BUNDLED WITH
114
- 2.1.4
114
+ 2.2.17
data/README.md CHANGED
@@ -136,7 +136,7 @@ Returns a `Player` object which has full details on a player by passing their id
136
136
  require "ahl_scraper"
137
137
  AhlScraper::Players.retrieve(6845)
138
138
 
139
- #=> #<Player:0x4b8c {:id=>6845, :current_age=>0.2534e2, :position=>"D", :first_name=>"Sebastian", :shoots=>"L", :last_name=>"Aho", :birthplace=>"Umea, Sweden", :height=>"5-11", :birthdate=>"1996-02-17", :draft_year=>2014, :weight=>177, :catches=>"R", :name=>"Sebastian Aho", :jersey_number=>28}>
139
+ #=> #<Player:0x4b8c {:id=>6845, :current_age=>0.2534e2, :position=>"D", :first_name=>"Sebastian", :handedness=>"L", :last_name=>"Aho", :birthplace=>"Umea, Sweden", :height=>"5-11", :birthdate=>"1996-02-17", :draft_year=>2014, :weight=>177, :name=>"Sebastian Aho", :jersey_number=>28}>
140
140
  ```
141
141
 
142
142
  ### Teams
@@ -182,9 +182,9 @@ Returns an array of `RosterPlayer` objects which provide information on all of a
182
182
  require "ahl_scraper"
183
183
  AhlScraper::RosterPlayers.retrieve_all(335, 68)
184
184
 
185
- #=> [#<RosterPlayer:0x3c3c {:id=>6379, :current_age=>0.2521e2, :season_id=>68, :position=>"C", :shoots=>"L", :birthplace=>"Saskatoon, SK", :birthdate=>"1996-04-03", :height=>"6-0", :draft_year=>2014, :weight=>203, :rookie?=>false, :team_id=>335, :name=>"Rourke Chartier", :jersey_number=>15}>,
186
- #<RosterPlayer:0x3c50 {:id=>1844, :current_age=>0.3416e2, :season_id=>68, :position=>"LW", :shoots=>"L", :birthplace=>"Toronto, ON", :birthdate=>"1987-04-25", :height=>"5-11", :draft_year=>2005, :weight=>207, :rookie?=>false, :team_id=>335, :name=>"Richard Clune", :jersey_number=>17}>,
187
- #<RosterPlayer:0x3c64 {:id=>5660, :current_age=>0.2914e2, :season_id=>68, :position=>"LW", :shoots=>"L", :birthplace=>"Morristown, NJ", :birthdate=>"1992-04-30", :height=>"6-0", :draft_year=>2010, :weight=>200, :rookie?=>false, :team_id=>335, :name=>"Kenny Agostino", :jersey_number=>18}>,
185
+ #=> [#<RosterPlayer:0x3c3c {:id=>6379, :current_age=>0.2521e2, :season_id=>68, :position=>"C", :handedness=>"L", :birthplace=>"Saskatoon, SK", :birthdate=>"1996-04-03", :height=>"6-0", :draft_year=>2014, :weight=>203, :rookie?=>false, :team_id=>335, :name=>"Rourke Chartier", :jersey_number=>15}>,
186
+ #<RosterPlayer:0x3c50 {:id=>1844, :current_age=>0.3416e2, :season_id=>68, :position=>"LW", :handedness=>"L", :birthplace=>"Toronto, ON", :birthdate=>"1987-04-25", :height=>"5-11", :draft_year=>2005, :weight=>207, :rookie?=>false, :team_id=>335, :name=>"Richard Clune", :jersey_number=>17}>,
187
+ #<RosterPlayer:0x3c64 {:id=>5660, :current_age=>0.2914e2, :season_id=>68, :position=>"LW", :handedness=>"L", :birthplace=>"Morristown, NJ", :birthdate=>"1992-04-30", :height=>"6-0", :draft_year=>2010, :weight=>200, :rookie?=>false, :team_id=>335, :name=>"Kenny Agostino", :jersey_number=>18}>,
188
188
  #...
189
189
  #]
190
190
  ```
@@ -3,12 +3,16 @@
3
3
  module AhlScraper
4
4
  module Games
5
5
  class Penalty < Resource
6
+ def id
7
+ @id ||= @raw_data.dig(:game_penalty_id)&.to_i
8
+ end
9
+
6
10
  def number
7
11
  @number ||= @opts[:number]
8
12
  end
9
13
 
10
14
  def period
11
- @period ||= @raw_data.dig(:period, :id).to_i
15
+ @period ||= @raw_data.dig(:period, :id)&.to_i
12
16
  end
13
17
 
14
18
  def time
@@ -70,12 +74,22 @@ module AhlScraper
70
74
  end
71
75
 
72
76
  def power_play?
73
- @power_play ||= @raw_data[:isPowerPlay]
77
+ @raw_data[:isPowerPlay]
78
+ end
79
+
80
+ def bench?
81
+ @raw_data[:isPowerPlay]
82
+ end
83
+
84
+ def invalid?
85
+ [240_773].include? id
74
86
  end
75
87
 
76
88
  def penalty_type
77
89
  @penalty_type ||=
78
90
  case @raw_data[:description]
91
+ when /penalty shot/i
92
+ :penalty_shot
79
93
  when /double minor/i
80
94
  :double_minor
81
95
  when /major/i
@@ -22,12 +22,8 @@ module AhlScraper
22
22
  @last_name ||= @raw_data.dig(:info, :lastName)
23
23
  end
24
24
 
25
- def shoots
26
- @shoots ||= @raw_data.dig(:info, :shoots)
27
- end
28
-
29
- def catches
30
- @catches ||= @raw_data.dig(:info, :catches)
25
+ def handedness
26
+ @handedness ||= position == "G" ? @raw_data.dig(:info, :catches) : @raw_data.dig(:info, :shoots)
31
27
  end
32
28
 
33
29
  def birthplace
@@ -18,8 +18,8 @@ module AhlScraper
18
18
  @name ||= @raw_data.dig(:bio, :row, :name)
19
19
  end
20
20
 
21
- def shoots
22
- @shoots ||= @raw_data.dig(:bio, :row, :shoots)
21
+ def handedness
22
+ @handedness ||= position == "G" ? @raw_data.dig(:bio, :row, :catches) : @raw_data.dig(:bio, :row, :shoots)
23
23
  end
24
24
 
25
25
  def birthplace
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AhlScraper
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jefftcraig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2021-07-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Allows users to gather game, season, and player data from the AHL website
14
14
  email:
@@ -24,6 +24,7 @@ files:
24
24
  - ".solargraph.yml"
25
25
  - ".travis.yml"
26
26
  - ".vscode/settings.json"
27
+ - CHANGELOG.md
27
28
  - CODE_OF_CONDUCT.md
28
29
  - Gemfile
29
30
  - Gemfile.lock