tfl_api_client 0.1.0 → 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
  SHA1:
3
- metadata.gz: 072de61d15adb1e4f79ec7e0ab0b3d85d1618fb7
4
- data.tar.gz: b06257ef4ec2284db1eb978c5b2372fd7ad38fc2
3
+ metadata.gz: 6a675ef39a4ee3a74f9c640099cb3666e4dd4488
4
+ data.tar.gz: 59fbcc3f97451689780750c39d4b68d9aa751f80
5
5
  SHA512:
6
- metadata.gz: cf7b44b929b47a007102911506a007ed293ca585361c6cd697871000e3632c8c8faef938e97e1e5003dde0184dd430a061a37567d9bdf5f3fef16f4dc7af5606
7
- data.tar.gz: 72c58429cc1b558c74f77836063000e359c5ea0d50afe83b8dd68dbf04c9753e2d7105b56218cbec2e5cd2a703f3f5f0ae09d004ff0a819025214db8fecb67b0
6
+ metadata.gz: 18b34c5215adbabf9285ff46cf65f856d54cf4dd70945a4ad0981b9619db5c6cff276f80b6d254d1a830415ff8395be8dbe1b8e39f4e705eee69077e6369eac5
7
+ data.tar.gz: 1b9a663cf16a4d5d4044240d54da7238b6955b6c716a42edbf58e77bb91d3aeee1cf8f8b8229665a19deeb8d503920a1a192170edbf4a3fd42edc62566d34334
data/.travis.yml CHANGED
@@ -3,13 +3,14 @@ sudo: false
3
3
  cache: bundler
4
4
 
5
5
  rvm:
6
+ - 2.3.0
6
7
  - 2.2.0
7
8
  - 2.1.0
8
9
  - 2.0.0
9
10
 
10
11
  before_install:
11
12
  - gem uninstall bundler
12
- - gem install bundler --version '~> 1.10'
13
+ - gem install bundler --version '~> 1.11'
13
14
 
14
15
  script:
15
16
  - bundle exec rake
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ -
2
+ CHANGELOG.md
3
+ GETTING_STARTED.md
4
+ LICENSE
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.2.0 [17-APR-2016]
4
+ * Added support for the /CycleSuperhighway resource.
5
+
3
6
 
4
7
  ## v0.1.0 [13-AUG-2015]
5
8
  * First Release containing support for the /BikePoint resource.
data/GETTING_STARTED.md CHANGED
@@ -20,7 +20,7 @@ and docking station status information.
20
20
 
21
21
  ### Obtain an individual BikePoint
22
22
 
23
- Information upon an individual BikePoint can be obtained using the location
23
+ Information upon an individual BikePoint can be obtained using the `location`
24
24
  method, whilst also passing the ID of the BikePoint.
25
25
 
26
26
  ```ruby
@@ -159,3 +159,73 @@ client.bike_point.search("St. James's")
159
159
  ...
160
160
  ]
161
161
  ```
162
+
163
+
164
+ ## Cycle Superhighway
165
+
166
+ The cycle superhighway interface interacts with the /CycleSuperhighway
167
+ end point upon the TFL API. This end point will return information
168
+ regarding the [Cycle Superhighways][cycle_superhighways] locations,
169
+ including coordinates of the route.
170
+
171
+ [cycle_superhighways]: https://tfl.gov.uk/modes/cycling/routes-and-maps/cycle-superhighways
172
+
173
+ ### Obtain all Cycle Superhighways routes
174
+
175
+ In order to obtain all Cycle Superhighway routes and their details the
176
+ `superhighways` method can be used.
177
+
178
+ ```ruby
179
+ client = TflApi::Client.new(app_id: YOUR_TFL_APP_ID, app_key: YOUR_TFL_APP_KEY)
180
+ client.cycle.superhighways
181
+
182
+ => [
183
+ {
184
+ 'id': 'CS-1',
185
+ 'label': 'CS Route 1',
186
+ 'labelShort': 'CS-1',
187
+ 'segmented': true,
188
+ 'geography': {
189
+ 'type': 'LineString',
190
+ 'coordinates': [],
191
+ 'crs': {
192
+ 'type': 'name',
193
+ 'properties': {
194
+ 'name': 'ABC:1234'
195
+ }
196
+ }
197
+ }
198
+ }
199
+ ...
200
+ // Additional Cycle Superhighways
201
+ ...
202
+ ]
203
+ ```
204
+
205
+ ### Obtain an individual Cycle Superhighway routes
206
+
207
+ Information upon an individual Cycle Superhighway can be obtained using
208
+ the `superhighway` method, whilst passing the ID of the Cycle
209
+ Superhighway route.
210
+
211
+ ```ruby
212
+ client = TflApi::Client.new(app_id: YOUR_TFL_APP_ID, app_key: YOUR_TFL_APP_KEY)
213
+ client.cycle.superhighway('CS-1')
214
+
215
+ => {
216
+ 'id': 'CS-1',
217
+ 'label': 'CS Route 1',
218
+ 'labelShort': 'CS-1',
219
+ 'segmented': true,
220
+ 'geography': {
221
+ 'type': 'LineString',
222
+ 'coordinates': [],
223
+ 'crs': {
224
+ 'type': 'name',
225
+ 'properties': {
226
+ 'name': 'ABC:1234'
227
+ }
228
+ }
229
+ }
230
+ }
231
+ ```
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 Luke Hackett
1
+ Copyright (c) 2015 - 2016 Luke Hackett
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -42,21 +42,81 @@ Checkout the [Getting Started][getting_started] guide.
42
42
  [getting_started]: GETTING_STARTED.md
