stattleship-ruby 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/examples/README.md +3 -1
- data/examples/at_bats.rb +25 -0
- data/examples/baseball_games.rb +2 -1
- data/examples/basketball_team_game_logs.rb +13 -6
- data/examples/line_ups.rb +21 -0
- data/examples/pitches.rb +26 -0
- data/lib/stattleship.rb +4 -0
- data/lib/stattleship/at_bats.rb +81 -0
- data/lib/stattleship/endpoint.rb +37 -0
- data/lib/stattleship/line_ups.rb +61 -0
- data/lib/stattleship/models.rb +4 -0
- data/lib/stattleship/models/at_bat.rb +51 -0
- data/lib/stattleship/models/line_up.rb +102 -0
- data/lib/stattleship/models/pitch.rb +369 -0
- data/lib/stattleship/models/player.rb +9 -1
- data/lib/stattleship/params.rb +4 -0
- data/lib/stattleship/params/at_bats_params.rb +23 -0
- data/lib/stattleship/params/line_ups_params.rb +18 -0
- data/lib/stattleship/params/pitches_params.rb +40 -0
- data/lib/stattleship/pitches.rb +70 -0
- data/lib/stattleship/validators.rb +14 -1
- data/lib/stattleship/validators/hit_location_validator.rb +9 -0
- data/lib/stattleship/validators/hit_type_validator.rb +9 -0
- data/lib/stattleship/validators/hitter_id_validator.rb +6 -0
- data/lib/stattleship/validators/inning_validator.rb +9 -0
- data/lib/stattleship/validators/lower_speed_validator.rb +9 -0
- data/lib/stattleship/validators/pitch_outcome_type_validator.rb +9 -0
- data/lib/stattleship/validators/pitch_type_validator.rb +9 -0
- data/lib/stattleship/validators/pitcher_id_validator.rb +6 -0
- data/lib/stattleship/validators/speed_and_over_validator.rb +9 -0
- data/lib/stattleship/validators/speed_and_under_validator.rb +9 -0
- data/lib/stattleship/validators/speed_validator.rb +10 -0
- data/lib/stattleship/validators/upper_speed_validator.rb +9 -0
- data/lib/stattleship/version.rb +1 -1
- metadata +26 -2
@@ -5,8 +5,16 @@ module Stattleship
|
|
5
5
|
active
|
6
6
|
end
|
7
7
|
|
8
|
+
def full_name
|
9
|
+
if name == ''
|
10
|
+
"#{first_name} #{last_name}"
|
11
|
+
else
|
12
|
+
name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
def label
|
9
|
-
"#{
|
17
|
+
"#{full_name} (#{position_abbreviation}) - #{team_nickname}"
|
10
18
|
end
|
11
19
|
|
12
20
|
def team_name
|
data/lib/stattleship/params.rb
CHANGED
@@ -96,6 +96,10 @@ require 'stattleship/params/football_total_team_stat_params'
|
|
96
96
|
require 'stattleship/params/hockey_total_team_stat_params'
|
97
97
|
require 'stattleship/params/baseball_total_team_stat_params'
|
98
98
|
|
99
|
+
require 'stattleship/params/at_bats_params'
|
100
|
+
require 'stattleship/params/line_ups_params'
|
101
|
+
require 'stattleship/params/pitches_params'
|
102
|
+
|
99
103
|
module Stattleship
|
100
104
|
module Params
|
101
105
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Stattleship
|
2
|
+
module Params
|
3
|
+
class AtBatsParams < Stattleship::Params::GameTimeParams
|
4
|
+
attr_accessor :hitter_id,
|
5
|
+
:inning,
|
6
|
+
:game_id,
|
7
|
+
:team_id,
|
8
|
+
:hitter_team_id,
|
9
|
+
:hit_location,
|
10
|
+
:hit_type
|
11
|
+
|
12
|
+
def params
|
13
|
+
super.merge('game_id' => game_id,
|
14
|
+
'hitter_id' => hitter_id,
|
15
|
+
'hitter_team_id' => hitter_team_id,
|
16
|
+
'inning' => inning,
|
17
|
+
'hit_location' => hit_location,
|
18
|
+
'hit_type' => hit_type,
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Stattleship
|
2
|
+
module Params
|
3
|
+
class LineUpsParams < Stattleship::Params::GameTimeParams
|
4
|
+
attr_accessor :inning,
|
5
|
+
:player_id,
|
6
|
+
:team_id,
|
7
|
+
:game_id
|
8
|
+
|
9
|
+
def params
|
10
|
+
super.merge('game_id' => game_id,
|
11
|
+
'team_id' => team_id,
|
12
|
+
'player_id' => player_id,
|
13
|
+
'inning' => inning,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Stattleship
|
2
|
+
module Params
|
3
|
+
class PitchesParams < Stattleship::Params::GameTimeParams
|
4
|
+
attr_accessor :hitter_id,
|
5
|
+
:pitch_outcome_type,
|
6
|
+
:pitcher_id,
|
7
|
+
:inning,
|
8
|
+
:game_id,
|
9
|
+
:team_id,
|
10
|
+
:hitter_team_id,
|
11
|
+
:lower_speed,
|
12
|
+
:upper_speed,
|
13
|
+
:speed,
|
14
|
+
:speed_and_over,
|
15
|
+
:speed_and_under,
|
16
|
+
:pitch_type,
|
17
|
+
:hit_location,
|
18
|
+
:hit_type
|
19
|
+
|
20
|
+
def params
|
21
|
+
super.merge('game_id' => game_id,
|
22
|
+
'hitter_id' => hitter_id,
|
23
|
+
'pitcher_id' => pitcher_id,
|
24
|
+
'team_id' => team_id,
|
25
|
+
'hitter_team_id' => hitter_team_id,
|
26
|
+
'inning' => inning,
|
27
|
+
'pitch_outcome_type' => pitch_outcome_type,
|
28
|
+
'lower_speed' => lower_speed,
|
29
|
+
'upper_speed' => upper_speed,
|
30
|
+
'speed' => speed,
|
31
|
+
'speed_and_over' => speed_and_over,
|
32
|
+
'speed_and_under' => speed_and_under,
|
33
|
+
'pitch_type' => pitch_type,
|
34
|
+
'hit_location' => hit_location,
|
35
|
+
'hit_type' => hit_type,
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Stattleship
|
2
|
+
class Pitches < Stattleship::Endpoint
|
3
|
+
PITCHES = 'baseball/mlb/pitches'.freeze
|
4
|
+
|
5
|
+
def self.fetch(params:)
|
6
|
+
super(path: PITCHES,
|
7
|
+
params: params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def populate
|
11
|
+
pitches.each do |model|
|
12
|
+
populate_games(model)
|
13
|
+
|
14
|
+
games.each do |game|
|
15
|
+
populate_game(game)
|
16
|
+
end
|
17
|
+
|
18
|
+
populate_pitchers(model)
|
19
|
+
populate_hitters(model)
|
20
|
+
populate_teams(model)
|
21
|
+
populate_hitter_teams(model)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module PitchesRepresenter
|
27
|
+
include Roar::JSON
|
28
|
+
include Stattleship::Models
|
29
|
+
|
30
|
+
collection :away_teams, extend: TeamRepresenter,
|
31
|
+
class: Team
|
32
|
+
|
33
|
+
collection :hitters, extend: PlayerRepresenter,
|
34
|
+
class: Player
|
35
|
+
|
36
|
+
collection :hitter_teams, extend: TeamRepresenter,
|
37
|
+
class: Team
|
38
|
+
|
39
|
+
collection :home_teams, extend: TeamRepresenter,
|
40
|
+
class: Team
|
41
|
+
|
42
|
+
collection :pitchers, extend: PlayerRepresenter,
|
43
|
+
class: Player
|
44
|
+
|
45
|
+
collection :winning_teams, extend: TeamRepresenter,
|
46
|
+
class: Team
|
47
|
+
|
48
|
+
collection :games, extend: GameRepresenter,
|
49
|
+
class: Game
|
50
|
+
|
51
|
+
collection :leagues, extend: LeagueRepresenter,
|
52
|
+
class: League
|
53
|
+
|
54
|
+
collection :officials, extend: OfficialRepresenter,
|
55
|
+
class: Official
|
56
|
+
|
57
|
+
collection :seasons, extend: SeasonRepresenter,
|
58
|
+
class: Season
|
59
|
+
|
60
|
+
collection :venues, extend: VenueRepresenter,
|
61
|
+
class: Venue
|
62
|
+
|
63
|
+
|
64
|
+
collection :teams, extend: TeamRepresenter,
|
65
|
+
class: Team
|
66
|
+
|
67
|
+
collection :pitches, extend: PitchRepresenter,
|
68
|
+
class: Pitch
|
69
|
+
end
|
70
|
+
end
|
@@ -3,6 +3,7 @@ require 'stattleship/validators/birth_date_validator'
|
|
3
3
|
require 'stattleship/validators/current_validator'
|
4
4
|
require 'stattleship/validators/feat_validator'
|
5
5
|
require 'stattleship/validators/game_id_validator'
|
6
|
+
require 'stattleship/validators/inning_validator'
|
6
7
|
require 'stattleship/validators/interval_type_validator'
|
7
8
|
require 'stattleship/validators/level_up_validator'
|
8
9
|
require 'stattleship/validators/level_validator'
|
@@ -11,8 +12,8 @@ require 'stattleship/validators/outcome_validator'
|
|
11
12
|
require 'stattleship/validators/page_validator'
|
12
13
|
require 'stattleship/validators/penalty_validator'
|
13
14
|
require 'stattleship/validators/per_page_validator'
|
14
|
-
require 'stattleship/validators/place_validator'
|
15
15
|
require 'stattleship/validators/player_id_validator'
|
16
|
+
require 'stattleship/validators/place_validator'
|
16
17
|
require 'stattleship/validators/rank_validator'
|
17
18
|
require 'stattleship/validators/ranked_validator'
|
18
19
|
require 'stattleship/validators/ranking_validator'
|
@@ -27,6 +28,18 @@ require 'stattleship/validators/team_id_validator'
|
|
27
28
|
require 'stattleship/validators/type_validator'
|
28
29
|
require 'stattleship/validators/week_validator'
|
29
30
|
|
31
|
+
require 'stattleship/validators/pitch_outcome_type_validator'
|
32
|
+
require 'stattleship/validators/pitcher_id_validator'
|
33
|
+
require 'stattleship/validators/hit_location_validator'
|
34
|
+
require 'stattleship/validators/hit_type_validator'
|
35
|
+
require 'stattleship/validators/hitter_id_validator'
|
36
|
+
require 'stattleship/validators/lower_speed_validator'
|
37
|
+
require 'stattleship/validators/pitch_type_validator'
|
38
|
+
require 'stattleship/validators/speed_validator'
|
39
|
+
require 'stattleship/validators/upper_speed_validator'
|
40
|
+
require 'stattleship/validators/speed_and_over_validator'
|
41
|
+
require 'stattleship/validators/speed_and_under_validator'
|
42
|
+
|
30
43
|
module Stattleship
|
31
44
|
module Validators
|
32
45
|
end
|
data/lib/stattleship/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stattleship-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stattleship
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- bin/total_player_stat
|
237
237
|
- bin/total_team_stat
|
238
238
|
- examples/README.md
|
239
|
+
- examples/at_bats.rb
|
239
240
|
- examples/baseball_feats.rb
|
240
241
|
- examples/baseball_games.rb
|
241
242
|
- examples/baseball_player_game_logs.rb
|
@@ -261,8 +262,11 @@ files:
|
|
261
262
|
- examples/hockey_team_ranked_streaks.rb
|
262
263
|
- examples/hockey_teams.rb
|
263
264
|
- examples/hockey_total_team_stat.rb
|
265
|
+
- examples/line_ups.rb
|
266
|
+
- examples/pitches.rb
|
264
267
|
- examples/sample.env
|
265
268
|
- lib/stattleship.rb
|
269
|
+
- lib/stattleship/at_bats.rb
|
266
270
|
- lib/stattleship/baseball_feats.rb
|
267
271
|
- lib/stattleship/baseball_game_logs.rb
|
268
272
|
- lib/stattleship/baseball_games.rb
|
@@ -331,12 +335,16 @@ files:
|
|
331
335
|
- lib/stattleship/hockey_total_player_stat.rb
|
332
336
|
- lib/stattleship/hockey_total_team_stat.rb
|
333
337
|
- lib/stattleship/injuries.rb
|
338
|
+
- lib/stattleship/line_ups.rb
|
334
339
|
- lib/stattleship/models.rb
|
340
|
+
- lib/stattleship/models/at_bat.rb
|
335
341
|
- lib/stattleship/models/game.rb
|
336
342
|
- lib/stattleship/models/injury.rb
|
337
343
|
- lib/stattleship/models/league.rb
|
344
|
+
- lib/stattleship/models/line_up.rb
|
338
345
|
- lib/stattleship/models/official.rb
|
339
346
|
- lib/stattleship/models/penalty.rb
|
347
|
+
- lib/stattleship/models/pitch.rb
|
340
348
|
- lib/stattleship/models/player.rb
|
341
349
|
- lib/stattleship/models/playing_position.rb
|
342
350
|
- lib/stattleship/models/ranking.rb
|
@@ -347,6 +355,7 @@ files:
|
|
347
355
|
- lib/stattleship/models/team_outcome_streak.rb
|
348
356
|
- lib/stattleship/models/venue.rb
|
349
357
|
- lib/stattleship/params.rb
|
358
|
+
- lib/stattleship/params/at_bats_params.rb
|
350
359
|
- lib/stattleship/params/baseball_feats_params.rb
|
351
360
|
- lib/stattleship/params/baseball_game_logs_params.rb
|
352
361
|
- lib/stattleship/params/baseball_games_params.rb
|
@@ -416,7 +425,9 @@ files:
|
|
416
425
|
- lib/stattleship/params/hockey_total_player_stat_params.rb
|
417
426
|
- lib/stattleship/params/hockey_total_team_stat_params.rb
|
418
427
|
- lib/stattleship/params/injuries_params.rb
|
428
|
+
- lib/stattleship/params/line_ups_params.rb
|
419
429
|
- lib/stattleship/params/penalties_params.rb
|
430
|
+
- lib/stattleship/params/pitches_params.rb
|
420
431
|
- lib/stattleship/params/players_params.rb
|
421
432
|
- lib/stattleship/params/query_params.rb
|
422
433
|
- lib/stattleship/params/rankings_params.rb
|
@@ -430,6 +441,7 @@ files:
|
|
430
441
|
- lib/stattleship/params/total_player_stat_params.rb
|
431
442
|
- lib/stattleship/params/total_team_stat_params.rb
|
432
443
|
- lib/stattleship/penalties.rb
|
444
|
+
- lib/stattleship/pitches.rb
|
433
445
|
- lib/stattleship/players.rb
|
434
446
|
- lib/stattleship/rankings.rb
|
435
447
|
- lib/stattleship/scoring_plays.rb
|
@@ -447,14 +459,22 @@ files:
|
|
447
459
|
- lib/stattleship/validators/current_validator.rb
|
448
460
|
- lib/stattleship/validators/feat_validator.rb
|
449
461
|
- lib/stattleship/validators/game_id_validator.rb
|
462
|
+
- lib/stattleship/validators/hit_location_validator.rb
|
463
|
+
- lib/stattleship/validators/hit_type_validator.rb
|
464
|
+
- lib/stattleship/validators/hitter_id_validator.rb
|
465
|
+
- lib/stattleship/validators/inning_validator.rb
|
450
466
|
- lib/stattleship/validators/interval_type_validator.rb
|
451
467
|
- lib/stattleship/validators/level_up_validator.rb
|
452
468
|
- lib/stattleship/validators/level_validator.rb
|
469
|
+
- lib/stattleship/validators/lower_speed_validator.rb
|
453
470
|
- lib/stattleship/validators/on_validator.rb
|
454
471
|
- lib/stattleship/validators/outcome_validator.rb
|
455
472
|
- lib/stattleship/validators/page_validator.rb
|
456
473
|
- lib/stattleship/validators/penalty_validator.rb
|
457
474
|
- lib/stattleship/validators/per_page_validator.rb
|
475
|
+
- lib/stattleship/validators/pitch_outcome_type_validator.rb
|
476
|
+
- lib/stattleship/validators/pitch_type_validator.rb
|
477
|
+
- lib/stattleship/validators/pitcher_id_validator.rb
|
458
478
|
- lib/stattleship/validators/place_validator.rb
|
459
479
|
- lib/stattleship/validators/player_id_validator.rb
|
460
480
|
- lib/stattleship/validators/rank_validator.rb
|
@@ -464,11 +484,15 @@ files:
|
|
464
484
|
- lib/stattleship/validators/scoring_type_validator.rb
|
465
485
|
- lib/stattleship/validators/season_id_validator.rb
|
466
486
|
- lib/stattleship/validators/since_validator.rb
|
487
|
+
- lib/stattleship/validators/speed_and_over_validator.rb
|
488
|
+
- lib/stattleship/validators/speed_and_under_validator.rb
|
489
|
+
- lib/stattleship/validators/speed_validator.rb
|
467
490
|
- lib/stattleship/validators/stat_validator.rb
|
468
491
|
- lib/stattleship/validators/status_validator.rb
|
469
492
|
- lib/stattleship/validators/streak_length_validator.rb
|
470
493
|
- lib/stattleship/validators/team_id_validator.rb
|
471
494
|
- lib/stattleship/validators/type_validator.rb
|
495
|
+
- lib/stattleship/validators/upper_speed_validator.rb
|
472
496
|
- lib/stattleship/validators/week_validator.rb
|
473
497
|
- lib/stattleship/version.rb
|
474
498
|
- sample.env
|