gtfs-realtime 0.1.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
+ SHA1:
3
+ metadata.gz: 5fdb5edf2bf700f13409ea826f59a78ebdd045ec
4
+ data.tar.gz: fe85177c932f143c406a0dab22619d4d91fdeadc
5
+ SHA512:
6
+ metadata.gz: 4266033628d5877f08e56b930a6856d000ae748724d42ec775dd95fef2c8375517e3ddf0639354ff08c898ab858dc5996a5afba68b96826b77d8e6d1894c3217
7
+ data.tar.gz: 52c2d5ec317e55cf9d496c2944277e860b6638d09e2f937a147142266c0ef73876f2c32ebc918ed2d910cff20f9ffb266ceee9080d7b1eecc5553d76e0d72ad8
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.2
5
+ before_install: gem install bundler -v 1.13.6
@@ -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 rofreg@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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gtfs-realtime.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ryan Laughlin
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,60 @@
1
+ # gtfs-realtime
2
+
3
+ gfts-realtime is a gem to interact with realtime transit data presented in the [GTFS Realtime format](https://developers.google.com/transit/gtfs-realtime/). It was built in order to interact with the RIPTA realtime data API for the public bus system in Providence, RI.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gtfs-realtime'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gtfs-realtime
20
+
21
+ ## Usage
22
+
23
+ Basic functionality currently works like this:
24
+
25
+ ```
26
+ require 'gtfs-realtime'
27
+
28
+ GTFS::Realtime.configure do |config|
29
+ config.static_feed = "http://www.ripta.com/googledata/current/google_transit.zip"
30
+ config.trip_updates_feed = "http://realtime.ripta.com:81/api/tripupdates"
31
+ config.vehicle_positions_feed = "http://realtime.ripta.com:81/api/vehiclepositions"
32
+ config.service_alerts_feed = "http://realtime.ripta.com:81/api/servicealerts"
33
+ end
34
+
35
+ # After calling 'configure', the gem loads all relevant GTFS info into a database.
36
+ # This may take some time (up to a minute) depending on the size of the input data.
37
+ # By default, gtfs-realtime uses an in-memory database, which requires reloading all
38
+ # data from scratch on each launch. If you'd like to use a persistent database instead,
39
+ # set the 'GTFS_DATABASE_PATH' environment variable, and a SQLite DB will be generated.
40
+
41
+ @nearby = GTFS::Realtime::Stop.nearby(41.834521, -71.396906)
42
+ stop = @nearby.first
43
+ upcoming_bus = stop.stop_time_updates.first
44
+ trip_info = upcoming_bus.trip
45
+ route_info = upcoming_bus.route
46
+ ```
47
+
48
+ ## Development
49
+
50
+ 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.
51
+
52
+ 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).
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rofreg/gtfs-realtime. 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.
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gtfs/realtime"
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
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,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gtfs/realtime/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gtfs-realtime"
8
+ spec.version = GTFS::Realtime::VERSION
9
+ spec.authors = ["Ryan Laughlin"]
10
+ spec.email = ["me@rofreg.com"]
11
+
12
+ spec.summary = %q{GTFS Realtime wrapper}
13
+ spec.description = %q{A gem to interact with realtime transit data presented in the GTFS Realtime format (https://developers.google.com/transit/gtfs-realtime/).}
14
+ spec.homepage = "https://github.com/rofreg/gtfs-realtime"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+
28
+ spec.add_dependency "gtfs-realtime-bindings"
29
+ spec.add_dependency "gtfs"
30
+ spec.add_dependency "sequel"
31
+ spec.add_dependency "sqlite3"
32
+ end
@@ -0,0 +1,36 @@
1
+ # TODO: remove this once my PR is accepted and a gtfs gem update is released
2
+ # (see https://github.com/nerdEd/gtfs/pull/33)
3
+ module GTFS
4
+ module Model
5
+ module ClassMethods
6
+ def each(filename)
7
+ headers = nil
8
+ CSV.foreach(filename, :headers => true) do |row|
9
+ headers ||= unprefixed_headers(row.headers)
10
+ yield parse_model(headers, row.fields)
11
+ end
12
+ end
13
+
14
+ def parse_model(headers, fields, options={})
15
+ self.new(Hash[headers.zip(fields)])
16
+ end
17
+
18
+ def parse_models(data, options={})
19
+ return [] if data.nil? || data.empty?
20
+
21
+ models = []
22
+ headers = nil
23
+ CSV.parse(data, :headers => true) do |row|
24
+ headers ||= unprefixed_headers(row.headers)
25
+ model = parse_model(headers, row.fields)
26
+ models << model if options[:strict] == false || model.valid?
27
+ end
28
+ models
29
+ end
30
+
31
+ def unprefixed_headers(headers)
32
+ headers.collect{|h| h.gsub(/^#{prefix}/, '')}
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,171 @@
1
+ require "google/transit/gtfs-realtime.pb"
2
+ require "gtfs"
3
+ require "sequel"
4
+ require "sqlite3"
5
+
6
+ # we must load our Sequel DB schema first
7
+ require "gtfs/realtime/db_schema"
8
+
9
+ require "gtfs/gtfs_gem_patch"
10
+ require "gtfs/realtime/configuration"
11
+ require "gtfs/realtime/route"
12
+ require "gtfs/realtime/service_alert"
13
+ require "gtfs/realtime/stop"
14
+ require "gtfs/realtime/stop_time"
15
+ require "gtfs/realtime/stop_time_update"
16
+ require "gtfs/realtime/trip"
17
+ require "gtfs/realtime/trip_update"
18
+ require "gtfs/realtime/vehicle_position"
19
+ require "gtfs/realtime/version"
20
+
21
+ module GTFS
22
+ class Realtime
23
+ # This is a singleton object, so everything will be on the class level
24
+ class << self
25
+ attr_accessor :configuration
26
+
27
+ def configuration
28
+ @configuration ||= GTFS::Realtime::Configuration.new
29
+ end
30
+
31
+ def configure
32
+ yield(configuration)
33
+
34
+ load_static_feed!
35
+ refresh_realtime_feed!
36
+ end
37
+
38
+ def load_static_feed!(force: false)
39
+ return if !force && GTFS::Realtime::Route.count > 0
40
+
41
+ static_data = GTFS::Source.build(@configuration.static_feed)
42
+
43
+ GTFS::Realtime::Model.db.transaction do
44
+ GTFS::Realtime::Route.dataset.delete
45
+ GTFS::Realtime::Route.multi_insert(
46
+ static_data.routes.collect do |route|
47
+ {
48
+ id: route.id.strip,
49
+ short_name: route.short_name,
50
+ long_name: route.long_name,
51
+ url: route.url
52
+ }
53
+ end
54
+ )
55
+
56
+ GTFS::Realtime::Stop.dataset.delete
57
+ GTFS::Realtime::Stop.multi_insert(
58
+ static_data.stops.collect do |stop|
59
+ {
60
+ id: stop.id.strip,
61
+ name: stop.name,
62
+ latitude: stop.lat.to_f,
63
+ longitude: stop.lon.to_f
64
+ }
65
+ end
66
+ )
67
+
68
+ GTFS::Realtime::StopTime.dataset.delete
69
+ GTFS::Realtime::StopTime.multi_insert(
70
+ static_data.stop_times.collect do |stop_time|
71
+ {
72
+ stop_id: stop_time.stop_id.strip,
73
+ trip_id: stop_time.trip_id.strip,
74
+ arrival_time: stop_time.arrival_time,
75
+ departure_time: stop_time.departure_time,
76
+ stop_sequence: stop_time.stop_sequence.to_i
77
+ }
78
+ end
79
+ )
80
+
81
+ GTFS::Realtime::Trip.dataset.delete
82
+ GTFS::Realtime::Trip.multi_insert(
83
+ static_data.trips.collect do |trip|
84
+ {
85
+ id: trip.id.strip,
86
+ headsign: trip.headsign.strip,
87
+ route_id: trip.route_id.strip,
88
+ service_id: trip.service_id.strip,
89
+ shape_id: trip.shape_id.strip
90
+ }
91
+ end
92
+ )
93
+
94
+ # TODO: load shapes
95
+ end
96
+ end
97
+
98
+ def refresh_realtime_feed!
99
+ trip_updates = get_entities(@configuration.trip_updates_feed)
100
+ vehicle_positions = get_entities(@configuration.vehicle_positions_feed)
101
+ service_alerts = get_entities(@configuration.service_alerts_feed)
102
+
103
+ GTFS::Realtime::Model.db.transaction do
104
+ GTFS::Realtime::TripUpdate.dataset.delete
105
+ GTFS::Realtime::TripUpdate.multi_insert(
106
+ trip_updates.collect do |trip_update|
107
+ {
108
+ id: trip_update.id.strip,
109
+ trip_id: trip_update.trip_update.trip.trip_id.strip,
110
+ route_id: trip_update.trip_update.trip.route_id.strip
111
+ }
112
+ end
113
+ )
114
+
115
+ GTFS::Realtime::StopTimeUpdate.dataset.delete
116
+ GTFS::Realtime::StopTimeUpdate.multi_insert(
117
+ trip_updates.collect do |trip_update|
118
+ trip_update.trip_update.stop_time_update.collect do |stop_time_update|
119
+ {
120
+ trip_update_id: trip_update.id.strip,
121
+ stop_id: stop_time_update.stop_id.strip,
122
+ arrival_delay: stop_time_update.arrival ? stop_time_update.arrival.delay : nil,
123
+ arrival_time: stop_time_update.arrival ? stop_time_update.arrival.time : nil,
124
+ departure_delay: stop_time_update.departure ? stop_time_update.departure.delay : nil,
125
+ departure_time: stop_time_update.departure ? stop_time_update.departure.time : nil,
126
+ }
127
+ end
128
+ end.flatten
129
+ )
130
+
131
+ GTFS::Realtime::VehiclePosition.dataset.delete
132
+ GTFS::Realtime::VehiclePosition.multi_insert(
133
+ vehicle_positions.collect do |vehicle|
134
+ {
135
+ trip_id: vehicle.vehicle.trip.trip_id.strip,
136
+ stop_id: vehicle.vehicle.stop_id.strip,
137
+ latitude: vehicle.vehicle.position.latitude.to_f,
138
+ longitude: vehicle.vehicle.position.longitude.to_f,
139
+ bearing: vehicle.vehicle.position.bearing.to_f,
140
+ timestamp: vehicle.vehicle.timestamp
141
+ }
142
+ end
143
+ )
144
+
145
+ GTFS::Realtime::ServiceAlert.dataset.delete
146
+ GTFS::Realtime::ServiceAlert.multi_insert(
147
+ service_alerts.collect do |service_alert|
148
+ {
149
+ stop_id: service_alert.alert.informed_entity.first.stop_id.strip,
150
+ header_text: service_alert.alert.header_text.translation.first.text,
151
+ description_text: service_alert.alert.description_text.translation.first.text,
152
+ start_time: service_alert.alert.active_period.first.start,
153
+ end_time: service_alert.alert.active_period.first.end
154
+ }
155
+ end
156
+ )
157
+ end
158
+ end
159
+
160
+ private
161
+
162
+ def get_entities(path)
163
+ return [] if path.nil?
164
+
165
+ data = Net::HTTP.get(URI.parse(path))
166
+ feed = Transit_realtime::FeedMessage.decode(data)
167
+ feed.entity # array of entities
168
+ end
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,7 @@
1
+ module GTFS
2
+ class Realtime
3
+ class Configuration
4
+ attr_accessor :static_feed, :trip_updates_feed, :vehicle_positions_feed, :service_alerts_feed
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,92 @@
1
+ # This script sets up an in-memory DB so that it can be used by this gem.
2
+ # It also extends Sequel::Model so that Sequel may be used independently by
3
+ # the parent project if desired.
4
+ db = Sequel.sqlite(ENV["GTFS_DATABASE_PATH"])
5
+
6
+ # Set up all database tables
7
+ db.create_table? :routes do
8
+ String :id, primary_key: true
9
+ String :short_name
10
+ String :long_name
11
+ String :url
12
+
13
+ index :id
14
+ end
15
+
16
+ db.create_table? :stops do
17
+ String :id, primary_key: true
18
+ String :name
19
+ Double :latitude
20
+ Double :longitude
21
+
22
+ index :id
23
+ end
24
+
25
+ db.create_table? :stop_times do
26
+ String :trip_id
27
+ String :stop_id
28
+ String :arrival_time
29
+ String :departure_time
30
+ Integer :stop_sequence
31
+
32
+ index :trip_id
33
+ index :stop_id
34
+ end
35
+
36
+ db.create_table? :trips do
37
+ String :id, primary_key: true
38
+ String :headsign
39
+ String :route_id
40
+ String :service_id
41
+ String :shape_id
42
+
43
+ index :id
44
+ index :route_id
45
+ end
46
+
47
+ db.create_table? :trip_updates do
48
+ String :id, primary_key: true
49
+ String :trip_id
50
+ String :route_id
51
+
52
+ index :id
53
+ end
54
+
55
+ db.create_table? :stop_time_updates do
56
+ String :trip_update_id
57
+ String :stop_id
58
+ Integer :arrival_delay
59
+ Time :arrival_time
60
+ Integer :departure_delay
61
+ Time :departure_time
62
+
63
+ index :trip_update_id
64
+ index :stop_id
65
+ end
66
+
67
+ db.create_table? :vehicle_positions do
68
+ String :trip_id
69
+ String :stop_id
70
+ Double :latitude
71
+ Double :longitude
72
+ Double :bearing
73
+ Time :timestamp
74
+
75
+ index :trip_id
76
+ index :stop_id
77
+ end
78
+
79
+ db.create_table? :service_alerts do
80
+ String :stop_id
81
+ String :header_text
82
+ Text :description_text
83
+ Time :start_time
84
+ Time :end_time
85
+
86
+ index :stop_id
87
+ end
88
+
89
+ # Set up all gtfs-realtime models to use this database
90
+ GTFS::Realtime::Model = Class.new(Sequel::Model)
91
+ GTFS::Realtime::Model.db = db
92
+ GTFS::Realtime::Model.plugin :many_through_many
@@ -0,0 +1,16 @@
1
+ module GTFS
2
+ class Realtime
3
+ module Nearby
4
+ def nearby(latitude, longitude)
5
+ # TODO: this math is terrible! It'll fail for various edge cases.
6
+ # (e.g. close to the poles, overlapping to the prime meridian)
7
+ # That said, it's an okay approximation within the United States.
8
+
9
+ all.select do |stop|
10
+ (stop.latitude - latitude).abs < 0.01 &&
11
+ (stop.longitude - longitude).abs < 0.01
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ module GTFS
2
+ class Realtime
3
+ class Route < GTFS::Realtime::Model
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module GTFS
2
+ class Realtime
3
+ class ServiceAlert < GTFS::Realtime::Model
4
+ many_to_one :stop
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ require "gtfs/realtime/nearby"
2
+
3
+ module GTFS
4
+ class Realtime
5
+ class Stop < GTFS::Realtime::Model
6
+ extend GTFS::Realtime::Nearby
7
+
8
+ one_to_many :service_alerts
9
+ one_to_many :stop_times
10
+ one_to_many :stop_time_updates
11
+ many_to_many :trip_updates, join_table: :stop_time_updates
12
+ many_to_many :trips, join_table: :stop_times
13
+ many_through_many :routes, through: [
14
+ [:stop_times, :stop_id, :trip_id],
15
+ [:trips, :id, :route_id]
16
+ ]
17
+ many_through_many :active_routes, class: GTFS::Realtime::Route, through: [
18
+ [:stop_time_updates, :stop_id, :trip_update_id],
19
+ [:trip_updates, :id, :route_id]
20
+ ]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ module GTFS
2
+ class Realtime
3
+ class StopTime < GTFS::Realtime::Model
4
+ many_to_one :trip
5
+ many_to_one :stop
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module GTFS
2
+ class Realtime
3
+ class StopTimeUpdate < GTFS::Realtime::Model
4
+ one_through_one :route, join_table: :trip_updates, left_key: :id, left_primary_key: :trip_update_id, right_key: :route_id
5
+ many_to_one :stop
6
+ one_through_one :trip, join_table: :trip_updates, left_key: :id, left_primary_key: :trip_update_id, right_key: :trip_id
7
+ many_to_one :trip_update
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module GTFS
2
+ class Realtime
3
+ class Trip < GTFS::Realtime::Model
4
+ many_to_one :route
5
+ many_to_many :stops, join_table: :stop_times
6
+
7
+ # TODO: find shapes by shape_id
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module GTFS
2
+ class Realtime
3
+ class TripUpdate < GTFS::Realtime::Model
4
+ many_to_one :trip
5
+ many_to_one :route
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ require "gtfs/realtime/nearby"
2
+
3
+ module GTFS
4
+ class Realtime
5
+ class VehiclePosition < GTFS::Realtime::Model
6
+ extend GTFS::Realtime::Nearby
7
+
8
+ many_to_one :stop
9
+ many_to_one :trip
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module GTFS
2
+ class Realtime
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtfs-realtime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Laughlin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gtfs-realtime-bindings
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gtfs
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sequel
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
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: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A gem to interact with realtime transit data presented in the GTFS Realtime
112
+ format (https://developers.google.com/transit/gtfs-realtime/).
113
+ email:
114
+ - me@rofreg.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - gtfs-realtime.gemspec
130
+ - lib/gtfs/gtfs_gem_patch.rb
131
+ - lib/gtfs/realtime.rb
132
+ - lib/gtfs/realtime/configuration.rb
133
+ - lib/gtfs/realtime/db_schema.rb
134
+ - lib/gtfs/realtime/nearby.rb
135
+ - lib/gtfs/realtime/route.rb
136
+ - lib/gtfs/realtime/service_alert.rb
137
+ - lib/gtfs/realtime/stop.rb
138
+ - lib/gtfs/realtime/stop_time.rb
139
+ - lib/gtfs/realtime/stop_time_update.rb
140
+ - lib/gtfs/realtime/trip.rb
141
+ - lib/gtfs/realtime/trip_update.rb
142
+ - lib/gtfs/realtime/vehicle_position.rb
143
+ - lib/gtfs/realtime/version.rb
144
+ homepage: https://github.com/rofreg/gtfs-realtime
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.4.5.1
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: GTFS Realtime wrapper
168
+ test_files: []