aucklandia 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64a96b6e08f8b5f24dac83c79969625e706b7437284cf5bbbe981d42801ec088
4
- data.tar.gz: 4581fa66cc57945e394d9480941a8d472a0621860285396090888e29390d114e
3
+ metadata.gz: 37fc92772d65047ed6b36dbfef375d30c1ef4f91e419dc1c03c6a7bc67fa33fb
4
+ data.tar.gz: 784d8d6839a632b1481c02c7ebe3a7a4ffb6da2c421b7b9254ffcdd64c1be7d2
5
5
  SHA512:
6
- metadata.gz: f5a386971953c0e69c95d104d262186c24c533d37db94cc3d9aa280259e8c6b0043b60fb1c0685e2a83b987ea5edd1b1ac044fda13555fa81aff50f16850450c
7
- data.tar.gz: 5f47f4fe62c6de259350ea2a851456cd0c3bfe77e8b918ac56ea0a7344de19084838da71fc55d6278b40d3b3310306b622b24df01f48f1584df044439c06c5be
6
+ metadata.gz: c35d82ea59bbbae8062dd6e0820e350aade128e1d1a28d9cc596fd3d5680f7ecf7685255fd4294cf7b6cb3abf4c45653125c8376757664d2c2e86a5ec7f7993b
7
+ data.tar.gz: baf405e5637b9fa5660e18f1b2dbcbcf1238da1a38e02cb5102f1e072c67c164195a75144add9e039491d7149f2c5003a33c1500ce977c4e9f699fa77264ab4e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aucklandia (0.1.0)
4
+ aucklandia (0.2.0)
5
5
  rest-client
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -36,6 +36,9 @@ client.get_routes
36
36
  route_short_name = "OUT"
37
37
  client.get_routes_by_short_name(route_short_name)
38
38
 
39
+ # GET all trips. Watch out as A LOT of data comes back.
40
+ client.get_trips
41
+
39
42
  # GET all trips by route ID
40
43
  route_id = '12345'
41
44
  client.get_trips_by_route_id(route_id)
@@ -43,14 +46,19 @@ client.get_trips_by_route_id(route_id)
43
46
  # GET all live vehicle positions
44
47
  client.get_vehicle_positions
45
48
 
46
- # GET all live vehicles positions by trip ID
49
+ # GET all live vehicles positions. Optional parameters include trip ID or vehicle ID
47
50
  trip_id = '<trip-id>'
48
- client.get_vehicle_positions(trip_id)
51
+ vehicle_id = '<vehicle-id>'
52
+ client.get_vehicle_positions(trip_id: trip_id, vehicle_id: vehicle_id)
49
53
 
50
54
  # GET all live vehicle positions by route ID
51
55
  route_id = '<route-id>'
52
56
  client.get_vehicle_positions_by_route_id(route_id)
53
57
 
58
+ # GET a single vehicle position by vehicle id
59
+ vehicle_id = '<vehicle-id>'
60
+ client.get_vehicle_position_by_vehicle_id(vehicle_id)
61
+
54
62
  # GET all shape points by trip ID
55
63
  trip_id = '<trip-id>'
56
64
  client.get_shapes_by_trip(trip_id)
@@ -72,6 +80,19 @@ client.get_versions
72
80
  # GET all stops by trip ID
73
81
  trip_id = '<trip-id>'
74
82
  client.get_stops_by_trip_id(trip_id)
