tpg 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tpg.rb +20 -24
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 968aa727818bd5c9ebe7e1776c599d6b29e38dda
|
4
|
+
data.tar.gz: 1d6f859b2b264ef770a2a688f0b1bcdbbaa966c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b82b40fa3dc60b1b03f5458e93b68577e6dcfc4faaca236ab270d03666e856f1eb56b80fc799361a22cb35a390e3fec0666b391c118fb824de323a6ae3efc00
|
7
|
+
data.tar.gz: 3d765ee8aa3428c41679b6d5af078223fc417380bc7261dbca35b8441c5c1de760fb7bed9271676572363bfb8d08ee04700d92534b4877d8e37772d90ba29e2b
|
data/lib/tpg.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rest_client'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
class Tpg
|
6
|
-
VERSION =
|
7
|
-
DOMAIN =
|
6
|
+
VERSION = 'v1'.freeze
|
7
|
+
DOMAIN = 'https://prod.ivtr-od.tpg.ch'.freeze
|
8
8
|
|
9
9
|
def initialize(api_key)
|
10
10
|
@api_key = api_key
|
@@ -13,73 +13,69 @@ class Tpg
|
|
13
13
|
#
|
14
14
|
# @param: stopCode, stopName, line, latitude, longitude
|
15
15
|
#
|
16
|
-
def
|
17
|
-
|
16
|
+
def stops(params = {})
|
17
|
+
query('GetStops', params)['stops']
|
18
18
|
end
|
19
19
|
|
20
20
|
#
|
21
21
|
# @param: stopCode, stopName
|
22
22
|
#
|
23
|
-
def
|
24
|
-
|
23
|
+
def physical_stops(params = {})
|
24
|
+
query('GetPhysicalStops', params)['stops']
|
25
25
|
end
|
26
26
|
|
27
27
|
#
|
28
28
|
# @param: stopCode, departureCode, linesCode, destinationCode
|
29
29
|
#
|
30
|
-
def
|
31
|
-
|
30
|
+
def next_departures(params = {})
|
31
|
+
query('GetNextDepartures', params)
|
32
32
|
end
|
33
33
|
|
34
34
|
#
|
35
35
|
# @param: stopCode, lineCode, destinationCode
|
36
36
|
#
|
37
|
-
def
|
38
|
-
|
37
|
+
def all_next_departures(params = {})
|
38
|
+
query('GetAllNextDepartures', params)
|
39
39
|
end
|
40
40
|
|
41
41
|
#
|
42
42
|
# @param: departureCode
|
43
43
|
#
|
44
|
-
def
|
45
|
-
|
44
|
+
def thermometer(params = {})
|
45
|
+
query('GetThermometer', params)
|
46
46
|
end
|
47
47
|
|
48
48
|
#
|
49
49
|
# @param: departureCode
|
50
50
|
#
|
51
|
-
def
|
52
|
-
|
51
|
+
def thermometer_physical_stops(params = {})
|
52
|
+
query('GetThermometerPhysicalStops', params)
|
53
53
|
end
|
54
54
|
|
55
55
|
#
|
56
56
|
# @param: -
|
57
57
|
#
|
58
|
-
def
|
59
|
-
|
58
|
+
def lines_colors
|
59
|
+
query('GetLinesColors')
|
60
60
|
end
|
61
61
|
|
62
62
|
#
|
63
63
|
# @param: -
|
64
64
|
#
|
65
|
-
def
|
66
|
-
|
65
|
+
def disruptions
|
66
|
+
query('GetDisruptions')
|
67
67
|
end
|
68
68
|
|
69
69
|
protected
|
70
70
|
|
71
71
|
def query(method, params = nil)
|
72
|
-
# looks like http://rtpi.data.tpg.ch/v1/GetDisruptions?key=xxxx
|
73
72
|
url = "#{DOMAIN}/#{VERSION}/#{method}.json?key=#{@api_key}"
|
74
|
-
|
75
|
-
if params
|
76
|
-
url = "#{url}&#{self.create_query(params)}"
|
77
|
-
end
|
73
|
+
url = "#{url}&#{create_query(params)}" if params
|
78
74
|
|
79
75
|
JSON.parse(RestClient.get(url))
|
80
76
|
end
|
81
77
|
|
82
78
|
def create_query(params)
|
83
|
-
params.map{|k,v| "#{k}=#{v}" }.join('&')
|
79
|
+
params.map { |k, v| "#{k}=#{v}" }.join('&')
|
84
80
|
end
|
85
81
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ghn
|
@@ -16,30 +16,30 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 2.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 2.1.0
|
41
41
|
description: Transports Publics Genevois
|
42
|
-
email:
|
42
|
+
email: germain@ghmail.ch
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.5.2
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: TPG
|