mlb 0.6.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +115 -98
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/lib/mlb/client.rb +73 -0
- data/lib/mlb/connection.rb +80 -0
- data/lib/mlb/errors/bad_gateway.rb +5 -0
- data/lib/mlb/errors/bad_request.rb +5 -0
- data/lib/mlb/errors/client_error.rb +5 -0
- data/lib/mlb/errors/connection_exception.rb +5 -0
- data/lib/mlb/errors/error.rb +3 -0
- data/lib/mlb/errors/forbidden.rb +5 -0
- data/lib/mlb/errors/gateway_timeout.rb +5 -0
- data/lib/mlb/errors/gone.rb +5 -0
- data/lib/mlb/errors/http_error.rb +14 -0
- data/lib/mlb/errors/internal_server_error.rb +5 -0
- data/lib/mlb/errors/network_error.rb +5 -0
- data/lib/mlb/errors/not_acceptable.rb +5 -0
- data/lib/mlb/errors/not_found.rb +5 -0
- data/lib/mlb/errors/payload_too_large.rb +5 -0
- data/lib/mlb/errors/server_error.rb +5 -0
- data/lib/mlb/errors/service_unavailable.rb +5 -0
- data/lib/mlb/errors/too_many_redirects.rb +5 -0
- data/lib/mlb/errors/too_many_requests.rb +5 -0
- data/lib/mlb/errors/unauthorized.rb +5 -0
- data/lib/mlb/errors/unprocessable_entity.rb +5 -0
- data/lib/mlb/player.rb +17 -22
- data/lib/mlb/redirect_handler.rb +55 -0
- data/lib/mlb/request_builder.rb +48 -0
- data/lib/mlb/response_parser.rb +61 -0
- data/lib/mlb/team.rb +33 -134
- data/lib/mlb/transaction.rb +37 -0
- data/lib/mlb/version.rb +3 -1
- data/lib/mlb.rb +3 -3
- data/sig/mlb.rbs +191 -0
- metadata +59 -119
- data/.yardopts +0 -5
- data/CONTRIBUTING.md +0 -49
- data/LICENSE.md +0 -20
- data/Rakefile +0 -22
- data/lib/mlb/request.rb +0 -24
- data/lib/mlb/response/parse_json.rb +0 -25
- data/mlb.gemspec +0 -26
- data/spec/helper.rb +0 -24
- data/spec/mlb_spec.rb +0 -53
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
metadata
CHANGED
@@ -1,145 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mlb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.8.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
- Erik
|
9
|
-
autorequire:
|
10
|
-
bindir:
|
11
|
-
cert_chain:
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
VnkKYVdzeEZUQVRCZ29Ka2lhSmsvSXNaQUVaRmdWbmJXRnBiREVUTUJFR0Nn
|
16
|
-
bVNKb21UOGl4a0FSa1dBMk52YlRBZQpGdzB4TXpBeU1ETXhNREF5TWpkYUZ3
|
17
|
-
MHhOREF5TURNeE1EQXlNamRhTUQweER6QU5CZ05WQkFNTUJuTm1aWEpwCmF6
|
18
|
-
RVZNQk1HQ2dtU0pvbVQ4aXhrQVJrV0JXZHRZV2xzTVJNd0VRWUtDWkltaVpQ
|
19
|
-
eUxHUUJHUllEWTI5dE1JSUIKSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4
|
20
|
-
QU1JSUJDZ0tDQVFFQWwweDVkeDh1S3hpN1Rrckl1eUJVVEpWQgp2MW85M25V
|
21
|
-
QjlqL3k0TTk2Z1Yycll3QWNpMUpQQnNlTmQ2RnliempvM1lHdUhsN0VRSHVT
|
22
|
-
SE5hZjFwMmx4ZXcvCnk2MEpYSUpCQmdQY0RLL0tDUDROVUhvZm0wamZvWUQr
|
23
|
-
SDV1TkpmSENOcTcvWnNUeE90RTNSYTkyczBCQ01UcG0Kd0JNTWxXUjVNdGRF
|
24
|
-
aElZdUJPNFhobmVqWWdIMEwvN0JMMmx5bW50Vm5zci9hZ2RRb29qUUNOMUlR
|
25
|
-
bXNSSnZyUgpkdVpSTzN0WnZvSW8xcEJjNEpFZWhEdXFDZXlCZ1BMT3FNb0t0
|
26
|
-
UWxvbGQxVFFzMWtXVUJLN0tXTUZFaEtDL0tnCnp5ektSSFFvOXlEWXdPdllu
|
27
|
-
Z29CTFkrVC9sd0NUNGR5c3NkaHpSYmZueEFoYUt1NFNBc3NJd2FDMDF5Vm93
|
28
|
-
SUQKQVFBQm96a3dOekFKQmdOVkhSTUVBakFBTUIwR0ExVWREZ1FXQkJTMHJ1
|
29
|
-
RGZSYWs1Y2kxT3BETlgvWmRERWtJcwppVEFMQmdOVkhROEVCQU1DQkxBd0RR
|
30
|
-
WUpLb1pJaHZjTkFRRUZCUUFEZ2dFQkFISFNNcy9NUDBzT2FMa0V2NEpvCnp2
|
31
|
-
a20zcW41QTZ0MHZhSHg3NzRjbWVqeU1VKzV3eVN4UmV6c3BMN1VMaDlOZXVL
|
32
|
-
Mk9oVStPZTNUcHFyQWc1VEsKUjhHUUlMblZ1MkZlbUdBNnNBa1BEbGNQdGdB
|
33
|
-
NmllSTE5UFpPRjZIVkxtYy9JRC9kUC9OZ1pXV3pFZXFRS21jSwoyK0hNK1NF
|
34
|
-
RURoWmtTY1lla3c0Wk9lMTY0WnRaRzgxNm9BdjV4MHBHaXRTSWt1bVVwN1Y4
|
35
|
-
aUVaLzZlaHI3WTllClhPZzRlZXVuNUwvSmptakFSb1cya05kdmtSRDNjMkVl
|
36
|
-
U0xxV3ZRUnNCbHlwSGZoczZKSnVMbHlaUEdoVTNSL3YKU2YzbFZLcEJDV2dS
|
37
|
-
cEdUdnk0NVhWcEIrNTl5MzNQSm1FdVExUFRFT1l2UXlhbzlVS01BQWFBTi83
|
38
|
-
cVdRdGpsMApobHc9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
39
|
-
date: 2013-02-10 00:00:00.000000000 Z
|
40
|
-
dependencies:
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
|
-
requirements:
|
46
|
-
- - ~>
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0.8'
|
49
|
-
- - <
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '0.10'
|
52
|
-
type: :runtime
|
53
|
-
prerelease: false
|
54
|
-
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
57
|
-
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0.8'
|
60
|
-
- - <
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0.10'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: multi_json
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ~>
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '1.0'
|
71
|
-
type: :runtime
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ~>
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '1.0'
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: bundler
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
|
-
requirements:
|
84
|
-
- - ~>
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: '1.0'
|
87
|
-
type: :development
|
88
|
-
prerelease: false
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ~>
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '1.0'
|
95
|
-
description: MLB.rb is a Ruby library for retrieving current Major League Baseball
|
96
|
-
players, managers, teams, divisions, and leagues.
|
7
|
+
- Erik Berlin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
97
14
|
email: sferik@gmail.com
|
98
15
|
executables: []
|
99
16
|
extensions: []
|
100
17
|
extra_rdoc_files: []
|
101
18
|
files:
|
102
|
-
- .
|
103
|
-
-
|
104
|
-
- LICENSE.md
|
19
|
+
- CHANGELOG.md
|
20
|
+
- LICENSE.txt
|
105
21
|
- README.md
|
106
|
-
-
|
107
|
-
-
|
22
|
+
- bin/console
|
23
|
+
- bin/setup
|
24
|
+
- lib/mlb.rb
|
25
|
+
- lib/mlb/client.rb
|
26
|
+
- lib/mlb/connection.rb
|
27
|
+
- lib/mlb/errors/bad_gateway.rb
|
28
|
+
- lib/mlb/errors/bad_request.rb
|
29
|
+
- lib/mlb/errors/client_error.rb
|
30
|
+
- lib/mlb/errors/connection_exception.rb
|
31
|
+
- lib/mlb/errors/error.rb
|
32
|
+
- lib/mlb/errors/forbidden.rb
|
33
|
+
- lib/mlb/errors/gateway_timeout.rb
|
34
|
+
- lib/mlb/errors/gone.rb
|
35
|
+
- lib/mlb/errors/http_error.rb
|
36
|
+
- lib/mlb/errors/internal_server_error.rb
|
37
|
+
- lib/mlb/errors/network_error.rb
|
38
|
+
- lib/mlb/errors/not_acceptable.rb
|
39
|
+
- lib/mlb/errors/not_found.rb
|
40
|
+
- lib/mlb/errors/payload_too_large.rb
|
41
|
+
- lib/mlb/errors/server_error.rb
|
42
|
+
- lib/mlb/errors/service_unavailable.rb
|
43
|
+
- lib/mlb/errors/too_many_redirects.rb
|
44
|
+
- lib/mlb/errors/too_many_requests.rb
|
45
|
+
- lib/mlb/errors/unauthorized.rb
|
46
|
+
- lib/mlb/errors/unprocessable_entity.rb
|
108
47
|
- lib/mlb/player.rb
|
109
|
-
- lib/mlb/
|
110
|
-
- lib/mlb/
|
48
|
+
- lib/mlb/redirect_handler.rb
|
49
|
+
- lib/mlb/request_builder.rb
|
50
|
+
- lib/mlb/response_parser.rb
|
111
51
|
- lib/mlb/team.rb
|
52
|
+
- lib/mlb/transaction.rb
|
112
53
|
- lib/mlb/version.rb
|
113
|
-
-
|
114
|
-
|
115
|
-
- spec/mlb_spec.rb
|
116
|
-
homepage: https://github.com/sferik/mlb
|
54
|
+
- sig/mlb.rbs
|
55
|
+
homepage: https://sferik.github.io/mlb-ruby
|
117
56
|
licenses:
|
118
57
|
- MIT
|
119
|
-
|
58
|
+
metadata:
|
59
|
+
allowed_push_host: https://rubygems.org
|
60
|
+
rubygems_mfa_required: 'true'
|
61
|
+
homepage_uri: https://sferik.github.io/mlb-ruby
|
62
|
+
source_code_uri: https://github.com/sferik/mlb-ruby
|
63
|
+
changelog_uri: https://github.com/sferik/mlb-ruby/blob/master/CHANGELOG.md
|
64
|
+
bug_tracker_uri: https://github.com/sferik/mlb-ruby/issues
|
65
|
+
documentation_uri: https://rubydoc.info/gems/mlb/
|
66
|
+
post_install_message:
|
120
67
|
rdoc_options: []
|
121
68
|
require_paths:
|
122
69
|
- lib
|
123
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
71
|
requirements:
|
126
|
-
- -
|
72
|
+
- - ">="
|
127
73
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
74
|
+
version: 3.1.2
|
129
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
76
|
requirements:
|
132
|
-
- -
|
77
|
+
- - ">="
|
133
78
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
79
|
+
version: '0'
|
135
80
|
requirements: []
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
managers, teams, divisions, and leagues.
|
142
|
-
test_files:
|
143
|
-
- spec/helper.rb
|
144
|
-
- spec/mlb_spec.rb
|
145
|
-
has_rdoc:
|
81
|
+
rubygems_version: 3.5.9
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: A Ruby interface to the MLB Data API.
|
85
|
+
test_files: []
|
data/.yardopts
DELETED
data/CONTRIBUTING.md
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
## Contributing
|
2
|
-
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
3
|
-
improve this project.
|
4
|
-
|
5
|
-
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
6
|
-
|
7
|
-
Here are some ways *you* can contribute:
|
8
|
-
|
9
|
-
* by using alpha, beta, and prerelease versions
|
10
|
-
* by reporting bugs
|
11
|
-
* by suggesting new features
|
12
|
-
* by writing or editing documentation
|
13
|
-
* by writing specifications
|
14
|
-
* by writing code (**no patch is too small**: fix typos, add comments, cleanup
|
15
|
-
inconsistent whitespace)
|
16
|
-
* by refactoring code
|
17
|
-
* by closing [issues][]
|
18
|
-
* by reviewing patches
|
19
|
-
|
20
|
-
[issues]: https://github.com/sferik/mlb/issues
|
21
|
-
|
22
|
-
## Submitting an Issue
|
23
|
-
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
24
|
-
submitting a bug report or feature request, check to make sure it hasn't
|
25
|
-
already been submitted. When submitting a bug report, please include a [Gist][]
|
26
|
-
that includes a stack trace and any details that may be necessary to reproduce
|
27
|
-
the bug, including your gem version, Ruby version, and operating system.
|
28
|
-
Ideally, a bug report should include a pull request with failing specs.
|
29
|
-
|
30
|
-
[gist]: https://gist.github.com/
|
31
|
-
|
32
|
-
## Submitting a Pull Request
|
33
|
-
1. [Fork the repository.][fork]
|
34
|
-
2. [Create a topic branch.][branch]
|
35
|
-
3. Add specs for your unimplemented feature or bug fix.
|
36
|
-
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
|
37
|
-
5. Implement your feature or bug fix.
|
38
|
-
6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
|
39
|
-
7. Run `open coverage/index.html`. If your changes are not completely covered
|
40
|
-
by your tests, return to step 3.
|
41
|
-
8. Add documentation for your feature or bug fix.
|
42
|
-
9. Run `bundle exec rake yard`. If your changes are not 100% documented, go
|
43
|
-
back to step 8.
|
44
|
-
10. Add, commit, and push your changes.
|
45
|
-
11. [Submit a pull request.][pr]
|
46
|
-
|
47
|
-
[fork]: http://help.github.com/fork-a-repo/
|
48
|
-
[branch]: http://learn.github.com/p/branching.html
|
49
|
-
[pr]: http://help.github.com/send-pull-requests/
|
data/LICENSE.md
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010-2013 Erik Michaels-Ober
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler::GemHelper.install_tasks
|
3
|
-
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
6
|
-
|
7
|
-
task :test => :spec
|
8
|
-
task :default => :spec
|
9
|
-
|
10
|
-
namespace :cache do
|
11
|
-
require 'mlb'
|
12
|
-
desc "Update the teams file cache"
|
13
|
-
task :update do
|
14
|
-
doc = MLB::Team.results_from_freebase(true)
|
15
|
-
File.open('cache/teams.json', 'w') do |file|
|
16
|
-
file.write(doc.body)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'yard'
|
22
|
-
YARD::Rake::YardocTask.new
|
data/lib/mlb/request.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'mlb/response/parse_json'
|
3
|
-
|
4
|
-
module MLB
|
5
|
-
# @private
|
6
|
-
class Request
|
7
|
-
# Perform an HTTP GET request
|
8
|
-
def self.get(path, options={}, raw=false)
|
9
|
-
response = connection(raw).get do |request|
|
10
|
-
request.url(path, options)
|
11
|
-
end
|
12
|
-
raw ? response : response.body
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def self.connection(raw=false)
|
18
|
-
Faraday.new(:url => 'http://api.freebase.com') do |builder|
|
19
|
-
builder.use MLB::Response::ParseJson unless raw
|
20
|
-
builder.adapter Faraday.default_adapter
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module MLB
|
5
|
-
module Response
|
6
|
-
class ParseJson < Faraday::Response::Middleware
|
7
|
-
|
8
|
-
def parse(body)
|
9
|
-
case body
|
10
|
-
when /\A^\s*$\z/, nil
|
11
|
-
nil
|
12
|
-
else
|
13
|
-
MultiJson.decode(body)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def on_complete(env)
|
18
|
-
if respond_to?(:parse)
|
19
|
-
env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/mlb.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'mlb/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.add_dependency 'faraday', ['~> 0.8', '< 0.10']
|
8
|
-
spec.add_dependency 'multi_json', '~> 1.0'
|
9
|
-
spec.add_development_dependency 'bundler', '~> 1.0'
|
10
|
-
spec.author = "Erik Michaels-Ober"
|
11
|
-
spec.cert_chain = ['certs/sferik.pem']
|
12
|
-
spec.description = %q{MLB.rb is a Ruby library for retrieving current Major League Baseball players, managers, teams, divisions, and leagues.}
|
13
|
-
spec.email = 'sferik@gmail.com'
|
14
|
-
spec.files = %w(.yardopts CONTRIBUTING.md LICENSE.md README.md Rakefile mlb.gemspec)
|
15
|
-
spec.files += Dir.glob("lib/**/*.rb")
|
16
|
-
spec.files += Dir.glob("spec/**/*")
|
17
|
-
spec.homepage = 'https://github.com/sferik/mlb'
|
18
|
-
spec.licenses = ['MIT']
|
19
|
-
spec.name = 'mlb'
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
spec.required_rubygems_version = '>= 1.3.6'
|
22
|
-
spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
|
23
|
-
spec.summary = spec.description
|
24
|
-
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
-
spec.version = MLB::VERSION
|
26
|
-
end
|
data/spec/helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
unless ENV['CI']
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter 'spec'
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'mlb'
|
9
|
-
require 'rspec'
|
10
|
-
require 'webmock/rspec'
|
11
|
-
|
12
|
-
RSpec.configure do |config|
|
13
|
-
config.expect_with :rspec do |c|
|
14
|
-
c.syntax = :expect
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def fixture_path
|
19
|
-
File.expand_path("../../cache", __FILE__)
|
20
|
-
end
|
21
|
-
|
22
|
-
def fixture(file)
|
23
|
-
File.new(fixture_path + '/' + file)
|
24
|
-
end
|
data/spec/mlb_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'helper'
|
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').with(:query => {:query => MLB::Team.mql_query}).to_return(:body => fixture("teams.json"))
|
7
|
-
end
|
8
|
-
|
9
|
-
after do
|
10
|
-
MLB::Team.reset
|
11
|
-
end
|
12
|
-
|
13
|
-
it "requests the correct resource" do
|
14
|
-
MLB::Team.all
|
15
|
-
expect(a_request(:get, 'http://api.freebase.com/api/service/mqlread').with(:query => {:query => MLB::Team.mql_query})).to have_been_made
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns the correct results" do
|
19
|
-
teams = MLB::Team.all
|
20
|
-
expect(teams.first.name).to eq "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').with(:query => {:query => MLB::Team.mql_query}).to_timeout
|
27
|
-
end
|
28
|
-
|
29
|
-
after do
|
30
|
-
MLB::Team.reset
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns the correct results" do
|
34
|
-
teams = MLB::Team.all
|
35
|
-
expect(teams.first.name).to eq "Arizona Diamondbacks"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "without connection" do
|
40
|
-
before do
|
41
|
-
stub_request(:get, 'http://api.freebase.com/api/service/mqlread').with(:query => {:query => MLB::Team.mql_query}).to_raise(SocketError)
|
42
|
-
end
|
43
|
-
|
44
|
-
after do
|
45
|
-
MLB::Team.reset
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns the correct results" do
|
49
|
-
teams = MLB::Team.all
|
50
|
-
expect(teams.first.name).to eq "Arizona Diamondbacks"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED
Binary file
|