gtfs_engine 1.2.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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/README.textile +11 -0
  3. data/Rakefile +37 -0
  4. data/app/controllers/gtfs_engine/agencies_controller.rb +24 -0
  5. data/app/controllers/gtfs_engine/application_controller.rb +21 -0
  6. data/app/controllers/gtfs_engine/calendar_dates_controller.rb +22 -0
  7. data/app/controllers/gtfs_engine/calendars_controller.rb +51 -0
  8. data/app/controllers/gtfs_engine/data_sets_controller.rb +47 -0
  9. data/app/controllers/gtfs_engine/fare_attributes_controller.rb +27 -0
  10. data/app/controllers/gtfs_engine/fare_rules_controller.rb +26 -0
  11. data/app/controllers/gtfs_engine/feed_infos_controller.rb +26 -0
  12. data/app/controllers/gtfs_engine/frequencies_controller.rb +26 -0
  13. data/app/controllers/gtfs_engine/routes_controller.rb +25 -0
  14. data/app/controllers/gtfs_engine/shapes_controller.rb +23 -0
  15. data/app/controllers/gtfs_engine/stop_times_controller.rb +28 -0
  16. data/app/controllers/gtfs_engine/stops_controller.rb +30 -0
  17. data/app/controllers/gtfs_engine/transfers_controller.rb +38 -0
  18. data/app/controllers/gtfs_engine/trips_controller.rb +34 -0
  19. data/app/helpers/gtfs_engine/default_views_helper.rb +38 -0
  20. data/app/helpers/gtfs_engine/fields_helper.rb +32 -0
  21. data/app/models/gtfs_engine/agency.rb +19 -0
  22. data/app/models/gtfs_engine/calendar.rb +78 -0
  23. data/app/models/gtfs_engine/calendar_date.rb +20 -0
  24. data/app/models/gtfs_engine/data_set.rb +73 -0
  25. data/app/models/gtfs_engine/fare_attribute.rb +19 -0
  26. data/app/models/gtfs_engine/fare_rule.rb +28 -0
  27. data/app/models/gtfs_engine/feed_info.rb +19 -0
  28. data/app/models/gtfs_engine/frequency.rb +20 -0
  29. data/app/models/gtfs_engine/route.rb +24 -0
  30. data/app/models/gtfs_engine/shape.rb +20 -0
  31. data/app/models/gtfs_engine/stop.rb +26 -0
  32. data/app/models/gtfs_engine/stop_time.rb +21 -0
  33. data/app/models/gtfs_engine/transfer.rb +23 -0
  34. data/app/models/gtfs_engine/trip.rb +27 -0
  35. data/app/views/gtfs_engine/calendars/dates.json.jbuilder +18 -0
  36. data/app/views/gtfs_engine/data_sets/index.json.jbuilder +26 -0
  37. data/app/views/gtfs_engine/data_sets/show.json.jbuilder +19 -0
  38. data/app/views/gtfs_engine/gtfs/index.json.jbuilder +15 -0
  39. data/app/views/gtfs_engine/gtfs/show.json.jbuilder +15 -0
  40. data/app/views/gtfs_engine/transfers/from.json.jbuilder +15 -0
  41. data/app/views/gtfs_engine/transfers/from_to.json.jbuilder +15 -0
  42. data/app/views/gtfs_engine/transfers/to.json.jbuilder +15 -0
  43. data/app/views/gtfs_engine/trips/block.json.jbuilder +15 -0
  44. data/bin/rails +8 -0
  45. data/config/initializers/extensions_loader.rb +15 -0
  46. data/config/routes.rb +45 -0
  47. data/db/migrate/20140320045108_create_gtfs_engine_data_sets.rb +17 -0
  48. data/db/migrate/20140320045232_create_gtfs_engine_calendars.rb +24 -0
  49. data/db/migrate/20140320045751_create_gtfs_engine_calendar_dates.rb +16 -0
  50. data/db/migrate/20140320050100_create_gtfs_engine_shapes.rb +20 -0
  51. data/db/migrate/20140320051140_create_gtfs_engine_routes.rb +22 -0
  52. data/db/migrate/20140320052005_create_gtfs_engine_stops.rb +28 -0
  53. data/db/migrate/20140320052508_create_gtfs_engine_trips.rb +26 -0
  54. data/db/migrate/20140320052907_create_gtfs_engine_stop_times.rb +24 -0
  55. data/db/migrate/20140401032609_create_gtfs_engine_agencies.rb +19 -0
  56. data/db/migrate/20140405235947_create_gtfs_engine_fare_attributes.rb +18 -0
  57. data/db/migrate/20140406063500_create_gtfs_engine_fare_rules.rb +17 -0
  58. data/db/migrate/20140406071922_create_gtfs_engine_frequencies.rb +17 -0
  59. data/db/migrate/20140406072309_create_gtfs_engine_transfers.rb +17 -0
  60. data/db/migrate/20140406073548_create_gtfs_engine_feed_infos.rb +16 -0
  61. data/lib/ext/active_record/associations/association.rb +41 -0
  62. data/lib/ext.rb +19 -0
  63. data/lib/gtfs_engine/concerns/controllers/data_access.rb +31 -0
  64. data/lib/gtfs_engine/concerns/controllers/gtfs.rb +158 -0
  65. data/lib/gtfs_engine/concerns/controllers.rb +20 -0
  66. data/lib/gtfs_engine/concerns.rb +19 -0
  67. data/lib/gtfs_engine/engine.rb +28 -0
  68. data/lib/gtfs_engine/exceptions.rb +35 -0
  69. data/lib/gtfs_engine/json_responder.rb +31 -0
  70. data/lib/gtfs_engine/sources.rb +86 -0
  71. data/lib/gtfs_engine/version.rb +84 -0
  72. data/lib/gtfs_engine.rb +33 -0
  73. data/lib/tasks/gtfs_engine_tasks.rake +89 -0
  74. metadata +230 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e84da8bed1f68352eaf059a895bd270f31e7d0a
