transilien_microservices 0.0.7 → 1.0.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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +9 -0
- data/Changelog.md +4 -0
- data/Gemfile.lock +30 -27
- data/LICENSE.txt +2 -2
- data/README.md +33 -71
- data/lib/transilien/line.rb +0 -16
- data/lib/transilien/micro_service.rb +4 -4
- data/lib/transilien/network.rb +0 -7
- data/lib/transilien/stop.rb +0 -1
- data/lib/transilien/stop_area.rb +0 -12
- data/lib/transilien/time.rb +5 -22
- data/lib/transilien/version.rb +1 -1
- data/lib/transilien_microservices.rb +13 -14
- data/spec/vehicle_journey_spec.rb +4 -0
- data/transilien_microservices.gemspec +2 -3
- metadata +18 -29
- data/CHANGELOG +0 -23
- data/lib/transilien/route_point.rb +0 -5
- data/spec/line_DUA800854046.xml +0 -1
- data/spec/line_spec.rb +0 -18
- data/spec/stop_area_spec.rb +0 -24
- data/spec/stoparea_DUA8738400.xml +0 -1
- data/spec/time_spec.rb +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9edc20c8388c63c1f098020303be8769383a272
|
|
4
|
+
data.tar.gz: c91f0fa738e3324982a240ec925d793b8ef1afcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 85c1d4722e0b2b6e0d35e789efa8ebd0ffcadf6952acd7136ed1be67c3f9bc2a910d6dcfae5291255db72d5bbbe5e16ed471e2c706ae5f8474a42cf7d6762b2c
|
|
7
|
+
data.tar.gz: f43eeed688f5ba7e4fbd3d359a223860ecce59db4c5b25248c782ff40aeeba5b2e2e7166acda0111a218bd1610c7164c712406724eb0f99a4e21053541fdc218
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.2.4
|
data/.travis.yml
ADDED
data/Changelog.md
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
transilien_microservices (0.0
|
|
4
|
+
transilien_microservices (1.0.0)
|
|
5
5
|
faraday (>= 0.8.4)
|
|
6
|
-
nokogiri (>= 1.
|
|
6
|
+
nokogiri (>= 1.6)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
11
|
celluloid (0.15.2)
|
|
12
12
|
timers (~> 1.1.0)
|
|
13
|
-
coderay (1.
|
|
13
|
+
coderay (1.0.9)
|
|
14
14
|
diff-lcs (1.2.5)
|
|
15
|
-
faraday (0.9.
|
|
15
|
+
faraday (0.9.2)
|
|
16
16
|
multipart-post (>= 1.2, < 3)
|
|
17
|
-
ffi (1.9.
|
|
17
|
+
ffi (1.9.0)
|
|
18
18
|
formatador (0.2.4)
|
|
19
|
-
guard (2.
|
|
19
|
+
guard (2.1.1)
|
|
20
20
|
formatador (>= 0.2.4)
|
|
21
21
|
listen (~> 2.1)
|
|
22
22
|
lumberjack (~> 1.0)
|
|
23
23
|
pry (>= 0.9.12)
|
|
24
24
|
thor (>= 0.18.1)
|
|
25
|
-
guard-rspec (
|
|
26
|
-
guard (
|
|
27
|
-
rspec (
|
|
28
|
-
listen (2.
|
|
25
|
+
guard-rspec (2.5.4)
|
|
26
|
+
guard (>= 1.1)
|
|
27
|
+
rspec (~> 2.11)
|
|
28
|
+
listen (2.1.1)
|
|
29
29
|
celluloid (>= 0.15.2)
|
|
30
30
|
rb-fsevent (>= 0.9.3)
|
|
31
31
|
rb-inotify (>= 0.9)
|
|
32
32
|
lumberjack (1.0.4)
|
|
33
33
|
method_source (0.8.2)
|
|
34
|
-
|
|
34
|
+
mini_portile2 (2.0.0)
|
|
35
35
|
multipart-post (2.0.0)
|
|
36
|
-
nokogiri (1.6.1)
|
|
37
|
-
|
|
38
|
-
pry (0.9.12.
|
|
39
|
-
coderay (~> 1.0)
|
|
36
|
+
nokogiri (1.6.7.1)
|
|
37
|
+
mini_portile2 (~> 2.0.0.rc2)
|
|
38
|
+
pry (0.9.12.2)
|
|
39
|
+
coderay (~> 1.0.5)
|
|
40
40
|
method_source (~> 0.8)
|
|
41
41
|
slop (~> 3.4)
|
|
42
|
-
pry-doc (0.
|
|
42
|
+
pry-doc (0.4.6)
|
|
43
43
|
pry (>= 0.9)
|
|
44
44
|
yard (>= 0.8)
|
|
45
|
-
rb-fsevent (0.9.
|
|
46
|
-
rb-inotify (0.9.
|
|
45
|
+
rb-fsevent (0.9.3)
|
|
46
|
+
rb-inotify (0.9.2)
|
|
47
47
|
ffi (>= 0.5.0)
|
|
48
|
-
rspec (2.
|
|
49
|
-
rspec-core (~> 2.
|
|
50
|
-
rspec-expectations (~> 2.
|
|
51
|
-
rspec-mocks (~> 2.
|
|
52
|
-
rspec-core (2.
|
|
53
|
-
rspec-expectations (2.
|
|
48
|
+
rspec (2.99.0)
|
|
49
|
+
rspec-core (~> 2.99.0)
|
|
50
|
+
rspec-expectations (~> 2.99.0)
|
|
51
|
+
rspec-mocks (~> 2.99.0)
|
|
52
|
+
rspec-core (2.99.2)
|
|
53
|
+
rspec-expectations (2.99.2)
|
|
54
54
|
diff-lcs (>= 1.1.3, < 2.0)
|
|
55
|
-
rspec-mocks (2.
|
|
56
|
-
slop (3.4.
|
|
55
|
+
rspec-mocks (2.99.2)
|
|
56
|
+
slop (3.4.6)
|
|
57
57
|
thor (0.18.1)
|
|
58
58
|
timers (1.1.0)
|
|
59
|
-
yard (0.8.7.
|
|
59
|
+
yard (0.8.7.2)
|
|
60
60
|
|
|
61
61
|
PLATFORMS
|
|
62
62
|
ruby
|
|
@@ -67,3 +67,6 @@ DEPENDENCIES
|
|
|
67
67
|
pry-doc
|
|
68
68
|
rspec
|
|
69
69
|
transilien_microservices!
|
|
70
|
+
|
|
71
|
+
BUNDLED WITH
|
|
72
|
+
1.11.2
|
data/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2012
|
|
1
|
+
Copyright (c) 2012 Thomas Lecavelier
|
|
2
2
|
|
|
3
3
|
MIT License
|
|
4
4
|
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,106 +1,74 @@
|
|
|
1
1
|
# TransilienMicroservices
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Here is the original service documentation: http://test.data-sncf.com/index.php/transilien.html/api.22.22-micro-services.html
|
|
6
|
-
|
|
7
|
-
These services let you know the theoric train times on the Transilien service.
|
|
8
|
-
|
|
9
|
-
Disclamer: The gem only intends to implements the API. If you want a « logical » way to exploits SNCF data, see EasyTransilien gem: https://github.com/ook/easy_transilien
|
|
3
|
+
TODO: Write a gem description
|
|
10
4
|
|
|
11
5
|
## Installation
|
|
12
6
|
|
|
13
|
-
Gem developped with ruby 2.0.0, should work with ruby 1.9.3
|
|
7
|
+
Gem developped with ruby 2.0.0, should work with ruby 1.9.3
|
|
14
8
|
|
|
15
9
|
Add this line to your application's Gemfile:
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
gem 'transilien_microservices'
|
|
19
|
-
````
|
|
11
|
+
gem 'transilien_microservices'
|
|
20
12
|
|
|
21
13
|
And then execute:
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
$ bundle
|
|
25
|
-
```
|
|
15
|
+
$ bundle
|
|
26
16
|
|
|
27
17
|
Or install it yourself as:
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
$ gem install transilien_microservices
|
|
31
|
-
```
|
|
19
|
+
$ gem install transilien_microservices
|
|
32
20
|
|
|
33
21
|
## Usage
|
|
34
22
|
|
|
35
|
-
The best way to access data is certainly querying through
|
|
23
|
+
The best way to access data is certainly querying through StopArea: start by fetching them.
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
stop_areas = Transilien::StopArea.find
|
|
39
|
-
```
|
|
25
|
+
stop_areas = Transilien::StopArea.find
|
|
40
26
|
|
|
41
|
-
Every Transilien "main"
|
|
27
|
+
Every Transilien "main" objects have the same attributes:
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
=> "#<Transilien::StopArea external_code=\"DUA8738221\" name=\"LA DEFENSE GRANDE ARCHE\" >"
|
|
46
|
-
```
|
|
29
|
+
stop_areas.first.inspect
|
|
30
|
+
=> "#<Transilien::StopArea external_code=\"DUA8738221\" name=\"LA DEFENSE GRANDE ARCHE\" >"
|
|
47
31
|
|
|
48
|
-
*
|
|
49
|
-
*
|
|
32
|
+
* "name" is a "public" name. Can't be filtered directly through Transilien API
|
|
33
|
+
* "external_code" is the true "key" to use in queries.
|
|
50
34
|
|
|
51
|
-
|
|
35
|
+
They have in bonus #payload method which return the node used to build this object.
|
|
52
36
|
|
|
53
|
-
If you want to find a commercial line that stops by two
|
|
37
|
+
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 this way:
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
val_stlaz_lines = Transilien::Line.find(stop_area_external_code: {and: ['DUA8738400', 'DUA8738179']})
|
|
57
|
-
```
|
|
39
|
+
val_stlaz_lines = Transilien::Line.find(stop_area_external_code: {and: ['DUA8738400', 'DUA8738179']})
|
|
58
40
|
|
|
59
|
-
Ok, but
|
|
41
|
+
Ok, but to tell the truth, I doubt that you don't bother about the way: you're going from Val to StLaz, not the inverse, so precise it:
|
|
60
42
|
|
|
61
|
-
|
|
62
|
-
val_to_stlaz_lines = Transilien::Line.find(destination_external_code: 'DUA8738400', stop_area_external_code: 'DUA8738179')
|
|
63
|
-
```
|
|
43
|
+
val_to_stlaz_lines = Transilien::Line.find(destination_external_code: 'DUA8738400', stop_area_external_code: 'DUA8738179')
|
|
64
44
|
|
|
65
|
-
You get an
|
|
45
|
+
You get an Array of Transilien::Line fullfilling your wish.
|
|
66
46
|
|
|
67
|
-
Staying on
|
|
47
|
+
Staying on that example, we'll stay with the "biggest" Line of the set: "Mantes la Jolie => Gare St Lazare via CONFLANS" DUA800854044
|
|
68
48
|
To get ALL the stops served by this Line:
|
|
69
49
|
|
|
70
|
-
|
|
71
|
-
Transilien::StopArea.find(line_external_code: 'DUA800854044')
|
|
72
|
-
```
|
|
73
|
-
|
|
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:
|
|
50
|
+
Transilien::StopArea.find(line_external_code: 'DUA800854044')
|
|
75
51
|
|
|
76
|
-
|
|
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
|
-
```
|
|
52
|
+
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
|
|
82
53
|
|
|
83
|
-
|
|
54
|
+
instant = Time.new
|
|
55
|
+
start_time = Time.local(instant.year, instant.month, instant.day, 17, 30)
|
|
56
|
+
end_time = Time.local(instant.year, instant.month, instant.day, 18, 45)
|
|
57
|
+
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) }
|
|
84
58
|
|
|
85
|
-
|
|
59
|
+
Yeah! Better. You still have a problem: this give you all the journey starting between start_time and end_time on date instant, but don't give a fuck to your way.
|
|
86
60
|
|
|
87
|
-
|
|
88
|
-
routes_stlaz_val = Transilien::Route.find(stop_area_external_code: {and:['DUA8738400','DUA8738179']}, check_order: 1)
|
|
89
|
-
```
|
|
61
|
+
Ready to forget what you just learnt? Go back a little bit before this point: a Line instance always have at least two Route (one way, the other). And its finder understand a convenient param: CheckOrder. If set to 1, and 2 stops are given, Route returned will honor the given way by stops order:
|
|
90
62
|
|
|
91
|
-
|
|
63
|
+
routes_stlaz_val = Transilien::Route.find(stop_area_external_code: {and:['DUA8738400','DUA8738179']}, check_order: 1)
|
|
92
64
|
|
|
93
|
-
|
|
65
|
+
Here you have only Route stoping by DUA8738400 then DUA8738179, not the inverse.
|
|
94
66
|
|
|
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
|
-
```
|
|
67
|
+
Now it'll be easy to get VehicleJourney matching your needs. The same VehicleJourney will become:
|
|
98
68
|
|
|
99
|
-
|
|
69
|
+
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)
|
|
100
70
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
You're reading it… Ok, have a look to http://rubydoc.info/gems/transilien_microservices for code documentation. Note: you'll get a better understanding of that implementations if your read API documentation, see first link.
|
|
71
|
+
Easier, isn't it? Now take every Stop and keep only your matching StopArea: you'll get your hours of departures and arrivals :)
|
|
104
72
|
|
|
105
73
|
## Contributing
|
|
106
74
|
|
|
@@ -110,10 +78,4 @@ You're reading it… Ok, have a look to http://rubydoc.info/gems/transilien_micr
|
|
|
110
78
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
111
79
|
5. Create new Pull Request
|
|
112
80
|
|
|
113
|
-
NOTA: you're a beginner gem dev? This command may help you:
|
|
114
|
-
|
|
115
|
-
```sh
|
|
116
|
-
$ pry -Ilib -rtransilien_microservices
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
(You can replace `pry` with `irb` if you're not that kind of person…)
|
|
81
|
+
NOTA: you're a beginner gem dev? This command may help you: pry -Ilib -rtransilien_microservices (you can replace pry with irb if you're not a good person…)
|
data/lib/transilien/line.rb
CHANGED
|
@@ -15,20 +15,4 @@ class Transilien::Line < Transilien::MicroService
|
|
|
15
15
|
def backward
|
|
16
16
|
payload.at('Backward')
|
|
17
17
|
end
|
|
18
|
-
|
|
19
|
-
def code
|
|
20
|
-
payload['LineCode']
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def stop_points
|
|
24
|
-
@stop_points ||= Transilien::StopPoint.find(line_external_code: external_code)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def stop_areas
|
|
28
|
-
@stop_areas ||= Transilien::StopArea.find(line_external_code: external_code)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def routes
|
|
32
|
-
@routes ||= Transilien::Route.find(line_external_code: external_code)
|
|
33
|
-
end
|
|
34
18
|
end
|
|
@@ -60,10 +60,10 @@ class Transilien::MicroService
|
|
|
60
60
|
|
|
61
61
|
self.filters = filters
|
|
62
62
|
response = self.http.get(action_param, params)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
puts('== Request: ')
|
|
64
|
+
puts(action_param.inspect)
|
|
65
|
+
puts(params.inspect)
|
|
66
|
+
puts(response.env[:url].inspect)
|
|
67
67
|
body = response.body
|
|
68
68
|
collection = []
|
|
69
69
|
doc = Nokogiri.XML(body)
|
data/lib/transilien/network.rb
CHANGED
data/lib/transilien/stop.rb
CHANGED
data/lib/transilien/stop_area.rb
CHANGED
|
@@ -49,16 +49,4 @@ class Transilien::StopArea < Transilien::MicroService
|
|
|
49
49
|
@hangs ||= payload.at('HangList').children
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def stop_points
|
|
53
|
-
@stop_points ||= Transilien::StopPoint.find(stop_area_external_code: external_code)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def lines
|
|
57
|
-
@lines ||= Transilien::Line.find(stop_area_external_code: external_code)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def codes
|
|
61
|
-
@codes ||= lines.map(&:code).uniq.sort
|
|
62
|
-
end
|
|
63
|
-
|
|
64
52
|
end
|
data/lib/transilien/time.rb
CHANGED
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
# Represents Time in Transilien MS API
|
|
2
|
-
# Theorically, you NEVER had to instanciate them by yourself
|
|
3
|
-
# Note: +total_seconds+ and +day+ looks like mysteries for myself right now…
|
|
4
1
|
class Transilien::Time < Transilien::FakeMicroService
|
|
5
2
|
attr_accessor :total_seconds, :day, :hour, :minute
|
|
6
3
|
|
|
7
4
|
class << self
|
|
8
|
-
# Build a `Transilien::Time` from a Nokogiri::Node
|
|
9
5
|
def from_node(node, access_time)
|
|
10
6
|
item = new
|
|
11
7
|
item.payload = node
|
|
12
8
|
|
|
13
9
|
item.total_seconds = node.at('TotalSeconds').text
|
|
14
|
-
item.day = node.at('Day').text
|
|
15
|
-
item.hour = node.at('Hour').text
|
|
16
|
-
item.minute = node.at('Minute').text
|
|
10
|
+
item.day = node.at('Day').text
|
|
11
|
+
item.hour = node.at('Hour').text
|
|
12
|
+
item.minute = node.at('Minute').text
|
|
17
13
|
item
|
|
18
14
|
end
|
|
19
15
|
end
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# @return [String] representation of that instance
|
|
24
|
-
def name
|
|
25
|
-
"#{day}:#{hour}:#{minute}|#{total_seconds}"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Convert this object to ruby `::Time`
|
|
29
|
-
# Since the current time is not known, set it to `Time.new` year, month and day
|
|
30
|
-
def time
|
|
31
|
-
now = Time.new
|
|
32
|
-
this_month_days_count = Date.new(now.year, now.month, -1).day
|
|
33
|
-
return Time.local(now.year + 1, 1, 1, hour, minute) if day == 1 && now.month == 12 && now.day == this_month_days_count
|
|
34
|
-
return Time.local(now.year, now.month + 1, 1, hour, minute) if day == 1 && this_month_days_count == now.day
|
|
35
|
-
Time.local(now.year, now.month, now.day + day, hour, minute)
|
|
17
|
+
def name # objective: enable caching
|
|
18
|
+
"#{day}:#{hour}:#{minutes}|#{total_seconds}"
|
|
36
19
|
end
|
|
37
20
|
end
|
data/lib/transilien/version.rb
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
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
|
-
require "transilien/route_point.rb"
|
|
1
|
+
require "./lib/transilien/version.rb"
|
|
2
|
+
require "./lib/transilien/micro_service.rb"
|
|
3
|
+
require "./lib/transilien/time.rb"
|
|
4
|
+
require "./lib/transilien/network.rb"
|
|
5
|
+
require "./lib/transilien/mode_type.rb"
|
|
6
|
+
require "./lib/transilien/line.rb"
|
|
7
|
+
require "./lib/transilien/route.rb"
|
|
8
|
+
require "./lib/transilien/stop_point.rb"
|
|
9
|
+
require "./lib/transilien/stop_area.rb"
|
|
10
|
+
require "./lib/transilien/vehicle_journey.rb"
|
|
11
|
+
require "./lib/transilien/mode.rb"
|
|
12
|
+
require "./lib/transilien/company.rb"
|
|
13
|
+
require "./lib/transilien/stop.rb"
|
|
15
14
|
|
|
16
15
|
module Transilien
|
|
17
16
|
def self.date(time)
|
|
@@ -10,11 +10,10 @@ Gem::Specification.new do |gem|
|
|
|
10
10
|
gem.email = ["thomas-gems@lecavelier.name"]
|
|
11
11
|
gem.description = %q{Implements SNCF Transilien micro-services API: enable access to their theoric offer.}
|
|
12
12
|
gem.summary = %q{See http://test.data-sncf.com/index.php?p=transilien}
|
|
13
|
-
gem.homepage = "
|
|
14
|
-
gem.license = 'MIT'
|
|
13
|
+
gem.homepage = ""
|
|
15
14
|
|
|
16
15
|
gem.add_runtime_dependency('faraday', '>= 0.8.4') # HTTP(S) connections
|
|
17
|
-
gem.add_runtime_dependency('nokogiri', '>= 1.
|
|
16
|
+
gem.add_runtime_dependency('nokogiri', '>= 1.6') # XML parsing
|
|
18
17
|
|
|
19
18
|
gem.files = `git ls-files`.split($/)
|
|
20
19
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: transilien_microservices
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Lecavelier
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 0.8.4
|
|
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
26
|
version: 0.8.4
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: nokogiri
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.
|
|
33
|
+
version: '1.6'
|
|
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: '1.6'
|
|
41
41
|
description: 'Implements SNCF Transilien micro-services API: enable access to their
|
|
42
42
|
theoric offer.'
|
|
43
43
|
email:
|
|
@@ -46,10 +46,11 @@ executables: []
|
|
|
46
46
|
extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
|
48
48
|
files:
|
|
49
|
-
- .gitignore
|
|
50
|
-
- .rspec
|
|
51
|
-
- .ruby-version
|
|
52
|
-
-
|
|
49
|
+
- ".gitignore"
|
|
50
|
+
- ".rspec"
|
|
51
|
+
- ".ruby-version"
|
|
52
|
+
- ".travis.yml"
|
|
53
|
+
- Changelog.md
|
|
53
54
|
- Gemfile
|
|
54
55
|
- Gemfile.lock
|
|
55
56
|
- Guardfile
|
|
@@ -63,7 +64,6 @@ files:
|
|
|
63
64
|
- lib/transilien/mode_type.rb
|
|
64
65
|
- lib/transilien/network.rb
|
|
65
66
|
- lib/transilien/route.rb
|
|
66
|
-
- lib/transilien/route_point.rb
|
|
67
67
|
- lib/transilien/stop.rb
|
|
68
68
|
- lib/transilien/stop_area.rb
|
|
69
69
|
- lib/transilien/stop_point.rb
|
|
@@ -71,19 +71,13 @@ files:
|
|
|
71
71
|
- lib/transilien/vehicle_journey.rb
|
|
72
72
|
- lib/transilien/version.rb
|
|
73
73
|
- lib/transilien_microservices.rb
|
|
74
|
-
- spec/line_DUA800854046.xml
|
|
75
|
-
- spec/line_spec.rb
|
|
76
74
|
- spec/microservice_spec.rb
|
|
77
75
|
- spec/spec_helper.rb
|
|
78
|
-
- spec/stop_area_spec.rb
|
|
79
|
-
- spec/stoparea_DUA8738400.xml
|
|
80
|
-
- spec/time_spec.rb
|
|
81
76
|
- spec/vehicle_journey_alone.xml
|
|
82
77
|
- spec/vehicle_journey_spec.rb
|
|
83
78
|
- transilien_microservices.gemspec
|
|
84
|
-
homepage:
|
|
85
|
-
licenses:
|
|
86
|
-
- MIT
|
|
79
|
+
homepage: ''
|
|
80
|
+
licenses: []
|
|
87
81
|
metadata: {}
|
|
88
82
|
post_install_message:
|
|
89
83
|
rdoc_options: []
|
|
@@ -91,28 +85,23 @@ require_paths:
|
|
|
91
85
|
- lib
|
|
92
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
87
|
requirements:
|
|
94
|
-
- -
|
|
88
|
+
- - ">="
|
|
95
89
|
- !ruby/object:Gem::Version
|
|
96
90
|
version: '0'
|
|
97
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
92
|
requirements:
|
|
99
|
-
- -
|
|
93
|
+
- - ">="
|
|
100
94
|
- !ruby/object:Gem::Version
|
|
101
95
|
version: '0'
|
|
102
96
|
requirements: []
|
|
103
97
|
rubyforge_project:
|
|
104
|
-
rubygems_version: 2.
|
|
98
|
+
rubygems_version: 2.4.5.1
|
|
105
99
|
signing_key:
|
|
106
100
|
specification_version: 4
|
|
107
101
|
summary: See http://test.data-sncf.com/index.php?p=transilien
|
|
108
102
|
test_files:
|
|
109
|
-
- spec/line_DUA800854046.xml
|
|
110
|
-
- spec/line_spec.rb
|
|
111
103
|
- spec/microservice_spec.rb
|
|
112
104
|
- spec/spec_helper.rb
|
|
113
|
-
- spec/stop_area_spec.rb
|
|
114
|
-
- spec/stoparea_DUA8738400.xml
|
|
115
|
-
- spec/time_spec.rb
|
|
116
105
|
- spec/vehicle_journey_alone.xml
|
|
117
106
|
- spec/vehicle_journey_spec.rb
|
|
118
107
|
has_rdoc:
|
data/CHANGELOG
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
0.0.7
|
|
2
|
-
* Bug fix: No longer crash like a drunk sea otter when we're at the end of a month or a year…
|
|
3
|
-
|
|
4
|
-
0.0.6
|
|
5
|
-
* Change: It no longer reject any Line due to weird CodeLine. See EasyTransilien gem for fixes of SNCF shitty data
|
|
6
|
-
|
|
7
|
-
0.0.5
|
|
8
|
-
* New: plenty of logical links to transverse object instances (ie: Transilien::Line -> #stop_areas #stop_points #routes, etc.)
|
|
9
|
-
* New: Transilien::RoutePoint that UFO between Route and StopArea and StopPoint...
|
|
10
|
-
|
|
11
|
-
0.0.4
|
|
12
|
-
* New: Transilien::Line#code give the Line code well known by customers (Ok, I admit it: I need that info for EasyTransilien T_T)
|
|
13
|
-
|
|
14
|
-
0.0.3
|
|
15
|
-
* Bug fix: Transilien::Time#name now works
|
|
16
|
-
* New : Transilien::Time#time convert instance into ruby Time instance
|
|
17
|
-
* Try to start documentation, Yard compatible
|
|
18
|
-
|
|
19
|
-
0.0.2
|
|
20
|
-
* Fix require path to ease gem usage
|
|
21
|
-
|
|
22
|
-
0.0.1
|
|
23
|
-
* Initial release. Just work
|
data/spec/line_DUA800854046.xml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="ISO-8859-1"?><ActionLineList><Params Function="api"><SafeMode>0</SafeMode><action>PTReferential</action><RequestedType>linelist</RequestedType><lineexternalcode>DUA800854046</lineexternalcode><networkexternalcode>dua801;dua802;dua803;dua804;dua805;dua850;dua851;dua852;dua853;dua854;dua855</networkexternalcode><interface>1_10</interface><login>opendata</login></Params><LineList LineCount="1"><Line LineIdx="1628" LineId="1627" LineName="Gare St Lazare => Vernon VIA CONFLANS" LineCode="J" LineExternalCode="DUA800854046" LineAdditionalData="" SortOrder="1628" LineColor="000000" HasAdaptedRoute="0"><ModeType ModeTypeIdx="15" ModeTypeExternalCode="RapidTransit" ModeTypeName="Train de banlieue / RER"/><Network NetworkIdx="76" NetworkId="8" NetworkName="Paris St Lazare" NetworkExternalCode="DUA854"></Network><Forward ForwardName="A"><Direction><StopArea StopAreaIdx="0" StopAreaId="-1" StopAreaName="" StopAreaExternalCode="" MainStopArea="0" MultiModal="0" CarPark="0" MainConnection="0" AdditionalData="" ResaRailCode=""><City CityIdx="0" CityId="-1" CityName="" CityExternalCode="" CityCode=""><Country CountryIdx="0" CountryId="-1" CountryName="" CountryExternalCode=""/></City><Coord/></StopArea></Direction></Forward><Backward BackwardName=""><Direction><StopArea StopAreaIdx="0" StopAreaId="-1" StopAreaName="" StopAreaExternalCode="" MainStopArea="0" MultiModal="0" CarPark="0" MainConnection="0" AdditionalData="" ResaRailCode=""><City CityIdx="0" CityId="-1" CityName="" CityExternalCode="" CityCode=""><Country CountryIdx="0" CountryId="-1" CountryName="" CountryExternalCode=""/></City><Coord/></StopArea></Direction></Backward></Line></LineList><PagerInfo ResponseCount="1" ResponseStartIndex="0" TotalCount="1"/></ActionLineList>
|
data/spec/line_spec.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Transilien::Line do
|
|
4
|
-
before(:each) do
|
|
5
|
-
# This payload was generated from
|
|
6
|
-
# http://ms.api.transilien.com/?Action=LineList&LineExternalCode=DUA800854046
|
|
7
|
-
@line = Transilien::Line.from_node(Nokogiri.XML((Pathname.new('spec') + 'line_DUA800854046.xml').read).at('Line'), Time.now)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it 'should get a Line' do
|
|
11
|
-
@line.class.should eql(Transilien::Line)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'should have a code' do
|
|
15
|
-
@line.code.should eql('J')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
data/spec/stop_area_spec.rb
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Transilien::StopArea do
|
|
4
|
-
before(:each) do
|
|
5
|
-
# This payload was generated from
|
|
6
|
-
# http://ms.api.transilien.com/?Action=StopAreaList&StopAreaExternalCode=DUA8738400
|
|
7
|
-
@sa = Transilien::StopArea.from_node(Nokogiri.XML((Pathname.new('spec') + 'stoparea_DUA8738400.xml').read).at('StopArea'), Time.now)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it 'should be a StopArea' do
|
|
11
|
-
@sa.class.should eq(Transilien::StopArea)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'should have at least a line' do
|
|
15
|
-
#puts @sa.lines.map { |l| l.name }.inspect
|
|
16
|
-
(@sa.lines.length >= 1).should be_true
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'should have some codes, at least one' do
|
|
20
|
-
@sa.codes.is_a?(Array).should be_true
|
|
21
|
-
(@sa.codes.length > 0).should be_true
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="ISO-8859-1"?><ActionStopAreaList><Params Function="api"><SafeMode>0</SafeMode><action>PTReferential</action><RequestedType>stoparealist</RequestedType><stopareaexternalcode>DUA8738400</stopareaexternalcode><networkexternalcode>dua801;dua802;dua803;dua804;dua805;dua850;dua851;dua852;dua853;dua854;dua855</networkexternalcode><interface>1_10</interface><login>opendata</login></Params><StopAreaList StopAreaCount="1"><StopArea StopAreaIdx="306" StopAreaId="311" StopAreaName="GARE DE PARIS SAINT-LAZARE" StopAreaExternalCode="DUA8738400" MainStopArea="1" MultiModal="0" CarPark="0" MainConnection="1" AdditionalData="" ResaRailCode=""><City CityIdx="1" CityId="0" CityName="Paris" CityExternalCode="75056" CityCode="75004"><Country CountryIdx="1" CountryId="0" CountryName="France" CountryExternalCode="FRA"/></City><Coord><CoordX>599145,21</CoordX><CoordY>2430788,22</CoordY></Coord><HangList><Hang StopPointIdx="1019" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1024" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1021" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1023" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1022" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1016" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1003" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1014" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1004" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1001" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="999" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1017" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="998" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1009" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1006" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1020" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1010" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1018" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="997" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1008" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1007" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1011" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1013" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1000" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1015" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1005" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1002" Duration="0" ConnectionKind="14"/><Hang StopPointIdx="1012" Duration="0" ConnectionKind="14"/></HangList><ModeList ModeCount="3"><ModeType ModeTypeIdx="5" ModeTypeExternalCode="Bus" ModeTypeName="Bus"/><ModeType ModeTypeIdx="10" ModeTypeExternalCode="Metro" ModeTypeName="M�tro"/><ModeType ModeTypeIdx="15" ModeTypeExternalCode="RapidTransit" ModeTypeName="Train de banlieue / RER"/></ModeList></StopArea></StopAreaList><PagerInfo ResponseCount="1" ResponseStartIndex="0" TotalCount="1"/></ActionStopAreaList>
|
data/spec/time_spec.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Transilien::Time do
|
|
4
|
-
it 'should convert to ::Time easily' do
|
|
5
|
-
tt = Transilien::Time.new
|
|
6
|
-
tt.day = 0
|
|
7
|
-
tt.hour = 14
|
|
8
|
-
tt.minute = 42
|
|
9
|
-
tt.time.is_a?(::Time).should be_true
|
|
10
|
-
now = Time.new
|
|
11
|
-
tt.time.should eql(Time.local(now.year, now.month, now.day, 14, 42))
|
|
12
|
-
tt.day = 1
|
|
13
|
-
this_month_days_count = Date.new(now.year, now.month, -1).day
|
|
14
|
-
if now.day == this_month_days_count
|
|
15
|
-
tt.time.should eql(Time.local(now.year, now.month+1, 1, 14, 42))
|
|
16
|
-
else
|
|
17
|
-
tt.time.should eql(Time.local(now.year, now.month, now.day+1, 14, 42))
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|