tpg 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tpg.rb +20 -24
  3. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8fc39c85f71e12e2bd18aa54253e08b50c5a55b
4
- data.tar.gz: e13a237a55db32026284d4e825bd3ebda4e0633b
3
+ metadata.gz: 968aa727818bd5c9ebe7e1776c599d6b29e38dda
4
+ data.tar.gz: 1d6f859b2b264ef770a2a688f0b1bcdbbaa966c3
5
5
  SHA512:
6
- metadata.gz: caa4846d44b6d6676b4a22457ce4484718bfc4514dc7a69919ee557a7dcde72da6e4f7fd9e076c0f464d7d7705f3e63eac6dc593496b0cb9b9e0bc0e6be5c70c
7
- data.tar.gz: cde113f59c58a427bc901c0e11be969fdafea264872a9b80592cb09799be7d725dc7ebd8ff35db23d24e0ff37704597cbeb8426990bb5e6bc6267e7c5433b5f5
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 = "v1"
7
- DOMAIN = "http://rtpi.data.tpg.ch"
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 get_stops(params = {})
17
- self.query("GetStops", params)["stops"]
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 get_physical_stops(params = {})
24
- self.query("GetPhysicalStops", params)["stops"]
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 get_next_departures(params = {})
31
- self.query("GetNextDepartures", params)
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 get_all_next_departures(params = {})
38
- self.query("GetAllNextDepartures", params)
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 get_thermometer(params = {})
45
- self.query("GetThermometer", params)
44
+ def thermometer(params = {})
45
+ query('GetThermometer', params)
46
46
  end
47
47
 
48
48
  #
49
49
  # @param: departureCode
50
50
  #
51
- def get_thermometer_physical_stops(params = {})
52
- self.query("GetThermometerPhysicalStops", params)
51
+ def thermometer_physical_stops(params = {})
52
+ query('GetThermometerPhysicalStops', params)
53
53
  end
54
54
 
55
55
  #
56
56
  # @param: -
57
57
  #
58
- def get_lines_colors
59
- self.query("GetLinesColors")
58
+ def lines_colors
59
+ query('GetLinesColors')
60
60
  end
61
61
 
62
62
  #
63
63
  # @param: -
64
64
  #
65
- def get_disruptions
66
- self.query("GetDisruptions")
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.1
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: 1.7.2
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: 1.7.2
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.8.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.8.1
40
+ version: 2.1.0
41
41
  description: Transports Publics Genevois
42
- email: ghugon@gmail.com
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.2.2
68
+ rubygems_version: 2.5.2
69
69
  signing_key:
70
70
  specification_version: 4
71
71
  summary: TPG