tpg 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/tpg.rb +85 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a8fc39c85f71e12e2bd18aa54253e08b50c5a55b
|
4
|
+
data.tar.gz: e13a237a55db32026284d4e825bd3ebda4e0633b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: caa4846d44b6d6676b4a22457ce4484718bfc4514dc7a69919ee557a7dcde72da6e4f7fd9e076c0f464d7d7705f3e63eac6dc593496b0cb9b9e0bc0e6be5c70c
|
7
|
+
data.tar.gz: cde113f59c58a427bc901c0e11be969fdafea264872a9b80592cb09799be7d725dc7ebd8ff35db23d24e0ff37704597cbeb8426990bb5e6bc6267e7c5433b5f5
|
data/lib/tpg.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rest_client'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Tpg
|
6
|
+
VERSION = "v1"
|
7
|
+
DOMAIN = "http://rtpi.data.tpg.ch"
|
8
|
+
|
9
|
+
def initialize(api_key)
|
10
|
+
@api_key = api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# @param: stopCode, stopName, line, latitude, longitude
|
15
|
+
#
|
16
|
+
def get_stops(params = {})
|
17
|
+
self.query("GetStops", params)["stops"]
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# @param: stopCode, stopName
|
22
|
+
#
|
23
|
+
def get_physical_stops(params = {})
|
24
|
+
self.query("GetPhysicalStops", params)["stops"]
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# @param: stopCode, departureCode, linesCode, destinationCode
|
29
|
+
#
|
30
|
+
def get_next_departures(params = {})
|
31
|
+
self.query("GetNextDepartures", params)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# @param: stopCode, lineCode, destinationCode
|
36
|
+
#
|
37
|
+
def get_all_next_departures(params = {})
|
38
|
+
self.query("GetAllNextDepartures", params)
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# @param: departureCode
|
43
|
+
#
|
44
|
+
def get_thermometer(params = {})
|
45
|
+
self.query("GetThermometer", params)
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# @param: departureCode
|
50
|
+
#
|
51
|
+
def get_thermometer_physical_stops(params = {})
|
52
|
+
self.query("GetThermometerPhysicalStops", params)
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# @param: -
|
57
|
+
#
|
58
|
+
def get_lines_colors
|
59
|
+
self.query("GetLinesColors")
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# @param: -
|
64
|
+
#
|
65
|
+
def get_disruptions
|
66
|
+
self.query("GetDisruptions")
|
67
|
+
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
71
|
+
def query(method, params = nil)
|
72
|
+
# looks like http://rtpi.data.tpg.ch/v1/GetDisruptions?key=xxxx
|
73
|
+
url = "#{DOMAIN}/#{VERSION}/#{method}.json?key=#{@api_key}"
|
74
|
+
|
75
|
+
if params
|
76
|
+
url = "#{url}&#{self.create_query(params)}"
|
77
|
+
end
|
78
|
+
|
79
|
+
JSON.parse(RestClient.get(url))
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_query(params)
|
83
|
+
params.map{|k,v| "#{k}=#{v}" }.join('&')
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tpg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ghn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.7.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.7.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.1
|
41
|
+
description: Transports Publics Genevois
|
42
|
+
email: ghugon@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/tpg.rb
|
48
|
+
homepage: http://rubygems.org/gems/tpg
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.2.2
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: TPG
|
72
|
+
test_files: []
|