4
+ data.tar.gz: 2f5e288cfce8186cc9e54ec22d664ff972866c65
5
+ SHA512:
6
+ metadata.gz: c98750840af8e9d732371abfb185f3fd9b5c036c503cccb95975ec4e0c4f9b1be063b9647d3b345c52ba3edcb318beb53833201661e43aa986b42b1d00b8cc54
7
+ data.tar.gz: def1c054d81f293665ec81b1afd38f2a4d42562092e7df5461aed213355172e2c9fc2a70b931acca02cb432009533459d6e4508d218d2f4a5d12ff1b1ee83fa5
data/README.textile ADDED
@@ -0,0 +1,11 @@
1
+ h1. gtfs_engine
2
+
3
+ @gtfs_engine@ is a "Rails Engine":http://guides.rubyonrails.org/engines.html which will add GTFS(General Transit Feed Specification) support to your application. It provides both the resources and controller actions necessary to provide a RESTful interface to one or more GTFS data sets.
4
+
5
+ See "*sangster.github.io/gtfs_engine*"://sangster.github.io/gtfs_engine more more information on how to use this engine.
6
+
7
+ h2. Sub-Components
8
+
9
+ This Rails Engine relies on the "gtfs_reader"://github.com/sangster/gtfs_reader rubygem to process the actual ZIP files in which GTFS data sets are provided.
10
+
11
+
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ require 'jeweler'
9
+ require File.dirname(__FILE__) + '/lib/gtfs_engine/version'
10
+
11
+ Jeweler::Tasks.new do |gem|
12
+ gem.name = 'gtfs_engine'
13
+ gem.version = GtfsEngine::Version.to_s
14
+ gem.homepage = 'http://github.com/sangster/gtfs_engine'
15
+ gem.license = 'GPL 3'
16
+ gem.summary = 'Read General Transit Feed Specification zip files'
17
+ gem.description = <<-EOF.strip.gsub /\s+/, ' '
18
+ A Rails Engine to provide a basic RESTful interface for GTFS feeds.
19
+
20
+ GTFS Spec: https://developers.google.com/transit/gtfs
21
+ EOF
22
+ gem.email = 'jon@ertt.ca'
23
+ gem.authors = ['Jon Sangster']
24
+
25
+ gem.files = Dir['{app,config,db,lib}/**/*', 'Rakefile']
26
+ end
27
+
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ task bump: ['bump:patch']
31
+ namespace :bump do
32
+ %i[major minor patch].each do |part|
33
+ bumper = GtfsEngine::Version::Bumper.new part
34
+ desc "Bump the version to #{bumper}"
35
+ task(part) { bumper.bump }
36
+ end
37
+ end
@@ -0,0 +1,24 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class AgenciesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :agency_name,
20
+ :agency_url,
21
+ :agency_timezone,
22
+ :agency_lang
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class ApplicationController < ActionController::Base
17
+ include Concerns::Controllers::DataAccess
18
+ respond_to :json
19
+ self.responder = GtfsEngine::JsonResponder
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class CalendarDatesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+ gtfs_id :service_id
19
+ filters :date,
20
+ :exception_type
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class CalendarsController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ gtfs_id :service_id
20
+
21
+ filters :monday,
22
+ :tuesday,
23
+ :wednesday,
24
+ :thursday,
25
+ :friday,
26
+ :saturday,
27
+ :sunday,
28
+ :start_date,
29
+ :end_date
30
+
31
+ def for_date
32
+ date = params[:YYYY_MM_DD]
33
+ check_format! date
34
+ @records = Calendar.from_date_string date
35
+ respond_with @records, template: 'gtfs_engine/gtfs/index'
36
+ end
37
+
38
+ def dates
39
+ @dates = record.dates
40
+ render :dates
41
+ end
42
+
43
+ private
44
+
45
+ def check_format!(date_str)
46
+ unless %r{^\d{4}-\d\d-\d\d$} === date_str
47
+ raise DateFormatError, "Got '#{date_str}. Expected format: YYYY-MM-DD'"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,47 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class DataSetsController < ApplicationController
17
+ def index
18
+ expires_in 3.hours
19
+
20
+ @data_sets = Rails.cache.fetch('data_sets_index') do
21
+ {}.tap do |sets|
22
+ DataSet.order(:created_at).each do |set|
23
+ (sets[set.name] ||= []) << set
24
+ end
25
+ end
26
+ end
27
+
28
+ dates = @data_sets.values.flatten.collect &:created_at
29
+ if stale? last_modified: dates.max, public: true
30
+ respond_with @data_sets
31
+ end
32
+ end
33
+
34
+ def show
35
+ expires_in 2.hours
36
+
37
+ @data_set = data :id
38
+
39
+ # Set location if the given id is a data-source name and not an ID
40
+ if param_is_data_set_name? :id
41
+ respond_with @data_set, location: data_set_url(@data_set)
42
+ else
43
+ respond_with @data_set
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class FareAttributesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ gtfs_id :fare_id
20
+
21
+ filters :price,
22
+ :currency_type,
23
+ :payment_method,
24
+ :transfers,
25
+ :transfer_duration
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class FareRulesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ gtfs_id :fare_id
20
+
21
+ filters :route_id,
22
+ :origin_id,
23
+ :destination_id,
24
+ :contains_id
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class FeedInfosController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :feed_publisher_name,
20
+ :feed_publisher_url,
21
+ :feed_lang,
22
+ :feed_start_date,
23
+ :feed_end_date,
24
+ :feed_version
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class FrequenciesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ gtfs_id :trip_id
20
+
21
+ filters :start_time,
22
+ :end_time,
23
+ :headway_secs,
24
+ :exact_times
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class RoutesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :agency_id,
20
+ :route_short_name,
21
+ :route_long_name,
22
+ :route_type,
23
+ :agency
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class ShapesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :shape_pt_lat,
20
+ :shape_pt_lon,
21
+ :shape_pt_sequence
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class StopTimesController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ gtfs_id :route_id
20
+
21
+ filters :arrival_time,
22
+ :departure_time,
23
+ :stop_sequence,
24
+ :stop_headsign,
25
+ :pickup_type,
26
+ :drop_off_type
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class StopsController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :stop_code,
20
+ :stop_name,
21
+ :stop_desc,
22
+ :stop_lat,
23
+ :stop_lon,
24
+ :zone_id,
25
+ :location_type,
26
+ :parent_station,
27
+ :stop_timezone,
28
+ :wheelchair_boarding
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class TransfersController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :transfer_type,
20
+ :min_transfer_time
21
+
22
+ def from
23
+ @transfers = collection.where from_stop_id: params[:stop_id]
24
+ respond_with @transfers
25
+ end
26
+
27
+ def to
28
+ @transfers = collection.where to_stop_id: params[:stop_id]
29
+ respond_with @transfers
30
+ end
31
+
32
+ def from_to
33
+ @transfer = collection.find_by from_stop_id: params[:from_id],
34
+ to_stop_id: params[:to_id]
35
+ respond_with @transfer
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,34 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class TripsController < ApplicationController
17
+ include Concerns::Controllers::Gtfs
18
+
19
+ filters :service_id,
20
+ :trip_headsign,
21
+ :short_name,
22
+ :direction_id,
23
+ :block_id,
24
+ :route_id,
25
+ :shape_id,
26
+ :wheelchair_accessible,
27
+ :bikes_allowed
28
+
29
+ def block
30
+ @trips = collection.where block_id: params[:id]
31
+ respond_with @trips
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ module DefaultViewsHelper
17
+ def index(json, records)
18
+ json.cache! [controller_name, filter] do
19
+ json.ignore_nil! true
20
+
21
+ json.status 'success'
22
+ json.data do
23
+ json.array!(records) {|record| json.extract! record, *fields }
24
+ end
25
+ end
26
+ end
27
+
28
+ def show(json, record)
29
+ json.cache! record do
30
+ json.ignore_nil! true
31
+ json.status 'success'
32
+ json.data do
33
+ json.extract! record, *fields
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,32 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ module FieldsHelper
17
+ def fields
18
+ (@fields ||= {})[model] ||= create_fields
19
+ end
20
+
21
+ private
22
+
23
+ def model
24
+ @model ||= controller_name.classify
25
+ end
26
+
27
+ def create_fields
28
+ attributes = GtfsEngine.const_get(model).attribute_names
29
+ attributes - %w(id data_set_id)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ # This file is part of the KNOWtime server.
2
+ #
3
+ # The KNOWtime server is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU General Public License as published by the Free
5
+ # Software Foundation, either version 3 of the License, or (at your option) any
6
+ # later version.
7
+ #
8
+ # The KNOWtime server is distributed in the hope that it will be useful, but
9
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with the KNOWtime server. If not, see <http://www.gnu.org/licenses/>.
15
+ module GtfsEngine
16
+ class Agency < ActiveRecord::Base
17
+ belongs_to :data_set, inverse_of: :agencies
18
+ end
19
+ end