mlb 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/mlb_spec.rb ADDED
@@ -0,0 +1,49 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ describe MLB::Team, ".all" do
4
+ context "with connection" do
5
+ before do
6
+ stub_request(:get, 'http://api.freebase.com/api/service/mqlread').
7
+ with(:query => {:query => MLB::Team.team_mql_query}).
8
+ to_return(:body => fixture("teams.json"))
9
+ end
10
+
11
+ it "should request the correct resource" do
12
+ MLB::Team.all
13
+ a_request(:get, 'http://api.freebase.com/api/service/mqlread').
14
+ with(:query => {:query => MLB::Team.team_mql_query}).
15
+ should have_been_made
16
+ end
17
+
18
+ it "should return the correct results" do
19
+ teams = MLB::Team.all
20
+ teams.first.name.should == "Arizona Diamondbacks"
21
+ end
22
+ end
23
+
24
+ context "with timeout" do
25
+ before do
26
+ stub_request(:get, 'http://api.freebase.com/api/service/mqlread').
27
+ with(:query => {:query => MLB::Team.team_mql_query}).
28
+ to_timeout
29
+ end
30
+
31
+ it "should return the correct results" do
32
+ teams = MLB::Team.all
33
+ teams.first.name.should == "Arizona Diamondbacks"
34
+ end
35
+ end
36
+
37
+ context "without connection" do
38
+ before do
39
+ stub_request(:get, 'http://api.freebase.com/api/service/mqlread').
40
+ with(:query => {:query => MLB::Team.team_mql_query}).
41
+ to_raise(SocketError)
42
+ end
43
+
44
+ it "should return the correct results" do
45
+ teams = MLB::Team.all
46
+ teams.first.name.should == "Arizona Diamondbacks"
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../../lib/mlb', __FILE__)
2
+
3
+ require 'webmock/rspec'
4
+ RSpec.configure do |config|
5
+ config.include WebMock::API
6
+ end
7
+
8
+ def fixture_path
9
+ File.expand_path("../fixtures", __FILE__)
10
+ end
11
+
12
+ def fixture(file)
13
+ File.new(fixture_path + '/' + file)
14
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mlb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 6
10
- version: 0.2.6
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Erik Michaels-Ober
@@ -15,54 +15,162 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-12 00:00:00 -07:00
18
+ date: 2010-11-06 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: httparty
22
+ name: bundler
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 7
29
+ hash: 15
30
30
  segments:
31
+ - 1
31
32
  - 0
32
- - 6
33
- version: "0.6"
34
- type: :runtime
33
+ version: "1.0"
34
+ type: :development
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
- name: json
37
+ name: rake
38
38
  prerelease: false
39
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 7
44
+ hash: 27
45
+ segments:
46
+ - 0
47
+ - 8
48
+ version: "0.8"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rcov
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 25
60
+ segments:
61
+ - 0
62
+ - 9
63
+ version: "0.9"
64
+ type: :development
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: rspec
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 2
77
+ - 0
78
+ version: "2.0"
79
+ type: :development
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: webmock
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 5
45
90
  segments:
46
91
  - 1
92
+ - 5
93
+ version: "1.5"
94
+ type: :development
95
+ version_requirements: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ name: yard
98
+ prerelease: false
99
+ requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ hash: 7
105
+ segments:
106
+ - 0
107
+ - 6
108
+ version: "0.6"
109
+ type: :development
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ name: ZenTest
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ~>
118
+ - !ruby/object:Gem::Version
119
+ hash: 19
120
+ segments:
121
+ - 4
47
122
  - 4
48
- version: "1.4"
123
+ version: "4.4"
124
+ type: :development
125
+ version_requirements: *id007
126
+ - !ruby/object:Gem::Dependency
127
+ name: faraday
128
+ prerelease: false
129
+ requirement: &id008 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ~>
133
+ - !ruby/object:Gem::Version
134
+ hash: 15
135
+ segments:
136
+ - 0
137
+ - 5
138
+ - 2
139
+ version: 0.5.2
49
140
  type: :runtime