43
43
 
44
44
 
45
+ ## Changelog
46
+
47
+ See [CHANGELOG][changelog] for a list of changes.
48
+
49
+ [changelog]: CHANGELOG.md
50
+
51
+
45
52
  ## Contributing
46
53
 
47
- Check out [CONTRIBUTING.md][contributing] for more information upon
48
- contributing.
54
+ This project started in order to fill a gap in the current offers for
55
+ gems that provide a programmatic interface to TFL's API.
56
+
57
+ The TFL API Client gem was originally developed by [Luke Hackett][luke_hackett],
58
+ and is not an official TFL client.
49
59
 
50
- The TFL API Client gem was originally developed by
51
- [Luke Hackett][luke_hackett], and is not an official TFL client.
60
+ In the spirit of [free software][free-sw], **everyone** is encouraged to
61
+ help improve this project.
62
+
63
+ Here are some ways in which *you* can contribute:
64
+
65
+ * by using prerelease versions
66
+ * by reporting [bugs][issues]
67
+ * by suggesting [new features][issues]
68
+ * by writing or editing documentation
69
+ * by writing code ( **no patch is too small** : fix typos, add comments, clean up inconsistent whitespace )
70
+ * by refactoring code
71
+ * by reviewing code
52
72
 
53
- [contributing]: CONTRIBUTING.md
54
73
  [luke_hackett]: http://www.lukehackett.com
