translink 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGELOG.md +12 -0
  2. data/README.md +44 -8
  3. data/doc/schema.graffle +396 -82
  4. data/doc/schema.png +0 -0
  5. data/lib/translink/cli.rb +10 -16
  6. data/lib/translink/crawler.rb +5 -6
  7. data/lib/translink/db.rb +6 -14
  8. data/lib/translink/model/route.rb +29 -18
  9. data/lib/translink/model/stop.rb +17 -19
  10. data/lib/translink/model/stop_time.rb +26 -0
  11. data/lib/translink/model/trip.rb +48 -0
  12. data/lib/translink/page/route.rb +42 -18
  13. data/lib/translink/page/timetable.rb +15 -18
  14. data/lib/translink/page/trip.rb +90 -17
  15. data/lib/translink/page.rb +1 -1
  16. data/lib/translink/version.rb +1 -1
  17. data/lib/translink.rb +2 -3
  18. data/test/fixtures/sample/route.html +401 -1049
  19. data/test/fixtures/sample/timetable.html +170 -216
  20. data/test/fixtures/verbatim/route.html +1976 -7178
  21. data/test/fixtures/verbatim/timetable.html +1501 -6165
  22. data/test/fixtures/verbatim/trip.html +311 -508
  23. data/test/unit/cli_test.rb +4 -20
  24. data/test/unit/crawler_test.rb +16 -36
  25. data/test/unit/model/route_test.rb +14 -25
  26. data/test/unit/model/stop_test.rb +6 -31
  27. data/test/unit/model/stop_time_test.rb +11 -0
  28. data/test/unit/model/trip_test.rb +28 -0
  29. data/test/unit/page/route_test.rb +38 -28
  30. data/test/unit/page/timetable_test.rb +12 -10
  31. data/test/unit/page/trip_test.rb +38 -22
  32. data/test/unit/page_test.rb +1 -1
  33. data/translink.gemspec +2 -2
  34. metadata +24 -27
  35. data/lib/translink/code.rb +0 -9
  36. data/lib/translink/model/service.rb +0 -20
  37. data/lib/translink/model/stop/extractor.rb +0 -67
  38. data/test/unit/code_test.rb +0 -12
  39. data/test/unit/model/service_test.rb +0 -23
  40. data/test/unit/model/stop/extractor_test.rb +0 -112
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## Current
4
+
5
+ * Compatibility with Translink website (2012-05-29).
6
+ * Changed schema to conform with Google Transit feed specification.
7
+ * Stops include latitude and longitude fields.
8
+ * Help command always gives working example.
9
+
10
+ ## 2012-03-15 / v0.0.1
11
+
12
+ * Initial release.
data/README.md CHANGED
@@ -3,32 +3,68 @@
3
3
  [![Build Status](https://secure.travis-ci.org/tatey/translink.png)](http://travis-ci.org/tatey/translink)
4
4
 
5
5
  [Translink](http://translink.com.au/) (Organisation) coordinates public transport operations in
6
- Brisbane. Their website has an abundance of data with no easy way for a developer
6
+ South-East Queensland. Their website has an abundance of data with no easy way for a developer
7
7
  to query it.
8
8
 
9
- Translink (Program) scrapes bus stops, routes and service times into a nicely structured
10
- database. Data is sourced from the [Translink website](http://translink.com.au/). Only routes
11
- with codes 100..499, GLIDER and LOOP are persisted. You should be aware their data is protected by [copyright](http://translink.com.au/site-information/legal/copyright).
9
+ Translink (Program) scrapes bus routes, trips, stops and times into a relational database.
10
+ Data is sourced from the [Translink website](http://translink.com.au/).You should be
11
+ aware their data is protected by [copyright](http://translink.com.au/site-information/legal/copyright).
12
12
 
13
- ## Usage
13
+ ## Installation
14
+
15
+ Translink requires Ruby 1.9.2 or greater. For documentation on how to install Ruby on your
16
+ platform, visit the [Download Ruby](http://www.ruby-lang.org/en/downloads/) page.
14
17
 
15
- First install.
18
+ Translink is available as a gem. On UNIX-like platforms, install translink from the command line.
16
19
 
17
20
  $ [sudo] gem install translink
18
21
 
19
- Then scrape all bus stops, routes and services for Thursday, 24 November 2011 saving
22
+ ## Usage
23
+
24
+ Scrape all bus stops, routes and services for Thursday, 24 November 2011 saving
20
25
  them into a SQLite database named "2011-11-24.sqlite3" in the current working directory.
21
26
 
22
27
  $ translink scrape 2011-11-24
23
28
 
24
29
  Change the path to the SQLite database.
25
30
 
26
- $ translink scrape 2011-11-24 --uri="sqlite:///Users/Tate/Downloads/translink.sqlite3"
31
+ $ translink scrape 2011-11-24 --uri=sqlite:///Users/Tate/Downloads/translink.sqlite3
32
+
33
+ ## Queries
34
+
35
+ Stops the 130 visits on the outbound trip.
36
+
37
+ SELECT DISTINCT(stops.id), stops.stop_name, stops.stop_lat, stops.stop_lon FROM routes
38
+ INNER JOIN trips ON trips.route_id = routes.id
39
+ INNER JOIN stop_times ON stop_times.trip_id = trips.id
40
+ INNER JOIN stops ON stop_times.stop_id = stops.id
41
+ WHERE routes.short_name = '130' AND trips.direction = 'outbound';
42
+
43
+ Routes that visit the 'Calam Rd near Honeywood St' stop.
44
+
45
+ SELECT DISTINCT(routes.id), short_name FROM stops
46
+ INNER JOIN stop_times ON stop_times.stop_id = stops.id
47
+ INNER JOIN trips ON stop_times.trip_id = trips.id
48
+ INNER JOIN routes ON routes.id = trips.route_id
49
+ WHERE stops.stop_name = 'Calam Rd near Honeywood St';
27
50
 
28
51
  ## Schema
29
52
 
30
53
  ![Class Analysis Diagram](https://github.com/tatey/translink/raw/master/doc/schema.png)
31
54
 
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Install dependencies (`bundle install`)
59
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 4. Run tests (`rake test`)
61
+ 5. Commit your changes (`git commit -am 'Added some feature'`)
62
+ 6. Push to the branch (`git push origin my-new-feature`)
63
+ 7. Create new Pull Request
64
+
32
65
  ## Copyright
33
66
 
67
+ Doing something interesting with this data? Shoot me an [e-mail](mailto:tate@tatey.com). I'd love to see how
68
+ this is being used. An acknowledgement of this project is appreciated, but not required.
69
+
34
70
  Copyright © 2011 Tate Johnson. Released under the MIT license. See LICENSE.