ruby_ptv 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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +123 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruby_ptv/client/departures.rb +26 -0
- data/lib/ruby_ptv/client/directions.rb +37 -0
- data/lib/ruby_ptv/client/disruptions.rb +35 -0
- data/lib/ruby_ptv/client/patterns.rb +16 -0
- data/lib/ruby_ptv/client/route_types.rb +13 -0
- data/lib/ruby_ptv/client/routes.rb +24 -0
- data/lib/ruby_ptv/client/runs.rb +49 -0
- data/lib/ruby_ptv/client/search.rb +16 -0
- data/lib/ruby_ptv/client/stops.rb +39 -0
- data/lib/ruby_ptv/client.rb +38 -0
- data/lib/ruby_ptv/request.rb +33 -0
- data/lib/ruby_ptv/version.rb +3 -0
- data/lib/ruby_ptv.rb +35 -0
- data/ruby_ptv.gemspec +32 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94cd749c60cb0f297aced57c99e4176e081a657b
|
4
|
+
data.tar.gz: 8483ef5042d542ce8d19ea7ff26f882fad85a2e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c56393dc656a135c4344035b211a60852857587131328fe009fffedacbdcadb1ad27cdab49286e4cba47a1c4d3b657cddec2a23c1f7cb5add3c9ae75b97a7ba3
|
7
|
+
data.tar.gz: 247de7a0c505aa6833a0005662e1871cb47cfd4fe4405801cc95d517e17a95920ce5bd817a63b4a93796dc99ed7238924ab68b123a44b01ec96443c456876ccd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Check quotes usage according to lint rule below.
|
2
|
+
Style/StringLiterals:
|
3
|
+
Enabled: true
|
4
|
+
EnforcedStyle: double_quotes
|
5
|
+
|
6
|
+
# Maximum line length
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 160
|
9
|
+
IgnoreCopDirectives: true
|
10
|
+
|
11
|
+
# Maximum block length
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Max: 40
|
14
|
+
|
15
|
+
# Disable the need for documentation at top of each module
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/NumericLiterals:
|
20
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dylan Shaw
|
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,123 @@
|
|
1
|
+
# RubyPtv
|
2
|
+
|
3
|
+
A ruby wrapper for the Public Transport Victoria API V3.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruby_ptv'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ruby_ptv
|
20
|
+
|
21
|
+
## Getting started
|
22
|
+
|
23
|
+
You must have a valid PTV developer API key. If you don't have one, you can find out how to register for one [here](https://www.ptv.vic.gov.au/about-ptv/ptv-data-and-reports/digital-products/ptv-timetable-api).
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Setup:
|
28
|
+
|
29
|
+
``` ruby
|
30
|
+
client = RubyPtv::Client.new(dev_id: "ID", secret_key: "SECRET")
|
31
|
+
```
|
32
|
+
|
33
|
+
### Optional global configuration:
|
34
|
+
|
35
|
+
``` ruby
|
36
|
+
client = RubyPtv.configure(
|
37
|
+
dev_id: "ID",
|
38
|
+
secret_key: "SECRET"
|
39
|
+
)
|
40
|
+
```
|
41
|
+
You can get the global configuration with:
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
RubyPtv.configuration # => { dev_id: "YOUR_ID", secret_key "YOUR_SECRET }
|
45
|
+
```
|
46
|
+
|
47
|
+
In case you need to reset the configuration:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
RubyPtv.reset_configuration
|
51
|
+
```
|
52
|
+
|
53
|
+
## Examples
|
54
|
+
|
55
|
+
### Departures
|
56
|
+
|
57
|
+
You can search departures for all routes or for a single route. You can add any optional paramaters, as a hash, that are specified in the PTV api documentation (NOTE: the parameter keys MUST match the exact names specified by PTV).
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
client.departures(0, 1023, direction_id: 1)
|
61
|
+
client.departures_for_route(0, 1127, 14)
|
62
|
+
```
|
63
|
+
|
64
|
+
Searching departures will return a number of nested hashes due to the number of optional params available. You can loop through the results easily:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
response = client.departures(0, 1023)
|
68
|
+
|
69
|
+
response["departures"].each do |departure|
|
70
|
+
departure["stop_id"] # => stop id
|
71
|
+
departure["platform_number"] # => platform number
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
### Routes
|
76
|
+
|
77
|
+
You can search all routes or search for a route with a specified route id. There are no optional paramters available for the routes methods.
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
client.routes
|
81
|
+
client.route(2)
|
82
|
+
```
|
83
|
+
|
84
|
+
Searching routes will return a single array of hashes:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
response = client.routes
|
88
|
+
|
89
|
+
routes.each do |route|
|
90
|
+
route["route_type"] # => route type
|
91
|
+
route["route_name"] # => route name
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
### Search
|
96
|
+
|
97
|
+
The search method allows you to query any stops, routes and myki ticket outlets with a specified search term. Just like departures, you can add any optional paramters that are specified by the PTV documentation.
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
client.search("Glen Waverley", route_types: 0)
|
101
|
+
```
|
102
|
+
|
103
|
+
### Further information
|
104
|
+
|
105
|
+
The source code is fully commented with any required parameters and basic information you may need to use this wrapper. If you are unsure of any specifics of the API, such as any optional parameters available, check the official PTV documentation.
|
106
|
+
|
107
|
+
## Testing
|
108
|
+
|
109
|
+
To run the test suite:
|
110
|
+
|
111
|
+
```
|
112
|
+
bundle exec rake test
|
113
|
+
```
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
Bug reports and pull requests are welcome. Just create a new branch for your feature, add the appropriate tests and open a pull request.
|
118
|
+
|
119
|
+
|
120
|
+
## License
|
121
|
+
|
122
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
123
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby_ptv"
|
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(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Departures
|
3
|
+
# Get departures for all routes for a specified stop
|
4
|
+
#
|
5
|
+
# Required params:
|
6
|
+
# route_type [Integer]
|
7
|
+
# stop_id [Integer]
|
8
|
+
#
|
9
|
+
# Optional params must have key matching official PTV param name
|
10
|
+
def departures(route_type, stop_id, options = {})
|
11
|
+
request("departures/route_type/#{route_type}/stop/#{stop_id}", options)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get departures for a single route for a specified stop
|
15
|
+
#
|
16
|
+
# Required params:
|
17
|
+
# route_type [Integer]
|
18
|
+
# stop_id [Integer]
|
19
|
+
# route_id [String]
|
20
|
+
#
|
21
|
+
# Optional params must have key matching official PTV param name
|
22
|
+
def departures_for_route(route_type, stop_id, route_id, options = {})
|
23
|
+
request("departures/route_type/#{route_type}/stop/#{stop_id}/route/#{route_id}", options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Directions
|
3
|
+
# Get all routes that travel in a specified direction
|
4
|
+
#
|
5
|
+
# Required params:
|
6
|
+
# direction_id [Integer]
|
7
|
+
#
|
8
|
+
# No optional params available
|
9
|
+
def direction(direction_id)
|
10
|
+
data = request("directions/#{direction_id}")
|
11
|
+
data["directions"]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get all directions that a specified route travels in
|
15
|
+
#
|
16
|
+
# Required params:
|
17
|
+
# route_id [Integer]
|
18
|
+
#
|
19
|
+
# No optional params available
|
20
|
+
def directions_for_route(route_id)
|
21
|
+
data = request("directions/route/#{route_id}")
|
22
|
+
data["directions"]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get all routes of the specified route type that travel in the specified direction
|
26
|
+
#
|
27
|
+
# Required params:
|
28
|
+
# direction_id [Integer]
|
29
|
+
# route_id [Integer]
|
30
|
+
#
|
31
|
+
# No optional params available
|
32
|
+
def directions_for_route_type(direction_id, route_type)
|
33
|
+
data = request("directions/#{direction_id}/route_type/#{route_type}")
|
34
|
+
data["directions"]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Disruptions
|
3
|
+
# Get all disruption information
|
4
|
+
#
|
5
|
+
# No required params
|
6
|
+
#
|
7
|
+
# Optional params must have key matching official PTV param name
|
8
|
+
def disruptions(options = {})
|
9
|
+
data = request("disruptions", options)
|
10
|
+
data["disruptions"]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get all disruption information for a specified route
|
14
|
+
#
|
15
|
+
# Required params:
|
16
|
+
# route_id [Integer]
|
17
|
+
#
|
18
|
+
# Optional params must have key matching official PTV param name
|
19
|
+
def disruptions_for_route(route_id, options = {})
|
20
|
+
data = request("disruptions/route/#{route_id}", options)
|
21
|
+
data["disruptions"]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get information on a specified disruption
|
25
|
+
#
|
26
|
+
# Required params:
|
27
|
+
# dispruption_id [Integer]
|
28
|
+
#
|
29
|
+
# No optional params available
|
30
|
+
def disruption(disruption_id)
|
31
|
+
data = request("disruptions/#{disruption_id}")
|
32
|
+
data["disruption"]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Patterns
|
3
|
+
# The stopping pattern of the specified run and route type
|
4
|
+
#
|
5
|
+
# Required params:
|
6
|
+
# run_id [Integer]
|
7
|
+
# route_type [Integer]
|
8
|
+
#
|
9
|
+
# Optional params must have key matching official PTV param name
|
10
|
+
def pattern(run_id, route_type, options = {})
|
11
|
+
data = request("pattern/run/#{run_id}/route_type/#{route_type}", options)
|
12
|
+
data.delete("status")
|
13
|
+
data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Routes
|
3
|
+
# Get route details of all route types
|
4
|
+
#
|
5
|
+
# No required params
|
6
|
+
#
|
7
|
+
# Optional params must have key matching official PTV param name
|
8
|
+
def routes(options = {})
|
9
|
+
data = request("routes", options)
|
10
|
+
data["routes"]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get route details for a specified route ID
|
14
|
+
#
|
15
|
+
# Required params:
|
16
|
+
# route_id [Integer]
|
17
|
+
#
|
18
|
+
# No optional params available
|
19
|
+
def route(route_id)
|
20
|
+
data = request("routes/#{route_id}")
|
21
|
+
data["route"]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Runs
|
3
|
+
# Get all runs for the specified route ID
|
4
|
+
#
|
5
|
+
# Required params:
|
6
|
+
# route_id [Integer]
|
7
|
+
#
|
8
|
+
# No optional params available
|
9
|
+
def runs_for_route_id(route_id)
|
10
|
+
data = request("runs/route/#{route_id}")
|
11
|
+
data["runs"]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get all runs for the specified route ID and route type
|
15
|
+
#
|
16
|
+
# Required params:
|
17
|
+
# route_id [Integer]
|
18
|
+
# route_type [Integer]
|
19
|
+
#
|
20
|
+
# No optional params available
|
21
|
+
def runs_for_route_id_and_type(route_id, route_type)
|
22
|
+
data = request("runs/route/#{route_id}/route_type/#{route_type}")
|
23
|
+
data["runs"]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get all runs for the specified run ID
|
27
|
+
#
|
28
|
+
# Required params:
|
29
|
+
# run_id [Integer]
|
30
|
+
#
|
31
|
+
# No optional params available
|
32
|
+
def runs_for_run_id(run_id)
|
33
|
+
data = request("runs/#{run_id}")
|
34
|
+
data["runs"]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get the run details for the specified run ID and route type
|
38
|
+
#
|
39
|
+
# Required params:
|
40
|
+
# run_id [Integer]
|
41
|
+
# route_type [Integer]
|
42
|
+
#
|
43
|
+
# No optional params available
|
44
|
+
def run_for_run_id_and_route_type(run_id, route_type)
|
45
|
+
data = request("runs/#{run_id}/route_type/#{route_type}")
|
46
|
+
data["run"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Search
|
3
|
+
# Stops, routes and myki ticket outlets that contain the specified search term
|
4
|
+
#
|
5
|
+
# Required params:
|
6
|
+
# search_term [String]
|
7
|
+
# NOTE: if search text is numeric and/or less than 3 characters
|
8
|
+
# the API will only return routes
|
9
|
+
#
|
10
|
+
# Optional params must have key matching official PTV param name
|
11
|
+
def search(search_term, options = {})
|
12
|
+
encoded_string = ERB::Util.url_encode(search_term)
|
13
|
+
request("search/#{encoded_string}", options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module RubyPtv
|
2
|
+
module Stops
|
3
|
+
# Stop location, amenity and accessibility facility information for the specified stop
|
4
|
+
#
|
5
|
+
# Required params:
|
6
|
+
# stop_id [Integer]
|
7
|
+
# route_type [Integer]
|
8
|
+
#
|
9
|
+
# Optional params must have key matching official PTV param name
|
10
|
+
def stop(stop_id, route_type, options = {})
|
11
|
+
data = request("stops/#{stop_id}/route_type/#{route_type}", options)
|
12
|
+
data["stop"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# All stops for the specified route
|
16
|
+
#
|
17
|
+
# Required params:
|
18
|
+
# route_id [Integer]
|
19
|
+
# route_type [Integer]
|
20
|
+
#
|
21
|
+
# No optional params available
|
22
|
+
def stops_for_route(route_id, route_type)
|
23
|
+
data = request("stops/route/#{route_id}/route_type/#{route_type}")
|
24
|
+
data["stops"]
|
25
|
+
end
|
26
|
+
|
27
|
+
# All stops for the specified location
|
28
|
+
#
|
29
|
+
# Required params:
|
30
|
+
# latitude [Float]
|
31
|
+
# longitude [Float]
|
32
|
+
#
|
33
|
+
# Optional params must have key matching official PTV param name
|
34
|
+
def stops_for_location(latitude, longitude, options = {})
|
35
|
+
data = request("stops/location/#{latitude},#{longitude}", options)
|
36
|
+
data["stops"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "ruby_ptv/client/departures"
|
2
|
+
require "ruby_ptv/client/directions"
|
3
|
+
require "ruby_ptv/client/disruptions"
|
4
|
+
require "ruby_ptv/client/patterns"
|
5
|
+
require "ruby_ptv/client/routes"
|
6
|
+
require "ruby_ptv/client/route_types"
|
7
|
+
require "ruby_ptv/client/runs"
|
8
|
+
require "ruby_ptv/client/search"
|
9
|
+
require "ruby_ptv/client/stops"
|
10
|
+
require "ruby_ptv/request"
|
11
|
+
|
12
|
+
module RubyPtv
|
13
|
+
class Client
|
14
|
+
include RubyPtv::Request
|
15
|
+
include RubyPtv::Departures
|
16
|
+
include RubyPtv::Directions
|
17
|
+
include RubyPtv::Disruptions
|
18
|
+
include RubyPtv::Patterns
|
19
|
+
include RubyPtv::Routes
|
20
|
+
include RubyPtv::RouteTypes
|
21
|
+
include RubyPtv::Runs
|
22
|
+
include RubyPtv::Search
|
23
|
+
include RubyPtv::Stops
|
24
|
+
|
25
|
+
# Initialize a RubyPtv::Client instance
|
26
|
+
#
|
27
|
+
# Both must be passed in:
|
28
|
+
# options[:dev_id] = PTV developer ID
|
29
|
+
# options[:secret_key] = PTV developer key
|
30
|
+
#
|
31
|
+
def initialize(options = {})
|
32
|
+
raise ArgumentError, "Options hash required." unless options.is_a?(Hash)
|
33
|
+
|
34
|
+
@dev_id = options[:dev_id]
|
35
|
+
@secret_key = options[:secret_key]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module RubyPtv
|
5
|
+
# Module used for dispatching http requests
|
6
|
+
module Request
|
7
|
+
include HTTParty
|
8
|
+
|
9
|
+
# Perform HTTP get request
|
10
|
+
#
|
11
|
+
# path = request path
|
12
|
+
# params = parameters hash
|
13
|
+
#
|
14
|
+
def request(path, params = {})
|
15
|
+
raise StandardError, "Dev ID and secret key are required." unless @dev_id && @secret_key
|
16
|
+
|
17
|
+
request_path = if params.empty?
|
18
|
+
"/v3/#{path}?devid=#{@dev_id}"
|
19
|
+
else
|
20
|
+
"/v3/#{path}?#{URI.encode_www_form(params)}&devid=#{@dev_id}"
|
21
|
+
end
|
22
|
+
# Create unique SHA1 signature with each request
|
23
|
+
signature = OpenSSL::HMAC.hexdigest("SHA1", @secret_key, request_path)
|
24
|
+
req = "https://timetableapi.ptv.vic.gov.au" + request_path + "&signature=" + signature.upcase
|
25
|
+
|
26
|
+
parse(HTTParty.get(req))
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse(resp)
|
30
|
+
JSON.parse(resp.body)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/ruby_ptv.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "ruby_ptv/version"
|
2
|
+
require "ruby_ptv/client"
|
3
|
+
|
4
|
+
module RubyPtv
|
5
|
+
class << self
|
6
|
+
attr_accessor :options
|
7
|
+
end
|
8
|
+
self.options = {}
|
9
|
+
|
10
|
+
# Define global configuration, if desired
|
11
|
+
#
|
12
|
+
# Required params:
|
13
|
+
# options[:dev_id] - PTV developer ID
|
14
|
+
# options[:secret_key] - PTV developer key
|
15
|
+
#
|
16
|
+
def self.configure(params = {})
|
17
|
+
raise(ArgumentError, "Options hash required.") unless params.is_a?(Hash)
|
18
|
+
|
19
|
+
options[:dev_id] = params[:dev_id]
|
20
|
+
options[:secret_key] = params[:secret_key]
|
21
|
+
options
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns global configuration hash
|
25
|
+
#
|
26
|
+
def self.configuration
|
27
|
+
options
|
28
|
+
end
|
29
|
+
|
30
|
+
# Resets the global configuration
|
31
|
+
#
|
32
|
+
def self.reset_configuration
|
33
|
+
self.options = {}
|
34
|
+
end
|
35
|
+
end
|
data/ruby_ptv.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "ruby_ptv/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruby_ptv"
|
7
|
+
spec.version = RubyPtv::VERSION
|
8
|
+
spec.authors = ["Dylan Shaw"]
|
9
|
+
spec.email = ["dylanshaw012@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "A wrapper for the Public Transport Victoria API written in Ruby. The official documentation is available here: https://timetableapi.ptv.vic.gov.au/swagger/ui/index."
|
12
|
+
spec.description = "Add a description later.."
|
13
|
+
spec.homepage = "https://github.com/dshaw1/ruby-ptv-api"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "httparty", "~> 0.13.7"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
26
|
+
spec.add_development_dependency "dotenv", "~> 2.2"
|
27
|
+
spec.add_development_dependency "multi_json", "~> 1.11"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "vcr", "~> 3.0"
|
31
|
+
spec.add_development_dependency "webmock", "~> 3.1"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_ptv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dylan Shaw
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: multi_json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.1'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.1'
|
125
|
+
description: Add a description later..
|
126
|
+
email:
|
127
|
+
- dylanshaw012@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/setup
|
142
|
+
- lib/ruby_ptv.rb
|
143
|
+
- lib/ruby_ptv/client.rb
|
144
|
+
- lib/ruby_ptv/client/departures.rb
|
145
|
+
- lib/ruby_ptv/client/directions.rb
|
146
|
+
- lib/ruby_ptv/client/disruptions.rb
|
147
|
+
- lib/ruby_ptv/client/patterns.rb
|
148
|
+
- lib/ruby_ptv/client/route_types.rb
|
149
|
+
- lib/ruby_ptv/client/routes.rb
|
150
|
+
- lib/ruby_ptv/client/runs.rb
|
151
|
+
- lib/ruby_ptv/client/search.rb
|
152
|
+
- lib/ruby_ptv/client/stops.rb
|
153
|
+
- lib/ruby_ptv/request.rb
|
154
|
+
- lib/ruby_ptv/version.rb
|
155
|
+
- ruby_ptv.gemspec
|
156
|
+
homepage: https://github.com/dshaw1/ruby-ptv-api
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.6.8
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: 'A wrapper for the Public Transport Victoria API written in Ruby. The official
|
180
|
+
documentation is available here: https://timetableapi.ptv.vic.gov.au/swagger/ui/index.'
|
181
|
+
test_files: []
|