aucklandia 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +73 -0
- data/LICENSE.txt +21 -0
- data/README.md +93 -0
- data/Rakefile +6 -0
- data/aucklandia.gemspec +42 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/aucklandia.rb +18 -0
- data/lib/aucklandia/client.rb +24 -0
- data/lib/aucklandia/notifications.rb +31 -0
- data/lib/aucklandia/routes.rb +21 -0
- data/lib/aucklandia/shapes.rb +14 -0
- data/lib/aucklandia/stops.rb +14 -0
- data/lib/aucklandia/support/requestable.rb +21 -0
- data/lib/aucklandia/trips.rb +13 -0
- data/lib/aucklandia/vehicle_positions.rb +21 -0
- data/lib/aucklandia/version.rb +3 -0
- data/lib/aucklandia/versions.rb +17 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64a96b6e08f8b5f24dac83c79969625e706b7437284cf5bbbe981d42801ec088
|
4
|
+
data.tar.gz: 4581fa66cc57945e394d9480941a8d472a0621860285396090888e29390d114e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5a386971953c0e69c95d104d262186c24c533d37db94cc3d9aa280259e8c6b0043b60fb1c0685e2a83b987ea5edd1b1ac044fda13555fa81aff50f16850450c
|
7
|
+
data.tar.gz: 5f47f4fe62c6de259350ea2a851456cd0c3bfe77e8b918ac56ea0a7344de19084838da71fc55d6278b40d3b3310306b622b24df01f48f1584df044439c06c5be
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.3
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 theo.markkus.paul@gmail.com. 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
data/Gemfile.lock
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
aucklandia (0.1.0)
|
5
|
+
rest-client
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.2)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
coderay (1.1.2)
|
13
|
+
crack (0.4.3)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
domain_name (0.5.20180417)
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
hashdiff (0.3.7)
|
19
|
+
http-cookie (1.0.3)
|
20
|
+
domain_name (~> 0.5)
|
21
|
+
method_source (0.9.0)
|
22
|
+
mime-types (3.2.2)
|
23
|
+
mime-types-data (~> 3.2015)
|
24
|
+
mime-types-data (3.2018.0812)
|
25
|
+
netrc (0.11.0)
|
26
|
+
pry (0.11.3)
|
27
|
+
coderay (~> 1.1.0)
|
28
|
+
method_source (~> 0.9.0)
|
29
|
+
public_suffix (3.0.3)
|
30
|
+
rake (10.5.0)
|
31
|
+
rest-client (2.0.2)
|
32
|
+
http-cookie (>= 1.0.2, < 2.0)
|
33
|
+
mime-types (>= 1.16, < 4.0)
|
34
|
+
netrc (~> 0.8)
|
35
|
+
rspec (3.8.0)
|
36
|
+
rspec-core (~> 3.8.0)
|
37
|
+
rspec-expectations (~> 3.8.0)
|
38
|
+
rspec-mocks (~> 3.8.0)
|
39
|
+
rspec-core (3.8.0)
|
40
|
+
rspec-support (~> 3.8.0)
|
41
|
+
rspec-expectations (3.8.1)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.8.0)
|
44
|
+
rspec-mocks (3.8.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.8.0)
|
47
|
+
rspec-support (3.8.0)
|
48
|
+
safe_yaml (1.0.4)
|
49
|
+
unf (0.1.4)
|
50
|
+
unf_ext
|
51
|
+
unf_ext (0.0.7.5)
|
52
|
+
vcr (4.0.0)
|
53
|
+
webmock (3.4.2)
|
54
|
+
addressable (>= 2.3.6)
|
55
|
+
crack (>= 0.3.2)
|
56
|
+
hashdiff
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
aucklandia!
|
63
|
+
bundler (~> 1.16)
|
64
|
+
pry
|
65
|
+
rake (~> 10.0)
|
66
|
+
rest-client
|
67
|
+
rspec (~> 3.0)
|
68
|
+
rspec-mocks (~> 3.8)
|
69
|
+
vcr
|
70
|
+
webmock
|
71
|
+
|
72
|
+
BUNDLED WITH
|
73
|
+
1.16.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Theo Markkus Paul
|
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,93 @@
|
|
1
|
+
# Aucklandia
|
2
|
+
|
3
|
+
Ruby wrapper gem for the Auckland Transport API (still in the works). Get messed up on all of ATs delicious data. Submit a PR if you want.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'aucklandia'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install aucklandia
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To interact with Auckland Transport's API, simply instantiate a client:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
client = Aucklandia::Client.new('<AT-API-KEY>')
|
27
|
+
```
|
28
|
+
|
29
|
+
Examples
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# GET all routes
|
33
|
+
client.get_routes
|
34
|
+
|
35
|
+
# GET all routes by route short name identifier
|
36
|
+
route_short_name = "OUT"
|
37
|
+
client.get_routes_by_short_name(route_short_name)
|
38
|
+
|
39
|
+
# GET all trips by route ID
|
40
|
+
route_id = '12345'
|
41
|
+
client.get_trips_by_route_id(route_id)
|
42
|
+
|
43
|
+
# GET all live vehicle positions
|
44
|
+
client.get_vehicle_positions
|
45
|
+
|
46
|
+
# GET all live vehicles positions by trip ID
|
47
|
+
trip_id = '<trip-id>'
|
48
|
+
client.get_vehicle_positions(trip_id)
|
49
|
+
|
50
|
+
# GET all live vehicle positions by route ID
|
51
|
+
route_id = '<route-id>'
|
52
|
+
client.get_vehicle_positions_by_route_id(route_id)
|
53
|
+
|
54
|
+
# GET all shape points by trip ID
|
55
|
+
trip_id = '<trip-id>'
|
56
|
+
client.get_shapes_by_trip(trip_id)
|
57
|
+
|
58
|
+
# GET all notifications
|
59
|
+
client.get_notifications
|
60
|
+
|
61
|
+
# GET all notifications by category
|
62
|
+
category = 'MOVED_STOP', 'ROAD', 'EVENTS', 'REAL_TIME', 'HIGHWAY'
|
63
|
+
client.get_notifications_by_category(category)
|
64
|
+
|
65
|
+
# GET all notifications by stop ID
|
66
|
+
stop_id = '<stop-id>'
|
67
|
+
client.get_notifications_by_stop_id(stop_id)
|
68
|
+
|
69
|
+
# GET all versions
|
70
|
+
client.get_versions
|
71
|
+
|
72
|
+
# GET all stops by trip ID
|
73
|
+
trip_id = '<trip-id>'
|
74
|
+
client.get_stops_by_trip_id(trip_id)
|
75
|
+
```
|
76
|
+
|
77
|
+
## Development
|
78
|
+
|
79
|
+
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.
|
80
|
+
|
81
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
82
|
+
|
83
|
+
## Contributing
|
84
|
+
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aucklandia. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
86
|
+
|
87
|
+
## License
|
88
|
+
|
89
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
90
|
+
|
91
|
+
## Code of Conduct
|
92
|
+
|
93
|
+
Everyone interacting in the Aucklandia project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/aucklandia/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/aucklandia.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "aucklandia/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "aucklandia"
|
8
|
+
spec.version = Aucklandia::VERSION
|
9
|
+
spec.authors = ["Theo Markkus Paul"]
|
10
|
+
spec.email = ["theo.markkus.paul@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Auckland Transport API wrapper gem. Provides a suite of easy-to-use methods to get your hands on AT\'s data effectively.'
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
21
|
+
"public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_dependency "rest-client"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "rspec-mocks", "~> 3.8"
|
39
|
+
spec.add_development_dependency "vcr"
|
40
|
+
spec.add_development_dependency "webmock"
|
41
|
+
spec.add_development_dependency "pry"
|
42
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "aucklandia"
|
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
data/lib/aucklandia.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "aucklandia/support/requestable"
|
2
|
+
require "aucklandia/version"
|
3
|
+
|
4
|
+
require "aucklandia/routes"
|
5
|
+
require "aucklandia/trips"
|
6
|
+
require "aucklandia/vehicle_positions"
|
7
|
+
require "aucklandia/versions"
|
8
|
+
require "aucklandia/stops"
|
9
|
+
require "aucklandia/shapes"
|
10
|
+
require "aucklandia/notifications"
|
11
|
+
require "aucklandia/client"
|
12
|
+
|
13
|
+
require 'rest-client'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
module Aucklandia
|
17
|
+
BASE_URL = "https://api.at.govt.nz/v2"
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Aucklandia
|
2
|
+
class Client
|
3
|
+
include Aucklandia::Routes
|
4
|
+
include Aucklandia::Trips
|
5
|
+
include Aucklandia::VehiclePositions
|
6
|
+
include Aucklandia::Versions
|
7
|
+
include Aucklandia::Stops
|
8
|
+
include Aucklandia::Shapes
|
9
|
+
include Aucklandia::Notifications
|
10
|
+
|
11
|
+
include Requestable
|
12
|
+
|
13
|
+
attr_reader :authorization_key
|
14
|
+
def initialize(authorization_key)
|
15
|
+
@authorization_key = authorization_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def headers
|
19
|
+
{
|
20
|
+
"Ocp-Apim-Subscription-Key" => @authorization_key
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Aucklandia
|
2
|
+
module Notifications
|
3
|
+
NOTIFICATIONS_ENDPOINT = '/notifications'
|
4
|
+
|
5
|
+
def get_notifications
|
6
|
+
url = build_url(BASE_URL, NOTIFICATIONS_ENDPOINT)
|
7
|
+
|
8
|
+
response = get(url)
|
9
|
+
|
10
|
+
JSON.parse(response)['response']
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_notifications_by_category(category)
|
14
|
+
url = build_url(BASE_URL, NOTIFICATIONS_ENDPOINT, '/', category)
|
15
|
+
|
16
|
+
response = get(url)
|
17
|
+
|
18
|
+
JSON.parse(response)['response']
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_notifications_by_stop_id(stop_id)
|
22
|
+
url = build_url(BASE_URL, NOTIFICATIONS_ENDPOINT, '/stop/', stop_id)
|
23
|
+
|
24
|
+
response = get(url)
|
25
|
+
|
26
|
+
data = JSON.parse(response)
|
27
|
+
|
28
|
+
data.has_key?('response') ? data['response'] : []
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Aucklandia
|
2
|
+
module Routes
|
3
|
+
ROUTE_ENDPOINT = '/gtfs/routes'
|
4
|
+
|
5
|
+
def get_routes
|
6
|
+
url = build_url(BASE_URL, ROUTE_ENDPOINT)
|
7
|
+
|
8
|
+
response = get(url)
|
9
|
+
|
10
|
+
JSON.parse(response)['response']
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_routes_by_short_name(short_name)
|
14
|
+
url = build_url(BASE_URL, ROUTE_ENDPOINT, '/routeShortName/', short_name)
|
15
|
+
|
16
|
+
response = get(url)
|
17
|
+
|
18
|
+
JSON.parse(response)['response']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Aucklandia
|
2
|
+
module Stops
|
3
|
+
STOPS_ENDPOINT = '/gtfs/stops'
|
4
|
+
|
5
|
+
def get_stops_by_trip_id(trip_id)
|
6
|
+
url = build_url(BASE_URL, STOPS_ENDPOINT, '/tripId/', trip_id)
|
7
|
+
|
8
|
+
response = get(url)
|
9
|
+
|
10
|
+
JSON.parse(response)['response']
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
module Requestable
|
3
|
+
def get(url)
|
4
|
+
RestClient::Request.execute(method: :get,
|
5
|
+
url: url,
|
6
|
+
headers: headers)
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_url(*pieces, params: nil)
|
10
|
+
url = pieces.join('')
|
11
|
+
|
12
|
+
if params
|
13
|
+
url << '?'
|
14
|
+
params.each do |key, value|
|
15
|
+
url << "#{key}=#{value}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
url
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Aucklandia
|
2
|
+
module VehiclePositions
|
3
|
+
VEHICLE_POSITIONS_ENDPOINT = '/public/realtime/vehiclelocations'
|
4
|
+
|
5
|
+
def get_vehicle_positions(trip_id=nil)
|
6
|
+
params = { tripid: trip_id } if trip_id
|
7
|
+
|
8
|
+
url = build_url(BASE_URL, VEHICLE_POSITIONS_ENDPOINT, params: params)
|
9
|
+
|
10
|
+
response = get(url)
|
11
|
+
|
12
|
+
JSON.parse(response)['response']['entity']
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_vehicle_positions_by_route_id(route_id)
|
16
|
+
get_vehicle_positions.select do |vehicle_position|
|
17
|
+
vehicle_position if vehicle_position['vehicle']['trip']['route_id'] == route_id
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Aucklandia
|
2
|
+
module Versions
|
3
|
+
VERSIONS_ENDPOINT = '/gtfs/versions'
|
4
|
+
# objects within the AT API
|
5
|
+
# have identifiers that adhere to a versioning convention.
|
6
|
+
# This API call returns the latest 'version'
|
7
|
+
# of the most up-to-date data.
|
8
|
+
def get_versions
|
9
|
+
url = build_url(BASE_URL, VERSIONS_ENDPOINT)
|
10
|
+
|
11
|
+
response = get(url)
|
12
|
+
|
13
|
+
JSON.parse(response)['response']
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aucklandia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Theo Markkus Paul
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-mocks
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- theo.markkus.paul@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".ruby-version"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CODE_OF_CONDUCT.md
|
137
|
+
- Gemfile
|
138
|
+
- Gemfile.lock
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- aucklandia.gemspec
|
143
|
+
- bin/console
|
144
|
+
- bin/setup
|
145
|
+
- lib/aucklandia.rb
|
146
|
+
- lib/aucklandia/client.rb
|
147
|
+
- lib/aucklandia/notifications.rb
|
148
|
+
- lib/aucklandia/routes.rb
|
149
|
+
- lib/aucklandia/shapes.rb
|
150
|
+
- lib/aucklandia/stops.rb
|
151
|
+
- lib/aucklandia/support/requestable.rb
|
152
|
+
- lib/aucklandia/trips.rb
|
153
|
+
- lib/aucklandia/vehicle_positions.rb
|
154
|
+
- lib/aucklandia/version.rb
|
155
|
+
- lib/aucklandia/versions.rb
|
156
|
+
homepage:
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata:
|
160
|
+
allowed_push_host: https://rubygems.org
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.7.7
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: Auckland Transport API wrapper gem. Provides a suite of easy-to-use methods
|
181
|
+
to get your hands on AT's data effectively.
|
182
|
+
test_files: []
|