mlb 0.7.0 → 0.9.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.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +113 -103
  5. data/bin/console +10 -0
  6. data/bin/setup +6 -0
  7. data/lib/mlb/client.rb +63 -0
  8. data/lib/mlb/connection.rb +80 -0
  9. data/lib/mlb/division.rb +42 -0
  10. data/lib/mlb/divisions.rb +30 -0
  11. data/lib/mlb/error_handler.rb +53 -0
  12. data/lib/mlb/errors/bad_gateway.rb +5 -0
  13. data/lib/mlb/errors/bad_request.rb +5 -0
  14. data/lib/mlb/errors/client_error.rb +5 -0
  15. data/lib/mlb/errors/connection_exception.rb +5 -0
  16. data/lib/mlb/errors/error.rb +3 -0
  17. data/lib/mlb/errors/forbidden.rb +5 -0
  18. data/lib/mlb/errors/gateway_timeout.rb +5 -0
  19. data/lib/mlb/errors/gone.rb +5 -0
  20. data/lib/mlb/errors/http_error.rb +14 -0
  21. data/lib/mlb/errors/internal_server_error.rb +5 -0
  22. data/lib/mlb/errors/network_error.rb +5 -0
  23. data/lib/mlb/errors/not_acceptable.rb +5 -0
  24. data/lib/mlb/errors/not_found.rb +5 -0
  25. data/lib/mlb/errors/payload_too_large.rb +5 -0
  26. data/lib/mlb/errors/server_error.rb +5 -0
  27. data/lib/mlb/errors/service_unavailable.rb +5 -0
  28. data/lib/mlb/errors/too_many_redirects.rb +5 -0
  29. data/lib/mlb/errors/too_many_requests.rb +5 -0
  30. data/lib/mlb/errors/unauthorized.rb +5 -0
  31. data/lib/mlb/errors/unprocessable_entity.rb +5 -0
  32. data/lib/mlb/handedness.rb +13 -0
  33. data/lib/mlb/league.rb +66 -0
  34. data/lib/mlb/leagues.rb +30 -0
  35. data/lib/mlb/player.rb +62 -18
  36. data/lib/mlb/players.rb +25 -0
  37. data/lib/mlb/position.rb +17 -0
  38. data/lib/mlb/redirect_handler.rb +55 -0
  39. data/lib/mlb/request_builder.rb +48 -0
  40. data/lib/mlb/roster.rb +22 -0
  41. data/lib/mlb/roster_entry.rb +22 -0
  42. data/lib/mlb/season_date_info.rb +49 -0
  43. data/lib/mlb/sport.rb +31 -0
  44. data/lib/mlb/sports.rb +22 -0
  45. data/lib/mlb/status.rb +8 -0
  46. data/lib/mlb/team.rb +56 -127
  47. data/lib/mlb/teams.rb +30 -0
  48. data/lib/mlb/transaction.rb +31 -0
  49. data/lib/mlb/transactions.rb +18 -0
  50. data/lib/mlb/venue.rb +13 -0
  51. data/lib/mlb/venues.rb +30 -0
  52. data/lib/mlb/version.rb +3 -13
  53. data/lib/mlb.rb +9 -3
  54. data/sig/mlb.rbs +186 -0
  55. metadata +74 -102
  56. checksums.yaml.gz.sig +0 -0
  57. data/.yardopts +0 -5
  58. data/CONTRIBUTING.md +0 -49
  59. data/LICENSE.md +0 -20
  60. data/Rakefile +0 -48
  61. data/lib/mlb/request.rb +0 -24
  62. data/mlb.gemspec +0 -27
  63. data/spec/helper.rb +0 -32
  64. data/spec/mlb_spec.rb +0 -114
  65. data.tar.gz.sig +0 -1
  66. metadata.gz.sig +0 -0
metadata CHANGED
@@ -1,123 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mlb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
- - Erik Michaels-Ober
8
- autorequire:
9
- bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ8wDQYDVQQDDAZzZmVy
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
7
+ - Erik Berlin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-05-21 00:00:00.000000000 Z
33
12
  dependencies:
34
13
  - !ruby/object:Gem::Dependency
35
- name: faraday
14
+ name: shale
36
15
  requirement: !ruby/object:Gem::Requirement
37
16
  requirements:
38
17
  - - "~>"
39
18
  - !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'
19
+ version: '1.1'
75
20
  type: :runtime
76
21
  prerelease: false
77
22
  version_requirements: !ruby/object:Gem::Requirement
78
23
  requirements:
79
24
  - - "~>"
80
25
  - !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.
26
+ version: '1.1'
27
+ description:
98
28
  email: sferik@gmail.com
99
29
  executables: []
100
30
  extensions: []
101
31
  extra_rdoc_files: []
102
32
  files:
103
- - ".yardopts"
104
- - CONTRIBUTING.md
105
- - LICENSE.md
33
+ - CHANGELOG.md
34
+ - LICENSE.txt
106
35
  - README.md
