greenmonster 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/LICENSE.txt +21 -0
- data/README.markdown +11 -28
- data/Rakefile +3 -8
- data/doc/Gemfile.html +6 -24
- data/doc/Greenmonster/Spider.html +47 -258
- data/doc/Greenmonster.html +25 -86
- data/doc/Rakefile.html +10 -25
- data/doc/created.rid +12 -18
- data/doc/index.html +6 -24
- data/doc/js/search_index.js +1 -1
- data/doc/table_of_contents.html +12 -129
- data/greenmonster.gemspec +16 -13
- data/lib/greenmonster/day_spider.rb +61 -0
- data/lib/greenmonster/file_downloader.rb +38 -0
- data/lib/greenmonster/game_spider.rb +100 -0
- data/lib/greenmonster/innings_downloader.rb +41 -0
- data/lib/greenmonster/spider.rb +1 -0
- data/lib/greenmonster/version.rb +2 -2
- data/lib/greenmonster.rb +16 -82
- data/spec/cassettes/aaa/year_2015/month_05/day_09.yml +153 -0
- data/spec/cassettes/gid_2007_10_01_sdnmlb_colmlb_1/innings.yml +135 -0
- data/spec/cassettes/gid_2015_04_18_balmlb_bos_mlb_1/players_xml.yml +292 -0
- data/spec/cassettes/gid_2015_04_18_balmlb_bos_mlb_2/players_xml.yml +46 -0
- data/spec/cassettes/mlb/year_2015/month_04/day_18.yml +170 -0
- data/spec/day_spider_spec.rb +80 -0
- data/spec/file_downloader_spec.rb +51 -0
- data/spec/fixtures/aaa_players.xml +70 -0
- data/spec/fixtures/boxscore.xml +1147 -0
- data/spec/fixtures/inning_all.xml +1 -0
- data/spec/fixtures/inning_hit.xml +1 -0
- data/spec/fixtures/linescore.xml +131 -0
- data/spec/fixtures/players.xml +63 -0
- data/spec/game_spider_spec.rb +116 -0
- data/spec/greenmonster_spec.rb +22 -34
- data/spec/innings_downloader_spec.rb +44 -0
- data/spec/spec_helper.rb +13 -21
- data/spec/support/path_helpers.rb +21 -0
- data/spec/support/vcr.rb +11 -0
- metadata +91 -67
- data/doc/Athlete.html +0 -254
- data/doc/Greenmonster/Generators/InstallGenerator.html +0 -253
- data/doc/Greenmonster/Generators.html +0 -147
- data/doc/Greenmonster/Parser.html +0 -263
- data/doc/Greenmonster/Player.html +0 -236
- data/doc/GreenmonsterPlayerTest.html +0 -199
- data/doc/GreenmonsterSpiderTest.html +0 -668
- data/doc/GreenmonsterTest.html +0 -262
- data/doc/GreenmonsterTraversalTest.html +0 -376
- data/doc/InstallGreenmonster.html +0 -260
- data/doc/TestCreatePlayersFromGamedayXMLGame.html +0 -266
- data/doc/TestParsePlayersFromGamedayXMLFiles.html +0 -307
- data/spec/games/tst/year_2012/month_03/day_27/gid_2012_03_27_aaamlb_aabmlb_1/blank.txt +0 -0
- data/spec/games/tst/year_2012/month_03/day_27/gid_2012_03_27_aaamlb_aabmlb_1_bak/blank.txt +0 -0
- data/spec/games/tst/year_2012/month_03/day_27/not_2012_03_27_aaamlb_aabmlb_1/blank.txt +0 -0
- data/spec/greenmonster/spider_spec.rb +0 -85
@@ -0,0 +1 @@
|
|
1
|
+
<!--Copyright 2015 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt--><hitchart><hip des="Flyout" x="118.71" y="81.31" batter="457477" pitcher="453329" type="O" team="A" inning="1"/><hip des="Single" x="84.72" y="115.36" batter="456665" pitcher="453329" type="H" team="A" inning="1"/><hip des="Single" x="180.16" y="119.43" batter="430945" pitcher="453329" type="H" team="A" inning="1"/><hip des="Groundout" x="143.38" y="175.83" batter="517370" pitcher="453329" type="O" team="A" inning="1"/><hip des="Groundout" x="137.33" y="160.59" batter="456030" pitcher="501957" type="O" team="H" inning="1"/><hip des="Single" x="52.14" y="102.66" batter="120074" pitcher="501957" type="H" team="H" inning="1"/><hip des="Groundout" x="115.91" y="176.85" batter="592518" pitcher="453329" type="O" team="A" inning="2"/><hip des="Single" x="132.67" y="89.44" batter="475247" pitcher="453329" type="H" team="A" inning="2"/><hip des="Groundout" x="143.38" y="165.16" batter="465784" pitcher="453329" type="O" team="A" inning="2"/><hip des="Groundout" x="137.79" y="154.49" batter="434670" pitcher="501957" type="O" team="H" inning="2"/><hip des="Flyout" x="56.79" y="101.64" batter="467055" pitcher="501957" type="O" team="H" inning="2"/><hip des="Groundout" x="114.98" y="158.56" batter="435063" pitcher="501957" type="O" team="H" inning="2"/><hip des="Groundout" x="138.26" y="163.13" batter="457477" pitcher="453329" type="O" team="A" inning="3"/><hip des="Groundout" x="155.95" y="151.44" batter="537953" pitcher="501957" type="O" team="H" inning="3"/><hip des="Single" x="136.86" y="92.49" batter="571788" pitcher="501957" type="H" team="H" inning="3"/><hip des="Groundout" x="111.72" y="179.90" batter="456030" pitcher="501957" type="O" team="H" inning="3"/><hip des="Single" x="86.12" y="114.34" batter="430945" pitcher="453329" type="H" team="A" inning="4"/><hip des="Double" x="54.00" y="110.79" batter="517370" pitcher="453329" type="H" team="A" inning="4"/><hip des="Groundout" x="121.03" y="151.44" batter="592518" pitcher="453329" type="O" team="A" inning="4"/><hip des="Single" x="122.90" y="84.87" batter="543376" pitcher="453329" type="H" team="A" inning="4"/><hip des="Single" x="99.62" y="101.64" batter="475247" pitcher="453329" type="H" team="A" inning="4"/><hip des="Single" x="132.21" y="92.49" batter="465784" pitcher="453329" type="H" team="A" inning="4"/><hip des="Single" x="128.02" y="86.90" batter="120074" pitcher="501957" type="H" team="H" inning="4"/><hip des="Groundout" x="118.71" y="155.51" batter="467055" pitcher="501957" type="O" team="H" inning="4"/><hip des="Flyout" x="136.40" y="74.70" batter="435063" pitcher="501957" type="O" team="H" inning="4"/><hip des="Single" x="120.10" y="91.47" batter="448801" pitcher="453329" type="H" team="A" inning="5"/><hip des="Single" x="125.69" y="147.88" batter="430945" pitcher="453329" type="H" team="A" inning="5"/><hip des="Single" x="59.12" y="95.03" batter="517370" pitcher="453329" type="H" team="A" inning="5"/><hip des="Groundout" x="143.84" y="176.34" batter="592518" pitcher="453329" type="O" team="A" inning="5"/><hip des="Flyout" x="161.53" y="103.67" batter="593428" pitcher="501957" type="O" team="H" inning="5"/><hip des="Single" x="150.36" y="94.52" batter="571788" pitcher="501957" type="H" team="H" inning="5"/><hip des="Flyout" x="89.84" y="87.41" batter="465784" pitcher="453329" type="O" team="A" inning="6"/><hip des="Groundout" x="145.24" y="164.15" batter="457477" pitcher="453329" type="O" team="A" inning="6"/><hip des="Flyout" x="98.69" y="73.69" batter="456665" pitcher="453329" type="O" team="A" inning="6"/><hip des="Double" x="200.17" y="75.21" batter="120074" pitcher="501957" type="H" team="H" inning="6"/><hip des="Groundout" x="120.57" y="153.98" batter="434670" pitcher="501957" type="O" team="H" inning="6"/><hip des="Field Error" x="134.53" y="189.56" batter="467055" pitcher="501957" type="E" team="H" inning="6"/><hip des="Single" x="91.71" y="112.82" batter="435063" pitcher="501957" type="H" team="H" inning="6"/><hip des="Groundout" x="142.45" y="161.61" batter="537953" pitcher="542960" type="O" team="H" inning="6"/><hip des="Groundout" x="134.07" y="189.56" batter="430945" pitcher="468396" type="O" team="A" inning="7"/><hip des="Groundout" x="153.62" y="170.75" batter="517370" pitcher="468396" type="O" team="A" inning="7"/><hip des="Lineout" x="123.36" y="81.82" batter="593428" pitcher="542960" type="O" team="H" inning="7"/><hip des="Single" x="141.98" y="177.87" batter="571788" pitcher="542960" type="H" team="H" inning="7"/><hip des="Bunt Groundout" x="131.74" y="190.06" batter="543376" pitcher="460008" type="O" team="A" inning="8"/><hip des="Lineout" x="182.95" y="89.95" batter="475247" pitcher="460008" type="O" team="A" inning="8"/><hip des="Groundout" x="120.57" y="155.00" batter="465784" pitcher="460008" type="O" team="A" inning="8"/><hip des="Groundout" x="128.02" y="181.42" batter="434670" pitcher="503285" type="O" team="H" inning="8"/><hip des="Bunt Groundout" x="135.00" y="186.51" batter="457477" pitcher="543726" type="O" team="A" inning="9"/><hip des="Single" x="92.64" y="107.23" batter="456665" pitcher="543726" type="H" team="A" inning="9"/><hip des="Home Run" x="55.86" y="81.82" batter="448801" pitcher="543726" type="H" team="A" inning="9"/><hip des="Flyout" x="136.86" y="106.72" batter="430945" pitcher="543726" type="O" team="A" inning="9"/><hip des="Flyout" x="178.29" y="93.00" batter="517370" pitcher="543726" type="O" team="A" inning="9"/><hip des="Groundout" x="127.55" y="193.62" batter="435063" pitcher="502154" type="O" team="H" inning="9"/></hitchart>
|
@@ -0,0 +1,131 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><!--Copyright 2015 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt-->
|
2
|
+
<game id="2015/04/18/balmlb-bosmlb-1" venue="Fenway Park" game_pk="413807"
|
3
|
+
time="4:05"
|
4
|
+
time_date="2015/04/18 4:05"
|
5
|
+
time_date_aw_lg="2015/04/18 4:05"
|
6
|
+
time_date_hm_lg="2015/04/18 4:05"
|
7
|
+
time_zone="ET"
|
8
|
+
ampm="PM"
|
9
|
+
first_pitch_et=""
|
10
|
+
away_time="4:05"
|
11
|
+
away_time_zone="ET"
|
12
|
+
away_ampm="PM"
|
13
|
+
home_time="4:05"
|
14
|
+
home_time_zone="ET"
|
15
|
+
home_ampm="PM"
|
16
|
+
game_type="R"
|
17
|
+
tiebreaker_sw="N"
|
18
|
+
original_date="2015/04/18"
|
19
|
+
time_zone_aw_lg="-4"
|
20
|
+
time_zone_hm_lg="-4"
|
21
|
+
time_aw_lg="4:05"
|
22
|
+
aw_lg_ampm="PM"
|
23
|
+
tz_aw_lg_gen="ET"
|
24
|
+
time_hm_lg="4:05"
|
25
|
+
hm_lg_ampm="PM"
|
26
|
+
tz_hm_lg_gen="ET"
|
27
|
+
venue_id="3"
|
28
|
+
scheduled_innings="9"
|
29
|
+
away_name_abbrev="BAL"
|
30
|
+
home_name_abbrev="BOS"
|
31
|
+
away_code="bal"
|
32
|
+
away_file_code="bal"
|
33
|
+
away_team_id="110"
|
34
|
+
away_team_city="Baltimore"
|
35
|
+
away_team_name="Orioles"
|
36
|
+
away_division="E"
|
37
|
+
away_league_id="103"
|
38
|
+
away_sport_code="mlb"
|
39
|
+
home_code="bos"
|
40
|
+
home_file_code="bos"
|
41
|
+
home_team_id="111"
|
42
|
+
home_team_city="Boston"
|
43
|
+
home_team_name="Red Sox"
|
44
|
+
home_division="E"
|
45
|
+
home_league_id="103"
|
46
|
+
home_sport_code="mlb"
|
47
|
+
day="SAT"
|
48
|
+
gameday_sw="P"
|
49
|
+
double_header_sw="N"
|
50
|
+
game_nbr="1"
|
51
|
+
tbd_flag="N"
|
52
|
+
away_games_back="1.0"
|
53
|
+
home_games_back="-"
|
54
|
+
away_games_back_wildcard="-"
|
55
|
+
venue_w_chan_loc="USMA0046"
|
56
|
+
location="Boston"
|
57
|
+
gameday_link="2015_04_18_balmlb_bosmlb_1"
|
58
|
+
away_win="6"
|
59
|
+
away_loss="5"
|
60
|
+
home_win="7"
|
61
|
+
home_loss="4"
|
62
|
+
game_data_directory="/components/game/mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1"
|
63
|
+
league="AA"
|
64
|
+
top_inning="N"
|
65
|
+
inning_state=""
|
66
|
+
note=""
|
67
|
+
status="Final"
|
68
|
+
ind="F"
|
69
|
+
inning="9"
|
70
|
+
balls="0"
|
71
|
+
strikes="0"
|
72
|
+
outs="3"
|
73
|
+
away_team_runs="4"
|
74
|
+
home_team_runs="1"
|
75
|
+
away_team_hits="13"
|
76
|
+
home_team_hits="7"
|
77
|
+
away_team_errors="1"
|
78
|
+
home_team_errors="0"
|
79
|
+
wrapup_link="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=wrap&c_id=mlb"
|
80
|
+
home_preview_link="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=preview&c_id=mlb"
|
81
|
+
away_preview_link="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=preview&c_id=mlb"
|
82
|
+
preview="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=preview&c_id=mlb"
|
83
|
+
tv_station="NESN, FS1"
|
84
|
+
home_recap_link="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=recap&c_id=mlb"
|
85
|
+
away_recap_link="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=recap&c_id=mlb"
|
86
|
+
photos_link="/mlb/gameday/index.jsp?gid=2015_04_18_balmlb_bosmlb_1&mode=photos">
|
87
|
+
<linescore inning="1" home_inning_runs="0" away_inning_runs="0"/>
|
88
|
+
<linescore inning="2" home_inning_runs="0" away_inning_runs="0"/>
|
89
|
+
<linescore inning="3" home_inning_runs="0" away_inning_runs="0"/>
|
90
|
+
<linescore inning="4" home_inning_runs="0" away_inning_runs="2"/>
|
91
|
+
<linescore inning="5" home_inning_runs="0" away_inning_runs="0"/>
|
92
|
+
<linescore inning="6" home_inning_runs="1" away_inning_runs="0"/>
|
93
|
+
<linescore inning="7" home_inning_runs="0" away_inning_runs="0"/>
|
94
|
+
<linescore inning="8" home_inning_runs="0" away_inning_runs="0"/>
|
95
|
+
<linescore inning="9" home_inning_runs="0" away_inning_runs="2"/>
|
96
|
+
<winning_pitcher first_name="Chris" first="Chris" id="501957" last_name="Tillman" last="Tillman"
|
97
|
+
name_display_roster="Tillman"
|
98
|
+
wins="2"
|
99
|
+
losses="1"
|
100
|
+
era="5.52"
|
101
|
+
s_wins=""
|
102
|
+
s_losses=""
|
103
|
+
s_era=""/>
|
104
|
+
<losing_pitcher first_name="Clay" first="Clay" id="453329" last_name="Buchholz" last="Buchholz"
|
105
|
+
name_display_roster="Buchholz"
|
106
|
+
wins="1"
|
107
|
+
losses="2"
|
108
|
+
era="6.06"
|
109
|
+
s_wins=""
|
110
|
+
s_losses=""
|
111
|
+
s_era=""/>
|
112
|
+
<save_pitcher first_name="Zach" first="Zach" id="502154" last_name="Britton" last="Britton"
|
113
|
+
name_display_roster="Britton"
|
114
|
+
wins="0"
|
115
|
+
losses="0"
|
116
|
+
era="1.42"
|
117
|
+
s_wins=""
|
118
|
+
s_losses=""
|
119
|
+
s_era=""
|
120
|
+
saves="4"/>
|
121
|
+
<game_media>
|
122
|
+
<media type="game" calendar_event_id="14-413807-2015-04-18"
|
123
|
+
start="2015-04-18T16:05:00-0400"
|
124
|
+
title="BAL @ BOS"
|
125
|
+
has_mlbtv="true"
|
126
|
+
free="NO"
|
127
|
+
media_state="media_archive"
|
128
|
+
thumbnail="http://mediadownloads.mlb.com/mlbam/preview/balbos_413807_th_7_preview.jpg"/>
|
129
|
+
</game_media>
|
130
|
+
</game>
|
131
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<!--Copyright 2015 MLB Advanced Media, L.P. Use of any content on this page acknowledges agreement to the terms posted here http://gdx.mlb.com/components/copyright.txt--><game venue="Fenway Park" date="April 18, 2015">
|
2
|
+
<team type="away" id="BAL" name="Baltimore Orioles">
|
3
|
+
<player id="429666" first="J.J." last="Hardy" num="2" boxname="Hardy" rl="R" bats="R" position="SS" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0"/>
|
4
|
+
<player id="430321" first="Delmon" last="Young" num="27" boxname="Young, D" rl="R" bats="R" position="LF" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".333" hr="0" rbi="2"/>
|
5
|
+
<player id="430945" first="Adam" last="Jones" num="10" boxname="Jones, Ad" rl="R" bats="R" position="CF" current_position="CF" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="4" game_position="CF" avg=".389" hr="4" rbi="11"/>
|
6
|
+
<player id="434622" first="Ubaldo" last="Jimenez" num="31" boxname="Jimenez, U" rl="R" bats="R" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="1" losses="0" era="0.00"/>
|
7
|
+
<player id="446308" first="Matt" last="Wieters" num="32" boxname="Wieters" rl="R" bats="S" position="C" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0"/>
|
8
|
+
<player id="448801" first="Chris" last="Davis" num="19" boxname="Davis, C" rl="R" bats="L" position="1B" current_position="1B" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="3" game_position="1B" avg=".235" hr="1" rbi="5"/>
|
9
|
+
<player id="449079" first="Wesley" last="Wright" num="40" boxname="Wright, W" rl="L" bats="R" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="5.40"/>
|
10
|
+
<player id="451085" first="Brian" last="Matusz" num="17" boxname="Matusz" rl="L" bats="L" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="1" era="2.08"/>
|
11
|
+
<player id="456068" first="Miguel" last="Gonzalez" num="50" boxname="Gonzalez, M" rl="R" bats="R" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="1" losses="1" era="1.42"/>
|
12
|
+
<player id="456665" first="Steve" last="Pearce" num="28" boxname="Pearce" rl="R" bats="R" position="LF" current_position="1B" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="2" game_position="RF" avg=".143" hr="2" rbi="3"/>
|
13
|
+
<player id="457477" first="Alejandro" last="De Aza" num="12" boxname="De Aza" rl="L" bats="L" position="LF" current_position="LF" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="1" game_position="LF" avg=".282" hr="2" rbi="4"/>
|
14
|
+
<player id="465784" first="Everth" last="Cabrera" num="1" boxname="Cabrera, E" rl="R" bats="S" position="SS" current_position="SS" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="9" game_position="SS" avg=".276" hr="0" rbi="1"/>
|
15
|
+
<player id="475247" first="Ryan" last="Flaherty" num="3" boxname="Flaherty" rl="R" bats="L" position="3B" current_position="2B" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="8" game_position="2B" avg=".154" hr="1" rbi="1"/>
|
16
|
+
<player id="488984" first="Tommy" last="Hunter" num="29" boxname="Hunter, T" rl="R" bats="R" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="1" era="14.73"/>
|
17
|
+
<player id="501957" first="Chris" last="Tillman" num="30" boxname="Tillman" rl="R" bats="R" position="P" current_position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="0" game_position="P" avg=".000" hr="0" rbi="0" wins="1" losses="1" era="7.71"/>
|
18
|
+
<player id="501983" first="Travis" last="Snider" num="23" boxname="Snider" rl="L" bats="L" position="RF" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".321" hr="1" rbi="6"/>
|
19
|
+
<player id="502032" first="Bud" last="Norris" num="25" boxname="Norris" rl="R" bats="R" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="1" era="12.38"/>
|
20
|
+
<player id="502154" first="Zach" last="Britton" num="53" boxname="Britton" rl="L" bats="L" position="P" current_position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="1.69"/>
|
21
|
+
<player id="503285" first="Darren" last="O'Day" num="56" boxname="O'Day" rl="R" bats="R" position="P" current_position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="1.50"/>
|
22
|
+
<player id="517370" first="Jimmy" last="Paredes" num="38" boxname="Paredes" rl="R" bats="S" position="3B" current_position="DH" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="5" game_position="DH" avg=".000" hr="0" rbi="0"/>
|
23
|
+
<player id="518953" first="David" last="Lough" num="9" boxname="Lough" rl="L" bats="L" position="LF" current_position="RF" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0"/>
|
24
|
+
<player id="542960" first="Brad" last="Brach" num="35" boxname="Brach" rl="R" bats="R" position="P" current_position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="1" losses="0" era="6.75"/>
|
25
|
+
<player id="543376" first="Caleb" last="Joseph" num="36" boxname="Joseph" rl="R" bats="R" position="C" current_position="C" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="7" game_position="C" avg=".370" hr="1" rbi="3"/>
|
26
|
+
<player id="543432" first="Ryan" last="Lavarnway" num="34" boxname="Lavarnway" rl="R" bats="R" position="C" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".167" hr="0" rbi="0"/>
|
27
|
+
<player id="570731" first="Jonathan" last="Schoop" num="6" boxname="Schoop" rl="R" bats="R" position="2B" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".259" hr="3" rbi="7"/>
|
28
|
+
<player id="592329" first="Jason" last="Garcia" num="61" boxname="Garcia, Ja" rl="R" bats="R" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="2.45"/>
|
29
|
+
<player id="592332" first="Kevin" last="Gausman" num="39" boxname="Gausman" rl="R" bats="L" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="1" losses="0" era="9.00"/>
|
30
|
+
<player id="592518" first="Manny" last="Machado" num="13" boxname="Machado, M" rl="R" bats="R" position="3B" current_position="3B" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" bat_order="6" game_position="3B" avg=".143" hr="1" rbi="3"/>
|
31
|
+
<player id="612672" first="Wei-Yin" last="Chen" num="16" boxname="Chen, W" rl="L" bats="L" position="P" status="A" team_abbrev="BAL" team_id="110" parent_team_abbrev="BAL" parent_team_id="110" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="4.35"/>
|
32
|
+
<coach position="manager" first="Buck" last="Showalter" id="427469" num="26"/><coach position="hitting_coach" first="Scott" last="Coolbaugh" id="112635" num="47"/><coach position="assistant_hitting_coach" first="Einar" last="Diaz" id="113330" num="55"/><coach position="pitching_coach" first="Dave" last="Wallace" id="123855" num="37"/><coach position="first_base_coach" first="Wayne" last="Kirby" id="117114" num="24"/><coach position="third_base_coach" first="Bobby" last="Dickerson" id="433638" num="11"/><coach position="bench_coach" first="John" last="Russell" id="121571" num="77"/><coach position="bullpen_coach" first="Dom" last="Chiti" id="492826" num="54"/> </team>
|
33
|
+
<team type="home" id="BOS" name="Boston Red Sox">
|
34
|
+
<player id="120074" first="David" last="Ortiz" num="34" boxname="Ortiz, D" rl="L" bats="L" position="D" current_position="DH" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="3" game_position="DH" avg=".171" hr="2" rbi="3"/>
|
35
|
+
<player id="425664" first="Shane" last="Victorino" num="18" boxname="Victorino" rl="R" bats="R" position="RF" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".125" hr="0" rbi="2"/>
|
36
|
+
<player id="434670" first="Hanley" last="Ramirez" num="13" boxname="Ramirez, H" rl="R" bats="R" position="LF" current_position="LF" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="4" game_position="LF" avg=".256" hr="4" rbi="9"/>
|
37
|
+
<player id="435063" first="Mike" last="Napoli" num="12" boxname="Napoli" rl="R" bats="R" position="1B" current_position="1B" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="6" game_position="1B" avg=".118" hr="0" rbi="0"/>
|
38
|
+
<player id="444520" first="Craig" last="Breslow" num="32" boxname="Breslow" rl="L" bats="L" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="0.00"/>
|
39
|
+
<player id="452672" first="Ryan" last="Hanigan" num="10" boxname="Hanigan" rl="R" bats="R" position="C" current_position="C" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="9" game_position="C" avg=".136" hr="1" rbi="5"/>
|
40
|
+
<player id="453329" first="Clay" last="Buchholz" num="11" boxname="Buchholz" rl="R" bats="L" position="P" current_position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="0" game_position="P" avg=".000" hr="0" rbi="0" wins="1" losses="1" era="7.84"/>
|
41
|
+
<player id="456030" first="Dustin" last="Pedroia" num="15" boxname="Pedroia" rl="R" bats="R" position="2B" current_position="2B" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="2" game_position="2B" avg=".279" hr="3" rbi="6"/>
|
42
|
+
<player id="460008" first="Anthony" last="Varvaro" num="46" boxname="Varvaro" rl="R" bats="R" position="P" current_position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="1.69"/>
|
43
|
+
<player id="465629" first="Edward" last="Mujica" num="54" boxname="Mujica" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="1" losses="0" era="3.18"/>
|
44
|
+
<player id="467055" first="Pablo" last="Sandoval" num="48" boxname="Sandoval" rl="R" bats="S" position="3B" current_position="3B" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="5" game_position="3B" avg=".316" hr="0" rbi="3"/>
|
45
|
+
<player id="468396" first="Alexi" last="Ogando" num="41" boxname="Ogando" rl="R" bats="R" position="P" current_position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="6.75"/>
|
46
|
+
<player id="475416" first="Justin" last="Masterson" num="63" boxname="Masterson" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".667" hr="0" rbi="1" wins="1" losses="0" era="7.59"/>
|
47
|
+
<player id="489119" first="Wade" last="Miley" num="20" boxname="Miley" rl="L" bats="L" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="1" era="10.57"/>
|
48
|
+
<player id="493157" first="Koji" last="Uehara" num="19" boxname="Uehara" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="1" losses="0" era="0.00"/>
|
49
|
+
<player id="501800" first="Allen" last="Craig" num="5" boxname="Craig" rl="R" bats="R" position="RF" current_position="PH" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".083" hr="0" rbi="0"/>
|
50
|
+
<player id="506702" first="Sandy" last="Leon" num="3" boxname="Leon, S" rl="R" bats="S" position="C" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".273" hr="0" rbi="2"/>
|
51
|
+
<player id="519144" first="Rick" last="Porcello" num="22" boxname="Porcello" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="1" losses="1" era="3.86"/>
|
52
|
+
<player id="519443" first="Brandon" last="Workman" num="67" boxname="Workman" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="-"/>
|
53
|
+
<player id="523260" first="Joe" last="Kelly" num="56" boxname="Kelly, J" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="1" losses="0" era="2.13"/>
|
54
|
+
<player id="537953" first="Daniel" last="Nava" num="29" boxname="Nava" rl="L" bats="L" position="RF" current_position="RF" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="7" game_position="RF" avg=".313" hr="0" rbi="5"/>
|
55
|
+
<player id="543726" first="Robbie" last="Ross" num="28" boxname="Ross" rl="L" bats="L" position="P" current_position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="3.86"/>
|
56
|
+
<player id="543877" first="Christian" last="Vazquez" num="7" boxname="Vazquez" rl="R" bats="R" position="C" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0"/>
|
57
|
+
<player id="546276" first="Edwin" last="Escobar" num="51" boxname="Escobar, Ed" rl="L" bats="L" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="-"/>
|
58
|
+
<player id="547749" first="Junichi" last="Tazawa" num="36" boxname="Tazawa" rl="R" bats="R" position="P" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".000" hr="0" rbi="0" wins="0" losses="0" era="0.00"/>
|
59
|
+
<player id="571788" first="Brock" last="Holt" num="26" boxname="Holt, B" rl="R" bats="L" position="3B" current_position="CF" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="1" game_position="CF" avg=".533" hr="0" rbi="5"/>
|
60
|
+
<player id="593428" first="Xander" last="Bogaerts" num="2" boxname="Bogaerts" rl="R" bats="R" position="SS" current_position="SS" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" bat_order="8" game_position="SS" avg=".395" hr="0" rbi="8"/>
|
61
|
+
<player id="605141" first="Mookie" last="Betts" num="50" boxname="Betts" rl="R" bats="R" position="O" current_position="DH" status="A" team_abbrev="BOS" team_id="111" parent_team_abbrev="BOS" parent_team_id="111" avg=".209" hr="2" rbi="8"/>
|
62
|
+
<coach position="manager" first="John" last="Farrell" id="114023" num="53"/><coach position="hitting_coach" first="Chili" last="Davis" id="113099" num="44"/><coach position="assistant_hitting_coach" first="Victor" last="Rodriguez" id="121367" num="57"/><coach position="pitching_coach" first="Juan" last="Nieves" id="119797" num="47"/><coach position="first_base_coach" first="Arnie" last="Beyeler" id="492469" num="43"/><coach position="third_base_coach" first="Brian" last="Butterfield" id="427047" num="55"/><coach position="bench_coach" first="Torey" last="Lovullo" id="117950" num="17"/><coach position="bullpen_coach" first="Dana" last="LeVangie" id="427298" num="58"/> </team>
|
63
|
+
<umpires><umpire position="home" name="Jerry Meals" id="427339" first="Jerry" last="Meals"/><umpire position="first" name="Paul Emmel" id="427144" first="Paul" last="Emmel"/><umpire position="second" name="Andy Fletcher" id="427164" first="Andy" last="Fletcher"/><umpire position="third" name="Jordan Baker" id="490319" first="Jordan" last="Baker"/></umpires></game>
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Greenmonster::GameSpider do
|
4
|
+
let(:downloader) { spy("FileDownloader") }
|
5
|
+
let(:dummy_downloader) { spy("Another FileDownloader") }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow(Greenmonster::FileDownloader).to receive(:new) { dummy_downloader }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#pull" do
|
12
|
+
it "creates the necessary folders to save data" do
|
13
|
+
FileUtils.mkdir_p("/tmp/custom_location")
|
14
|
+
Greenmonster.set_local_data_location("/tmp/custom_location")
|
15
|
+
|
16
|
+
described_class.new(game_id: "gid_2015_04_18_balmlb_bosmlb_1").pull
|
17
|
+
|
18
|
+
expect(File.exists?(File.expand_path("/tmp/custom_location/games/mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1/inning", __FILE__))).
|
19
|
+
to be_truthy
|
20
|
+
|
21
|
+
Greenmonster.set_local_data_location("/tmp")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "downloads the inning_all.xml file" do
|
25
|
+
allow(Greenmonster::FileDownloader).to receive(:new).
|
26
|
+
with(
|
27
|
+
game_path: "mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1",
|
28
|
+
file_name: "inning/inning_all.xml"
|
29
|
+
) { downloader }
|
30
|
+
|
31
|
+
described_class.new(game_id: "gid_2015_04_18_balmlb_bosmlb_1").pull
|
32
|
+
|
33
|
+
expect(downloader).to have_received(:pull)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "downloads the per-inning inning_x.xml files if inning_all.xml does not exist (pre-2008)" do
|
37
|
+
allow(Greenmonster::InningsDownloader).to receive(:new).
|
38
|
+
with(
|
39
|
+
game_path:
|
40
|
+
"mlb/year_2007/month_10/day_01/gid_2007_10_01_colmlb_sdnmlb_1",
|
41
|
+
) { downloader }
|
42
|
+
|
43
|
+
described_class.new(game_id: "gid_2007_10_01_colmlb_sdnmlb_1").pull
|
44
|
+
|
45
|
+
expect(downloader).to have_received(:pull)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "downloads the inning_hit.xml file" do
|
49
|
+
allow(Greenmonster::FileDownloader).to receive(:new).
|
50
|
+
with(
|
51
|
+
game_path:
|
52
|
+
"mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1",
|
53
|
+
file_name: "inning/inning_hit.xml"
|
54
|
+
) { downloader }
|
55
|
+
|
56
|
+
described_class.new(game_id: "gid_2015_04_18_balmlb_bosmlb_1").pull
|
57
|
+
|
58
|
+
expect(downloader).to have_received(:pull)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "downloads the boxscore.xml file" do
|
62
|
+
allow(Greenmonster::FileDownloader).to receive(:new).
|
63
|
+
with(
|
64
|
+
game_path:
|
65
|
+
"mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1",
|
66
|
+
file_name: "boxscore.xml"
|
67
|
+
) { downloader }
|
68
|
+
|
69
|
+
described_class.new(game_id: "gid_2015_04_18_balmlb_bosmlb_1").pull
|
70
|
+
|
71
|
+
expect(downloader).to have_received(:pull)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "downloads the linescore.xml file" do
|
75
|
+
allow(Greenmonster::FileDownloader).to receive(:new).
|
76
|
+
with(
|
77
|
+
game_path:
|
78
|
+
"mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1",
|
79
|
+
file_name: "linescore.xml"
|
80
|
+
) { downloader }
|
81
|
+
|
82
|
+
described_class.new(game_id: "gid_2015_04_18_balmlb_bosmlb_1").pull
|
83
|
+
|
84
|
+
expect(downloader).to have_received(:pull)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "downloads the players.xml file" do
|
88
|
+
allow(Greenmonster::FileDownloader).to receive(:new).
|
89
|
+
with(
|
90
|
+
game_path:
|
91
|
+
"mlb/year_2015/month_04/day_18/gid_2015_04_18_balmlb_bosmlb_1",
|
92
|
+
file_name: "players.xml"
|
93
|
+
) { downloader }
|
94
|
+
|
95
|
+
described_class.new(game_id: "gid_2015_04_18_balmlb_bosmlb_1").pull
|
96
|
+
|
97
|
+
expect(downloader).to have_received(:pull)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "downloads files for sport codes outside of mlb" do
|
101
|
+
allow(Greenmonster::FileDownloader).to receive(:new).
|
102
|
+
with(
|
103
|
+
game_path:
|
104
|
+
"aaa/year_2015/month_05/day_08/gid_2015_05_08_albaaa_srcaaa_1",
|
105
|
+
file_name: "players.xml"
|
106
|
+
) { downloader }
|
107
|
+
|
108
|
+
described_class.new(
|
109
|
+
game_id: "gid_2015_05_08_albaaa_srcaaa_1",
|
110
|
+
sport_code: "aaa"
|
111
|
+
).pull
|
112
|
+
|
113
|
+
expect(downloader).to have_received(:pull)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/spec/greenmonster_spec.rb
CHANGED
@@ -1,45 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
describe Greenmonster do
|
4
|
-
|
5
|
-
|
6
|
-
Greenmonster.set_games_folder("spec/games")
|
3
|
+
RSpec.describe Greenmonster do
|
4
|
+
it "has a version number" do
|
5
|
+
expect(Greenmonster::VERSION).not_to be_nil
|
7
6
|
end
|
8
7
|
|
9
|
-
describe ".
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}.to yield_successive_args(
|
15
|
-
[Date.new(2012,1,1), {test: true}],
|
16
|
-
[Date.new(2012,1,2), {test: true}],
|
17
|
-
[Date.new(2012,1,3), {test: true}]
|
8
|
+
describe ".local_data_location" do
|
9
|
+
it "returns the local data location" do
|
10
|
+
Greenmonster.class_variable_set(
|
11
|
+
:@@local_data_location,
|
12
|
+
"/tmp/my_custom_location"
|
18
13
|
)
|
14
|
+
|
15
|
+
expect(Greenmonster.local_data_location).to eq("/tmp/my_custom_location")
|
19
16
|
end
|
20
|
-
end
|
21
17
|
|
22
|
-
|
18
|
+
it "raises an error if the data location isn't set" do
|
19
|
+
Greenmonster.class_variable_set(:@@local_data_location, nil)
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
Greenmonster.traverse_folders_for_date(
|
27
|
-
Date.new(2012,3,27), {sport_code: 'tst', other_arg: 1}, &m
|
28
|
-
)
|
29
|
-
}.to yield_successive_args(
|
30
|
-
["gid_2012_03_27_aaamlb_aabmlb_1", {sport_code: "tst", other_arg: 1}],
|
31
|
-
["gid_2012_03_27_bbbmlb_bbcmlb_1", {sport_code: "tst", other_arg: 1}]
|
32
|
-
)
|
21
|
+
expect { Greenmonster.local_data_location }.
|
22
|
+
to raise_error(Greenmonster::NoLocalDataLocationSet)
|
33
23
|
end
|
24
|
+
end
|
34
25
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
Date.new(1700,1,1), {sport_code: 'mlb'}
|
39
|
-
)
|
40
|
-
}.to_not raise_error
|
41
|
-
end
|
26
|
+
describe ".set_local_data_location" do
|
27
|
+
it "sets the local folder for saved game data" do
|
28
|
+
Greenmonster.set_local_data_location("/tmp/my_custom_location")
|
42
29
|
|
30
|
+
expect(Greenmonster.local_data_location).to eq("/tmp/my_custom_location")
|
31
|
+
end
|
43
32
|
end
|
44
|
-
|
45
|
-
end
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Greenmonster::InningsDownloader do
|
4
|
+
let(:downloader) { spy("FileDownloader") }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(Greenmonster::FileDownloader).to receive(:new) { downloader }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#pull" do
|
11
|
+
it "invokes a FileDownloader for each inning in the game" do
|
12
|
+
VCR.use_cassette "gid_2007_10_01_sdnmlb_colmlb_1/innings" do
|
13
|
+
described_class.new(
|
14
|
+
game_path:
|
15
|
+
"mlb/year_2007/month_10/day_01/gid_2007_10_01_sdnmlb_colmlb_1"
|
16
|
+
).pull
|
17
|
+
|
18
|
+
(1..13).each do |inning|
|
19
|
+
expect(Greenmonster::FileDownloader).to have_received(:new).with(
|
20
|
+
game_path:
|
21
|
+
"mlb/year_2007/month_10/day_01/gid_2007_10_01_sdnmlb_colmlb_1",
|
22
|
+
file_name: "inning/inning_#{inning}.xml"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
expect(downloader).to have_received(:pull).exactly(13).times
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does not attempt to download innings that don't exist" do
|
30
|
+
VCR.use_cassette "gid_2007_10_01_sdnmlb_colmlb_1/innings" do
|
31
|
+
described_class.new(
|
32
|
+
game_path:
|
33
|
+
"mlb/year_2007/month_10/day_01/gid_2007_10_01_sdnmlb_colmlb_1"
|
34
|
+
).pull
|
35
|
+
|
36
|
+
expect(Greenmonster::FileDownloader).not_to have_received(:new).with(
|
37
|
+
game_path:
|
38
|
+
"mlb/year_2007/month_10/day_01/gid_2007_10_01_sdnmlb_colmlb_1",
|
39
|
+
file_name: "inning/inning_14.xml"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,25 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
require 'rspec'
|
8
|
-
require 'rspec/autorun'
|
9
|
-
require 'greenmonster'
|
10
|
-
require 'mocha/api'
|
11
|
-
require 'bourne'
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
|
+
require "greenmonster"
|
3
|
+
|
4
|
+
Dir["./spec/support/**/*.rb"].each { |file| require file }
|
12
5
|
|
13
6
|
RSpec.configure do |config|
|
14
|
-
config.
|
15
|
-
config.run_all_when_everything_filtered = true
|
16
|
-
config.filter_run :focus
|
7
|
+
config.include GreenmonsterPathHelpers
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# --seed 1234
|
22
|
-
config.order = 'random'
|
9
|
+
config.before(:all) do
|
10
|
+
create_tmp_directory
|
11
|
+
end
|
23
12
|
|
24
|
-
config.
|
25
|
-
|
13
|
+
config.before(:each) do
|
14
|
+
remove_games_directory
|
15
|
+
Greenmonster.set_local_data_location(tmp_path)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GreenmonsterPathHelpers
|
2
|
+
def remove_games_directory
|
3
|
+
FileUtils.rm_rf(games_path)
|
4
|
+
end
|
5
|
+
|
6
|
+
def games_path
|
7
|
+
@games_path ||= Pathname.new("#{tmp_path}/games")
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_tmp_directory
|
11
|
+
FileUtils.mkdir_p(tmp_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def tmp_path
|
15
|
+
@tmp_path ||= Pathname.new("#{root_path}/tmp")
|
16
|
+
end
|
17
|
+
|
18
|
+
def root_path
|
19
|
+
File.expand_path("../../../", __FILE__)
|
20
|
+
end
|
21
|
+
end
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "webmock/rspec"
|
2
|
+
require "vcr"
|
3
|
+
|
4
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
5
|
+
|
6
|
+
VCR.configure do |c|
|
7
|
+
c.allow_http_connections_when_no_cassette = false
|
8
|
+
c.cassette_library_dir = "spec/cassettes"
|
9
|
+
c.configure_rspec_metadata!
|
10
|
+
c.hook_into :webmock
|
11
|
+
end
|