mlb_gameday 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bae054da0a3ef8922cb9cb5eab7542728c4f1d1
4
- data.tar.gz: 60448bfe2ca8ef3e6dba5202b2122f997a7d644e
3
+ metadata.gz: aec132ec1fdd0f070d3012089f342fc57154c4c9
4
+ data.tar.gz: 0e7aef799fb4444a3b92a80f2fb91368edaa29de
5
5
  SHA512:
6
- metadata.gz: 84869e98325b6243d80414757bec77066721bb7e216df244d37578108ed91a62f0e6c48157ceb726d95b4272065224d778f6e0731af13bcaf796b13d5fd501ad
7
- data.tar.gz: 3087b8bb3ef9a347b93d2e444e0697855783d01fed20ba36dc690205b98816f438d088190c89929add4ebfc7102fa97bed0e7093fcdbe085a379b399eabf1b8b
6
+ metadata.gz: 320fc58b8406663d86de6c025f6db214de94a90d9673fe52f5aa91d03b6c577b772c4ed3fe6d3e125a0ea1e809055eff41492b730955a3da381a5fd3b9854112
7
+ data.tar.gz: 41cd5d32bb3e110b08848a5c80419197cb81b61955384b0f82ba29cc6d92e2fa981f281c110b62d835408ad9a225aa50ad9f84c34a92507eb68a27e8e734e38a
data/lib/mlb_gameday.rb CHANGED
@@ -114,7 +114,11 @@ module MLBGameday
114
114
  end
115
115
 
116
116
  def fetch_gamecenter_xml(date, gameday_link)
117
- Nokogiri::XML(open(API_URL + date.strftime("/year_%Y/month_%m/day_%d/gid_#{ gameday_link }/gamecenter.xml")))
117
+ begin
118
+ Nokogiri::XML(open(API_URL + date.strftime("/year_%Y/month_%m/day_%d/gid_#{ gameday_link }/gamecenter.xml")))
119
+ rescue Exception
120
+ nil
121
+ end
118
122
  end
119
123
 
120
124
  def fetch_batter_xml(id, year: nil)
@@ -159,21 +159,33 @@ module MLBGameday
159
159
  end
160
160
 
161
161
  def home_tv
162
+ return nil if !@gamecenter
163
+
162
164
  @gamecenter.xpath("//game/broadcast/home/tv").first.content
163
165
  end
164
166
 
165
167
  def away_tv
168
+ return nil if !@gamecenter
169
+
166
170
  @gamecenter.xpath("//game/broadcast/away/tv").first.content
167
171
  end
168
172
 
169
173
  def home_radio
174
+ return nil if !@gamecenter
175
+
170
176
  @gamecenter.xpath("//game/broadcast/home/radio").first.content
171
177
  end
172
178
 
173
179
  def away_radio
180
+ return nil if !@gamecenter
181
+
174
182
  @gamecenter.xpath("//game/broadcast/away/radio").first.content
175
183
  end
176
184
 
185
+ def is_free?
186
+ @linescore.xpath("//game/game_media/media/@free").first.value == "ALL"
187
+ end
188
+
177
189
  def linescore
178
190
  @linescore
179
191
  end
@@ -1,3 +1,3 @@
1
1
  module MLBGameday
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/game_spec.rb CHANGED
@@ -6,52 +6,44 @@ describe "An MLB Gameday Game object" do
6
6
  before :all do
7
7
  @api = MLBGameday::API.new
8
8
 
9
- @dodgers = @api.team("Dodgers")
10
- @giants = @api.team("Giants")
11
-
12
- @games = @api.find_games(team: @dodgers, date: Date.parse("2013-04-01"))
9
+ @game = @api.find_games(team: "LAD", date: Date.parse("2013-04-01")).first
10
+ @free_game = @api.game("2013_04_01_slnmlb_arimlb_1")
13
11
  end
14
12
 
15
13
  it "should have two starting pitchers" do
16
- game = @games[0]
17
-
18
- expect(game.teams.count).to eq(2)
14
+ expect(@game.teams.count).to eq(2)
19
15
  end
20
16
 
21
17
  it "should have the correct venue" do
22
- game = @games[0]
23
-
24
- expect(game.venue).to eq("Dodger Stadium")
18
+ expect(@game.venue).to eq("Dodger Stadium")
25
19
  end
26
20
 
27
21
  it "should start at the correct time for the home team" do
28
- game = @games[0]
29
-
30
- expect(game.home_start_time).to eq("1:10 PT")
22
+ expect(@game.home_start_time).to eq("1:10 PT")
31
23
  end
32
24
 
33
25
  # TODO: Pick another game, LA and SF are both Pacific
34
26
  it "should start at the correct time for the away team" do
35
- game = @games[0]
36
-
37
- expect(game.away_start_time).to eq("1:10 PT")
27
+ expect(@game.away_start_time).to eq("1:10 PT")
38
28
  end
39
29
 
40
30
  it "should have Clayton Kershaw starting" do
41
- game = @games[0]
42
-
43
- expect(game.home_pitcher.name).to eq("Clayton Kershaw")
31
+ expect(@game.home_pitcher.name).to eq("Clayton Kershaw")
44
32
  end
45
33
 
46
34
  it "should be on Prime Ticket and ESPN in Los Angeles" do
47
- game = @games[0]
48
-
49
- expect(game.home_tv).to eq("PRIME, ESPN")
35
+ expect(@game.home_tv).to eq("PRIME, ESPN")
50
36
  end
51
37
 
52
38
  it "should be on KNBR 680 in San Francisco" do
53
- game = @games[0]
39
+ expect(@game.away_radio).to eq("KNBR 680")
40
+ end
41
+
42
+ it "should not be free" do
43
+ expect(@game.is_free?).to be_false
44
+ end
54
45
 
55
- expect(game.away_radio).to eq("KNBR 680")
46
+ it "should have a free game" do
47
+ expect(@free_game.is_free?).to be_true
56
48
  end
57
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mlb_gameday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Hoffman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-01 00:00:00.000000000 Z
11
+ date: 2013-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler