mlb_rb 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: d8531eef783590d9d243f53f2f8a29f9cd0a590d8d4191a427c5a7997ea86f33
4
- data.tar.gz: 496df599f736b806cc38aacb8df5543481d9a54eec849daa1fa6853e73bd00b5
3
+ metadata.gz: f9f528f022d9a42c20e0aaf3877559adcb029fe6f7ea17f057e72ea1e916b977
4
+ data.tar.gz: c3c480fd8fbede7de2751d52e84c0df2f63fa95fcbe43fedf5b8b82697c5b657
5
5
  SHA512:
6
- metadata.gz: 87ce9910bc1b335c384f8fa2307929f73aeb7996db1d44381dc65f7cc177e767ec7e27b2b32213dc420c42b3f9b320f2cc8009435b2df045a69b72aef050aa81
7
- data.tar.gz: f41dded18c3439711a3b101e308dbd315a7529939c16b8ab1fd4fd1495f99372efd7fb6f42a0c7f72ccc5ba88647559994942e0f07285d9c86405056db02875b
6
+ metadata.gz: 388d2dc7a6e588348f93aef7dbc02255c0db06e54a68855aab4fcae503ea5ab12c5bf92ce2bbac7235e32607549144b0dede25696abfe51dbad881f0067c69d9
7
+ data.tar.gz: 380ef60178e1a07fcd6460361c91ee3b66d04c86988fdbe77cc7fb8bc147c439a7d5a193dc3bc390d98036d2086d3d867530a371790fba9158f01d5871cba18a
metadata CHANGED
@@ -1,42 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mlb_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Miranda
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-10 00:00:00.000000000 Z
11
+ date: 2022-04-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - mmiranda@doximity.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".rspec"
21
- - ".standard.yml"
22
- - CHANGELOG.md
23
- - CODE_OF_CONDUCT.md
24
- - Gemfile
25
- - Gemfile.lock
26
- - LICENSE.txt
27
- - README.md
28
- - Rakefile
29
- - bin/console
30
- - bin/setup
31
20
  - lib/mlb_rb.rb
32
- - lib/mlb_rb/client.rb
33
- - lib/mlb_rb/errors.rb
34
- - lib/mlb_rb/game.rb
35
- - lib/mlb_rb/games.rb
36
- - lib/mlb_rb/team.rb
37
- - lib/mlb_rb/version.rb
38
- - mlb_rb.gemspec
39
- - sig/mlb_rb.rbs
40
21
  homepage: https://www.github.com/notmarkmiranda/mlb_rb
41
22
  licenses:
42
23
  - MIT
@@ -44,7 +25,7 @@ metadata:
44
25
  homepage_uri: https://www.github.com/notmarkmiranda/mlb_rb
45
26
  source_code_uri: https://www.github.com/notmarkmiranda/mlb_rb
46
27
  changelog_uri: https://www.github.com/notmarkmiranda/mlb_rb/blob/main/CHANGELOG.md
47
- post_install_message:
28
+ post_install_message:
48
29
  rdoc_options: []
49
30
  require_paths:
50
31
  - lib
@@ -59,8 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
40
  - !ruby/object:Gem::Version
60
41
  version: '0'
61
42
  requirements: []
62
- rubygems_version: 3.2.32
63
- signing_key:
43
+ rubygems_version: 3.2.3
44
+ signing_key:
64
45
  specification_version: 4
65
46
  summary: MLB API Wrapper for Ruby
