gtfs-realtime-bindings 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0cb1f6e4148c1f328701415117f818b02f12d7a8
4
+ data.tar.gz: 027467436bab8120ec4dd54294267ec5567c8dd9
5
+ SHA512:
6
+ metadata.gz: fd4053e28257a2e8357eb3d420c6f2342713db32ab02235f79fae38f3cfbc5b81d5f8297cd5322e4cd483050f2e304596aa02def962c0ee82eb1db3dce7ed32a
7
+ data.tar.gz: 41f16836433686ca9753e1ab1fe5915435a209f72a05d56298f458eb45b83269d9fc4198f4dc1b5690dfc2dbdb2a293fdb4929e2bc30e0d9b5324ddb56b6ca7a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+
16
+ mkmf.log
17
+ *~
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gtfs-realtime-api.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Ruby GTFS-realtime Language Bindings
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/gtfs-realtime-bindings.svg)](http://badge.fury.io/rb/gtfs-realtime-bindings)
4
+
5
+ Provides Ruby classes generated from the
6
+ [GTFS-realtime](https://developers.google.com/transit/gtfs-realtime/) Protocol
7
+ Buffer specification. These classes will allow you to parse a binary Protocol
8
+ Buffer GTFS-realtime data feed into Ruby objects.
9
+
10
+ ## Add the Dependency
11
+
12
+ To use the `gtfs-realtime-bindings` classes in your own project, you need to
13
+ first install the Ruby gem:
14
+
15
+ ```
16
+ gem install gtfs-realtime-bindings
17
+ ```
18
+
19
+ ## Example Code
20
+
21
+ The following code snippet demonstrates downloading a GTFS-realtime data feed
22
+ from a particular URL, parsing it as a FeedMessage (the root type of the
23
+ GTFS-realtime schema), and iterating over the results.
24
+
25
+ ```ruby
26
+ require 'protobuf'
27
+ require 'google/transit/gtfs-realtime.pb'
28
+ require 'net/http'
29
+ require 'uri'
30
+
31
+ data = Net::HTTP.get(URI.parse("URL OF YOUR GTFS-REALTIME SOURCE GOES HERE"))
32
+ feed = Transit_realtime::FeedMessage.decode(data)
33
+ for entity in feed.entity do
34
+ if entity.field?(:trip_update)
35
+ p entity.trip_update
36
+ end
37
+ end
38
+ ```
39
+
40
+ For more details on the naming conventions for the Ruby classes generated from
41
+ the [gtfs-realtime.proto](https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto),
42
+ check out the [the gtfs-realtime.pb.rb source file](TODO).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/UPDATING.md ADDED
@@ -0,0 +1,22 @@
1
+ # How-To Update Bindings When gtfs-realtime.proto Changes
2
+
3
+ Regenerate the language binding source from gtfs-realtime.proto.
4
+
5
+ ```
6
+ protoc --ruby_out=lib/google/transit gtfs-realtime.proto
7
+ ```
8
+
9
+ Add the license header back to the generated source file.
10
+
11
+ Test the generated code:
12
+
13
+ ```
14
+ rspec specs/
15
+ ````
16
+
17
+ Build and deploy the gem to rubygems.org
18
+
19
+ ```
20
+ gem build gtfs-realtime-bindings.gemspec
21
+ gem push gtfs-realtime-bindings-0.0.1.gem
22
+ ```
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "gtfs-realtime-bindings"
7
+ spec.version = "0.0.2"
8
+ spec.authors = ["Google Inc."]
9
+ spec.email = ["gtfs-realtime@googlegroups.com"]
10
+ spec.homepage = "http://github.com/google/gtfs-realtime-bindings"
11
+ spec.summary = %q{Ruby classes generated from the GTFS-realtime protocol buffer specification.}
12
+ spec.license = 'Apache License, Version 2.0'
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ ##
19
+ # Dependencies
20
+ #
21
+ spec.add_dependency "protobuf", ">= 3.0"
22
+
23
+ ##
24
+ # Development dependencies
25
+ #
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
@@ -0,0 +1,259 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright 2015 Google Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ ##
18
+ # This file is auto-generated. DO NOT EDIT!
19
+ #
20
+ require 'protobuf/message'
21
+
22
+ module Transit_realtime
23
+
24
+ ##
25
+ # Message Classes
26
+ #
27
+ class FeedMessage < ::Protobuf::Message; end
28
+ class FeedHeader < ::Protobuf::Message
29
+ class Incrementality < ::Protobuf::Enum
30
+ define :FULL_DATASET, 0
31
+ define :DIFFERENTIAL, 1
32
+ end
33
+
34
+ end
35
+
36
+ class FeedEntity < ::Protobuf::Message; end
37
+ class TripUpdate < ::Protobuf::Message
38
+ class StopTimeEvent < ::Protobuf::Message; end
39
+ class StopTimeUpdate < ::Protobuf::Message
40
+ class ScheduleRelationship < ::Protobuf::Enum
41
+ define :SCHEDULED, 0
42
+ define :SKIPPED, 1
43
+ define :NO_DATA, 2
44
+ end
45
+
46
+ end
47
+
48
+
49
+ end
50
+
51
+ class VehiclePosition < ::Protobuf::Message
52
+ class VehicleStopStatus < ::Protobuf::Enum
53
+ define :INCOMING_AT, 0
54
+ define :STOPPED_AT, 1
55
+ define :IN_TRANSIT_TO, 2
56
+ end
57
+
58
+ class CongestionLevel < ::Protobuf::Enum
59
+ define :UNKNOWN_CONGESTION_LEVEL, 0
60
+ define :RUNNING_SMOOTHLY, 1
61
+ define :STOP_AND_GO, 2
62
+ define :CONGESTION, 3
63
+ define :SEVERE_CONGESTION, 4
64
+ end
65
+
66
+ class OccupancyStatus < ::Protobuf::Enum
67
+ define :EMPTY, 0
68
+ define :MANY_SEATS_AVAILABLE, 1
69
+ define :FEW_SEATS_AVAILABLE, 2
70
+ define :STANDING_ROOM_ONLY, 3
71
+ define :CRUSHED_STANDING_ROOM_ONLY, 4
72
+ define :FULL, 5
73
+ define :NOT_ACCEPTING_PASSENGERS, 6
74
+ end
75
+
76
+ end
77
+
78
+ class Alert < ::Protobuf::Message
79
+ class Cause < ::Protobuf::Enum
80
+ define :UNKNOWN_CAUSE, 1
81
+ define :OTHER_CAUSE, 2
82
+ define :TECHNICAL_PROBLEM, 3
83
+ define :STRIKE, 4
84
+ define :DEMONSTRATION, 5
85
+ define :ACCIDENT, 6
86
+ define :HOLIDAY, 7
87
+ define :WEATHER, 8
88
+ define :MAINTENANCE, 9
89
+ define :CONSTRUCTION, 10
90
+ define :POLICE_ACTIVITY, 11
91
+ define :MEDICAL_EMERGENCY, 12
92
+ end
93
+
94
+ class Effect < ::Protobuf::Enum
95
+ define :NO_SERVICE, 1
96
+ define :REDUCED_SERVICE, 2
97
+ define :SIGNIFICANT_DELAYS, 3
98
+ define :DETOUR, 4
99
+ define :ADDITIONAL_SERVICE, 5
100
+ define :MODIFIED_SERVICE, 6
101
+ define :OTHER_EFFECT, 7
102
+ define :UNKNOWN_EFFECT, 8
103
+ define :STOP_MOVED, 9
104
+ end
105
+
106
+ end
107
+
108
+ class TimeRange < ::Protobuf::Message; end
109
+ class Position < ::Protobuf::Message; end
110
+ class TripDescriptor < ::Protobuf::Message
111
+ class ScheduleRelationship < ::Protobuf::Enum
112
+ define :SCHEDULED, 0
113
+ define :ADDED, 1
114
+ define :UNSCHEDULED, 2
115
+ define :CANCELED, 3
116
+ end
117
+
118
+ end
119
+
120
+ class VehicleDescriptor < ::Protobuf::Message; end
121
+ class EntitySelector < ::Protobuf::Message; end
122
+ class TranslatedString < ::Protobuf::Message
123
+ class Translation < ::Protobuf::Message; end
124
+
125
+ end
126
+
127
+
128
+
129
+ ##
130
+ # Message Fields
131
+ #
132
+ class FeedMessage
133
+ required ::Transit_realtime::FeedHeader, :header, 1
134
+ repeated ::Transit_realtime::FeedEntity, :entity, 2
135
+ end
136
+
137
+ class FeedHeader
138
+ required :string, :gtfs_realtime_version, 1
139
+ optional ::Transit_realtime::FeedHeader::Incrementality, :incrementality, 2, :default => ::Transit_realtime::FeedHeader::Incrementality::FULL_DATASET
140
+ optional :uint64, :timestamp, 3
141
+ # Extension Fields
142
+ extensions 1000...2000
143
+ end
144
+
145
+ class FeedEntity
146
+ required :string, :id, 1
147
+ optional :bool, :is_deleted, 2, :default => false
148
+ optional ::Transit_realtime::TripUpdate, :trip_update, 3
149
+ optional ::Transit_realtime::VehiclePosition, :vehicle, 4
150
+ optional ::Transit_realtime::Alert, :alert, 5
151
+ end
152
+
153
+ class TripUpdate
154
+ class StopTimeEvent
155
+ optional :int32, :delay, 1
156
+ optional :int64, :time, 2
157
+ optional :int32, :uncertainty, 3
158
+ # Extension Fields
159
+ extensions 1000...2000
160
+ end
161
+
162
+ class StopTimeUpdate
163
+ optional :uint32, :stop_sequence, 1
164
+ optional :string, :stop_id, 4
165
+ optional ::Transit_realtime::TripUpdate::StopTimeEvent, :arrival, 2
166
+ optional ::Transit_realtime::TripUpdate::StopTimeEvent, :departure, 3
167
+ optional ::Transit_realtime::TripUpdate::StopTimeUpdate::ScheduleRelationship, :schedule_relationship, 5, :default => ::Transit_realtime::TripUpdate::StopTimeUpdate::ScheduleRelationship::SCHEDULED
168
+ # Extension Fields
169
+ extensions 1000...2000
170
+ end
171
+
172
+ required ::Transit_realtime::TripDescriptor, :trip, 1
173
+ optional ::Transit_realtime::VehicleDescriptor, :vehicle, 3
174
+ repeated ::Transit_realtime::TripUpdate::StopTimeUpdate, :stop_time_update, 2
175
+ optional :uint64, :timestamp, 4
176
+ # Extension Fields
177
+ extensions 1000...2000
178
+ end
179
+
180
+ class VehiclePosition
181
+ optional ::Transit_realtime::TripDescriptor, :trip, 1
182
+ optional ::Transit_realtime::VehicleDescriptor, :vehicle, 8
183
+ optional ::Transit_realtime::Position, :position, 2
184
+ optional :uint32, :current_stop_sequence, 3
185
+ optional :string, :stop_id, 7
186
+ optional ::Transit_realtime::VehiclePosition::VehicleStopStatus, :current_status, 4, :default => ::Transit_realtime::VehiclePosition::VehicleStopStatus::IN_TRANSIT_TO
187
+ optional :uint64, :timestamp, 5
188
+ optional ::Transit_realtime::VehiclePosition::CongestionLevel, :congestion_level, 6
189
+ optional ::Transit_realtime::VehiclePosition::OccupancyStatus, :occupancy_status, 9
190
+ # Extension Fields
191
+ extensions 1000...2000
192
+ end
193
+
194
+ class Alert
195
+ repeated ::Transit_realtime::TimeRange, :active_period, 1
196
+ repeated ::Transit_realtime::EntitySelector, :informed_entity, 5
197
+ optional ::Transit_realtime::Alert::Cause, :cause, 6, :default => ::Transit_realtime::Alert::Cause::UNKNOWN_CAUSE
198
+ optional ::Transit_realtime::Alert::Effect, :effect, 7, :default => ::Transit_realtime::Alert::Effect::UNKNOWN_EFFECT
199
+ optional ::Transit_realtime::TranslatedString, :url, 8
200
+ optional ::Transit_realtime::TranslatedString, :header_text, 10
201
+ optional ::Transit_realtime::TranslatedString, :description_text, 11
202
+ # Extension Fields
203
+ extensions 1000...2000
204
+ end
205
+
206
+ class TimeRange
207
+ optional :uint64, :start, 1
208
+ optional :uint64, :end, 2
209
+ end
210
+
211
+ class Position
212
+ required :float, :latitude, 1
213
+ required :float, :longitude, 2
214
+ optional :float, :bearing, 3
215
+ optional :double, :odometer, 4
216
+ optional :float, :speed, 5
217
+ # Extension Fields
218
+ extensions 1000...2000
219
+ end
220
+
221
+ class TripDescriptor
222
+ optional :string, :trip_id, 1
223
+ optional :string, :route_id, 5
224
+ optional :string, :start_time, 2
225
+ optional :string, :start_date, 3
226
+ optional ::Transit_realtime::TripDescriptor::ScheduleRelationship, :schedule_relationship, 4
227
+ # Extension Fields
228
+ extensions 1000...2000
229
+ end
230
+
231
+ class VehicleDescriptor
232
+ optional :string, :id, 1
233
+ optional :string, :label, 2
234
+ optional :string, :license_plate, 3
235
+ # Extension Fields
236
+ extensions 1000...2000
237
+ end
238
+
239
+ class EntitySelector
240
+ optional :string, :agency_id, 1
241
+ optional :string, :route_id, 2
242
+ optional :int32, :route_type, 3
243
+ optional ::Transit_realtime::TripDescriptor, :trip, 4
244
+ optional :string, :stop_id, 5
245
+ # Extension Fields
246
+ extensions 1000...2000
247
+ end
248
+
249
+ class TranslatedString
250
+ class Translation
251
+ required :string, :text, 1
252
+ optional :string, :language, 2
253
+ end
254
+
255
+ repeated ::Transit_realtime::TranslatedString::Translation, :translation, 1
256
+ end
257
+
258
+ end
259
+
@@ -0,0 +1,30 @@
1
+ # Copyright 2015 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'protobuf'
16
+ require 'google/transit/gtfs-realtime.pb'
17
+
18
+ describe ::Transit_realtime::FeedMessage, "#decode" do
19
+ it "decodes serialized proto data without error" do
20
+ feed = Transit_realtime::FeedMessage.new
21
+ File.open("spec/google/transit/vehicle_position.pb", "r") do |file|
22
+ feed.decode_from(file)
23
+ end
24
+
25
+ expect(feed.entity.length).to eq(1)
26
+ entity = feed.entity[0]
27
+ expect(entity.id).to eq("1")
28
+ expect(entity.field?(:vehicle)).to be true
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gtfs-realtime-bindings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Google Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: protobuf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - gtfs-realtime@googlegroups.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - UPDATING.md
67
+ - gtfs-realtime-bindings.gemspec
68
+ - lib/google/transit/gtfs-realtime.pb.rb
69
+ - spec/google/transit/gtfs-realtime_spec.rb
70
+ - spec/google/transit/vehicle_position.pb
71
+ homepage: http://github.com/google/gtfs-realtime-bindings
72
+ licenses:
73
+ - Apache License, Version 2.0
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.14
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Ruby classes generated from the GTFS-realtime protocol buffer specification.
95
+ test_files:
96
+ - spec/google/transit/gtfs-realtime_spec.rb
97
+ - spec/google/transit/vehicle_position.pb
98
+ has_rdoc: