greenmonster 0.5.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,307 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
-
|
7
|
-
<title>class TestParsePlayersFromGamedayXMLFiles - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
-
|
11
|
-
<script type="text/javascript">
|
12
|
-
var rdoc_rel_prefix = "./";
|
13
|
-
</script>
|
14
|
-
|
15
|
-
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
-
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
-
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
-
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
-
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
-
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
-
|
22
|
-
|
23
|
-
<body id="top" class="class">
|
24
|
-
<nav id="metadata">
|
25
|
-
<nav id="home-section" class="section">
|
26
|
-
<h3 class="section-header">
|
27
|
-
<a href="./index.html">Home</a>
|
28
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
29
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
30
|
-
</h3>
|
31
|
-
</nav>
|
32
|
-
|
33
|
-
|
34
|
-
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
-
<form action="#" method="get" accept-charset="utf-8">
|
36
|
-
<h3 class="section-header">
|
37
|
-
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
-
</h3>
|
40
|
-
</form>
|
41
|
-
|
42
|
-
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
-
</nav>
|
44
|
-
|
45
|
-
|
46
|
-
<div id="file-metadata">
|
47
|
-
<nav id="file-list-section" class="section">
|
48
|
-
<h3 class="section-header">Defined In</h3>
|
49
|
-
<ul>
|
50
|
-
<li>test/test_parse_players_from_gameday_xml_files.rb
|
51
|
-
</ul>
|
52
|
-
</nav>
|
53
|
-
|
54
|
-
|
55
|
-
</div>
|
56
|
-
|
57
|
-
<div id="class-metadata">
|
58
|
-
|
59
|
-
<nav id="parent-class-section" class="section">
|
60
|
-
<h3 class="section-header">Parent</h3>
|
61
|
-
|
62
|
-
<p class="link">MiniTest::Unit::TestCase
|
63
|
-
|
64
|
-
</nav>
|
65
|
-
|
66
|
-
|
67
|
-
<!-- Method Quickref -->
|
68
|
-
<nav id="method-list-section" class="section">
|
69
|
-
<h3 class="section-header">Methods</h3>
|
70
|
-
|
71
|
-
<ul class="link-list">
|
72
|
-
|
73
|
-
<li><a href="#method-i-setup">#setup</a>
|
74
|
-
|
75
|
-
<li><a href="#method-i-teardown">#teardown</a>
|
76
|
-
|
77
|
-
<li><a href="#method-i-test_parse_players_from_game">#test_parse_players_from_game</a>
|
78
|
-
|
79
|
-
<li><a href="#method-i-test_player_ids_stored_as_integers">#test_player_ids_stored_as_integers</a>
|
80
|
-
|
81
|
-
</ul>
|
82
|
-
</nav>
|
83
|
-
|
84
|
-
</div>
|
85
|
-
|
86
|
-
<div id="project-metadata">
|
87
|
-
<nav id="fileindex-section" class="section project-section">
|
88
|
-
<h3 class="section-header">Pages</h3>
|
89
|
-
|
90
|
-
<ul>
|
91
|
-
|
92
|
-
<li class="file"><a href="./Gemfile.html">Gemfile</a>
|
93
|
-
|
94
|
-
<li class="file"><a href="./Rakefile.html">Rakefile</a>
|
95
|
-
|
96
|
-
</ul>
|
97
|
-
</nav>
|
98
|
-
|
99
|
-
<nav id="classindex-section" class="section project-section">
|
100
|
-
<h3 class="section-header">Class and Module Index</h3>
|
101
|
-
|
102
|
-
<ul class="link-list">
|
103
|
-
|
104
|
-
<li><a href="./Greenmonster.html">Greenmonster</a>
|
105
|
-
|
106
|
-
<li><a href="./Greenmonster/Generators.html">Greenmonster::Generators</a>
|
107
|
-
|
108
|
-
<li><a href="./Greenmonster/Generators/InstallGenerator.html">Greenmonster::Generators::InstallGenerator</a>
|
109
|
-
|
110
|
-
<li><a href="./Greenmonster/Parser.html">Greenmonster::Parser</a>
|
111
|
-
|
112
|
-
<li><a href="./Greenmonster/Player.html">Greenmonster::Player</a>
|
113
|
-
|
114
|
-
<li><a href="./Greenmonster/Spider.html">Greenmonster::Spider</a>
|
115
|
-
|
116
|
-
<li><a href="./Athlete.html">Athlete</a>
|
117
|
-
|
118
|
-
<li><a href="./GreenmonsterPlayerTest.html">GreenmonsterPlayerTest</a>
|
119
|
-
|
120
|
-
<li><a href="./GreenmonsterSpiderTest.html">GreenmonsterSpiderTest</a>
|
121
|
-
|
122
|
-
<li><a href="./GreenmonsterTest.html">GreenmonsterTest</a>
|
123
|
-
|
124
|
-
<li><a href="./GreenmonsterTraversalTest.html">GreenmonsterTraversalTest</a>
|
125
|
-
|
126
|
-
<li><a href="./InstallGreenmonster.html">InstallGreenmonster</a>
|
127
|
-
|
128
|
-
<li><a href="./TestCreatePlayersFromGamedayXMLGame.html">TestCreatePlayersFromGamedayXMLGame</a>
|
129
|
-
|
130
|
-
<li><a href="./TestParsePlayersFromGamedayXMLFiles.html">TestParsePlayersFromGamedayXMLFiles</a>
|
131
|
-
|
132
|
-
</ul>
|
133
|
-
</nav>
|
134
|
-
|
135
|
-
</div>
|
136
|
-
</nav>
|
137
|
-
|
138
|
-
<div id="documentation">
|
139
|
-
<h1 class="class">class TestParsePlayersFromGamedayXMLFiles</h1>
|
140
|
-
|
141
|
-
<div id="description" class="description">
|
142
|
-
|
143
|
-
</div><!-- description -->
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
<!-- Methods -->
|
158
|
-
|
159
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
160
|
-
<h3 class="section-header">Public Instance Methods</h3>
|
161
|
-
|
162
|
-
|
163
|
-
<div id="method-i-setup" class="method-detail ">
|
164
|
-
|
165
|
-
<div class="method-heading">
|
166
|
-
<span class="method-name">setup</span><span
|
167
|
-
class="method-args">()</span>
|
168
|
-
<span class="method-click-advice">click to toggle source</span>
|
169
|
-
</div>
|
170
|
-
|
171
|
-
|
172
|
-
<div class="method-description">
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
<div class="method-source-code" id="setup-source">
|
179
|
-
<pre><span class="ruby-comment"># File test/test_parse_players_from_gameday_xml_files.rb, line 6</span>
|
180
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">setup</span>
|
181
|
-
<span class="ruby-constant">Greenmonster</span>.<span class="ruby-identifier">set_games_folder</span>(<span class="ruby-string">'./greenmonster_test_games'</span>)
|
182
|
-
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span> <span class="ruby-constant">Greenmonster</span>.<span class="ruby-identifier">games_folder</span>
|
183
|
-
<span class="ruby-constant">Greenmonster</span><span class="ruby-operator">::</span><span class="ruby-constant">Spider</span>.<span class="ruby-identifier">pull_game</span>(<span class="ruby-string">'gid_2011_07_04_tormlb_bosmlb_1'</span>, {<span class="ruby-value">:print_games</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">false</span>})
|
184
|
-
<span class="ruby-keyword">end</span></pre>
|
185
|
-
</div><!-- setup-source -->
|
186
|
-
|
187
|
-
</div>
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
</div><!-- setup-method -->
|
193
|
-
|
194
|
-
|
195
|
-
<div id="method-i-teardown" class="method-detail ">
|
196
|
-
|
197
|
-
<div class="method-heading">
|
198
|
-
<span class="method-name">teardown</span><span
|
199
|
-
class="method-args">()</span>
|
200
|
-
<span class="method-click-advice">click to toggle source</span>
|
201
|
-
</div>
|
202
|
-
|
203
|
-
|
204
|
-
<div class="method-description">
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
<div class="method-source-code" id="teardown-source">
|
211
|
-
<pre><span class="ruby-comment"># File test/test_parse_players_from_gameday_xml_files.rb, line 30</span>
|
212
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">teardown</span>
|
213
|
-
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">remove_dir</span> <span class="ruby-constant">Greenmonster</span>.<span class="ruby-identifier">games_folder</span>
|
214
|
-
<span class="ruby-keyword">end</span></pre>
|
215
|
-
</div><!-- teardown-source -->
|
216
|
-
|
217
|
-
</div>
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
</div><!-- teardown-method -->
|
223
|
-
|
224
|
-
|
225
|
-
<div id="method-i-test_parse_players_from_game" class="method-detail ">
|
226
|
-
|
227
|
-
<div class="method-heading">
|
228
|
-
<span class="method-name">test_parse_players_from_game</span><span
|
229
|
-
class="method-args">()</span>
|
230
|
-
<span class="method-click-advice">click to toggle source</span>
|
231
|
-
</div>
|
232
|
-
|
233
|
-
|
234
|
-
<div class="method-description">
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
<div class="method-source-code" id="test_parse_players_from_game-source">
|
241
|
-
<pre><span class="ruby-comment"># File test/test_parse_players_from_gameday_xml_files.rb, line 12</span>
|
242
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_parse_players_from_game</span>
|
243
|
-
<span class="ruby-identifier">players</span> = []
|
244
|
-
<span class="ruby-constant">Greenmonster</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">extract_players_from_game</span>(<span class="ruby-string">'gid_2011_07_04_tormlb_bosmlb_1'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
|
245
|
-
<span class="ruby-identifier">players</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">p</span>
|
246
|
-
<span class="ruby-keyword">end</span>
|
247
|
-
<span class="ruby-identifier">players</span>.<span class="ruby-identifier">sort!</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>[<span class="ruby-value">:id</span>] <span class="ruby-operator"><=></span> <span class="ruby-identifier">y</span>[<span class="ruby-value">:id</span>]}
|
248
|
-
|
249
|
-
<span class="ruby-identifier">assert_equal</span> <span class="ruby-value">50</span>, <span class="ruby-identifier">players</span>.<span class="ruby-identifier">count</span>
|
250
|
-
<span class="ruby-keyword">end</span></pre>
|
251
|
-
</div><!-- test_parse_players_from_game-source -->
|
252
|
-
|
253
|
-
</div>
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
</div><!-- test_parse_players_from_game-method -->
|
259
|
-
|
260
|
-
|
261
|
-
<div id="method-i-test_player_ids_stored_as_integers" class="method-detail ">
|
262
|
-
|
263
|
-
<div class="method-heading">
|
264
|
-
<span class="method-name">test_player_ids_stored_as_integers</span><span
|
265
|
-
class="method-args">()</span>
|
266
|
-
<span class="method-click-advice">click to toggle source</span>
|
267
|
-
</div>
|
268
|
-
|
269
|
-
|
270
|
-
<div class="method-description">
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
<div class="method-source-code" id="test_player_ids_stored_as_integers-source">
|
277
|
-
<pre><span class="ruby-comment"># File test/test_parse_players_from_gameday_xml_files.rb, line 22</span>
|
278
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test_player_ids_stored_as_integers</span>
|
279
|
-
<span class="ruby-identifier">players</span> = []
|
280
|
-
<span class="ruby-constant">Greenmonster</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">extract_players_from_game</span>(<span class="ruby-string">'gid_2011_07_04_tormlb_bosmlb_1'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
|
281
|
-
<span class="ruby-identifier">players</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">p</span>
|
282
|
-
<span class="ruby-keyword">end</span>
|
283
|
-
<span class="ruby-identifier">assert</span> <span class="ruby-identifier">players</span>.<span class="ruby-identifier">first</span>[<span class="ruby-value">:id</span>].<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>
|
284
|
-
<span class="ruby-keyword">end</span></pre>
|
285
|
-
</div><!-- test_player_ids_stored_as_integers-source -->
|
286
|
-
|
287
|
-
</div>
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
</div><!-- test_player_ids_stored_as_integers-method -->
|
293
|
-
|
294
|
-
|
295
|
-
</section><!-- public-instance-method-details -->
|
296
|
-
|
297
|
-
</section><!-- 5Buntitled-5D -->
|
298
|
-
|
299
|
-
</div><!-- documentation -->
|
300
|
-
|
301
|
-
|
302
|
-
<footer id="validator-badges">
|
303
|
-
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
304
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
305
|
-
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
306
|
-
</footer>
|
307
|
-
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Greenmonster::Spider do
|
4
|
-
before(:all) do
|
5
|
-
FileUtils.rm_r('spec/games/mlb')
|
6
|
-
Greenmonster.set_games_folder('spec/games')
|
7
|
-
@spider = Greenmonster::Spider.new
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#pull_days" do
|
11
|
-
it "calls #pull_day for each date in the supplied range" do
|
12
|
-
@spider.stubs(pull_day: nil)
|
13
|
-
|
14
|
-
@spider.pull_days(Date.new(2012,1,1)..Date.new(2012,1,3), {arg: 123})
|
15
|
-
|
16
|
-
@spider.should have_received(:pull_day).with(Date.new(2012,1,1), {arg: 123})
|
17
|
-
@spider.should have_received(:pull_day).with(Date.new(2012,1,2), {arg: 123})
|
18
|
-
@spider.should have_received(:pull_day).with(Date.new(2012,1,3), {arg: 123})
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#pull_day" do
|
23
|
-
before(:each) do
|
24
|
-
@spider.stubs(
|
25
|
-
game_links_on_gameday_date_page: ['gid_2012_03_27_aaamlb_aabmlb_1', 'gid_2012_03_27_bbbmlb_bbcmlb_1'],
|
26
|
-
pull_game: true
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "calls #game_links_on_gameday_date_page with the date and sport code" do
|
31
|
-
@spider.pull_day(Date.new(2012,3,27), 'mlb')
|
32
|
-
|
33
|
-
@spider.should have_received(:game_links_on_gameday_date_page).with(
|
34
|
-
Date.new(2012,3,27),
|
35
|
-
'mlb'
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "calls #pull_game for each game link on the page" do
|
40
|
-
@spider.pull_day(Date.new(2012,3,27), 'mlb')
|
41
|
-
|
42
|
-
@spider.should have_received(:pull_game).with(
|
43
|
-
'gid_2012_03_27_aaamlb_aabmlb_1',
|
44
|
-
Date.new(2012,3,27)
|
45
|
-
)
|
46
|
-
|
47
|
-
@spider.should have_received(:pull_game).with(
|
48
|
-
'gid_2012_03_27_bbbmlb_bbcmlb_1',
|
49
|
-
Date.new(2012,3,27)
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#pull_game" do
|
55
|
-
context "when all files are present on mlb.com server" do
|
56
|
-
before(:all) do
|
57
|
-
@spider.pull_game('gid_2012_09_10_atlmlb_milmlb_1', Date.new(2012,9,10))
|
58
|
-
@local_path = Pathname.new(
|
59
|
-
'./spec/games/mlb/year_2012/month_09/day_10/gid_2012_09_10_atlmlb_milmlb_1'
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "downloads boxscore.xml for the game" do
|
64
|
-
(@local_path + 'boxscore.xml').exist?.should be_true
|
65
|
-
end
|
66
|
-
|
67
|
-
it "downloads game_events.xml for the game" do
|
68
|
-
(@local_path + 'game_events.xml').exist?.should be_true
|
69
|
-
end
|
70
|
-
|
71
|
-
it "downloads linescore.xml for the game" do
|
72
|
-
(@local_path + 'linescore.xml').exist?.should be_true
|
73
|
-
end
|
74
|
-
|
75
|
-
it "downloads players.xml for the game" do
|
76
|
-
(@local_path + 'players.xml').exist?.should be_true
|
77
|
-
end
|
78
|
-
|
79
|
-
it "downloads the inning files for the games in 2007 or later" do
|
80
|
-
(@local_path + 'inning' + 'inning_all.xml').exist?.should be_true
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|