transilien_microservices 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +60 -36
- data/lib/transilien/version.rb +1 -1
- data/lib/transilien_microservices.rb +13 -13
- data/spec/vehicle_journey_spec.rb +0 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8cfb26dac1858fbf4b4c7ebac75daadda2c7cb
|
4
|
+
data.tar.gz: 4cadc46e4741ee1a22f7f367aae37588f6f285f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ace09e85bfcce2c6ed9fbd9a590ff119ad00c178fe008f934175a0f196b1cfc555da411eea90f4b0f62922aae559ec13c5dc40358465168e84ef3c906e2a25b5
|
7
|
+
data.tar.gz: 5109350653b20ad975bace3d805855f3ab468b480f1dcee6c85fe83b1b181e9bbe537e72120192cdd2c8d20a788a4bfb588f2cc99b63577aa702db55c89c5c84
|
data/README.md
CHANGED
@@ -2,79 +2,101 @@
|
|
2
2
|
|
3
3
|
Ruby implementation of SNCF Transilien Microservices.
|
4
4
|
|
5
|
-
Here the original service documentation: http://test.data-sncf.com/index.php/transilien.html/api.22.22-micro-services.html
|
5
|
+
Here is the original service documentation: http://test.data-sncf.com/index.php/transilien.html/api.22.22-micro-services.html
|
6
6
|
|
7
|
-
These services let you know the theoric
|
7
|
+
These services let you know the theoric train times on the Transilien service.
|
8
8
|
|
9
|
-
Disclamer: The gem only
|
9
|
+
Disclamer: The gem only intends to implements the API. I'll create a "easy" wrapper to access these data in a convenient way very soon.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
-
Gem developped with ruby 2.0.0, should work with ruby 1.9.3
|
13
|
+
Gem developped with ruby 2.0.0, should work with ruby 1.9.3.
|
14
14
|
|
15
15
|
Add this line to your application's Gemfile:
|
16
16
|
|
17
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'transilien_microservices'
|
19
|
+
````
|
18
20
|
|
19
21
|
And then execute:
|
20
22
|
|
21
|
-
|
23
|
+
```sh
|
24
|
+
$ bundle
|
25
|
+
```
|
22
26
|
|
23
27
|
Or install it yourself as:
|
24
28
|
|
25
|
-
|
29
|
+
```sh
|
30
|
+
$ gem install transilien_microservices
|
31
|
+
```
|
26
32
|
|
27
33
|
## Usage
|
28
34
|
|
29
|
-
The best way to access data is certainly querying through StopArea
|
35
|
+
The best way to access data is certainly querying through `StopArea`. Start by fetching them.
|
30
36
|
|
31
|
-
|
37
|
+
```ruby
|
38
|
+
stop_areas = Transilien::StopArea.find
|
39
|
+
```
|
32
40
|
|
33
|
-
Every Transilien "main"
|
41
|
+
Every Transilien "main" object has the same attributes:
|
34
42
|
|
35
|
-
|
36
|
-
|
43
|
+
```ruby
|
44
|
+
stop_areas.first.inspect
|
45
|
+
=> "#<Transilien::StopArea external_code=\"DUA8738221\" name=\"LA DEFENSE GRANDE ARCHE\" >"
|
46
|
+
```
|
37
47
|
|
38
|
-
*
|
39
|
-
*
|
48
|
+
* `name` is a "public" name. Can't be filtered directly through Transilien API
|
49
|
+
* `external_code` is the true "key" to use in queries.
|
40
50
|
|
41
|
-
|
51
|
+
As a bonus method, `#payload` returns the node used to build this object.
|
42
52
|
|
43
|
-
If you want to find a commercial line that stops by two StopArea
|
53
|
+
If you want to find a commercial line that stops by two `StopArea`, say: Val d'Argenteuil (DUA8738179) and Paris Saint Lazare (DUA8738400) you can query them this way:
|
44
54
|
|
45
|
-
|
55
|
+
```ruby
|
56
|
+
val_stlaz_lines = Transilien::Line.find(stop_area_external_code: {and: ['DUA8738400', 'DUA8738179']})
|
57
|
+
```
|
46
58
|
|
47
|
-
Ok, but
|
59
|
+
Ok, but you will probably care about the direction you're taking. You're going from Val to StLaz, not the inverse, so precise it:
|
48
60
|
|
49
|
-
|
61
|
+
```ruby
|
62
|
+
val_to_stlaz_lines = Transilien::Line.find(destination_external_code: 'DUA8738400', stop_area_external_code: 'DUA8738179')
|
63
|
+
```
|
50
64
|
|
51
|
-
You get an Array of Transilien::Line
|
65
|
+
You get an `Array` of `Transilien::Line` that meet your wish.
|
52
66
|
|
53
|
-
Staying on
|
67
|
+
Staying on this example, we'll stay with the "biggest" Line of the set: "Mantes la Jolie => Gare St Lazare via CONFLANS" DUA800854044
|
54
68
|
To get ALL the stops served by this Line:
|
55
69
|
|
56
|
-
|
70
|
+
```ruby
|
71
|
+
Transilien::StopArea.find(line_external_code: 'DUA800854044')
|
72
|
+
```
|
57
73
|
|
58
|
-
Ok, that's fun. But Transilien is all about train and departures. What are the trains going from Val d’Argenteuil to Paris Saint Lazare? Transilien::VehicleJourney is all about it
|
74
|
+
Ok, that's fun. But Transilien is all about train and departures. What are the trains going from Val d’Argenteuil to Paris Saint Lazare? `Transilien::VehicleJourney` is all about it:
|
59
75
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
76
|
+
```ruby
|
77
|
+
instant = Time.new
|
78
|
+
start_time = Time.local(instant.year, instant.month, instant.day, 17, 30)
|
79
|
+
end_time = Time.local(instant.year, instant.month, instant.day, 18, 45)
|
80
|
+
Transilien::VehicleJourney.find stop_area_external_code: {and: ['DUA8738400', 'DUA8738179'], date: Transilien.date(instant), start_time: Transilien.time(start_time), end_time: Transilien.time(end_time) }
|
81
|
+
```
|
64
82
|
|
65
|
-
Yeah! Better. You still have a problem: this
|
83
|
+
Yeah! Better. You still have a problem: this gives you all the journeys starting between `start_time` and `end_time`, but doesnt't give a fuck about your direction.
|
66
84
|
|
67
|
-
Ready to forget what you just learnt? Go back a little bit before this point: a Line instance always
|
85
|
+
Ready to forget what you just learnt? Go back a little bit before this point: a `Line` instance always has at least two `Route` (one way and the other). And its finder accepts a convenient parameter: `check_order`. If set to `1` or `2` stops, `Route` returned will honor the given way by stops order:
|
68
86
|
|
69
|
-
|
87
|
+
```ruby
|
88
|
+
routes_stlaz_val = Transilien::Route.find(stop_area_external_code: {and:['DUA8738400','DUA8738179']}, check_order: 1)
|
89
|
+
```
|
70
90
|
|
71
|
-
Here you
|
91
|
+
Here you only get `Route`s stoping by DUA8738400 then DUA8738179, not the inverse.
|
72
92
|
|
73
|
-
Now it'll be easy to get VehicleJourney matching your needs. The same VehicleJourney will become:
|
93
|
+
Now it'll be easy to get a `VehicleJourney` matching your needs. The same `VehicleJourney` will become:
|
74
94
|
|
75
|
-
|
95
|
+
```
|
96
|
+
Transilien::VehicleJourney.find route_external_code: routes_stlaz_val.map(&:external_code), date: Transilien.date(instant), start_time: Transilien.time(start_time), end_time: Transilien.time(end_time)
|
97
|
+
```
|
76
98
|
|
77
|
-
Easier, isn't it? Now take every Stop and keep only your matching StopArea
|
99
|
+
Easier, isn't it? Now take every `Stop` and keep only your matching `StopArea`: you'll get your hours of departures and arrivals :)
|
78
100
|
|
79
101
|
## Contributing
|
80
102
|
|
@@ -86,6 +108,8 @@ Easier, isn't it? Now take every Stop and keep only your matching StopArea: you'
|
|
86
108
|
|
87
109
|
NOTA: you're a beginner gem dev? This command may help you:
|
88
110
|
|
89
|
-
|
111
|
+
```sh
|
112
|
+
$ pry -Ilib -rtransilien_microservices
|
113
|
+
```
|
90
114
|
|
91
|
-
(
|
115
|
+
(You can replace `pry` with `irb` if you're not that kind of person…)
|
data/lib/transilien/version.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
require "
|
10
|
-
require "
|
11
|
-
require "
|
12
|
-
require "
|
13
|
-
require "
|
1
|
+
require "transilien/version.rb"
|
2
|
+
require "transilien/micro_service.rb"
|
3
|
+
require "transilien/time.rb"
|
4
|
+
require "transilien/network.rb"
|
5
|
+
require "transilien/mode_type.rb"
|
6
|
+
require "transilien/line.rb"
|
7
|
+
require "transilien/route.rb"
|
8
|
+
require "transilien/stop_point.rb"
|
9
|
+
require "transilien/stop_area.rb"
|
10
|
+
require "transilien/vehicle_journey.rb"
|
11
|
+
require "transilien/mode.rb"
|
12
|
+
require "transilien/company.rb"
|
13
|
+
require "transilien/stop.rb"
|
14
14
|
|
15
15
|
module Transilien
|
16
16
|
def self.date(time)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transilien_microservices
|
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
|
- Thomas Lecavelier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|