83
+
84
+ # GET all parking locations
85
+ client.get_parking_locations
86
+
87
+ # GET all scheduled works
88
+ client.get_scheduled_works
89
+
90
+ # GET all stop times by trip ID
91
+ trip_id = '<trip-id>'
92
+ client.get_stop_times_by_trip_id
93
+
94
+ # GET all calendars
95
+ client.get_calendars
75
96
  ```
76
97
 
77
98
  ## Development
@@ -0,0 +1,14 @@
1
+ module Aucklandia
2
+ module CalendarDates
3
+ CALENDAR_DATES_ENDPOINT = '/gtfs/calendarDate'
4
+
5
+ def get_calendar_dates
6
+ url = build_url(BASE_URL, CALENDAR_DATES_ENDPOINT)
7
+
8
+ response = get(url)
9
+
10
+ JSON.parse(response)['response']
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Aucklandia
2
+ module Calendars
3
+ CALENDARS_ENDPOINT = '/gtfs/calendar'
4
+
5
+ def get_calendars
6
+ url = build_url(BASE_URL, CALENDARS_ENDPOINT)
7
+
8
+ response = get(url)
9
+
10
+ JSON.parse(response)['response']
11
+ end
12
+
13
+ end
14
+ end
@@ -6,7 +6,12 @@ module Aucklandia
6
6
  include Aucklandia::Versions
7
7
  include Aucklandia::Stops
8
8
  include Aucklandia::Shapes
9
+ include Aucklandia::ScheduledWorks
10
+ include Aucklandia::StopTimes
9
11
  include Aucklandia::Notifications
12
+ include Aucklandia::ParkingLocations
13
+ include Aucklandia::Calendars
14
+ include Aucklandia::CalendarDates
10
15
 
11
16
  include Requestable
12
17
 
@@ -0,0 +1,13 @@
1
+ module Aucklandia
2
+ module ParkingLocations
3
+ PARKING_LOCATIONS_ENDPOINT = '/locations/parkinglocations'
4
+
5
+ def get_parking_locations
6
+ url = build_url(BASE_URL, PARKING_LOCATIONS_ENDPOINT)
7
+
8
+ response = get(url)
9
+
10
+ JSON.parse(response)['response']
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Aucklandia
2
+ module ScheduledWorks
3
+ SCHEDULED_WORKS_ENDPOINT = '/locations/scheduledWorks'
4
+
5
+ def get_scheduled_works
6
+ url = build_url(BASE_URL, SCHEDULED_WORKS_ENDPOINT)
7
+
8
+ response = get(url)
9
+
10
+ JSON.parse(response)['response']
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+
2
+ module Aucklandia
3
+ module StopTimes
4
+ STOP_TIMES_ENDPOINT = '/gtfs/stopTimes'
5
+
6
+ def get_stop_times_by_trip_id(trip_id)
7
+ url = build_url(BASE_URL, STOP_TIMES_ENDPOINT, '/tripId/', trip_id)
8
+
9
+ response = get(url)
10
+
11
+ JSON.parse(response)['response']
12
+ end
13
+
14
+ end
15
+ end
@@ -2,6 +2,14 @@ module Aucklandia
2
2
  module Trips
3
3
  TRIPS_ENDPOINT = '/gtfs/trips'
4
4
 
5
+ def get_trips
6
+ url = build_url(BASE_URL, TRIPS_ENDPOINT)
7
+
8
+ response = get(url)
9
+
10
+ JSON.parse(response)['response']
11
+ end
12
+
5
13
  def get_trips_by_route(route_id)
6
14
  url = build_url(BASE_URL, TRIPS_ENDPOINT, '/routeid/', route_id)
7
15
 
@@ -2,8 +2,8 @@ module Aucklandia
2
2
  module VehiclePositions
3
3
  VEHICLE_POSITIONS_ENDPOINT = '/public/realtime/vehiclelocations'
4
4
 
5
- def get_vehicle_positions(trip_id=nil)
6
- params = { tripid: trip_id } if trip_id
5
+ def get_vehicle_positions(trip_id: nil, vehicle_id: nil)
6
+ params = { tripid: trip_id, vehicleid: vehicle_id }.delete_if { |k,v| v.nil? }
7
7
 
8
8
  url = build_url(BASE_URL, VEHICLE_POSITIONS_ENDPOINT, params: params)
9
9
 
@@ -12,6 +12,11 @@ module Aucklandia
12
12
  JSON.parse(response)['response']['entity']
13
13
  end
14
14
 
15
+
16
+ def get_vehicle_position_by_vehicle_id(vehicle_id)
17
+ get_vehicle_positions(vehicle_id: vehicle_id).first
18
+ end
19
+
15
20
  def get_vehicle_positions_by_route_id(route_id)
16
21
  get_vehicle_positions.select do |vehicle_position|
17
22
  vehicle_position if vehicle_position['vehicle']['trip']['route_id'] == route_id
@@ -1,3 +1,3 @@
1
1
  module Aucklandia
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/aucklandia.rb CHANGED
@@ -6,8 +6,13 @@ require "aucklandia/trips"
6
6
  require "aucklandia/vehicle_positions"
7
7
  require "aucklandia/versions"
8
8
  require "aucklandia/stops"
9
+ require "aucklandia/stop_times"
9
10
  require "aucklandia/shapes"
11
+ require "aucklandia/scheduled_works"
10
12
  require "aucklandia/notifications"
13
+ require "aucklandia/parking_locations"
14
+ require "aucklandia/calendars"
15
+ require "aucklandia/calendar_dates"
11
16
  require "aucklandia/client"
12
17
 
13
18
  require 'rest-client'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aucklandia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Markkus Paul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -143,10 +143,15 @@ files:
143
143
  - bin/console
144
144
  - bin/setup
145
145
  - lib/aucklandia.rb
146
+ - lib/aucklandia/calendar_dates.rb
147
+ - lib/aucklandia/calendars.rb
146
148
  - lib/aucklandia/client.rb
147
149
  - lib/aucklandia/notifications.rb
150
+ - lib/aucklandia/parking_locations.rb
148
151
  - lib/aucklandia/routes.rb
152
+ - lib/aucklandia/scheduled_works.rb
149
153
  - lib/aucklandia/shapes.rb
154
+ - lib/aucklandia/stop_times.rb
150
155
  - lib/aucklandia/stops.rb
151
156
  - lib/aucklandia/support/requestable.rb
152
157
  - lib/aucklandia/trips.rb