weese 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e962956bc43863c94a15563930aa0d041865bc4258f0a28403781b3cdaf6f908
4
+ data.tar.gz: f6d9f14e0a979ffa035fc40b68857079b5b109447cd5b5139fcc7b504015da9d
5
+ SHA512:
6
+ metadata.gz: 9d6f41d08c461bb0c4ccb4b342cd7d23b6ff9269c53a40319b3b52c094511f74bd8a8e70a81522af8bd57ef2033626afb9e90968b0809e753983da46ca3dc17e
7
+ data.tar.gz: 6c5c872fce25bc302697265a728f5c0b4c3bbc94f970ce4068d42463cb07a833673e234dfd3d225d1e765860e9621573a84b0eed797975fe624e805140c1231b
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.0.pre.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at emma@emma.sh. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in weese.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ weese (1.0.0)
5
+ faraday (~> 0.17.3)
6
+ vcr (~> 5.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ faraday (0.17.3)
12
+ multipart-post (>= 1.2, < 3)
13
+ minitest (5.14.0)
14
+ multipart-post (2.1.1)
15
+ rake (12.3.3)
16
+ vcr (5.0.0)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ bundler (~> 2.1.a)
23
+ minitest (~> 5.0)
24
+ rake (~> 12.0)
25
+ weese!
26
+
27
+ BUNDLED WITH
28
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Emma K Alexandra
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 ADDED
@@ -0,0 +1,78 @@
1
+ # weese
2
+ weese is a simple Ruby interface to the [Washington Metropolitan Area Transit Authority API](https://developer.wmata.com).
3
+
4
+ ## Contents
5
+ - [Requirements](#requirements)
6
+ - [Installation](#installation)
7
+ - [Usage](#usage)
8
+ - [Getting Started](#getting-started)
9
+ - [Design](#design)
10
+ - [Using `MetroRail`](#using-MetroRail)
11
+ - [Using `MetroBus`](#using-MetroBus)
12
+ - [Testing](#testing)
13
+ - [Dependencies](#dependencies)
14
+ - [Contact](#contact)
15
+ - [License](#license)
16
+
17
+ ## Requirements
18
+ - Ruby 2.5+
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ ```ruby
25
+ gem 'weese'
26
+ ```
27
+
28
+ And then execute:
29
+
30
+ $ bundle install
31
+
32
+ Or install it yourself as:
33
+
34
+ $ gem install weese
35
+
36
+ ## Usage
37
+
38
+ ### Getting Started
39
+ ```ruby
40
+ require 'weese'
41
+
42
+ client = Weese::Rail::MetroRail.new api_key
43
+
44
+ trains = client.next_trains Weese::Rail::Station::A01
45
+ ```
46
+
47
+ ### Design
48
+ weese breaks the WMATA API into two components: `MetroRail` and `MetroBus`.
49
+
50
+ #### `MetroRail`
51
+ Provides access to all MetroRail related endpoints.
52
+
53
+ ##### Using `MetroRail`
54
+ See [Getting Started](#getting-started)
55
+
56
+ #### `MetroBus`
57
+ Provides access to all MetroBus related endpoints.
58
+
59
+ ##### Using `MetroBus`
60
+ ```ruby
61
+ require 'weese'
62
+
63
+ client = Weese::Rail::MetroBus.new api_key
64
+
65
+ routes = client.routes
66
+ ```
67
+
68
+ ## Testing
69
+ All testing is done with [vcr](https://github.com/vcr/vcr), and can be run with `rake test`.
70
+
71
+ ## Dependencies
72
+ - Faraday
73
+
74
+ ## Contact
75
+ Feel free to email questions and comments to [emma@emma.sh](mailto:emma@emma.sh)
76
+
77
+ ## License
78
+ weese is released under the MIT license. [See LICENSE](https://github.com/emma-k-alexandra/weese/blob/master/LICENSE) for details.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "weese"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'weese/bus/stop'
4
+ require 'weese/bus/route'
5
+
6
+ module Weese
7
+ # MetroBus related structures. Most important: {MetroBus}
8
+ module Bus
9
+ # MetroBus client. Used for accessing MetroBus-related WMATA APIs.
10
+ class MetroBus
11
+ include Requests::Requester
12
+ include Bus::RequiresStop
13
+ include Bus::RequiresRoute
14
+
15
+ # @return [String] WMATA API key
16
+ attr_accessor :api_key
17
+
18
+ #
19
+ # MetroBus client. Used for accessing MetroBus related endpoints
20
+ #
21
+ # @param [String] api_key WMATA API key, get one at {http://developer.wmata.com}
22
+ #
23
+ def initialize(api_key)
24
+ @api_key = api_key
25
+ end
26
+
27
+ #
28
+ # List of all bus route variants.
29
+ # {https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6a WMATA Documentation}
30
+ #
31
+ # @raise [WeeseError] If request or JSON parse fails
32
+ #
33
+ # @return [Hash] JSON Response
34
+ #
35
+ def routes
36
+ fetch(
37
+ Requests::Request.new(
38
+ @api_key,
39
+ Bus::Urls::ROUTES,
40
+ {}
41
+ )
42
+ )
43
+ end
44
+
45
+ #
46
+ # Nearby bus stops based on latitude, longitude, and radius.
47
+ # {https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6d WMATA Documentation}
48
+ #
49
+ # @param [RadiusAtCoordinates] radius_at_coordinates A radius in meters around a lat/long
50
+ #
51
+ # @raise [WeeseError] If request or JSON parse fails
52
+ #
53
+ # @return [Hash] JSON Response
54
+ #
55
+ def stops(radius_at_coordinates = nil)
56
+ query = radius_at_coordinates ? radius_at_coordinates.to_h : {}
57
+
58
+ fetch(
59
+ Requests::Request.new(
60
+ @api_key,
61
+ Bus::Urls::STOPS,
62
+ query
63
+ )
64
+ )
65
+ end
66
+ end
67
+ end
68
+ end