74
+ [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
75
+ [issues]: https://github.com/LukeHackett/tfl_api_client/issues
76
+
77
+ ### Submitting an Issue
78
+
79
+ I utilise the [GitHub issue tracking][issues] to track bugs and features.
80
+ Before submitting a bug report or feature request, check to make sure it
81
+ hasn't already been submitted.
82
+
83
+ When submitting a bug report, please include a [Gist][gist] that includes
84
+ a stack trace and any details that may be necessary to reproduce the bug,
85
+ including your gem version, Ruby version, and operating system.
86
+
87
+ Ideally, a bug report should include a pull request with failing specs.
88
+
89
+ [gist]: https://gist.github.com/
90
+
91
+ ### Submitting a Pull Request
92
+
93
+ 1. [Fork][fork] the [repository][repo].
94
+ 2. [Create a feature branch][branch] using the [gitflow][gitflow] naming convention e.g. `feature/my-new-feature`.
95
+ 3. Implement your feature or bug fix.
96
+ 4. Add, commit, and push your changes.
97
+ 5. [Submit a pull request][pr].
98
+
99
+ [repo]: https://github.com/LukeHackett/tfl_api_client/tree/master
100
+ [fork]: https://help.github.com/articles/fork-a-repo/
101
+ [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
102
+ [pr]: https://help.github.com/articles/using-pull-requests/
103
+ [gitflow]: http://danielkummer.github.io/git-flow-cheatsheet/#features
104
+
105
+ ### Notes
106
+
107
+ * Please add tests if you changed code - contributions without tests won't be accepted.
108
+ * Please don't update the Gem version.
109
+
110
+ The contributing guidelines was inspired by [Middleman-Heroku][middleman]
111
+ and [Factory Girl][factory_girl].
112
+
113
+ [middleman]: https://github.com/middleman/middleman-heroku/blob/master/CONTRIBUTING.md
114
+ [factory_girl]: https://github.com/thoughtbot/factory_girl/blob/master/CONTRIBUTING.md
55
115
 
56
116
 
57
117
  ## License
58
118
 
59
- Transport for London API Client is released under the [MIT License][license].
119
+ Copyright (c) 2015 - 2016 Luke Hackett. MIT Licensed, see [LICENSE][license] for details.
60
120
 
61
- [licence]: http://www.opensource.org/licenses/MIT
121
+ [license]: LICENSE
62
122
 
data/Rakefile CHANGED
@@ -28,3 +28,9 @@ namespace :test do
28
28
  spec.pattern = FileList['spec/integration/*_spec.rb']
29
29
  end
30
30
  end
31
+
32
+ desc "Generates the project's YARD documentation"
33
+ YARD::Rake::YardocTask.new do |task|
34
+ task.files = ['lib/**/*.rb']
35
+ task.options = ['-yardopts .yardopts']
36
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2015 Luke Hackett
2
+ # Copyright (c) 2015 - 2016 Luke Hackett
3
3
  #
4
4
  # MIT License
5
5
  #
@@ -26,6 +26,7 @@
26
26
  require 'tfl_api_client/version'
27
27
  require 'tfl_api_client/client'
28
28
  require 'tfl_api_client/bike_point'
29
+ require 'tfl_api_client/cycle'
29
30
  require 'tfl_api_client/exceptions'
30
31
 
31
32
  module TflApi
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2015 Luke Hackett
2
+ # Copyright (c) 2015 - 2016 Luke Hackett
3
3
  #
4
4
  # MIT License
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2015 Luke Hackett
2
+ # Copyright (c) 2015 - 2016 Luke Hackett
3
3
  #
4
4
  # MIT License
5
5
  #
@@ -104,6 +104,14 @@ module TflApi
104
104
  TflApi::Client::BikePoint.new(self)
105
105
  end
106
106
 
107
+ # Creates an instance to the Cycle class by passing a reference to self
108
+ #
109
+ # @return [TflApi::Client::Cycle] An object to Cycle subclass
110
+ #
111
+ def cycle
112
+ TflApi::Client::Cycle.new(self)
113
+ end
114
+
107
115
  # Performs a HTTP GET request to the api, based upon the given URI resource
108
116
  # and any additional HTTP query parameters. This method will automatically
109
117
  # inject the mandatory application id and application key HTTP query
@@ -0,0 +1,66 @@
1
+ #
2
+ # Copyright (c) 2015 - 2016 Luke Hackett
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+
27
+ module TflApi
28
+ class Client
29
+ # This class communicates with the TFL "/CycleSuperhighway" API to obtain
30
+ # details about the cycle superhighways based upon their IDs.
31
+ #
32
+ class Cycle
33
+
34
+ # Initialize the Cycle object and store the reference to Client object
35
+ #
36
+ # @param client [Client] the client object
37
+ #
38
+ # @return [Cycle] the Cycle object
39
+ #
40
+ def initialize(client)
41
+ @client = client
42
+ end
43
+
44
+ # Returns all Cycle Superhighway locations known by the TFL service
45
+ #
46
+ # @return [Array] An array of hashes containing all Cycle Superhighways
47
+ # and their details
48
+ #
49
+ def superhighways
50
+ @client.get('/CycleSuperhighway')
51
+ end
52
+
53
+ # Returns the all details known by the TFL service for the given
54
+ # Cycle Superhighway id.
55
+ #
56
+ # @param id [String] the TFL Cycle Superhighway id
57
+ #
58
+ # @return [hash] A hash containing the details of the given Cycle Superhighway
59
+ #
60
+ def superhighway(id)
61
+ @client.get("/CycleSuperhighway/#{id}")
62
+ end
63
+
64
+ end
65
+ end
66
+ end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2015 Luke Hackett
2
+ # Copyright (c) 2015 - 2016 Luke Hackett
3
3
  #
4
4
  # MIT License
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2015 Luke Hackett
2
+ # Copyright (c) 2015 - 2016 Luke Hackett
3
3
  #
4
4
  # MIT License
5
5
  #
@@ -24,5 +24,5 @@
24
24
  #
25
25
 
26
26
  module TflApi
27
- VERSION = '0.1.0'
27
+ VERSION = '0.2.0'
28
28
  end
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.tfl.gov.uk/CycleSuperhighway/RMP-006?app_id=TFL_APP_ID&app_key=TFL_APP_KEY
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - api.tfl.gov.uk
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Access-Control-Allow-Headers:
24
+ - Content-Type
25
+ Access-Control-Allow-Methods:
26
+ - GET,POST,PUT,DELETE,OPTIONS
27
+ Access-Control-Allow-Origin:
28
+ - "*"
29
+ Age:
30
+ - '0'
31
+ Api-Entity-Payload:
32
+ - CycleSuperhighway, CycleSuperhighway
33
+ Cache-Control:
34
+ - public, must-revalidate, max-age=150, s-maxage=300
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Date:
38
+ - Sun, 17 Apr 2016 17:00:44 GMT
39
+ Server:
40
+ - Microsoft-IIS/8.5
41
+ Via:
42
+ - 1.1 varnish
43
+ X-Aspnet-Version:
44
+ - 4.0.30319
45
+ X-Backend:
46
+ - api
47
+ X-Backend-Url:
48
+ - "/CycleSuperhighway/RMP-006"
49
+ X-Banning:
50
+ - ''
51
+ X-Cache:
52
+ - MISS
53
+ X-Cacheable:
54
+ - Yes. Cacheable
55
+ X-Hash-Url:
56
+ - "/cyclesuperhighway/rmp-006"
57
+ X-Ttl:
58
+ - '300.000'
59
+ X-Ttl-Rule:
60
+ - '0'
61
+ X-Varnish:
62
+ - 10.73.2.250
63
+ - '1504412933'
64
+ Transfer-Encoding:
65
+ - chunked
66
+ Connection:
67
+ - keep-alive
68
+ body:
69
+ encoding: ASCII-8BIT
70
+ string: '{"$id":"1","$type":"Tfl.Api.Presentation.Entities.CycleSuperhighway,
71
+ Tfl.Api.Presentation.Entities","id":"RMP-006","label":"CS North South - Elephant
72
+ & Castle to Greville Street","labelShort":"CSNS","geography":{"type":"LineString","coordinates":[[-0.1016,51.49514],[-0.10168,51.49517],[-0.10182,51.49523],[-0.1023,51.49543],[-0.1026,51.49551],[-0.10293,51.4956],[-0.10318,51.49567],[-0.10366,51.49581],[-0.1047297,51.4961447],[-0.1052686,51.4963158],[-0.1058087,51.4965074],[-0.1063538,51.4967403],[-0.1075906,51.4974068],[-0.1068546,51.4976099],[-0.106493,51.4977209],[-0.1061314,51.4978586],[-0.1048004,51.4985484],[-0.1049138,51.4985766],[-0.1049933,51.4986046],[-0.1050337,51.4986272],[-0.105075,51.4986576],[-0.1051059,51.498691],[-0.1051122,51.498705],[-0.1051152,51.498717],[-0.1051141,51.4987296],[-0.1051147,51.4987399],[-0.105112,51.4987473],[-0.1051109,51.4987546],[-0.1051068,51.4987606],[-0.1051063,51.4987652],[-0.1051032,51.4987709],[-0.1051016,51.4987788],[-0.1050984,51.4987818],[-0.1050988,51.4987868],[-0.1050948,51.498792],[-0.1050789,51.4988094],[-0.1050608,51.4988267],[-0.1050373,51.4988457],[-0.1050094,51.4988654],[-0.1049672,51.4988837],[-0.1049192,51.498903],[-0.1048709,51.4989147],[-0.1048106,51.4989234],[-0.10473,51.49892],[-0.10473,51.49903],[-0.10472,51.49932],[-0.1046946,51.499902],[-0.1046846,51.500171],[-0.1046757,51.5003957],[-0.10468,51.50046],[-0.10469,51.50054],[-0.1046943,51.5006183],[-0.1046934,51.5007113],[-0.1046882,51.500814],[-0.10468,51.501],[-0.1046732,51.5012487],[-0.1046579,51.501506],[-0.10465,51.50157],[-0.10463,51.50166],[-0.10461,51.50176],[-0.10461,51.50177],[-0.1046,51.50193],[-0.1046145,51.5021054],[-0.1046246,51.502225],[-0.1046157,51.5025123],[-0.10462,51.5026],[-0.1046127,51.5028394],[-0.104603,51.5031284],[-0.1045911,51.5034178],[-0.1045848,51.503708],[-0.1045848,51.5037463],[-0.1045654,51.504093],[-0.1045457,51.5043787],[-0.10454,51.50454],[-0.1045348,51.5046237],[-0.10453,51.5047],[-0.10453,51.50481],[-0.10452,51.50519],[-0.1045152,51.5054073],[-0.10449,51.5059],[-0.10448,51.5061],[-0.1044843,51.506284],[-0.10449,51.5067],[-0.104492,51.506764],[-0.1044679,51.5069422],[-0.1044437,51.5072042],[-0.1044236,51.5075781],[-0.1044015,51.508086],[-0.1044194,51.5083727],[-0.1044208,51.5084321],[-0.1044183,51.508482],[-0.1044205,51.5085461],[-0.1044012,51.5092205],[-0.1043847,51.5098347],[-0.1043558,51.5105147],[-0.1043694,51.5107926],[-0.1043715,51.5108413],[-0.1043801,51.5108907],[-0.1043851,51.5109507],[-0.1044023,51.5110507],[-0.1044359,51.5112147],[-0.104413,51.5113835],[-0.1041943,51.5117906],[-0.1041979,51.5120463],[-0.1042172,51.5121869],[-0.1042302,51.5122616],[-0.1042452,51.5123462],[-0.1042573,51.5124494],[-0.1042638,51.5124967],[-0.1042652,51.5125547],[-0.1042695,51.5126026],[-0.104268,51.5126507],[-0.1042666,51.5126933],[-0.1042664,51.5127056],[-0.1042699,51.5127296],[-0.1042731,51.5127507],[-0.1042735,51.5127711],[-0.1042738,51.5127897],[-0.1042754,51.5128111],[-0.1042789,51.5128454],[-0.10428,51.51293],[-0.1042879,51.5130073],[-0.10429,51.51307],[-0.10429,51.51315],[-0.10429,51.5132],[-0.1042873,51.513243],[-0.1042889,51.513289],[-0.10429,51.51335],[-0.10429,51.51342],[-0.1042966,51.5134637],[-0.1043,51.51349],[-0.10431,51.51357],[-0.10432,51.51368],[-0.1043254,51.513713],[-0.10433,51.51375],[-0.10434,51.5138],[-0.104363,51.5139217],[-0.1043896,51.5140245],[-0.1044206,51.5141591],[-0.1044815,51.5144837],[-0.1045349,51.5147302],[-0.1045813,51.514942],[-0.1045942,51.5149957],[-0.1046014,51.515032],[-0.10461,51.51506],[-0.10462,51.5151341],[-0.10464,51.51527],[-0.1046764,51.5154187],[-0.104715,51.5155704],[-0.10477,51.51581],[-0.1048097,51.5159961],[-0.10484,51.51618],[-0.1048862,51.5163883],[-0.10493,51.5166],[-0.1049659,51.5167654],[-0.1050011,51.5169557],[-0.10501,51.517],[-0.1050286,51.5170724],[-0.10506,51.51721],[-0.1050991,51.5173857],[-0.10515,51.51757],[-0.1051732,51.5176573],[-0.1051925,51.5177223],[-0.1052188,51.5178431],[-0.10528,51.51812],[-0.10533,51.518355],[-0.1053364,51.5183983],[-0.10534,51.51844],[-0.1053446,51.518545],[-0.10535,51.51861],[-0.1053564,51.5186703],[-0.10537,51.51873],[-0.1053897,51.5188074],[-0.1054071,51.5189274],[-0.1054506,51.5190838],[-0.105526,51.5193523],[-0.1056585,51.5197776]],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}},"segmented":true,"modified":"2016-04-15T16:51:31.177"}'
73
+ http_version:
74
+ recorded_at: Sun, 17 Apr 2016 17:00:43 GMT
75
+ recorded_with: VCR 3.0.1