mlb 0.7.0 → 0.8.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 +5 -5
- data/CHANGELOG.md +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +115 -103
- 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 -20
- 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 -131
- data/lib/mlb/transaction.rb +37 -0
- data/lib/mlb/version.rb +3 -13
- data/lib/mlb.rb +3 -3
- data/sig/mlb.rbs +191 -0
- metadata +55 -114
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +0 -5
- data/CONTRIBUTING.md +0 -49
- data/LICENSE.md +0 -20
- data/Rakefile +0 -48
- data/lib/mlb/request.rb +0 -24
- data/mlb.gemspec +0 -27
- data/spec/helper.rb +0 -32
- data/spec/mlb_spec.rb +0 -114
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -0
metadata
CHANGED
@@ -1,123 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mlb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Erik
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
aWsxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2NvbTAe
|
15
|
-
Fw0xMzAyMDMxMDAyMjdaFw0xNDAyMDMxMDAyMjdaMD0xDzANBgNVBAMMBnNmZXJp
|
16
|
-
azEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29tMIIB
|
17
|
-
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl0x5dx8uKxi7TkrIuyBUTJVB
|
18
|
-
v1o93nUB9j/y4M96gV2rYwAci1JPBseNd6Fybzjo3YGuHl7EQHuSHNaf1p2lxew/
|
19
|
-
y60JXIJBBgPcDK/KCP4NUHofm0jfoYD+H5uNJfHCNq7/ZsTxOtE3Ra92s0BCMTpm
|
20
|
-
wBMMlWR5MtdEhIYuBO4XhnejYgH0L/7BL2lymntVnsr/agdQoojQCN1IQmsRJvrR
|
21
|
-
duZRO3tZvoIo1pBc4JEehDuqCeyBgPLOqMoKtQlold1TQs1kWUBK7KWMFEhKC/Kg
|
22
|
-
zyzKRHQo9yDYwOvYngoBLY+T/lwCT4dyssdhzRbfnxAhaKu4SAssIwaC01yVowID
|
23
|
-
AQABozkwNzAJBgNVHRMEAjAAMB0GA1UdDgQWBBS0ruDfRak5ci1OpDNX/ZdDEkIs
|
24
|
-
iTALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQADggEBAHHSMs/MP0sOaLkEv4Jo
|
25
|
-
zvkm3qn5A6t0vaHx774cmejyMU+5wySxRezspL7ULh9NeuK2OhU+Oe3TpqrAg5TK
|
26
|
-
R8GQILnVu2FemGA6sAkPDlcPtgA6ieI19PZOF6HVLmc/ID/dP/NgZWWzEeqQKmcK
|
27
|
-
2+HM+SEEDhZkScYekw4ZOe164ZtZG816oAv5x0pGitSIkumUp7V8iEZ/6ehr7Y9e
|
28
|
-
XOg4eeun5L/JjmjARoW2kNdvkRD3c2EeSLqWvQRsBlypHfhs6JJuLlyZPGhU3R/v
|
29
|
-
Sf3lVKpBCWgRpGTvy45XVpB+59y33PJmEuQ1PTEOYvQyao9UKMAAaAN/7qWQtjl0
|
30
|
-
hlw=
|
31
|
-
-----END CERTIFICATE-----
|
32
|
-
date: 2014-01-04 00:00:00.000000000 Z
|
33
|
-
dependencies:
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: faraday
|
36
|
-
requirement: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.8'
|
41
|
-
- - "<"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.10'
|
44
|
-
type: :runtime
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
requirements:
|
48
|
-
- - "~>"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '0.8'
|
51
|
-
- - "<"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.10'
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: faraday_middleware
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.9'
|
61
|
-
type: :runtime
|
62
|
-
prerelease: false
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0.9'
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: json
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.8'
|
75
|
-
type: :runtime
|
76
|
-
prerelease: false
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '1.8'
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: bundler
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.0'
|
89
|
-
type: :development
|
90
|
-
prerelease: false
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '1.0'
|
96
|
-
description: MLB.rb is a Ruby library for retrieving current Major League Baseball
|
97
|
-
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:
|
98
14
|
email: sferik@gmail.com
|
99
15
|
executables: []
|
100
16
|
extensions: []
|
101
17
|
extra_rdoc_files: []
|
102
18
|
files:
|
103
|
-
-
|
104
|
-
-
|
105
|
-
- LICENSE.md
|
19
|
+
- CHANGELOG.md
|
20
|
+
- LICENSE.txt
|
106
21
|
- README.md
|
107
|
-
-
|
22
|
+
- bin/console
|
23
|
+
- bin/setup
|
108
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
|
109
47
|
- lib/mlb/player.rb
|
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
|
-
- mlb.
|
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
|
-
metadata:
|
120
|
-
|
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:
|
121
67
|
rdoc_options: []
|
122
68
|
require_paths:
|
123
69
|
- lib
|
@@ -125,20 +71,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
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
76
|
requirements:
|
131
77
|
- - ">="
|
132
78
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
79
|
+
version: '0'
|
134
80
|
requirements: []
|
135
|
-
|
136
|
-
|
137
|
-
signing_key:
|
81
|
+
rubygems_version: 3.5.9
|
82
|
+
signing_key:
|
138
83
|
specification_version: 4
|
139
|
-
summary:
|
140
|
-
|
141
|
-
test_files:
|
142
|
-
- spec/helper.rb
|
143
|
-
- spec/mlb_spec.rb
|
144
|
-
has_rdoc:
|
84
|
+
summary: A Ruby interface to the MLB Data API.
|
85
|
+
test_files: []
|
checksums.yaml.gz.sig
DELETED
Binary file
|
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 verify_measurements`. If your changes are not 100%
|
43
|
-
documented, go 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,48 +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
|
-
|
9
|
-
namespace :cache do
|
10
|
-
require 'mlb'
|
11
|
-
desc 'Update the teams file cache'
|
12
|
-
task :update do
|
13
|
-
json = MLB::Team.results_from_freebase
|
14
|
-
file = File.new('cache/teams.json', 'w+')
|
15
|
-
tempfile = Tempfile.new('teams.json')
|
16
|
-
tempfile.write(JSON.dump(json))
|
17
|
-
if system("python -mjson.tool #{tempfile.path} #{file.path}")
|
18
|
-
puts "File sucessfully written to #{file.path}"
|
19
|
-
tempfile.delete
|
20
|
-
else
|
21
|
-
abort "Error parsing #{tempfile.path}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
begin
|
27
|
-
require 'rubocop/rake_task'
|
28
|
-
Rubocop::RakeTask.new
|
29
|
-
rescue LoadError
|
30
|
-
task :rubocop do
|
31
|
-
$stderr.puts 'Rubocop is disabled'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
require 'yard'
|
36
|
-
YARD::Rake::YardocTask.new
|
37
|
-
|
38
|
-
require 'yardstick/rake/measurement'
|
39
|
-
Yardstick::Rake::Measurement.new do |measurement|
|
40
|
-
measurement.output = 'measurement/report.txt'
|
41
|
-
end
|
42
|
-
|
43
|
-
require 'yardstick/rake/verify'
|
44
|
-
Yardstick::Rake::Verify.new do |verify|
|
45
|
-
verify.threshold = 56.2
|
46
|
-
end
|
47
|
-
|
48
|
-
task :default => [:spec, :rubocop, :verify_measurements]
|
data/lib/mlb/request.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
|
-
|
4
|
-
module MLB
|
5
|
-
# @private
|
6
|
-
class Request
|
7
|
-
# Perform an HTTP GET request
|
8
|
-
def self.get(path, options = {})
|
9
|
-
connection.get do |request|
|
10
|
-
request.url(path, options)
|
11
|
-
end.body
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def self.connection
|
17
|
-
Faraday.new(:url => 'https://www.googleapis.com', :ssl => {:verify => false}) do |builder|
|
18
|
-
builder.request :url_encoded
|
19
|
-
builder.use FaradayMiddleware::ParseJson
|
20
|
-
builder.adapter Faraday.default_adapter
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/mlb.gemspec
DELETED
@@ -1,27 +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 'faraday_middleware', '~> 0.9'
|
9
|
-
spec.add_dependency 'json', '~> 1.8'
|
10
|
-
spec.add_development_dependency 'bundler', '~> 1.0'
|
11
|
-
spec.author = 'Erik Michaels-Ober'
|
12
|
-
spec.cert_chain = ['certs/sferik.pem']
|
13
|
-
spec.description = %q{MLB.rb is a Ruby library for retrieving current Major League Baseball players, managers, teams, divisions, and leagues.}
|
14
|
-
spec.email = 'sferik@gmail.com'
|
15
|
-
spec.files = %w(.yardopts CONTRIBUTING.md LICENSE.md README.md Rakefile mlb.gemspec)
|
16
|
-
spec.files += Dir.glob('lib/**/*.rb')
|
17
|
-
spec.files += Dir.glob('spec/**/*')
|
18
|
-
spec.homepage = 'https://github.com/sferik/mlb'
|
19
|
-
spec.licenses = ['MIT']
|
20
|
-
spec.name = 'mlb'
|
21
|
-
spec.require_paths = ['lib']
|
22
|
-
spec.required_rubygems_version = '>= 1.3.5'
|
23
|
-
spec.signing_key = File.expand_path('~/.gem/private_key.pem') if $PROGRAM_NAME =~ /gem\z/
|
24
|
-
spec.summary = spec.description
|
25
|
-
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
-
spec.version = MLB::Version
|
27
|
-
end
|
data/spec/helper.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter '/spec/'
|
11
|
-
minimum_coverage(100)
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'mlb'
|
15
|
-
require 'rspec'
|
16
|
-
require 'webmock/rspec'
|
17
|
-
|
18
|
-
WebMock.disable_net_connect!(:allow => 'coveralls.io')
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
config.expect_with :rspec do |c|
|
22
|
-
c.syntax = :expect
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def fixture_path
|
27
|
-
File.expand_path('../../cache', __FILE__)
|
28
|
-
end
|
29
|
-
|
30
|
-
def fixture(file)
|
31
|
-
File.new(fixture_path + '/' + file)
|
32
|
-
end
|
data/spec/mlb_spec.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe MLB::Team, '.all' do
|
4
|
-
before do
|
5
|
-
stub_request(:get, 'https://www.googleapis.com/freebase/v1/mqlread').with(:query => {:query => described_class.mql_query}).to_return(:body => fixture('teams.json'))
|
6
|
-
end
|
7
|
-
after do
|
8
|
-
described_class.reset
|
9
|
-
end
|
10
|
-
subject do
|
11
|
-
described_class.all
|
12
|
-
end
|
13
|
-
it 'there are thirty teams' do
|
14
|
-
expect(subject.size).to eq 30
|
15
|
-
end
|
16
|
-
it 'teams are sorted alphabetically, by name' do
|
17
|
-
# Arizona Diamondbacks..Washington Nationals
|
18
|
-
expect(subject).to eq subject.sort_by(&:name)
|
19
|
-
end
|
20
|
-
it 'every team belongs to a league' do
|
21
|
-
subject.each do |team|
|
22
|
-
expect(team.league).to match /^(American|National|Major) League( Baseball)?$/
|
23
|
-
end
|
24
|
-
end
|
25
|
-
it 'every team belongs to a division' do
|
26
|
-
subject.each do |team|
|
27
|
-
expect(team.division).to match /^(American|National) League (East|Central|West)$/
|
28
|
-
end
|
29
|
-
end
|
30
|
-
it 'every team has win and loss statistics' do
|
31
|
-
subject.each do |team|
|
32
|
-
expect(team.wins).to be_between(0, 162), "got: #{team.wins} for #{team.name}"
|
33
|
-
expect(team.losses).to be_between(0, 162), "got: #{team.losses} for #{team.name}"
|
34
|
-
games = team.wins + team.losses
|
35
|
-
# Allow up to 163 total games, since there may be a tie-breaking game
|
36
|
-
expect(games).to be <= 163, "got: #{games} for #{team.name}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
it 'every team has a founding year' do
|
40
|
-
subject.each do |team|
|
41
|
-
# Chicago Cubs..Washington Nationals
|
42
|
-
expect(team.founded).to be_between(1870, 2005), "got: #{team.founded} for #{team.name}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
it 'every team has a ballpark' do
|
46
|
-
subject.each do |team|
|
47
|
-
expect(team.ballpark).to match /(Ballpark|Centre|Coliseum|Field|Park|Stadium)( (at|in|of) .+)?$/
|
48
|
-
end
|
49
|
-
end
|
50
|
-
it 'every team has a 25-player roster' do
|
51
|
-
subject.each do |team|
|
52
|
-
expect(team.players.size).to be >= 25, "got: #{team.players.size} for #{team.name}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
it 'every player has a first and last name' do
|
56
|
-
subject.each do |team|
|
57
|
-
team.players.each do |player|
|
58
|
-
expect(player.name.size).to be >= 7, "got: #{player.name.size} for #{player.name}"
|
59
|
-
expect(player.name.split.size).to be >= 2, "got: #{player.name.split.size} for #{player.name}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
it 'every player has a one- or two-digit number' do
|
64
|
-
subject.each do |team|
|
65
|
-
team.players.each do |player|
|
66
|
-
expect(player.number).to be_between(0, 99), "got: #{player.number} for #{player.name}"
|
67
|
-
# Jackie Robinson
|
68
|
-
expect(player.number).not_to eq(42), "got: #{player.number} for #{player.name}"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
it 'every player has at least one position' do
|
73
|
-
subject.each do |team|
|
74
|
-
team.players.each do |player|
|
75
|
-
pending 'Some players do not have a position'
|
76
|
-
expect(player.positions.size).to be >= 1, "got: #{player.positions.size} for #{player.name}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
it 'every player has a starting year' do
|
81
|
-
subject.each do |team|
|
82
|
-
team.players.each do |player|
|
83
|
-
pending 'Some players do not have a starting year'
|
84
|
-
expect(player.from).to be >= 1995, "got: #{player.from} for #{player.name}"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
it 'every player is active' do
|
89
|
-
subject.each do |team|
|
90
|
-
team.players.each do |player|
|
91
|
-
expect(player.to).to eq('Present'), "got: #{player.to} for #{player.name}"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'with timeout' do
|
97
|
-
before do
|
98
|
-
stub_request(:get, 'https://www.googleapis.com/freebase/v1/mqlread').with(:query => {:query => described_class.mql_query}).to_timeout
|
99
|
-
end
|
100
|
-
it 'does not raise an exception' do
|
101
|
-
expect { subject }.not_to raise_exception
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'without connection' do
|
106
|
-
before do
|
107
|
-
stub_request(:get, 'https://www.googleapis.com/freebase/v1/mqlread').with(:query => {:query => described_class.mql_query}).to_raise(SocketError)
|
108
|
-
end
|
109
|
-
it 'does not raise an exception' do
|
110
|
-
expect { subject }.not_to raise_exception
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
data.tar.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Il�������_JeXp?��� b4싛�U��[2=й��浟,c�u�!f�2��`/7���x)��l���-��-��n�ǀ0v�_���J�D4\�<�LK☮2�(��V���f)�!ڸ��Q�2�����4%��a(<�����)�ldE;�-H���s�-�ay���I������fd�%P��%�8u�Q�!�A{��殰ZZ���]:1}h���A�Y�rc�b!nR�2Gȱe`�odqŢf�c�/ נzS
|
metadata.gz.sig
DELETED
Binary file
|