107
- - Rakefile
36
+ - bin/console
37
+ - bin/setup
108
38
  - lib/mlb.rb
39
+ - lib/mlb/client.rb
40
+ - lib/mlb/connection.rb
41
+ - lib/mlb/division.rb
42
+ - lib/mlb/divisions.rb
43
+ - lib/mlb/error_handler.rb
44
+ - lib/mlb/errors/bad_gateway.rb
45
+ - lib/mlb/errors/bad_request.rb
46
+ - lib/mlb/errors/client_error.rb
47
+ - lib/mlb/errors/connection_exception.rb
48
+ - lib/mlb/errors/error.rb
49
+ - lib/mlb/errors/forbidden.rb
50
+ - lib/mlb/errors/gateway_timeout.rb
51
+ - lib/mlb/errors/gone.rb
52
+ - lib/mlb/errors/http_error.rb
53
+ - lib/mlb/errors/internal_server_error.rb
54
+ - lib/mlb/errors/network_error.rb
55
+ - lib/mlb/errors/not_acceptable.rb
56
+ - lib/mlb/errors/not_found.rb
57
+ - lib/mlb/errors/payload_too_large.rb
58
+ - lib/mlb/errors/server_error.rb
59
+ - lib/mlb/errors/service_unavailable.rb
60
+ - lib/mlb/errors/too_many_redirects.rb
61
+ - lib/mlb/errors/too_many_requests.rb
62
+ - lib/mlb/errors/unauthorized.rb
63
+ - lib/mlb/errors/unprocessable_entity.rb
64
+ - lib/mlb/handedness.rb
65
+ - lib/mlb/league.rb
66
+ - lib/mlb/leagues.rb
109
67
  - lib/mlb/player.rb
110
- - lib/mlb/request.rb
68
+ - lib/mlb/players.rb
69
+ - lib/mlb/position.rb
70
+ - lib/mlb/redirect_handler.rb
71
+ - lib/mlb/request_builder.rb
72
+ - lib/mlb/roster.rb
73
+ - lib/mlb/roster_entry.rb
74
+ - lib/mlb/season_date_info.rb
75
+ - lib/mlb/sport.rb
76
+ - lib/mlb/sports.rb
77
+ - lib/mlb/status.rb
111
78
  - lib/mlb/team.rb
79
+ - lib/mlb/teams.rb
80
+ - lib/mlb/transaction.rb
81
+ - lib/mlb/transactions.rb
82
+ - lib/mlb/venue.rb
83
+ - lib/mlb/venues.rb
112
84
  - lib/mlb/version.rb
113
- - mlb.gemspec
114
- - spec/helper.rb
115
- - spec/mlb_spec.rb
116
- homepage: https://github.com/sferik/mlb
85
+ - sig/mlb.rbs
86
+ homepage: https://sferik.github.io/mlb-ruby
117
87
  licenses:
118
88
  - MIT
119
- metadata: {}
120
- post_install_message:
89
+ metadata:
90
+ allowed_push_host: https://rubygems.org
91
+ rubygems_mfa_required: 'true'
92
+ homepage_uri: https://sferik.github.io/mlb-ruby
93
+ source_code_uri: https://github.com/sferik/mlb-ruby
94
+ changelog_uri: https://github.com/sferik/mlb-ruby/blob/master/CHANGELOG.md
95
+ bug_tracker_uri: https://github.com/sferik/mlb-ruby/issues
96
+ documentation_uri: https://rubydoc.info/gems/mlb/
97
+ post_install_message:
121
98
  rdoc_options: []
122
99
  require_paths:
123
100
  - lib
@@ -125,20 +102,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
102
  requirements:
126
103
  - - ">="
127
104
  - !ruby/object:Gem::Version
128
- version: '0'
105
+ version: 3.1.2
129
106
  required_rubygems_version: !ruby/object:Gem::Requirement
130
107
  requirements:
131
108
  - - ">="
132
109
  - !ruby/object:Gem::Version
133
- version: 1.3.5
110
+ version: '0'
134
111
  requirements: []
135
- rubyforge_project:
136
- rubygems_version: 2.2.0
137
- signing_key:
112
+ rubygems_version: 3.5.10
113
+ signing_key:
138
114
  specification_version: 4
139
- summary: MLB.rb is a Ruby library for retrieving current Major League Baseball players,
140
- managers, teams, divisions, and leagues.
141
- test_files:
142
- - spec/helper.rb
143
- - spec/mlb_spec.rb
144
- has_rdoc:
115
+ summary: A Ruby interface to the MLB Stats API.
116
+ test_files: []
checksums.yaml.gz.sig DELETED
Binary file
data/.yardopts DELETED
@@ -1,5 +0,0 @@
1
- --markup markdown
2
- -
3
- CONTRIBUTING.md
4
- LICENSE.md
5
- README.md
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