66
47
  test_files: []
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.standard.yml DELETED
@@ -1,2 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/testdouble/standard
data/CHANGELOG.md DELETED
@@ -1,21 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.0.5] - 2022-04-09
4
-
5
- - Change to only pull games that are final
6
-
7
- ## [0.0.4] - 2022-03-26
8
-
9
- - Clean up main class and extract games methods to MlbRb::Games class
10
-
11
- ## [0.0.3] - 2022-03-26
12
-
13
- - Add method to retrieve games for date range
14
-
15
- ## [0.0.2] - 2022-03-25
16
-
17
- - Add method to retrieve games for one date
18
-
19
- ## [0.0.1] - 2022-03-24
20
-
21
- - Add healthcheck that returns a string
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at mmiranda@doximity.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in mlb_rb.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "standard", "~> 1.3"
data/Gemfile.lock DELETED
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mlb_rb (0.0.4)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- diff-lcs (1.5.0)
11
- parallel (1.22.0)
12
- parser (3.1.1.0)
13
- ast (~> 2.4.1)
14
- rainbow (3.1.1)
15
- rake (13.0.6)
16
- regexp_parser (2.2.1)
17
- rexml (3.2.5)
18
- rspec (3.11.0)
19
- rspec-core (~> 3.11.0)
20
- rspec-expectations (~> 3.11.0)
21
- rspec-mocks (~> 3.11.0)
22
- rspec-core (3.11.0)
23
- rspec-support (~> 3.11.0)
24
- rspec-expectations (3.11.0)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.11.0)
27
- rspec-mocks (3.11.0)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.11.0)
30
- rspec-support (3.11.0)
31
- rubocop (1.26.0)
32
- parallel (~> 1.10)
33
- parser (>= 3.1.0.0)
34
- rainbow (>= 2.2.2, < 4.0)
35
- regexp_parser (>= 1.8, < 3.0)
36
- rexml
37
- rubocop-ast (>= 1.16.0, < 2.0)
38
- ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 3.0)
40
- rubocop-ast (1.16.0)
41
- parser (>= 3.1.1.0)
42
- rubocop-performance (1.13.3)
43
- rubocop (>= 1.7.0, < 2.0)
44
- rubocop-ast (>= 0.4.0)
45
- ruby-progressbar (1.11.0)
46
- standard (1.9.0)
47
- rubocop (= 1.26.0)
48
- rubocop-performance (= 1.13.3)
49
- unicode-display_width (2.1.0)
50
-
51
- PLATFORMS
52
- x86_64-darwin-20
53
- x86_64-linux
54
-
55
- DEPENDENCIES
56
- mlb_rb!
57
- rake (~> 13.0)
58
- rspec (~> 3.0)
59
- standard (~> 1.3)
60
-
61
- BUNDLED WITH
62
- 2.3.1
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 Mark Miranda
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,53 +0,0 @@
1
- # MlbRb
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mlb_rb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- I started writing this gem because I wanted to extract a piece of a rails app that I had previously used to a gem, but the API changed from the first time I used it, so I had to rewrite it anyway, so instead of starting a new rails app immediately. I figured I could kill two birds and learn to write a gem and use the new MLB API.
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'mlb_rb'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install mlb_rb
22
-
23
- ## Usage
24
-
25
- There are currently only two methods available:
26
-
27
- ```ruby
28
- MlbRb::Games.games_for_date({ date: { year: 2022, month: 3, day: 24 } })
29
- MlbRb::Games.games_for_date_range(
30
- {
31
- start_date: { year: 2022, month: 3, day: 23 },
32
- end_date: { year: 2022, month: 3, day: 24 }
33
- }
34
- )
35
- ```
36
-
37
- ## Development
38
-
39
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
-
41
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
-
43
- ## Contributing
44
-
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mlb_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mlb_rb/blob/main/CODE_OF_CONDUCT.md).
46
-
47
- ## License
48
-
49
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
-
51
- ## Code of Conduct
52
-
53
- Everyone interacting in the MlbRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mlb_rb/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "standard/rake"
9
-
10
- task default: %i[spec standard]
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "mlb_rb"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/lib/mlb_rb/client.rb DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "net/http"
4
- require "json"
5
-
6
- module MlbRb
7
- class Client
8
- attr_reader :json_response
9
-
10
- def initialize(json_response)
11
- @json_response = json_response
12
- end
13
-
14
- def parse_games_by_date_response
15
- JSON.parse(json_response)["dates"].map do |date_hash|
16
- date_hash["games"].map do |game|
17
- final_state = game["status"]["detailedState"] == "Final"
18
- Game.new(game) if final_state
19
- end
20
- end.flatten.compact
21
- end
22
-
23
- class << self
24
- def get_games_for_date(date)
25
- json_response = Net::HTTP.get("statsapi.mlb.com", "/api/v1/schedule/games/?sportId=1&date=#{date}")
26
- new(json_response).parse_games_by_date_response
27
- end
28
-
29
- def get_games_for_range(start_date, end_date)
30
- json_response = Net::HTTP.get("statsapi.mlb.com", "/api/v1/schedule/games/?sportId=1&startDate=#{start_date}&endDate=#{end_date}")
31
- new(json_response).parse_games_by_date_response
32
- end
33
- end
34
- end
35
- end
data/lib/mlb_rb/errors.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MlbRb
4
- class DateError < StandardError; end
5
- end
data/lib/mlb_rb/game.rb DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "./lib/mlb_rb/team"
4
- require "date"
5
-
6
- module MlbRb
7
- class Game
8
- attr_reader :game_pk,
9
- :home_team,
10
- :away_team,
11
- :home_score,
12
- :away_score,
13
- :game_date
14
-
15
- def initialize(game_hash)
16
- @game_pk = game_hash["gamePk"]
17
- @home_team = Team.new(game_hash["teams"]["home"]["team"])
18
- @away_team = Team.new(game_hash["teams"]["away"]["team"])
19
- @home_score = game_hash["teams"]["home"]["score"]
20
- @away_score = game_hash["teams"]["away"]["score"]
21
- @game_date = Date.parse(game_hash["gameDate"])
22
- end
23
-
24
- def home_team_name
25
- home_team.name
26
- end
27
-
28
- def home_team_id
29
- home_team.id
30
- end
31
-
32
- def away_team_name
33
- away_team.name
34
- end
35
-
36
- def away_team_id
37
- away_team.id
38
- end
39
- end
40
- end
data/lib/mlb_rb/games.rb DELETED
@@ -1,51 +0,0 @@
1
- require "./lib/mlb_rb/errors"
2
- require "./lib/mlb_rb/client"
3
- require "./lib/mlb_rb/game"
4
-
5
- module MlbRb
6
- class Games
7
- class << self
8
- def games_for_date(options)
9
- date = options[:date]
10
- raise DateError unless validate_date(date)
11
-
12
- client.get_games_for_date(format_date(date))
13
- end
14
-
15
- def games_for_date_range(options)
16
- start_date = options[:start_date]
17
- end_date = options[:end_date]
18
- [start_date, end_date].each do |date|
19
- raise DateError unless validate_date(date)
20
- end
21
- client.get_games_for_range(format_date(start_date), format_date(end_date))
22
- end
23
-
24
- private
25
-
26
- def format_date(date)
27
- "#{"%02d" % date[:month]}/#{"%02d" % date[:day]}/#{date[:year]}"
28
- end
29
-
30
- def validate_date(date)
31
- date.map do |key, value|
32
- valid_number_for_date(value, key)
33
- end.all?
34
- end
35
-
36
- def valid_number_for_date(date_number, type)
37
- if type == :year
38
- date_number.between?(1876, Date.today.year)
39
- elsif type == :month
40
- date_number.between?(1, 12)
41
- elsif type == :day
42
- date_number.between?(1, 31)
43
- end
44
- end
45
-
46
- def client
47
- MlbRb::Client
48
- end
49
- end
50
- end
51
- end
data/lib/mlb_rb/team.rb DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MlbRb
4
- class Team
5
- attr_reader :id, :name
6
- def initialize(team_hash)
7
- @id = team_hash["id"]
8
- @name = team_hash["name"]
9
- end
10
- end
11
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MlbRb
4
- VERSION = "0.0.5"
5
- end
data/mlb_rb.gemspec DELETED
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/mlb_rb/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "mlb_rb"
7
- spec.version = MlbRb::VERSION
8
- spec.authors = ["Mark Miranda"]
9
- spec.email = ["mmiranda@doximity.com"]
10
-
11
- spec.summary = "MLB API Wrapper for Ruby"
12
- spec.homepage = "https://www.github.com/notmarkmiranda/mlb_rb"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.6.0"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
- end
26
- end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
30
-
31
- # Uncomment to register a new dependency of your gem
32
- # spec.add_dependency "example-gem", "~> 1.0"
33
-
34
- # For more information and examples about making a new gem, check out our
35
- # guide at: https://bundler.io/guides/creating_gem.html
36
- end
data/sig/mlb_rb.rbs DELETED
@@ -1,4 +0,0 @@
1
- module MlbRb
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end