50
- version_requirements: *id002
141
+ version_requirements: *id008
142
+ - !ruby/object:Gem::Dependency
143
+ name: yajl-ruby
144
+ prerelease: false
145
+ requirement: &id009 !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ~>
149
+ - !ruby/object:Gem::Version
150
+ hash: 19
151
+ segments:
152
+ - 0
153
+ - 7
154
+ - 8
155
+ version: 0.7.8
156
+ type: :runtime
157
+ version_requirements: *id009
51
158
  - !ruby/object:Gem::Dependency
52
159
  name: sqlite3-ruby
53
160
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
161
+ requirement: &id010 !ruby/object:Gem::Requirement
55
162
  none: false
56
163
  requirements:
57
164
  - - ~>
58
165
  - !ruby/object:Gem::Version
59
- hash: 9
166
+ hash: 31
60
167
  segments:
61
168
  - 1
62
169
  - 3
63
- version: "1.3"
170
+ - 2
171
+ version: 1.3.2
64
172
  type: :runtime
65
- version_requirements: *id003
173
+ version_requirements: *id010
66
174
  description: MLB.rb is a Ruby library for retrieving current Major League Baseball players, managers, teams, divisions, and leagues.
67
175
  email:
68
176
  - sferik@gmail.com
@@ -70,23 +178,29 @@ executables: []
70
178
 
71
179
  extensions: []
72
180
 
73
- extra_rdoc_files:
74
- - LICENSE
75
- - README.rdoc
181
+ extra_rdoc_files: []
182
+
76
183
  files:
77
184
  - .gitignore
185
+ - .rspec
186
+ - .yardopts
78
187
  - Gemfile
79
188
  - Gemfile.lock
80
- - LICENSE
81
- - README.rdoc
189
+ - LICENSE.mkd
190
+ - README.mkd
82
191
  - Rakefile
192
+ - autotest/discover.rb
83
193
  - db/cleanup.sql
84
194
  - db/mlb.sqlite3
85
195
  - lib/mlb.rb
86
196
  - lib/mlb/player.rb
197
+ - lib/mlb/request.rb
87
198
  - lib/mlb/team.rb
88
199
  - lib/mlb/version.rb
89
200
  - mlb.gemspec
201
+ - spec/fixtures/teams.json
202
+ - spec/mlb_spec.rb
203
+ - spec/spec_helper.rb
90
204
  has_rdoc: true
91
205
  homepage: http://rubygems.org/gems/mlb
92
206
  licenses: []
@@ -123,5 +237,7 @@ rubygems_version: 1.3.7
123
237
  signing_key:
124
238
  specification_version: 3
125
239
  summary: MLB.rb is a Ruby library for retrieving current Major League Baseball players, managers, teams, divisions, and leagues.
126
- test_files: []
127
-
240
+ test_files:
241
+ - spec/fixtures/teams.json
242
+ - spec/mlb_spec.rb
243
+ - spec/spec_helper.rb
data/README.rdoc DELETED
@@ -1,25 +0,0 @@
1
- = MLB.rb
2
- ==== MLB.rb is a Ruby library for retrieving current Major League Baseball players, managers, teams, divisions, and leagues.
3
- == Installation
4
- $ gem install mlb -s http://gemcutter.org
5
- == Usage
6
- $ irb
7
- >> require 'mlb'
8
- >> MLB::Team.all.first.name # => "Arizona Diamondbacks"
9
- >> MLB::Team.all.first.league # => "National League"
10
- >> MLB::Team.all.first.division # => "National League West"
11
- >> MLB::Team.all.first.manager # => "Bob Melvin"
12
- >> MLB::Team.all.first.wins # => 82
13
- >> MLB::Team.all.first.losses # => 80
14
- >> MLB::Team.all.first.founded # => 1998
15
- >> MLB::Team.all.first.mascot # => nil
16
- >> MLB::Team.all.first.ballpark # => "Chase Field"
17
- >> MLB::Team.all.first.logo_url # => "http://img.freebase.com/api/trans/image_thumb/wikipedia/images/en_id/13104064"
18
- >> MLB::Team.all.first.players.first.name # => "Alex Romero"
19
- >> MLB::Team.all.first.players.first.number # => 28
20
- >> MLB::Team.all.first.players.first.position # => "Right fielder"
21
- == Credits
22
- Many thanks to:
23
- * Freebase[http://www.freebase.com]
24
- * httparty[http://github.com/jnunemaker/httparty]
25
- Also, thanks to beer[http://www.21st-amendment.com].